ping and traceroute: How They Work and How to Read Them
How ping uses ICMP echo and what its sequence numbers, TTLs, timings, losses and duplicates mean, and how traceroute, tracepath and mtr map a path with UDP, ICMP or TCP probes, run over a lab with known delays, plus how to read stars and rate limits.
kvi5hnuCode Sprout team member17 min readOn this page
ping and traceroute are the first tools almost anyone reaches for when a network misbehaves. Both are thin layers over the ICMP messages from articles 39 and 40. Knowing exactly how they work makes the difference between reading their output correctly and chasing problems that aren't there.
The lab for this article is a chain of three routers with a fixed delay added on each link with netem, Linux's network emulator, which can add delay, loss or duplication to an interface: client → r1 → r2 → r3 → server. One-way delays are 1, 5, 10 and 2 ms, so the round trip has 36 ms of configured delay. The virtual links add a few milliseconds of their own, so the measured round-trip times are somewhat higher, around 42 to 50 ms.
ping: Echo Request and Echo Reply
ping sends ICMP Echo Request messages (ICMPv4 type 8, ICMPv6 type 128) and waits for Echo Reply messages (type 0, type 129). Every IP host is required to answer echo requests and to return their data unchanged, though firewalls often block them. Here's ping to the lab server by name:
PING www.example.com (198.51.100.10) 56(84) bytes of data.
64 bytes from www.example.com (198.51.100.10): icmp_seq=1 ttl=61 time=103 ms
64 bytes from www.example.com (198.51.100.10): icmp_seq=2 ttl=61 time=51.1 ms
64 bytes from www.example.com (198.51.100.10): icmp_seq=3 ttl=61 time=49.3 ms
64 bytes from www.example.com (198.51.100.10): icmp_seq=4 ttl=61 time=51.0 ms
--- www.example.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3015ms
rtt min/avg/max/mdev = 49.340/63.555/102.825/22.682 ms
And over IPv6:
PING www.example.com (2001:db8:2::10) 56 data bytes
64 bytes from www.example.com (2001:db8:2::10): icmp_seq=1 ttl=61 time=154 ms
64 bytes from www.example.com (2001:db8:2::10): icmp_seq=2 ttl=61 time=47.4 ms
--- www.example.com ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1002ms
rtt min/avg/max/mdev = 47.446/100.556/153.666/53.110 ms
Each reply line shows:
- The size.
56(84) bytesmeans 56 bytes of echo data, plus 8 bytes of ICMP header and 20 of IPv4 header. The reply's "64 bytes" is the ICMP message: 8 + 56. icmp_seq, the sequence number, which counts up from 1 with each request. Gaps mean lost packets, out-of-order numbers mean reordering, and repeated ones mean duplicates.ttl, the TTL of the reply as it arrived. The server sent it with a TTL of 64, the usual Linux default, and three routers each took one off, so 61. Windows typically starts at 128, and many routers at 255, so the TTL gives a rough idea of how far away the replier is and what it runs.time, the round-trip time (RTT): from sending the request to receiving the reply.
The first reply is much slower than the rest. Before the first packet could go anywhere, each device along the path had to resolve its next hop's link-layer address with ARP or neighbor discovery. Later packets used the cached entries.
The summary line gives the loss percentage and the minimum, average, maximum and mdev of the round-trip times. mdev (mean deviation) is a measure of how much they vary.
Inside the messages
A capture of two pings shows the fields that make this work:
frame.number icmp.type icmp.ident icmp.seq ip.ttl data.len
1 8 99 1 64 40
2 0 99 1 61 40
3 8 99 2 64 40
4 0 99 2 61 40
Timestamp from icmp data: Nov 20, 2026 23:01:48.218436000 UTC
[Timestamp from icmp data (relative): 0.001792000 seconds]
- Identifier is the same in every request from one
pingprocess, and it's copied into each reply. ICMP has no ports, so this is how a host running severalpings at once, or a NAT (article 35), matches replies to requests. Older Unixpings used the process ID. Linux's unprivileged "ping sockets" have the kernel choose it. - Sequence number goes up by one per request and is also copied back.
- The data starts with a timestamp, the sending time, which
tsharkdecodes (the remaining 40 of the 56 bytes are filler). When the reply comes back with the same data,pingsubtracts that timestamp from the current time to get the round-trip time. Only the sender's clock is used, so the two hosts' clocks don't need to agree.
Loss and duplicates
With 25% random loss added to one direction of one link (r2 toward r3, so only the requests cross it), ping reports the losses in its summary:
20 packets transmitted, 15 received, 25% packet loss, time 3899ms
rtt min/avg/max/mdev = 43.874/49.872/55.153/3.172 ms
Here only the requests could be lost, so the measured loss matches the 25% that was configured (in a short run it can easily land a little above or below). Losing either the request or the reply loses the round trip, so if both directions dropped 25%, you'd expect about 1 − 0.75² ≈ 44% loss. That's why ping loss is often higher than the loss rate of any one direction of a link.
With duplication added on the server's link, some replies arrive twice:
64 bytes from 198.51.100.10: icmp_seq=2 ttl=61 time=45.3 ms (DUP!)
5 packets transmitted, 5 received, +1 duplicates, 0% packet loss, time 814ms
ping marks these (DUP!) and counts them separately. Duplicates are rare on real networks. They usually point to a link-layer problem, such as a loop or a misbehaving switch or wireless retransmission.
Jitter
With 10 ms of delay on one link now varying by ±4 ms, 60 quick pings show how round-trip times spread:
rtt min/avg/max/mdev = 38.642/49.154/64.480/5.036 ms

