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

  Write a python program to implement the diff command

Without using the system() function to call any bash commands, write a python program that will implement a simple version of the diff command.

  Write a program for checking a circle

Write a program for checking a circle program must either print "is a circle: YES" or "is a circle: NO", appropriately.

  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.

  Python atm program to enter account number

Write a simple Python ATM program. Ask user to enter their account number, and print their initail balance. (Just make one up). Ask them if they wish to make deposit or withdrawal.

  Python function to calculate two roots

Write a Python function main() to calculate two roots. You must input a,b and c from keyboard, and then print two roots. Suppose the discriminant D= b2-4ac is positive.

  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.

  Write python program which imports three dictionaries

Write a Python program called hours.py which imports three dictionaries, and uses the data in them to calculate how many hours each person has spent in the lab.

  Write python program to create factors of numbers

Write down a python program which takes two numbers and creates the factors of both numbers and displays the greatest common factor.

  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.

  Improve the readability and structural design of the code

Improve the readability and structural design of the code by improving the function names, variables, and loops, as well as whitespace. Move functions close to related functions or blocks of code related to your organised code.

  Create a simple and responsive gui

Please use primarily PHP or Python to solve the exercise and create a simple and responsive GUI, using HTML, CSS and JavaScript.Do not use a database.

  The program is to print the time

The program is to print the time in seconds that the iterative version takes, the time in seconds that the recursive version takes, and the difference between the times.

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