An easy-to-understand explanation of network exploration and packet travel using 'traceroute'



On the Internet, where routers, switches, computers, and other devices are intricately intertwined, packets must pass through many routers before they can reach the destination server. However, if a router is misconfigured or down, packets may be dropped and the destination may not be reached. In such cases, a tool called '

traceroute ' can be used to obtain information about the routers that have been passed through and to help with diagnosis. Software engineer Sebastian Marins explains traceroute.

The journey of an internet packet: Exploring networks with traceroute - Sebastian Marines
https://sebastianmarines.com/post/journey-of-a-packet-exploring-networks-with-traceroute/



When you try to connect to any server on the Internet, your computer first checks if the destination IP address is in the same network, if so it sends the packet directly to the destination, otherwise it sends the packet to the '

default gateway ' that connects your network to the Internet.

The router then checks if the destination IP address is in its routing table and if so, sends the packet directly, if not, sends the packet to the next router in the path, and this process is repeated until the packet reaches its destination.

The ' ping command ,' which can be used to check network connectivity, can be used to check whether packets can reach their destination. However, while the ping command can confirm that a problem has occurred, it is not possible to determine which router is causing the problem.



That's where traceroute comes in. Traceroute is a network diagnostic tool that shows the routers a packet will pass through from source to destination, allowing you to see all the routers in the path and the response time of each router. Below is an example of using traceroute. In this example, five routers in total are passed on the way to the desired server, but while the information for the first and second routers is accurate, no information is available from the third and subsequent routers. Therefore, in this case, we can see that the problem is with router 3.
[code]$ traceroute 10.0.0.2
traceroute to 10.0.0.2 (10.0.0.2), 30 hops max, 60 byte packets
1 10.1.0.5 1.123 ms 0.912 ms 1.145 ms
2 10.1.0.6 2.145 ms 2.023 ms 2.311 ms
3*****
4* * *
5 * * * [/code]



In addition to the source and destination IP addresses, traceroute first refers to the 'Time to Live (TTL)', which is the maximum number of routers a packet can pass through. When a packet is sent, the TTL is always set to a value of '64'. When the packet reaches a router, the TTL value is decremented to '63'. Each time the packet reaches a router, the TTL value is decremented by 1, and when it reaches 0, the router drops the packet and sends a 'Time Exceeded' error message back to the source computer indicating that the connection was not possible. However, if the TTL is greater than 0, the router will always forward the packet to the next router in the path. In this way, traceroute can show the path from the source to the destination.

Marins also illustrated the different reactions caused by different TTL values. If you send a packet with a TTL of 3 to a destination server, and there are three routers on the way, the packet will decrement its TTL by 1 as it passes through the routers, and by the time it reaches router 3, its TTL value will be 0. As a result, it will never reach the destination server, and router 3 will send a 'Time Exceeded' message back to the sender's computer.



If you then send a packet with a TTL value of 4, the TTL value will never reach 0 at any router along the way, allowing the packet to be received by the destination server, which will then send a response to the originating computer.



'As we've seen, the Internet is a complex network of interconnected devices, and traceroute helps simplify this complexity,' says Marins. 'If you have a network problem, use traceroute to save time troubleshooting.'

For those who want to learn more about traceroute, Richard Steenbergen, CEO of technology company PacketFabric , has published detailed documentation.

A Practical Guide to (Correctly) Troubleshooting with Traceroute
(PDF file) https://archive.nanog.org/sites/default/files/traceroute-2014.pdf

in Software, Posted by log1r_ut