in this assignment you will write a program that


In this assignment you will write a program that does simple packet routing. Your program will take three command-line arguments:

Then your program will:

• read its routing table from the specified file

? The file will consist of multiple lines with the format:

The subnet and netmask will be in IPv4 dotted decimal. The nexthop value will be a port number, not an address. The three values will be separated by spaces. For example:

112.23.56.0 255.255.255.0 45334

• listen on the specified UDP port

• accept simplified IP packets in the format:
,,,,

Example:
23921,192.168.0.1,192.168.45.102,64,testing

For each received packet, your program will:

• decrement the TTL field of the packet
? if it reaches zero, the packet will be dropped and the "expired packets" counter will be updated

• figure out which of the entries in the routing table (if any) match the packet

? it will do this by checking whether the destination address in the packet matches the subnet entry for a particular route, after being ANDed with the netmask of that entry in the routing table.

? it will scan the routing table sequentially and will use the first route that matches (you can assume the table is sorted longest-prefix first)

? if there is no matching entry, the packet will be dropped and the "unroutable packets" counter will be updated

• if the value of the nexthop field for the entry is 0:

? print the following:

Delivering direct: packet ID=, dest=

? update the "delivered direct" counter

? not process the packet any further

• if the value of the nexthop field for the entry is a valid port number

? forward the IP packet, as a UDP packet to address 127.0.0.1 and UDP port equal to the nexthop value

? update the counter corresponding to the packets forwarded to that router

Request for Solution File

Ask an Expert for Answer!!
Python Programming: in this assignment you will write a program that
Reference No:- TGS0501191

Expected delivery within 24 Hours