Question: Write a program that reads data from a file containing a datum called prefix in each line of the file called routing _ table. Each

Write a program that reads data from a file containing a datum called prefix in each line of the file called routing_table. Each prefix has the format of IP/length as following examples: 0.2.64.0/15
0.3.8.0/22
1.3.33.0
1.3.38.0/23
The first part a.b.c.d is a 32-bit IP address. So, you have to store the IP address into an unsigned variable. For prefixe length, you can use an unsigned character. So, for all the prefixes, you can use an array of struct prefix {unsigned ip; unsigned char len; struct prefix *next; } to store all the prefixes. Assume prefix 0.0.0.0/0 does not exist.
Do the following,
(a) write a function input(..)toreadalltheprefixesfromtheinputfile
(b) print out the total number of prefixes in the input file,
(c) write a function length_distribution(..) to compute the number of prefixes with prefix length i, for i=0 to 32,
(d) write a function segment int d) to divide the prefixes into 2d groups such that the prefixes in the same group have the same first d bits.
(e) Now, the prefix of length ii=02d-1 are put in a special group so that no prefix duplicate is created.
(f) printout the number of prefixes in group i for i=0to2d-1.
(g) For each group, you have to use singly linked list to chain the prefixes together.
(h) Therefore, you have to write a function prefixinsert()to insert a prefix in a one-by-one fashion in the increasing order of the unsigned numbers of the prefixes. The prefixes tobe inserted after the segments are built are from a file called insertedprefixes.
(i) Also, you have to write a function prefixdelete()to insert a prefix. The prefixes tobe deleted after inserting all the prefixes from files routingtable and insertedprefixes are from a file called deletedprefixes.
(j) you have to write a function search()by giving anIP address to report if the search is successful or fails.
(k) Finally, you have to report average numbers of search, insert, delete clock cycles, draw three figures as followe
 Write a program that reads data from a file containing a

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!