Basics is must for Network Engineer.Traceroute is an imp and handy tool while troubleshooting any network issue.How Traceroute works ? Whats the concept behind it ?
Its task is to determine the path taken by packet to reach its destination .Before going further ,lets see the IP header .
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|Version| IHL |Type of Service| Total Length |
| Identification |Flags| Fragment Offset |
| Time to Live | Protocol | Header Checksum |
| Source Address |
| Destination Address |
| Options | Padding |
There is field Known as Time to Live i.e TTL .Its actually measured by number of hops that a packet travel across the internet before getting discarded.This field was brought to make sure that packet should not flow endlessly from one hope to another forever searching destination .Thus if Destination is not available after specific Hops ,TTL becomes zero and packet will be discarded and also informs same to sender.
Lets take an example of traceroute
When i run traceroute command ,My PC will send 3 UDP packet to destination 22.214.171.124 with source as my PC IP and to invalid UDP port number (33434 to 33534) means that these port are not used,also with the TTL value of one.
When first hop router (126.96.36.199) receives that packet ,It noticed that TTL value is one and destination 188.8.131.52 is not directly connected to it.It will revert with with ICMP error message (ICMP CODE 11 -TTL excedded) with its source address.
Traceroute now knows first hop to 184.108.40.206 it will start again send 3 packet but with TTL value of 2 .Now gateway router (220.127.116.11) will reduce TTL value by one and forward to the next hop .Next hop on receiving this packet will reduce the TTL by one thus TTL once again become zero and it will send back ICMP error message with source address .
Thus on receiving TTL Time excedded ,traceroute will show hop/router on screen.
This process will continue till we reach final host/destination or run into maximum hop count .
Thus the screen will show all the intermediate hop till destination . It helps Network engineer to verify the path taken by packet to reach the destination.