Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Traceroute in Network Layer

  • Difficulty Level : Easy
  • Last Updated : 25 Oct, 2021

Consider a situation when you are not able to access a website and can access other websites. You would want to know if this is a problem with your network, some intermediate network, or with the webserver. How do you figure it out? 

You can use Traceroute. 

Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.

 

What is a traceroute? 
Traceroute is a widely used command-line utility available in almost all operating systems. It shows you the complete route to a destination address. It also shows the time is taken (or delays) between intermediate routers. Isn’t it great? Below is an example of the Windows operating system. 



 

tracert

What does the above output mean? 
A first column is a serial number for intermediate routers. In the above output, three packets are sent to every hop to get a good estimate of delays for every router. The three columns show the time taken by three different packets. The last column is the IP/Name of intermediate routers. 
The output shows three delays for the first hop, followed by delays for the second hop, and so on. 

What is a command in Linux and other Operating Systems? 
In Windows, as shown above, the command name is “tracert”, but in Linux, Unix, and Apple MAC OS, a command is “traceroute”. 

How does traceroute work? 
As shown in the below diagram, there are intermediate routers between source and destination. 
 

tracert

It sends many packets toward the destination. 

The first set of packets (3 packets in the above example) are sent in a way that they are dropped by the first intermediate hop and a control message is received from the first intermediate node to get the time estimation for the first hop. 

The second set of packets (3 packets in the above example) are sent in a way that they are dropped by the second intermediate hop and a control message is received from the second intermediate node to get the time estimation for the first hop. 

How does traceroute make sure that a packet is dropped at i’th hop? 
It uses the TTL field for this purpose. TTL is set as 1 for the first packet(s), then 2, and so on until the destination is reached. 

How is the total time estimated? 
When a packet is dropped, the router sends an ICMP Time Exceeded message back to the source. That is how the source figures out the total time. 

Traceroute is a widely used command-line utility in networks. 

References: 
https://www.youtube.com/watch?v=wTncuOHQbMw&index=5&list=PLkHsKoi6eZnzJl1qTzmvBwTxrSJW4D2Jj 

This article is contributed by Rahul Gupta. Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above
 

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!