Write a program that does simple packet routing

Assignment Help Python Programming
Reference no: EM13186028

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

<port number to listen at> <routing table file path> <statistics file path>

Then your program will:

• read its routing table from the specified file

? The file will consist of multiple lines with the format:
<subnet> <netmask> <nexthop>

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:
<packet ID>,<source IP>,<destination IP>,<TTL>,<payload>

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=<packet ID>, dest=<dest. IP address>

? 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

Reference no: EM13186028

Questions Cloud

How will this policy affect national saving : Suppose Congress (in an attempt to stimulate the economy in both the short and long run) passes an investment-tax credit, which subsidizes domestic investment. How will this policy affect (comparing the state of the economy prior to the enactment o..
State what volume should dilute ki solution : what volume should you dilute 43.5mL of a 4.00M KI solution so that 24.0mL of the diluted solution contains
What type of market structure would farmers like to convert : The story states that good weather has resulted in an unexpectedly large crop, which we know will increase supply and reduce the market price for their coffee beans. If all of the farmers know that picking this large crop will guarantee them lowe..
State what is the perecent of nacl by mass in the sample : A smple of mixture of NaCl, Caco3 and SiO2 weighed 7.30 grams. During the water wash the sample lost 2.21 grams. After treatment with HCL, the sample weighed 2.05 grams.
Write a program that does simple packet routing : Write a program that does simple packet routing and your program will take three command-line arguments:
Will the firm earn positive economic profits : For a particular good that is monopolized, the monopolist faces the following demand and cost conditions: P= 12 - 2 qd MR= 12-4qd MC= 2 q  a) What price will the firm charge its customers b) Will the firm earn positive economic profits
How fast is the water level rising : A swimming pool is 22 feet wide and has transverse cross-sections,being filled at a rate of 1.1 cubic feet per minute, how fast is the water level rising when the depth of water is 1 feet?
Explain the preparion of acetate buffer : Describe the preparion of 1.00 liters of a 1.00 M acetate buffer, pH 6.00, starting from a 17.40 N solution of glacial acetic acid
Find the general solution of the given differential equation : find the general solution of the given differential equation:

Reviews

Write a Review

Python Programming Questions & Answers

  Prepare a python program

Prepare a Python program which evaluates how many stuck numbers there are in a range of integers. The range will be input as two command-line arguments.

  Function by sum of sines

code the program using an editor (DO NOT COMMAND LINE THE PROGRAM) and show the results

  Define a function to calculate the values

Be sure to define a function to calculate the values and print the table displaying the interest rate in the first column, the monthly payment in the second column, and the total payment in the third column. Your program should not allow the user to ..

  The initial number for generating the sequences

Then, after the functions, read in the initial number for generating the sequences. Here, check that it is a positive integer. If it is not, give an error message and exit the program.

  The function should return the day name (''su'',''mo''..etc)

Write the function day(d,m) where m is an integer from 1 through 12 expressing a month, and d is an integer from 1 through 31 expressing the day part of a date in 2014.

  The computer game function collision

The computer game function collision () checks whether two circular objects collide; it returns True if they do and False otherwise. Each circular object will be given by it's radius and the (x,y) coordinates of it's center.

  Write a function comp(d1,u1,d2,u2)

Write a function comp(d1,u1,d2,u2)

  Evaluate a user''s expression

Write a function that will evaluate a user's expression. It should call the getExpression function that you previously wrote to get the expression to evaluate from the user. You should evaluate the expression step-by-step.

  Interaction between the customer and the machine

In Python:Simulate a cash register or ATM including the interaction between the customer and the machine (i.e. assume that you are automating the responses)

  Design program that asks user to enter amount in python

IN Python Design a program that asks the user to enter the amount that he or she has budget in a month. A loop should then prompt the user to enter his or her expenses for the month.

  Program that creates a dictionary containing

Write a program that creates a dictionary containing the U.S. states as keys and their capitals as values. The program should then randomly quiz the user by displaying

  Email spam filter

Analyze the emails and predict whether the mail is a spam or not a spam - Create a training file and copy the text of several mails and spams in to it And create a test set identical to the training set but with different examples.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd