ASSIGNMENT : Implementation of IP Forwarding Algorithm
The purpose of this assignment is to implement the IP forwarding algorithm and understand how the routing table can be ordered by the prefix. It should also enhance understanding of bitwise operations.
The program should accept the name of an input file containing the routing table information and the name of the file that contains the IP addresses to be matched in the routing table as command line arguments. This file will have the information regarding the routing table. You need to parse the contents of this file and using the information read, construct the forwarding table such that the entries are ordered from the longest prefix to the shortest prefix.
The format of the file containing routing table information is as given below:
IP destination network, Subnet mask, Gateway, Interface
The IP destination network, subnet mask and Gateway are given in dotted decimal notation. Use the system call inet_addr/inet_aton to convert it into an unsigned long (as in the previous assignment) and store it in your data structure as an unsigned long as required.
The format of the file containing destination IP addresses to be matched is as given below:
IP destination address1
IP destination address2
IP destination address3
...
where the IP destination address is also in dotted decimal notation. This also needs to be converted using inet_aton() or inet_addr() call.
Once you have read the file and stored the routing table in your data structure in memory, read the inputs from the second file and match the addresses in the routing table. Print the entire matching entry in an output file which is also a command line argument.