mtr
mtr (My Traceroute) combines traceroute and ping: it finds every hop to the destination and then keeps probing all of them, showing live loss, latency and jitter per hop. It is the Linux/macOS tool for catching intermittent loss and for sending a clean report to an ISP.
41.1 What it does, where it runs
| Platform | How to get it |
|---|---|
| Linux | apt: mtr / mtr-tiny, dnf: mtr |
| macOS | brew install mtr (run with sudo) |
| Windows | Not built in: use pathping or WinMTR |
| Permission | Raw sockets: sudo, or the mtr-packet helper |
41.2 How it works
- Like traceroute, it sends a probe with TTL 1; the first router decrements it to 0 and replies ICMP Time Exceeded, so mtr learns hop 1.
- TTL 2 expires at the second router, TTL 3 at the third, and so on; mtr notes each hop's address and reply time.
- The last probe has a TTL big enough to reach the server, which answers with an Echo Reply.
- traceroute stops here; mtr starts a new cycle about every second and probes all hops again.
- So Loss% and Avg for every hop keep updating live.
- Step 1
1.Probe TTL 1 -> Router 1 (192.168.61.1): TTL 0, Time Exceeded back = hop 1
- Step 2
2.Probe TTL 2 -> Router 2 (192.168.61.66): Time Exceeded = hop 2
- Step 3
3.Probe TTL 3 -> Router 3 (192.168.61.130): Time Exceeded = hop 3
- Step 4
4.Probe with a large TTL -> Server 192.168.61.194: Echo Reply = hop 4
- Step 5
5.New cycle every second: all 4 hops probed again
- Step 6
6.Loss% and Avg ms per hop update live
Lab: Docker network namespaces, netem delay 2 ms (r1-r2) and 10 ms (r2-r3)
41.3 General options and report mode
- -v: version (0.95 in the lab); -h: short option list.
- Just a hostname opens the live screen; -r -c 5 prints a report after 5 cycles and exits.
- -4 / -6: IPv4 only / IPv6 only; -F file: read hostnames from a file and report each one.
- -w: wide report, long names are not cut; the best format to paste into a ticket.
mtr -vmtr -r -c 5 srv.labmtr -4 -rn -c 3 192.168.61.194mtr -rn -c 3 -F hosts.txtmtr -rw -c 10 srv.lab$ mtr -vmtr 0.95$ mtr -r -c 5 srv.labHOST: lab Loss% Snt Last Avg Best Wrst StDev 1.|-- r1.lab 0.0% 5 0.1 0.1 0.1 0.2 0.0 2.|-- r2.lab 0.0% 5 2.3 6.2 2.3 22.0 8.8 3.|-- r3.lab 0.0% 5 12.4 14.4 12.4 22.5 4.5 4.|-- srv.lab 0.0% 5 12.4 12.4 12.4 12.5 0.141.4 Reading the report columns
| Column | Meaning |
|---|---|
| Loss% | Probes that got no reply |
| Snt | Probes sent |
| Last | Newest reply time (ms) |
| Avg / Best / Wrst | Average, best and worst latency |
| StDev | Spread of latency: an idea of jitter |
- In the lab, hop 3 jumps to about 12 ms because a 10 ms delay was added on the r2 to r3 link.
- A high Wrst with a normal Avg (hop 2: Wrst 30.2) means one probe came back late, not a constant problem.
41.5 Display modes
-r report: -c cycles, then exit-w wide report, names not cut-t force curses terminal UI-g GTK+ window (GTK build)--displaymode 0 statistics view (default)--displaymode 1 stripchart, no latency--displaymode 2 stripchart + latency-p split-user interface format41.6 Machine-readable output
- Always fix the cycle count with -c when scripting.
- -j: JSON, every hop is an entry in report.hubs, Loss% and Avg are numbers.
- -C: one CSV line per hop, good for appending to a history file.
- -x: XML; -l: raw format, where p lines carry the reply time in microseconds.
mtr -j -c 3 -n 192.168.61.194mtr -C -c 3 -n 192.168.61.194mtr -x -c 3 -n 192.168.61.194mtr -l -c 1 -n 192.168.61.194$ mtr -C -c 3 -n 192.168.61.194Mtr_Version,Start_Time,Status,Host,Hop,Ip,Loss%,Snt, ,Last,Avg,Best,Wrst,StDev,MTR.0.95,1794160742,OK,192.168.61.194,1,192.168.61.1,0.00,3,0,0.10,0.09,0.08,0.10,0.01MTR.0.95,1794160742,OK,192.168.61.194,2,192.168.61.66,0.00,3,0,2.28,2.32,2.27,2.39,0.06$ mtr -l -c 1 -n 192.168.61.194x 0 33000h 0 192.168.61.1p 0 95 33000x 1 33001h 1 192.168.61.66p 1 2261 3300141.7 Names, columns and IP information
- -n: no DNS, numeric IPs only; reports stay fast even when DNS is slow.
- -b: name and IP both; use it with -w.
- -o: choose columns and their order, e.g. 'LSD NBAW JMX' (loss, sent, drop / newest, best, avg, worst / jitter columns).
- -z: AS number of each hop; -y 0..4: AS, prefix, country, RIR, allocation date; -e: MPLS labels (RFC 4950).
| Letter | Column | Letter | Column |
|---|---|---|---|
| L | Loss% | D | Dropped |
| R | Received | S | Sent |
| N | Newest RTT | B | Best RTT |
| A | Average RTT | W | Worst RTT |
| V | StDev | G | Geometric mean |
| J | Current jitter | M | Jitter mean |
| X | Worst jitter | I | Interarrival jitter |
mtr -rwb -c 5 srv.labmtr -rn -c 20 -o 'LSD NBAW JMX' 192.168.61.194mtr -rwz -c 10 8.8.8.8mtr -rn -c 5 -y 2 8.8.8.8$ mtr -rwb -c 5 srv.labHOST: lab Loss% Snt Last Avg 1.|-- r1.lab (192.168.61.1) 0.0% 5 0.1 0.1 2.|-- r2.lab (192.168.61.66) 0.0% 5 2.3 2.2 3.|-- r3.lab (192.168.61.130) 0.0% 5 12.4 16.2 4.|-- srv.lab (192.168.61.194) 0.0% 5 12.4 12.4$ mtr -rwz -c 10 8.8.8.8HOST: lab Loss% Snt Last Avg 1. AS??? 172.17.0.1 0.0% 10 0.2 0.1 2. AS15169 8.8.8.8 0.0% 10 52.3 42.9$ mtr -rn -c 5 -y 2 8.8.8.8 1. ??? 172.17.0.1 0.0% 5 0.2 1.1 2. US 8.8.8.8 0.0% 5 45.6 39.2AS15169 is Google's AS number. Only two hops appear because the Docker Desktop NAT (172.17.0.1) hides all the ISP hops in between.
41.8 Probing, timing and protocol options
| Option | What it does |
|---|---|
| -c 100 | Number of cycles (about 1 sec each) |
| -i 0.2 | Gap between probes (below 1 sec needs root) |
| -s 1400 | Packet size: catches loss that only hits big frames |
| -f 3 / -m 20 | First TTL (default 1) / max TTL (default 30) |
| -G 10 / -Z 2 | Wait after last request / probe socket timeout |
| -B / -Q / -U | Payload bit pattern / TOS byte / max unknown hops (default 5) |
| -T -P 443 | TCP SYN probes to port 443 (when ICMP is blocked) |
| -u -P 53 -L 40000 | UDP probes to port 53, fixed source port |
| -I eth0 / -a IP | Pick interface / source address |
| -M 10 / -S | Linux packet mark / SCTP probes |
time mtr -rn -c 50 -i 0.2 192.168.61.194mtr -rn -c 3 -f 2 -m 3 192.168.61.194mtr -rn -T -P 443 -c 5 192.168.61.194mtr -rn -u -P 53 -L 40000 -c 5 192.168.61.194$ time mtr -rn -c 50 -i 0.2 192.168.61.194HOST: lab Loss% Snt Last Avg 1.|-- 192.168.61.1 0.0% 50 0.1 0.1 4.|-- 192.168.61.194 0.0% 50 12.4 12.8real 0m15.087s$ mtr -rn -c 3 -f 2 -m 3 192.168.61.194HOST: lab Loss% Snt Last Avg 2.|-- 192.168.61.66 0.0% 3 2.4 2.3 3.|-- 192.168.61.130 0.0% 3 12.4 12.5- The man page says a negative size (-s -1400) means a random size, but mtr 0.95 in the lab rejected it: mtr: invalid argument: '-1400'. Check your version.
- Env vars: MTR_OPTIONS holds default options (MTR_OPTIONS='-n -c 3' mtr -r gave a numeric 3-cycle report), MTR_PACKET is the helper path, DISPLAY picks the X11 server for -g.
41.9 Interactive keys
- p pause, SPACE resume, q quit, ? or h help.
- d display mode, r reset counters, n DNS on/off, j latency/jitter view.
- c / i change cycles and interval; f / m change the TTL range without restarting.
- u switches ICMP/UDP, z toggles AS, y cycles IP info.
41.10 Reading loss correctly
- Step 1
1.Run 1: hop 2 shows 36.0% loss
- Step 2
2.Hop 3 and the server show 0.0%: traffic is forwarded fine
- Step 3
3.So hop 2 only rate-limits its own Time Exceeded replies: ignore
- Step 4
4.Run 2: hops 1-2 at 0.0%, hop 3 at 27.0%
- Step 5
5.Server also at 25.0%: loss continues to the destination
- Step 6
6.Real problem on the r2 to r3 link (25% netem loss was added there)
Rule: the last hop's Loss% and Avg are the final truth
# run 1: r2 rate-limits Time Exceeded 2.|-- 192.168.61.66 36.0% 100 2.2 2.3 3.|-- 192.168.61.130 0.0% 100 12.4 12.4 4.|-- 192.168.61.194 0.0% 100 12.4 12.6# run 2: 25% loss on the r2 to r3 link 2.|-- 192.168.61.66 0.0% 100 2.3 2.3 3.|-- 192.168.61.130 27.0% 100 12.4 12.4 4.|-- 192.168.61.194 25.0% 100 12.5 12.841.11 Common mistakes
- Blaming the hop that shows loss: routers give low priority to replying to probes aimed at themselves; only loss that continues to the end is real.
- Running with DNS on over a slow resolver: use -n.
- Testing with ICMP when the firewall blocks it: use -T -P 443 or -u.
- Scripting without -c: the report never ends.
41.12 Interview tips
- traceroute vs mtr: traceroute sends a few probes per hop and stops (shows the path); mtr probes continuously and gives loss, latency and jitter stats.
- mtr is better for intermittent loss and for reports to an ISP (mtr -rw -c 100).
- Loss at a middle hop but 0% at the destination = ICMP rate-limit, not a broken router.
- Windows equivalent: pathping (or WinMTR).