Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke

4th Edition

0136086535, 9780136086536

More Books

Students also viewed these Databases questions

Question

Can knowledge workers and/or professionals be performance-managed?

Answered: 1 week ago

Question

Does a PMS enhance strategic integration within HRM?

Answered: 1 week ago