mtr is the linux utility which is equivalent to the pathping command on windows system. So whatever pathping command does on windows, mtr does the same on linux. In this article, we will go through both the utilities and compare their outputs.
What is pathping?
Pathping is a windows command line tool which gives information regarding network. It describes the network latency and packet loss in between hops from local machine to the target address.
Pathping works by sending multiple echo requests to the hops and receives the packets from them. Then It analyzes the percentage of packets returned from each router. This way we can understand the problems in the network.
Let’s run pathping on akashmittal.com and check the output –
pathping /n akashmittal.com
The output will look like this –
C:\Users\akash>pathping /n akashmittal.com Tracing route to akashmittal.com [104.21.24.98] over a maximum of 30 hops: 0 192.168.1.3 1 192.168.1.1 2 223.177.143.255 3 122.186.81.173 4 182.79.154.138 5 80.81.193.129 6 172.70.240.5 7 104.21.24.98 Computing statistics for 175 seconds... Source to Here This Node/Link Hop RTT Lost/Sent = Pct Lost/Sent = Pct Address 0 192.168.1.3 0/ 100 = 0% | 1 15ms 0/ 100 = 0% 0/ 100 = 0% 192.168.1.1 0/ 100 = 0% | 2 19ms 0/ 100 = 0% 0/ 100 = 0% 223.177.143.255 0/ 100 = 0% | 3 21ms 0/ 100 = 0% 0/ 100 = 0% 122.186.81.173 0/ 100 = 0% | 4 209ms 0/ 100 = 0% 0/ 100 = 0% 182.79.154.138 0/ 100 = 0% | 5 222ms 0/ 100 = 0% 0/ 100 = 0% 80.81.193.129 2/ 100 = 2% | 6 226ms 3/ 100 = 3% 1/ 100 = 1% 172.70.240.5 0/ 100 = 0% | 7 225ms 2/ 100 = 2% 0/ 100 = 0% 104.21.24.98 Trace complete.
The first list of IP addresses signifies the total hops through which a request will reach my website from my local system. In the second list we can see the time taken at each router along with the packet loss in percentage.
How pathping is different from tracert?
tracert is another command line tool in windows which determines the path from source to destination. It uses ICMP (Internet Control Message Protocol) or ICMPV6 messages to send echo requests to routers in the path. A maximum TTL hop value (default 30) is set in IP packet which is decremented by each router by 1 or more. This way either the destination is reached or ttl becomes 0 and a time exceeded message is returned.
tracert is different from pathping as it gives no information about packet loss. This utility is way faster than pathping because it’s only responsible to trace the path from source to destination.
To use tracert, run this command on cmd –
tracert akashmittal.com
The output will look like this –
C:\Users\akash>tracert akashmittal.com Tracing route to akashmittal.com [172.67.218.41] over a maximum of 30 hops: 1 79 ms 2 ms 1 ms RTK_GW [192.168.1.1] 2 12 ms 13 ms 9 ms 223.177.143.255 3 13 ms 10 ms 9 ms nsg-corporate-177.81.186.122.airtel.in [122.186.81.177] 4 197 ms 203 ms 205 ms 116.119.61.206 5 262 ms 203 ms 203 ms de-cix-frankfurt.as13335.net [80.81.193.129] 6 219 ms 205 ms 202 ms 172.70.240.5 7 265 ms 203 ms 163 ms 172.67.218.41 Trace complete.
You can see that when I run tracert command over my website akashmittal.com, I got 7 hops and it tried to fetch the DNS host name of each IP, whenever possible.
How mtr is equivalent to pathping?
mtr
is the linux utility which combines the functionality of traceroute and ping commands. While ping command determines the total packet loss from source to destination, traceroute gives route from source to destination. traceroute in linux is equivalent to tracert in windows.
Let’s check the output of ping on akashmittal.com –
ping -c 10 akashmittal.com
In the above command I used -c 10
flag to limit the ping request to 10. Otherwise it would have gone forever and we need to terminate it by pressing ctrl+c
. The output of ping looks like this –
akash@LAPTOP-389NRSIQ:/mnt/c/Users/akash/OneDrive/Desktop$ ping -c 10 akashmittal.com PING akashmittal.com (104.21.24.98) 56(84) bytes of data. 64 bytes from 104.21.24.98 (104.21.24.98): icmp_seq=1 ttl=59 time=178 ms 64 bytes from 104.21.24.98 (104.21.24.98): icmp_seq=2 ttl=59 time=158 ms 64 bytes from 104.21.24.98 (104.21.24.98): icmp_seq=3 ttl=59 time=199 ms 64 bytes from 104.21.24.98 (104.21.24.98): icmp_seq=4 ttl=59 time=174 ms 64 bytes from 104.21.24.98 (104.21.24.98): icmp_seq=5 ttl=59 time=245 ms 64 bytes from 104.21.24.98 (104.21.24.98): icmp_seq=7 ttl=59 time=164 ms 64 bytes from 104.21.24.98 (104.21.24.98): icmp_seq=8 ttl=59 time=210 ms 64 bytes from 104.21.24.98 (104.21.24.98): icmp_seq=9 ttl=59 time=233 ms 64 bytes from 104.21.24.98 (104.21.24.98): icmp_seq=10 ttl=59 time=163 ms --- akashmittal.com ping statistics --- 10 packets transmitted, 9 received, 10% packet loss, time 9011ms rtt min/avg/max/mdev = 157.716/191.543/244.817/30.137 ms
You can see that out of 10 packets, it received 9 and lost 1. So, it’s 10% packet loss.
Now let’s check the output of traceroute command. You might need to install traceroute first before using it. Also in WSL, you need to install inetutils-traceroute
otherwise firewalls will prevent the packets at routers. Run these commands –
sudo apt-get update sudo apt install inetutils-traceroute sudo apt install traceroute
Now run traceroute on akashmittal.com –
traceroute -I akashmittal.com
-I
flag is used to send ICMP packets. Why? because firewall at routers do not block these packets.
If you are using WSL then run the below command –
inetutils-traceroute -M icmp akashmittal.com
The output of traceroute will look like this –
akash@LAPTOP-389NRSIQ:/mnt/c/Users/akash/OneDrive/Desktop$ inetutils-traceroute -M icmp akashmittal.com traceroute to akashmittal.com (104.21.24.98), 64 hops max 1 192.168.1.1 0.961ms 0.636ms 0.904ms 2 223.177.143.255 61.149ms 12.027ms 8.989ms 3 122.186.81.173 86.341ms 9.369ms 9.490ms 4 116.119.49.38 260.385ms 129.901ms 198.882ms 5 80.81.193.129 202.327ms 317.201ms * 6 172.70.240.5 1503.906ms 187.019ms 203.571ms 7 104.21.24.98 203.277ms 202.917ms 203.475ms
You can see that the output is quite similar to that of tracert.
Finally we will run mtr on akashmittal.com and check the output –
mtr akashmittal.com
If you are getting error on windows WSL while running mtr then it means you are using WSL1. You need to set it to WSL2. Run this command on Windows CMD –
wsl --set-version Ubuntu 2
This will take few minutes in conversion. After that, you can run mtr command again on terminal. The output should look like this –
My traceroute [v0.93] LAPTOP-389NRSIQ (172.28.162.232) 2022-10-01T12:47:27+0530 Keys: Help Display mode Restart statistics Order of fields quit Packets Pings Host Loss% Snt Last Avg Best Wrst StDev 1. LAPTOP-389NRSIQ.mshome.net 0.0% 13 0.4 0.5 0.4 0.7 0.1 2. RTK_GW 0.0% 13 4.0 20.6 2.0 230.0 62.9 3. 223.177.143.255 0.0% 13 13.1 20.7 10.8 104.4 25.3 4. 177.81.186.122.airtel.in 0.0% 13 13.9 14.1 10.6 30.1 5.0 5. 116.119.61.206 0.0% 13 132.0 132.4 130.4 137.0 1.6 6. de-cix-frankfurt.as13335.net 0.0% 13 166.2 179.7 160.3 273.6 30.4 7. 172.70.240.5 0.0% 13 186.8 166.9 159.7 186.8 7.2 8. 172.67.218.41 8.3% 13 253.9 196.0 162.5 255.0 37.2
The result of mtr shows list of hosts, packet lost in percentage and the latency. Along with them, it shows the total packets sent.
Conclusion
In this article we saw the similarity and differences between multiple route commands on both windows and Linux. We also discussed about windows pathping
and it’s counterpart application in Linux, mtr
. We use these utilities to track the route of requests from source to destination and get enough information about congestion on particular router.