ping, traceroute & mtr
Test reachability and locate where along a path packets are lost or delayed.
By Invicly Tech, , in Computer Networking. About 12 minutes to read.
In short
ping sends ICMP echo requests to test whether a host is reachable and how long round trips take. traceroute sends probes with increasing TTL to reveal each router along the path. mtr combines both, showing loss and latency per hop over time.
Explained simply
ping is the simplest network test. It sends a small "are you there?" message to another computer and waits for the answer. If the answer comes back, the path works both ways. ping also tells you how long the round trip took, in milliseconds. That time is called RTT (round-trip time).
traceroute shows the road, not just the destination. Packets cross many routers on their way, and each router is one hop. traceroute lists those hops in order, with the time to reach each one. When something breaks, it shows roughly where the path stops.
mtr is ping and traceroute combined, running again and again. After a minute it shows, for every hop, how many probes were lost and how much the time jumps around. That makes it the best tool for "it is slow sometimes" problems.
One warning: many routers and firewalls treat these test messages as low priority or block them. A missing reply does not always mean traffic is broken. You will learn to read the output carefully so you do not chase false alarms.
Press Play on a diagram to walk through it one step at a time.
- Step 1ping gateway
Local network healthy?
- Step 2ping remote IP
Internet path working?
- Step 3traceroute
Where does the path stop?
- Step 4mtr
Which hop introduces loss or latency?
- 1Host
Router IP or name at this hop
- 2Loss% and Snt
Share of probes with no reply, out of how many sent
- 3Last, Avg
Latest and average round-trip time in ms
- 4Best, Wrst
Fastest and slowest reply seen
- 5StDev
How much RTT varies: high means jitter
In depth
What ping really sends
ping uses ICMP (Internet Control Message Protocol). It sends an Echo Request (ICMP type 8) and the target answers with an Echo Reply (type 0). Each request carries a sequence number, so ping can spot lost or reordered replies. The ttl value in each reply is the TTL left when it arrived: Linux usually starts at 64 and Windows at 128, so a reply with ttl=57 likely came from a Linux host about 7 hops away.
Useful Linux options: -c sets the count, -i the interval in seconds, -W the timeout per reply, -s the payload size, and -M do forbids fragmentation. With -M do -s 1472 you test a 1500-byte path (1472 data + 8 ICMP + 20 IP header). If that fails but smaller sizes work, the path has a smaller MTU, a classic cause of VPN hangs. On Windows, ping -n sets the count and -f -l 1472 does the same MTU test.
- Echo Request is type 8, Echo Reply type 0
- Destination Unreachable is type 3, Time Exceeded type 11
- Look at min/avg/max/mdev: mdev shows jitter
- ping -M do -s 1472 tests a full 1500-byte packet
How traceroute finds each hop
Every IP packet has a TTL (time to live) field. Each router lowers it by one and drops the packet when it reaches zero, sending back an ICMP Time Exceeded message from its own address. traceroute uses this on purpose. It sends probes with TTL 1, then 2, then 3, and each router that drops a probe reveals itself.
On Linux, traceroute sends UDP probes to high ports starting at 33434 by default, and the destination answers with ICMP Port Unreachable, which tells traceroute it has arrived. traceroute -I uses ICMP echo instead, and -T uses TCP SYN (root needed), which passes firewalls that allow only web traffic. Windows tracert uses ICMP. By default it sends 3 probes per hop and gives up after 30 hops (-m changes that). Use -n to skip reverse DNS lookups, which are often the slowest part.
- Your host to Router 1: Probe with TTL 11Probe with TTL 1
- Router 1 to Your host: ICMP Time Exceeded (hop 1)2ICMP Time Exceeded (hop 1)
- Your host to Router 2: Probe with TTL 2, passes R13Probe with TTL 2, passes R1
- Router 2 to Your host: ICMP Time Exceeded (hop 2)4ICMP Time Exceeded (hop 2)
- Your host to Target: Probe with TTL 3 reaches target5Probe with TTL 3 reaches target
- Target to Your host: Port Unreachable or reply: done6Port Unreachable or reply: done
Reading mtr without fooling yourself
mtr shows one row per hop with Loss%, Snt (sent), Last, Avg, Best, Wrst and StDev. The golden rule: loss is real only if it continues to the final hop. Routers forward traffic in fast hardware, but answering probes is done by their slower CPU, and many limit how many ICMP replies they send. So a middle hop showing 30% loss while later hops show 0% is just a busy router ignoring probes, not a problem.
The same logic applies to latency. A hop that shows 200 ms while the next hops show 20 ms is slow to reply, not slow to forward. Real trouble looks like a step: loss or latency that starts at hop N and stays for every hop after it. Run mtr in both directions if you can, because the return path may be different. For reports, use mtr -rwzc 100 host to get a text summary with AS numbers.
- Loss at one middle hop only
- Later hops show 0% loss
- High RTT at one hop, normal after
- Asterisks in the middle, target replies
- Loss starts at hop N and continues
- Final hop shows the same loss
- RTT jumps and stays high after a hop
- Target never replies on any protocol
When ICMP is filtered
Many cloud servers and firewalls drop ICMP echo, so ping fails while the website works perfectly. Before declaring a host down, test the real service: curl for HTTP, nc -zv host 22 for SSH, or traceroute -T -p 443 to trace with TCP to the web port. tcptraceroute and mtr -T -P 443 do the same.
Rows of three asterisks (* * *) mean no reply arrived for that TTL. If later hops reply, the router just does not answer probes. If every row after a point is asterisks, the probes may be blocked by a firewall there, or the path is truly broken; test with a different probe type to tell which. Note that blocking all ICMP is a bad idea: ICMP type 3 code 4 (Fragmentation Needed) is how path MTU discovery works, and dropping it causes connections that start fine and then hang.
- traceroute -T -p 443 host traces with TCP SYN to port 443
- mtr -T -P 443 host does the same continuously
- nc -zv host 443 checks the port without ICMP
Learn it in 4 short steps
About 30m each. Track them with a timer in your plan.
- 1Test reachability and latency with ping~30m
- 2Trace the path with traceroute~30m
- 3Read per-hop loss with mtr~30m
- 4Explain ICMP filtering false alarms~30m
Key points
- Loss that starts at one hop and persists to the end is real.
- Loss at a single middle hop only is often ICMP rate limiting, not a fault.
- Rows of asterisks mean probes got no reply, not necessarily that traffic is blocked.
- Use traceroute -T or tcptraceroute when ICMP or UDP probes are filtered.
Key terms
Tap a card to flip it. 0/4 known
Examples
ping -c 5 192.168.1.1
ping -c 5 1.1.1.1
traceroute -n 1.1.1.1
sudo traceroute -T -p 443 example.com # TCP probes
mtr -rwc 50 example.com # report mode, 50 cyclesFinding where packets are lost
Users report video calls breaking up. Step 1: ping the gateway for 100 packets; 0% loss, so the LAN is fine. Step 2: run mtr in report mode to the call server. Hop 3 (ISP edge) shows 0%, hop 4 shows 12% loss, and every hop after it, including the target, also shows around 12%. Step 3: since the loss starts at hop 4 and continues to the end, the fault is real and lies between hops 3 and 4. Step 4: send the mtr report to the ISP with the time and your public IP.
ping -c 100 -i 0.2 192.168.1.1 | tail -2
mtr -rwzc 200 calls.example.net
# HOST Loss% Snt Avg Wrst
# 3. isp-edge-1 0.0% 200 8.1 12.0
# 4. isp-core-7 12.0% 200 14.3 80.2
# 5. peer-xyz 11.5% 200 15.0 77.9
# 9. calls.example.net 12.0% 200 21.4 90.1A VPN where SSH connects but then freezes
SSH over a new VPN logs in, but listing a big directory hangs. That smells like an MTU problem: small packets pass, big ones vanish. Step 1: ping the server with full 1500-byte packets and the do-not-fragment bit set; it fails. Step 2: lower the size until it works; 1392 bytes of payload pass, so the path MTU is 1420 (1392 + 28). Step 3: set the tunnel interface MTU to 1420, or allow ICMP Fragmentation Needed through the firewall so path MTU discovery works.
ping -c 2 -M do -s 1472 10.0.5.20 # fails: message too long or no reply
ping -c 2 -M do -s 1392 10.0.5.20 # works
# path MTU = 1392 + 8 (ICMP) + 20 (IP) = 1420
sudo ip link set dev wg0 mtu 1420Quick reference
- ping -c 5 host: five echo requests, then a summary with loss and min/avg/max
- ping -M do -s 1472 host: test a 1500-byte path with fragmentation forbidden (Linux)
- traceroute -n host: skip reverse DNS so the trace is fast
- traceroute -I uses ICMP, -T uses TCP SYN; Linux default is UDP from port 33434
- Windows: ping -n 5 host, tracert host, pathping host
- mtr -rwzc 100 host: 100-cycle text report with AS numbers
- Loss that does not continue to the last hop is ICMP rate limiting, not a fault
- Reply ttl near 64 suggests Linux, near 128 suggests Windows
Quick quiz
Pick an answer to see if you're right and why.
Practice exercises
Try each one yourself first. Use the hint if you get stuck, then compare with the solution.
- Exercise 1easy
Ping your gateway and a public IP 20 times each. Write down the loss and the average RTT, and explain what the difference between them tells you.
- Exercise 2medium
Trace the path to a website three ways (UDP, ICMP, TCP 443) and compare where each one stops or shows asterisks.
- Exercise 3hard
Find the path MTU to a host with a small bash loop that lowers the ping payload until a do-not-fragment ping succeeds.
Check yourself
Answer in your head, reveal, then be honest with yourself.
Feel confident about this topic?
Frequently asked questions
- Why does traceroute show * * * for some hops?
- That router did not answer the probe in time, usually because it drops or rate-limits ICMP replies. If later hops answer, traffic is passing through it fine.
- What is a good ping time?
- On a wired LAN, under 1 to 2 ms; on Wi-Fi, a few ms; across a country, 20 to 60 ms. Steady times matter as much as low times, because jitter hurts voice and video.
- What is the difference between traceroute and tracert?
- tracert is the Windows tool and uses ICMP echo probes. Linux traceroute uses UDP probes by default but can use ICMP with -I or TCP with -T.
- Is it safe to block ping on my server?
- Blocking ICMP echo is common and mostly harmless, but do not block all ICMP. Messages such as Fragmentation Needed and Packet Too Big are needed for path MTU discovery.