The variation in delay is called jitter. A single ping RTT is just one sample, so to judge a path, look at the minimum (closest to the fixed propagation and processing delay) and at the spread. A high maximum with a low minimum usually means queuing somewhere, not a long path.
Record Route
IPv4 has an option that asks each router to write its address into the packet (article 26): the Record Route option, which ping -R uses. Its 40-byte option space holds at most 9 addresses:
64 bytes from 198.51.100.10: icmp_seq=1 ttl=61 time=49.0 ms
RR: 192.0.2.10
203.0.113.1
203.0.113.5
198.51.100.1
198.51.100.10
198.51.100.10
203.0.113.6
203.0.113.2
192.0.2.1
This shows both directions, because the reply carries the recorded list back and continues recording:
- Out: the client, then each router's outgoing interface (
203.0.113.1,203.0.113.5,198.51.100.1), then the server. - Back: the server again, then the routers' outgoing interfaces toward the client.
On the real Internet, Record Route is rarely useful, because many routers ignore or drop packets with IP options. But on a path that allows it, it can show return paths that traceroute can't see.
Useful ping options
-c Nstops after N requests. Linux runs until interrupted by default, while Windows sends 4.-i SECONDSsets the interval. Current Linuxping(iputils) lets ordinary users go down to 2 ms and needs root below that; older versions needed root below 0.2 seconds.-s BYTESsets the data size, for example to test whether large packets get through.-M dosets DF (the Don't Fragment bit), and with-s, it tests the path MTU (article 40).-t TTLsets the TTL.-4and-6choose the protocol. With a name that has both A and AAAA records, Linuxpinguses whatever the resolver lists first, usually IPv6.-Ichooses the source interface or address.
traceroute: finding each hop
traceroute (tracert on Windows) lists the routers on the path to a destination. It uses the TTL and the ICMP Time Exceeded message (article 40):

- Send probes with TTL 1. The first router decrements the TTL to 0, drops the probe and sends Time Exceeded. Its source address identifies the router.
- Send probes with TTL 2, which expire at the second router, and so on.
- Eventually a probe reaches the destination, which answers in a way that tells
tracerouteit has arrived, and the trace stops.
Here's the default Linux traceroute, sending three probes per hop:
traceroute to 198.51.100.10 (198.51.100.10), 30 hops max, 60 byte packets
1 192.0.2.1 5.673 ms 5.641 ms 5.630 ms
2 203.0.113.2 18.252 ms 18.240 ms 18.237 ms
3 203.0.113.6 36.915 ms 36.906 ms 36.892 ms
4 198.51.100.10 42.437 ms 42.433 ms 42.430 ms
The header says traceroute will give up after 30 hops and sends 60-byte probe packets. Each line is one TTL value, with the address that answered and the round-trip time of each probe. The times grow with distance: the largest jump is at hop 3, after the 10 ms link.
The classic Unix traceroute sends UDP datagrams to unlikely ports, starting at 33434 and adding one per probe. A capture shows both sides:
probe TTL 1 to UDP port 33434
probe TTL 2 to UDP port 33435
probe TTL 3 to UDP port 33436
probe TTL 4 to UDP port 33437
reply from 192.0.2.1 ICMP type 11 code 0
reply from 203.0.113.2 ICMP type 11 code 0
reply from 203.0.113.6 ICMP type 11 code 0
The destination answers the last probe with Port Unreachable, because nothing listens on port 33437. That's how traceroute knows it has arrived. Changing the port with every probe also lets it match each reply to its probe, using the UDP header quoted inside the ICMP error.
With names, traceroute does a reverse DNS lookup on each address (here from the lab's hosts file). Names often reveal a router's location or role, such as ae-1.cr2.fra.example.net:
traceroute to www.example.com (198.51.100.10), 30 hops max, 60 byte packets
1 r1.example.net (192.0.2.1) 4.488 ms
2 r2.example.net (203.0.113.2) 16.860 ms
3 r3.example.net (203.0.113.6) 38.391 ms
4 www.example.com (198.51.100.10) 45.763 ms
IPv6 works the same way, with Hop Limit and ICMPv6 Time Exceeded:
traceroute to www.example.com (2001:db8:2::10), 30 hops max, 80 byte packets
1 2001:db8:1::1 4.211 ms
2 2001:db8:f1::2 15.487 ms
3 2001:db8:f2::2 39.482 ms
4 2001:db8:2::10 45.556 ms
Which address does a router report?
A router sends Time Exceeded from the address of the interface the probe arrived on, the one facing you, in most implementations. That's why the trace shows 192.0.2.1, 203.0.113.2 and 203.0.113.6, the routers' "west" interfaces, while Record Route showed the outgoing ones. Some routers use a loopback or management address instead. RFC 5837's interface information extension, which traceroute prints when present, removes the guesswork.
Reading stars
A * means no answer arrived for that probe within the wait time (5 seconds by default, or -w). It doesn't necessarily mean packets were lost. In the next lab run, r2 was configured to never send Time Exceeded, which many routers on the Internet are configured to do:
traceroute to 198.51.100.10 (198.51.100.10), 30 hops max, 60 byte packets
1 192.0.2.1 4.101 ms 4.094 ms
2 * *
3 203.0.113.6 41.016 ms 41.013 ms
4 * *
5 * *
6 * *
7 * *
8 * *
9 * *
10 * *
11 198.51.100.10 50.554 ms *
Hop 2 shows stars, but the path clearly continues: hop 3 answered. A silent hop in the middle of a working path is normal and harmless.
The stars at hops 4 to 10 in this run are a different effect, worth knowing. Linux traceroute sends many probes at once to save time, so the probes with TTL 4, 5, 6 and so on all reached the server together. The server's ICMP rate limit (article 39) let only a few Port Unreachable messages out, so most of those probes went unanswered. Hop 11 finally got a reply. The server is really 4 hops away, and the first line showing its address is the real distance, as the earlier traces showed. Rate limiting at routers causes similar random stars.
When probes are filtered: UDP, ICMP and TCP
Firewalls often drop traceroute's UDP probes before they reach the destination. In the lab, r3 was configured to drop UDP to ports 33434–33534, and the trace was run three ways:
--- UDP (default)
traceroute to 198.51.100.10 (198.51.100.10), 6 hops max, 60 byte packets
1 192.0.2.1 4.077 ms
2 203.0.113.2 16.914 ms
3 203.0.113.6 38.742 ms
4 *
5 *
6 *
--- ICMP echo (-I)
traceroute to 198.51.100.10 (198.51.100.10), 30 hops max, 60 byte packets
1 192.0.2.1 4.283 ms
2 203.0.113.2 16.146 ms
3 203.0.113.6 41.200 ms
4 198.51.100.10 47.273 ms
--- TCP SYN to port 80 (-T)
traceroute to 198.51.100.10 (198.51.100.10), 30 hops max, 60 byte packets
1 192.0.2.1 3.904 ms
2 203.0.113.2 15.075 ms
3 203.0.113.6 39.253 ms
4 198.51.100.10 46.597 ms
- UDP (the default) got answers from the routers up to
r3, but the probes thatr3dropped never got an answer, so the trace never reached the server. - ICMP echo probes (
-I), the method Windowstracertuses, got through, and the server answered with an Echo Reply. - TCP SYN probes (
-T -p 80) to a port the server actually serves look like ordinary connection attempts, and they pass most firewalls. The server answered with a SYN-ACK (or an RST for a closed port), andtraceroutethen reset the half-open connection.
When a trace stops early, try another probe type before concluding that the destination is unreachable.
Multiple paths and Paris traceroute
Many networks spread traffic across several equal-cost paths (ECMP), choosing the path for each packet from a hash of its addresses, protocol and ports. Classic traceroute changes the destination port for every probe, so successive probes may take different paths, and the output can show routers from different paths at different hops, or even links that don't exist.
Paris traceroute keeps the fields used by such hashes constant across probes, so every probe follows the same path. Modern implementations such as mtr and scamper, and Linux traceroute's -U and -T modes, use this approach. Paris traceroute's multipath mode can also find all the paths deliberately.
Remember also that traceroute shows only the forward path. The return path, which carries the Time Exceeded messages and their timing, may be completely different. A large jump in RTT at one hop may be caused by a slow return path, not by that hop.
tracepath and mtr
tracepath traces the path without root privileges, using UDP, and also discovers the path MTU along the way. In the lab, the link between r2 and r3 was set to an MTU of 1400:
1?: [LOCALHOST] pmtu 1500
1: 192.0.2.1 3.799ms
1: 192.0.2.1 4.339ms
2: 203.0.113.2 17.644ms
3: 203.0.113.2 18.096ms pmtu 1400
3: 203.0.113.6 44.740ms
4: 198.51.100.10 48.561ms reached
Resume: pmtu 1400 hops 4 back 4
The ? on the first line marks tracepath's own host, before any probe went out. Hop 3 appears twice because the first full-size probe with TTL 3 was too big for the 1400-byte link, so r2 sent back an error instead of forwarding it. tracepath started with the local MTU of 1500, got a "fragmentation needed" error from r2 (shown as pmtu 1400 on the line for 203.0.113.2), resent smaller probes, and summarized: pmtu 1400 hops 4 back 4. "back 4" is its estimate of the return path's length, from the TTL of the replies.
mtr combines traceroute and ping: it probes every hop repeatedly and keeps statistics. Its report mode (-r) is ideal for sharing:
Start: 2026-11-20T23:02:19+0000
HOST: client Loss% Snt Last Avg Best Wrst StDev
1.|-- 192.0.2.1 60.0% 10 4.1 4.1 3.9 4.5 0.2
2.|-- 203.0.113.2 50.0% 10 16.3 17.9 16.3 19.2 1.4
3.|-- 203.0.113.6 50.0% 10 41.9 44.2 41.9 49.0 2.8
4.|-- 198.51.100.10 0.0% 10 51.9 49.6 46.0 54.2 2.8
The columns are the loss percentage, the number of probes sent (Snt), and the last, average, best and worst RTT in milliseconds, plus their standard deviation. This is a textbook example of how to misread mtr. Hops 1–3 show 50–60% "loss", but the destination shows 0%. If packets were really being lost at hop 1, every later hop would show at least as much loss. What's happening is that mtr sent 5 probes per second per hop, and each router rate-limits the Time Exceeded messages it generates, as Linux does at one per second after a small burst. The probes passed through just fine. Only the routers' replies were limited.
The rule for reading mtr and traceroute: loss or high latency that starts at one hop and continues to the destination is real; loss or latency at one hop that disappears at later hops is just that router being slow or unwilling to answer.
Common questions
Why does ping show 0% loss when my application is slow?
ping measures reachability and round-trip time for small ICMP packets every second or so. It doesn't measure throughput, can miss short bursts of loss, and may be treated differently from your application's traffic. Some networks prioritize or rate-limit ICMP. Test with the application's own protocol (for example curl, iperf3, or a TCP traceroute to its port).
Why does traceroute show a hop with higher latency than later hops?
The router took longer to generate the ICMP message than to forward packets. Routers forward in hardware but generate ICMP in a slower control-plane CPU, often at low priority. Only latency that persists through to the destination matters.
What does !H, !N or !X mean in traceroute output?
They're ICMP errors other than Time Exceeded or Port Unreachable: !H is host unreachable, !N network unreachable, !P protocol unreachable, and !X communication administratively prohibited (a filter). The hop that reported it is where the problem is (article 40).
Can traceroute tell me where a packet is being dropped?
Often, yes. The trace usually stops responding at or just after the point where packets are dropped. But stars can also mean a firewall drops only the probe type you used, or a router that doesn't send Time Exceeded. Try ICMP and TCP probes, and compare a trace from the other end if you can.
Why does traceroute need root privileges for some modes?
Sending ICMP echo probes or TCP SYNs with chosen TTLs, and receiving the ICMP errors, needs raw sockets on many systems. Plain UDP probes and tracepath work without them on Linux, using the socket error queue (IP_RECVERR) to receive the ICMP errors for their own datagrams.
Why do ping and traceroute disagree about the RTT to the destination?
They use different packets, sent at different times, and possibly along different paths (ECMP hashes UDP and ICMP differently), and the destination may handle echo requests and closed-port UDP at different priorities. Small differences are normal. Use many samples and the minimum value for comparison.
Summary
pingsends ICMP Echo Requests and times the Echo Replies. The identifier matches replies to the process, the sequence number reveals loss, reordering and duplicates, and a timestamp in the data gives the RTT using only the sender's clock.- The reply's TTL hints at the replier's distance and operating system. The first ping is often slow because of address resolution. The minimum RTT and the spread (jitter) say more than one sample.
ping -Rrecords the route in IPv4, in both directions, for up to 9 addresses, but many networks don't allow IP options.traceroutesends probes with increasing TTLs. Each router where a probe expires answers with Time Exceeded, usually from the interface facing the sender, and the destination's reply ends the trace.- Probes can be UDP to high ports (the Unix default, ending with Port Unreachable), ICMP echo (Windows) or TCP SYN (best through firewalls). Try another type when a trace stops early.
- Stars mean no reply, not necessarily loss: routers may not send Time Exceeded, and rate limits silence some replies, as the lab showed at both routers and the destination.
- ECMP can confuse classic traceroute, and Paris traceroute keeps probes on one path. traceroute shows only the forward path.
tracepathalso finds the path MTU, andmtrkeeps per-hop statistics. Loss that doesn't continue to later hops isn't real.
Practice questions
1. A ping reply shows ttl=57. The replying host is a Linux server. Roughly how many routers are between you and it?
Answer
Linux usually sends with TTL 64, so 64 − 57 = 7 routers decremented it on the way back to you. The forward path may have a different number of hops, since paths can be asymmetric.
2. Why can ping measure the round-trip time accurately even though the two hosts' clocks aren't synchronized?
Answer
ping puts its own sending time in the echo data, and the replier must return the data unchanged. When the reply arrives, ping subtracts that timestamp from its current time. Both times come from the sender's clock, so the replier's clock never matters.
3. A traceroute shows hops 1–5 normally, hop 6 as * * *, and hops 7–9 normally, reaching the destination. Is there a problem at hop 6?
Answer
No. Hop 6 is forwarding packets fine, since the probes with higher TTLs passed through it. It just doesn't send Time Exceeded messages, or rate-limits them heavily, which is a common configuration.
4. A UDP traceroute reaches a company's border router and then shows only stars, but the company's web server works fine. What could you try?
Answer
The company's firewall probably drops UDP to high ports. Try traceroute -T -p 443, which sends TCP SYNs to the HTTPS port that the firewall allows, or traceroute -I for ICMP echo if ping is allowed. A TCP trace to the service's own port has the best chance of following the same path as real traffic.
5. An mtr report shows 40% loss at hop 3 and 0% at hops 4 to 8, including the destination. Where is the packet loss?
Answer
There's no real packet loss on the path. If hop 3 were dropping packets, every later hop would show at least that much loss. Hop 3 is rate-limiting or deprioritizing the ICMP Time Exceeded messages it generates, so some of mtr's probes at that TTL get no reply.
6. Why does classic traceroute sometimes show two different routers at the same hop in a single line?
Answer
The network is load-balancing traffic across several paths (ECMP), hashing on fields that include the UDP ports. Classic traceroute changes the destination port for every probe, so its three probes for the same TTL can take different paths and expire at different routers. Paris traceroute keeps those fields constant to stay on one path.
Previous: ICMP Error Messages: Unreachable, Packet Too Big, Redirect, Time Exceeded and Parameter Problem
Next: IPv6 Neighbor Discovery: Router and Neighbor Messages, NUD and ND Options

More in TCP/IP Course
Quiz: TCP/IP Delicate Details
Twenty-five questions on the details that catch out experienced engineers: sequence numbers for SYN and FIN, TIME_WAIT versus tcp_fin_timeout, Karn's algorithm, socket buffer doubling, even and odd ephemeral ports, IPv6 checksums and fragmentation, negative DNS caching, and capture filter traps.
Quiz: TCP/IP Interview Questions
Thirty-three networking questions of the kind asked in developer, SRE and network engineering interviews: what happens when you load a URL, TCP versus UDP, handshakes, closing and TIME_WAIT, subnetting, NAT, DNS, MTU problems, congestion, TLS and QUIC, and debugging slow or failing connections.
Quiz: TCP/IP Course Final Exam (All Parts)
The final exam for the TCP/IP course: thirty questions across all fourteen parts, from packets and addressing through Ethernet, ARP, IP, DHCP, NAT, ICMP, UDP, DNS, TCP connections, reliability, congestion control, security, QUIC and troubleshooting.
Quiz: Modern Transports and Troubleshooting (TCP/IP Part 14)
Review modern transports and troubleshooting: QUIC packets, handshakes, 0-RTT, streams and connection migration, HTTP/3, Multipath TCP, SCTP multihoming, and a layered method for diagnosing real network faults.
Discussion
Sign in to ask a question or share what you learned.