A packet lab

The problem

Build a small Python program that models a network of hosts, switches and routers on paper: it plans the subnets, builds the forwarding tables, and follows one packet from a source host to a destination, printing the frame and TTL on every link.

Requirements

Technologies

Step by step

  1. Choose a private network and the number of hosts for each subnet, then allocate the blocks, biggest first.
  2. Write the forwarding table of each router as (network, prefix, next hop) entries.
  3. Write a function that picks the next hop by longest prefix match.
  4. Send a packet through the network and print one line per link with the MAC addresses, IP addresses and TTL, then test a packet that has no route.

Expected result

A program that prints the full path of a packet through a small network, and reports clearly when it is dropped.

How it is evaluated

Ways to improve it