The mtr(my traceroute) command, originally named Matt's traceroute, is a computer program that combines the functions of the traceroute and ping programs in one network diagnostic tool.
The mtr output contains information about the entire route a packet takes from the source server originated to the destination server. It carries their information and includes the response time and percentages for the network hops between the two machines(source and destination servers).
This article will provide you with the basics of this command-line utility and examples of specific circumstances allowing you to read the output correctly.
The basic syntax of the command is as follows:
mtr <IP ADDRESS>/<HOSTNAME>
When you execute the command attaching an IP address or hostname, you will be redirected to its interface, updated once per second or until you press the "q" button on your keyboard.
Scenario #1:
To sufficient data in a more easily readable format, use this command-line utility's "report" mode. For that, please use the -r and the -w flags. The "-r" flag will "tell" the command to provide a report, while the "-w" flag will clear out the output:
[root@server ~]# mtr -rw google.com Start: Wed Sep 15 14:15:04 2021 HOST: server.hostname.com Loss% Snt Last Avg Best Wrst StDev 1.|-- 2a01:7e01::e6c7:22ff:fe1f:22c1 0.0% 10 0.9 1.3 0.9 2.0 0.0 2.|-- 2a01:7e01:b::1 0.0% 10 11.2 3.6 0.5 11.2 4.7 3.|-- de-cix.fra.google.com 0.0% 10 0.9 0.9 0.8 1.4 0.0 4.|-- 2001:4860:0:11df::1 0.0% 10 0.8 0.9 0.8 1.0 0.0 5.|-- 2001:4860:0:1::2171 0.0% 10 0.8 1.0 0.8 1.1 0.0 6.|-- fra15s29-in-x0e.1e100.net 0.0% 10 1.0 1.0 1.0 1.1 0.0
The data provided by the command herein each of the lines inside will represent a hop. These hops are the nodes that each packet passes through to reach its destination. If you want to hide the hostnames presented in the output, you can add the --no-dns option.
Let's go over the last 7 columns and explains what they contain:
- Loss% - this shows the number of packets lost after each hop.
- Snt - The numbers of packets sent. The default will be 10.
- Last, Avg, Best, Wrst - these columns show the latency in milliseconds for each hop.
- StDev - provides the standard divergence between all the above latencies in each host. The higher this value is, the higher is the contrast between the measured latency.
Scenario #2:
To lower the number of packets sent, you may use the "-c" flag. Here is an example:
[root@server~]# mtr -rw -c5 google.com Start: Wed Sep 15 14:18:38 2021 HOST: server.hostname.com Loss% Snt Last Avg Best Wrst StDev 1.|-- 2a01:7e01::5287:89ff:fe40:a1c1 0.0% 5 1.4 1.1 0.9 1.4 0.0 2.|-- 2a01:7e01:c::1 0.0% 5 0.6 1.9 0.6 6.1 2.3 3.|-- 2a01:7e01:5::2 0.0% 5 0.7 0.8 0.6 0.9 0.0
Scenario #3:
In this case, you deal with a packet loss, and the indication is 100% loss. Do not be alarmed if you see such output in your reports, as most probably it is not a network problem.
[root@server~]# mtr -rw -c5 google.com Start: Wed Sep 15 14:18:38 2021 HOST: server.hostname.com Loss% Snt Last Avg Best Wrst StDev 1.|-- 2a01:7e01::5287:89ff:fe40:a1c1 0.0% 5 1.4 1.1 0.9 1.4 0.0 2.|-- 2a01:7e01:c::1 0.0% 5 0.6 1.9 0.6 6.1 2.3 3.|-- 2a01:7e01:5::2 0.0% 5 0.7 0.8 0.6 0.9 0.0 4.|-- de-cix.fra.google.com 0.0% 5 1.0 0.9 0.8 1.0 0.0 5.|-- ??? 100.0 5 0.0 0.0 0.0 0.0 0.0 6.|-- ??? 100.0 5 0.0 0.0 0.0 0.0 0.0 7.|-- fra02s19-in-x0e.1e100.net 0.0% 5 0.9 1.0 0.9 1.0 0.0
If you notice, you can see 100% loss indication on the 5th and 6th hop. Do not be scared, as this does not suggest network problems. Since the final destination, which is on the 7th hop, is reached with 0% loss. That means 5th or 6th hops are most likely routed through residential or business routers, which sometimes generate misleading outputs.
Scenario #4:
Sometimes, you will face a situation where the hostnames will be represented by a "???" though the column under the "Loss%" will show no packet loss.
Here is an example:
[root@server ~]# mtr -rw -c5 google.com Start: Wed Sep 15 14:20:18 2021 HOST: server.hostname.com Loss% Snt Last Avg Best Wrst StDev 1.|-- 2a01:7e01::5287:89ff:fe40:a1c1 0.0% 5 1.4 1.1 0.9 1.4 0.0 2.|-- 2a01:7e01:c::1 0.0% 5 0.6 1.9 0.6 6.1 2.3 3.|-- 2a01:7e01:5::2 0.0% 5 0.7 0.8 0.6 0.9 0.0 4.|-- de-cix.fra.google.com 0.0% 5 1.0 0.9 0.8 1.0 0.0 5.|-- ??? 0.0% 5 0.8 1.0 0.9 1.0 0.0 6.|-- ??? 0.0% 5 0.8 1.0 0.7 7.0 0.0 7.|-- fra02s19-in-x0e.1e100.net 0.0% 5 0.9 1.0 0.9 1.0 0.0
In this case, you are dealing with a timeout. We cannot say the reason for this, as a dozen issues could trigger it. This does not indicate a packet loss, as seen from the output above, and packets still reach their destinations.