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

  Networking and types of networking

This assignment explains the networking features, different kinds of networks and also how they are arranged.

  National and Global economic environment and ICICI Bank

While working in an economy, it has a separate identity but cannot operate insolently.

  Ssh or openssh server services

Write about SSH or OpenSSH server services discussion questions

  Network simulation

Network simulation on Hierarchical Network Rerouting against wormhole attacks

  Small internet works

Prepare a network simulation

  Solidify the concepts of client/server computing

One-way to solidify the concepts of client/server computing and interprocess communication is to develop the requirements for a computer game which plays "Rock, Paper, Scissors" using these techniques.

  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.

  Describe how the modern view of customer service

Describe how the greater reach of telecommunication networks today affects the security of resources which an organisation provides for its employees and customers.

  Technology in improving the relationship building process

Discuss the role of Technology in improving the relationship building process Do you think that the setting of a PR department may be helpful for the ISP provider? Why?

  Remote access networks and vpns

safekeeping posture of enterprise (venture) wired and wireless LANs (WLANs), steps listed in OWASP, Securing User Services, IPV4 ip address, IPV6 address format, V4 address, VPN, Deploying Voice over IP, Remote Management of Applications and Ser..

  Dns

problems of IPV, DNS server software, TCP SYN attack, Ping of Death, Land attack, Teardrop attack, Smurf attack, Fraggle attack

  Outline the difference between an intranet and an extranet

Outline the difference between an intranet and an extranet A programmer is trying to produce an applet with the display shown in Figure 1 below such that whenever one of the checkboxes is selected the label changes to indicate correctly what has..

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