Reassembly of IP fragments

The format of the file is as given below: There is a space between fields in the record.
“IPsourceaddr” “ID” “fragOffset” “MF” “Length”
The IP source address is given in dotted decimal notation. Use the system call inet_addr to convert it into an unsigned long and store it in your data structure as an unsigned long. Remember that string operations such as comparison are much costlier than integer comparisons. Hence, store the IP address as an unsigned long.
The output of the program should be the following:
For every “IP source addr, ID” combination read, print whether the fragments given form a complete datagram. If so, print the Source IP address in dotted decimal notation using inet_ntoa, ID and total length of the datagram. If not, print the Source IP address and ID and the error encountered while reassembling such as, “Duplicate Fragment”, “Missing Fragment”, “Mismatch in length” etc…

//