How to decrement the ttl field of the packet

Assignment Help Computer Networking
Reference no: EM13315193

If you are referencing any outside sources you must cite them clearly.

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

Note: whenever a packet is dropped, it should not be processed any further. Statistics file:

After every 100 processed packets you will update the statistics file (the path to which was given as a

command-line argument). The format of the file will be:
expired packets: <number of packets>
unroutable packets: <number of packets>
delivered direct: <number of packets>
router <router1>: <number of packets forwarded to router1>
router <router2>: <number of packets forwarded to router2>
...

And so on, for each router. <routerX> is the port number corresponding to this router.

You will also update the statistics file before the program exits, when the user interrupts with Ctrl+C.

To do this you will need to handle the KeyboardInterrupt exception.

Error handling:

In addition to the above-mentioned  KeyboardInterrupt (used to terminate the program), you will need to handle any I/O-related exceptions.

If the routing table file does not exist or cannot be read, your program should print an error message and exit. If the statistics file does not exist and it is unable to create it, it should print an error message and exit. If, later, an error occurs while trying to update the statistics file, it should print an error message and it should continue running (i.e. it should not exit in this case).

If your program is unable to listen on the specified UDP port it should print an error message and exit.

If an error occurs while receiving an incoming packet, or while trying to forward the packet, it should print an error message and it should continue running (i.e. it should not exit in this case).

Reference no: EM13315193

Questions Cloud

What does the slope of the linear line : A graph of the Force applied to a spring and the distance it stretches F vs. x yields some valuable information. What does the slope of the linear line
Calculate what is the force required at a constant rate : A 20-kg iron ball is moving at 100 km/hr should be accelerated at a constant rate of 10 m/(sec)^2. What is the force required
Hat is the direction of the net electrical field : Consider two particles, each with a charge of +Q located at the opposite corners of a square of side d. What is the direction of the net electrical field at point P
Determine the average normal stress at the critical section : two 10 mm thick steel plates are fastened together by means of two 20mm bolts that fit tightly into the holes. if the joint transmits a tensile force of 45 kn determine the average normal stress in the plates at a section where no holes occur
How to decrement the ttl field of the packet : In addition to the above-mentioned  KeyboardInterrupt (used to terminate the program), you will need to handle any I/O-related exceptions.
Determine the magnitude and location of the resultant force : The tank contains water to depth of 2m and oil (SG=0.8) on top of the water to a depth of 1m. Determine the magnitude and location of the resultant force acting on one end of the tank (i.e. 3m high by 3m wide).
Determine by trigonometry corresponding magnitude of r : Knowing that the magnitude of P is 35 N, determine by trigonometry (a) the required angle a if the resultant R of the two forces applied to the support is to be horizontal, (b) the corresponding magnitude of R.
What are the predominant types of bond in each category : what are the three meterials based on the predominant types of bond and what are the predominant types of bond in each category
Concept of environmental sustainability : Discuss the concept of environmental sustainability. Discuss the challenges to sustainability faced by developed, emerging, and survival economies. Do you think the “green” movement is a fad, or is it here to stay? 200 Word Maximum

Reviews

Write a Review

Computer Networking Questions & Answers

  Describe advantages of having a componentized system

Describe some of the advantages of having a componentized system. For example, what happens if the microwave breaks?

  Storage systems increasingly rely on the internet

Storage systems increasingly rely on the Internet infrastructure as a transport medium. What are the advantages of this approach? What problems are present in terms of security and reliability?

  Explain lan topology design which will be used at office

Explain LAN topology design which will be used at each office, and give checklist of cabling specifications for cabling contractor.

  Kind of challenges did irs encounter when implementing cdw

What kind of challenges did the IRS encounter when implementing its CDW? What management,organization, and technology issues had to be addressed?

  Identify the various costs associated with the deployment

Identify the various costs associated with the deployment, operation and maintenance of a mobile-access system. Identify the benefits to the various categories of user, arising from the addition of a mobile-access facility.

  Historical crimes have changed the culture

Determine if these historical crimes have changed the culture or ethics associated with computers and information management. Explain the effectiveness of existing computer crime detection methods and technologie

  Starting and ending security and integrity levels of object

In Lipner's model consider moving the program from development into production. Write down the starting and ending security and integrity levels of this object.

  Calculate rsa signature on long message by computing mod

Calculate RSA signature on long message by ?rst computing what the message equals mod n, for some ?xed n and then signing this computed value only. Why or why not?

  Determine the queuing delay for packet

Packet switch receives a packet and determines outbound link to which packet should be forwarded. Determine the queuing delay for packet? Show work.

  Conduct a research on network address translation

Research network address translation (NAT). While conducting your research, consider purpose of NAT, compatibility with IPv6, and functions of automatic IP assignment and automatic name resolution.

  Andrea stevens cosmetics is a small cosmetics

Andrea Stevens Cosmetics is a small cosmetics company that has a network of 30 computers. They are currently using a 10BaseT network that is wired with Category 5 Plenum cable

  Describe what happens in getting this request message

Describe what happens in getting this request message to the server and how the server gets the response message back to the client.

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