Debuggingtraceroutetracertttlicmp time exceededmtr

traceroute: Discovering the Path Hop by Hop

traceroute sends probes with TTL 1, 2, 3… and collects the ICMP Time Exceeded replies each router returns when it discards them, revealing the forward path one hop at a time — and the same mechanism is why the output is full of honest-looking lies.

ConceptualLinuxUnix-styleWindows
▶ InteractiveInterview question
Progress

You have not marked these as done yet. Read on anyway if they feel familiar; come back to them if something here does not land.

The problem

Packets to a host in another region take 400 ms when geography says 80 ms, or they never arrive at all. Which router on the way is responsible — and how do you ask routers that were never designed to tell you?

TTL as a probe

Every IP packet carries a TTL (hop limit in IPv6). Each router decrements it by one before forwarding; a router that decrements it to zero discards the packet and sends an ICMP Time Exceeded (type 11, code 0; ICMPv6 type 3) back to the source. The mechanism exists to kill packets caught in a routing loop. traceroute abuses it: send a probe with TTL 1 and the first router replies; TTL 2 and the second router replies; keep going until the destination itself answers — with an ICMP Port Unreachable for a UDP probe, an echo reply for an ICMP probe, or a SYN-ACK/RST for a TCP probe.

The source address of each Time Exceeded message is the router’s interface that received the probe (the ingress interface, usually), so what you see is a list of ingress addresses along the forward path, with the RTT to each measured as probe-out to ICMP-back. Three probes per TTL by default give three RTTs per hop; 30 TTLs is the default maximum.

One traceroute, one TTL at a time
  1. Probe TTL=1first router decrements to 0, discards, replies Time Exceeded — hop 1 and its RTT
    ↓
  2. Probe TTL=2passes router 1; router 2 discards and replies — hop 2
    ↓
  3. Probe TTL=3 … neach TTL reveals one more ingress interface
    ↓
  4. Probe reaches destinationUDP → ICMP Port Unreachable; ICMP → Echo Reply; TCP → SYN-ACK or RST; the trace ends

UDP, ICMP or TCP probes — platform differences

Linux and macOS traceroute send UDP datagrams to high ports starting at 33434, incrementing per probe, so the destination answers with Port Unreachable. Windows tracert sends ICMP echo requests, so the destination answers with an echo reply. Linux traceroute -I uses ICMP echo and -T uses TCP SYN (needs root; tcptraceroute is the standalone version); -p 443 sets the port. The choice matters because firewalls treat them differently: a firewall that drops UDP to random high ports kills the Linux default at the last hop while tcptraceroute -p 443 sails through to the real service port. mtr (winmtr on Windows) runs the trace continuously and shows per-hop loss and RTT distributions — better than a single traceroute for intermittent problems.

The intermediate hops reply with Time Exceeded regardless of probe type, so the middle of the path looks the same with every variant; the probe type mainly decides whether the last hop answers.

Probe types and where each one gets stuck
Tool / flagProbeDestination answers withTypical failure
Linux/macOS traceroute (default)UDP to 33434+ICMP Port UnreachableFirewall drops UDP to high ports → * * * at the end
Windows tracert, Linux traceroute -IICMP echoICMP Echo ReplyDestination filters ICMP echo → * * * at the end
Linux traceroute -T -p 443, tcptracerouteTCP SYN to the service portSYN-ACK (open) or RST (closed)Rarely fails at the end; needs root; some middleboxes intercept SYNs
mtr / winmtrICMP (default) or UDP/TCPAs above, continuouslySame blind spots, but per-hop loss over time is visible

Reading a trace

Read RTT jumps between consecutive hops, not absolute values: the hop where RTT goes from 15 ms to 95 ms is where the packet crossed an ocean or a satellite link. Read * * * as "no reply from this hop", which is not the same as "this hop dropped my traffic" — if later hops reply, the silent one forwarded fine and merely declined to generate ICMP. A trace that ends in * * * forever means either the destination filters the probe type or the path really is broken; switch probe type before concluding.

Hostnames from reverse DNS often encode location and role (ae-3.r21.frankfurt.de style), which is how you learn that a Berlin-to-Munich packet went via Amsterdam. Private addresses (10.x, 172.16–31.x, 192.168.x) in the middle of a trace are normal inside carriers and clouds.

A Linux traceroute from a European office to a US server; hop 6 is the transatlantic jump, hop 8 rate-limits ICMP
$ traceroute -n api.example.com
traceroute to api.example.com (203.0.113.10), 30 hops max, 60 byte packets
 1  192.168.1.1     0.8 ms   0.7 ms   0.7 ms     <- home/office router
 2  100.64.12.1     9.3 ms   8.9 ms   9.1 ms     <- ISP access (CGNAT range)
 3  62.115.40.7    10.2 ms  10.0 ms  10.4 ms
 4  62.115.118.1   11.7 ms  11.6 ms  11.9 ms
 5  80.91.246.33   18.4 ms  18.1 ms  18.3 ms     <- Amsterdam
 6  213.155.135.9  94.6 ms  94.2 ms  94.8 ms     <- +76 ms: crossed the Atlantic
 7  198.51.100.2   95.1 ms  95.0 ms  95.3 ms
 8  * * *                                        <- forwards fine, no ICMP
 9  198.51.100.77  96.0 ms  95.8 ms  96.1 ms
10  203.0.113.10   96.4 ms  96.2 ms  96.3 ms     <- destination

Why traces lie

Silent hops. Routers generate ICMP on their control-plane CPU, not in forwarding hardware, and rate-limit it aggressively. A hop showing * * * or 30% loss in mtr while every later hop shows 0% loss is rate-limiting, not path loss. The rule: loss that does not persist to the destination is not real loss. Similarly a latency spike at one hop that disappears at the next means the router was slow to generate the ICMP, not slow to forward.

Asymmetric paths. Each RTT is forward-path-to-that-hop plus that hop’s return path to you, and the return path is chosen by the hop’s own routing, which may differ entirely from yours. A sudden RTT increase can come from a bad return route from that router, invisible in the forward trace. Tracing from the other end shows the other half; Internet Routing: Autonomous Systems and BGP explains why the halves differ.

MPLS and tunnels. Inside carrier networks packets are label-switched; providers frequently disable TTL propagation into the MPLS tunnel, so a dozen physical routers show up as one hop, or several hops show the same RTT because the ICMP travelled to the tunnel end first. ECMP. Load-balanced paths hash each probe differently, so probes for TTL n and n+1 may traverse different routers, producing a trace that interleaves two paths — paris-traceroute and mtr keep flow identifiers stable to avoid this.

None of this makes traceroute useless. It reliably shows: the rough geography of the path, the hop where a large RTT is added and persists, and the last hop that responded before silence. It does not reliably show per-hop loss, the return path, or the hops inside a carrier’s core.

  • Loss or latency that appears at a hop and vanishes at later hops is control-plane behaviour, not forwarding behaviour.
  • Loss or latency that appears at a hop and persists to the destination is real and started at or before that hop.
  • A trace that ends in silence is inconclusive until you change probe type (-I, -T -p 443).
  • The last responding hop before permanent silence is usually a firewall, or the boundary of a network that drops the probe type.

Key points

  • traceroute discovers the forward path by sending probes with increasing TTL and collecting ICMP Time Exceeded replies from each router.
  • Linux/macOS default to UDP probes, Windows tracert to ICMP echo; -I/-T change the probe type and decide whether the last hop answers.
  • Read RTT jumps between hops, not absolute values; a persistent jump is distance or a detour.
  • * * * and per-hop loss that do not persist downstream are ICMP rate-limiting on the router’s control plane, not real loss.
  • RTTs include the hop’s own return path, which may differ from yours; MPLS hides hops; ECMP interleaves paths.
  • mtr shows loss and latency distribution per hop over time, which single traces cannot.

Why does this exist?

Mechanisms are answers to constraints. Open each question before reading the answer.

▸Why does traceroute work at all, if routers were never asked to cooperate?

Because every router must implement TTL expiry to kill looping packets, and the standard says to report it with ICMP Time Exceeded. traceroute is a side effect of loop protection.

▸Why three probe types?

Firewalls filter by protocol and port. A probe that looks like real traffic to the real service port (TCP SYN to 443) survives filters that kill UDP to random ports or ICMP echo — so the choice of probe decides whether the end of the path is visible.

▸Why does a hop show loss when the path is fine?

Forwarding happens in hardware at line rate; generating an ICMP error happens on a small CPU that rate-limits itself. The probe was forwarded; the reply was never created.

traceroute

traceroute: one probe per TTL
Each probe is sent with TTL = n; the n-th router decrements it to zero and reports back. The path is reconstructed from who complains.
Probe type
Simulated
$ traceroute -n example.com          # Linux/macOS default: UDP to ports 33434+
 1  192.168.1.1  (_gateway)              1.0 ms  1.0 ms  1.4 ms
Probe, TTL=1
UDP → 203.0.113.10:33434, ttl 1
Reply
ICMP Time Exceeded (type 11) from the router
What it hides. Each RTT is measured on the forward path plus the reply's own return path, which may run through different networks (asymmetric routing) — a slow hop can be a slow way back. Inside an MPLS core the label-switched routers often do not decrement TTL, so a continent of hops collapses into one line. Three samples per hop, and each sample may take a different route under ECMP.
1/8 · TTL 1

How it fails

What the failure looks like from inside real software.
Reference · show
  • Escalating to a carrier about "30% loss at hop 8" that is ICMP rate limiting and does not persist to the destination.
  • Concluding the destination is unreachable from a trace that ends in * * * when the destination merely filters UDP; -T -p 443 would have completed.
  • Blaming the hop where RTT jumped 80 ms for congestion when it is an ocean crossing.
  • Reading a single trace as the path when ECMP hashes each probe onto different routers.
  • Diagnosing the return path from a forward trace — the return route belongs to the other end and needs a trace from there.

Check yourself

Answer out loud or on paper first, then compare. These come from the interview questions linked to this lesson.

  1. A router has routes for 10.0.0.0/8, 10.4.0.0/16 and 0.0.0.0/0. A packet arrives for 10.4.7.9. Which route wins, and why is that the rule?

    Show a strong answer

    All three routes match 10.4.7.9 — the default matches everything, /8 matches anything starting with 10, /16 matches 10.4.x.x — and the router picks the one with the longest prefix, 10.4.0.0/16. The rule encodes specificity: a longer prefix is a more precise statement about where that address lives. It is what lets a table hold a broad route ("everything in 10/8 goes to the core") and carve exceptions out of it ("except 10.4/16, which goes to the Frankfurt link") without listing every subnet. The default route is simply the shortest possible prefix, so it loses to anything.

    Host routes (/32 in IPv4, /128 in IPv6) are the other extreme: they always win, which is how VPN clients steer one server through the tunnel, and how a stray /32 can hijack traffic to a single address. Between matches of equal length, metric/administrative distance decides; equal-cost routes can be used together (ECMP), hashing flows across paths.

    The same lookup runs on every host, not just routers: your laptop chooses between 192.168.1.0/24 dev wlan0 (on-link), a VPN’s 10.0.0.0/8 dev tun0, and default via 192.168.1.1. When a VPN pushes a /16 that overlaps the office network, longest-prefix match sends office traffic into the tunnel — silently. ip route get <dst> on Linux shows the winner.

    Full interview question, with follow-ups and red flags →
  2. ping api.example.com times out, but curl https://api.example.com/ returns 200 from the same machine. Explain how both can be true, and what ping actually proves in each direction.

    Show a strong answer

    ping sends an ICMP Echo Request (protocol 1 on IPv4, ICMPv6 type 128 on IPv6) and waits for an Echo Reply; curl opens a TCP connection to port 443 (protocol 6). These are different IP protocols, and every filter on the path — host firewall, cloud security group, network ACL, the load balancer’s own stack — decides about them separately. An AWS security group that allows TCP 443 and says nothing about ICMP drops the echo silently; Windows blocks incoming echo by default; many load balancer VIPs and anycast addresses never answer ICMP at all because nothing behind the VIP is a "host". The name may also resolve to a CDN or LB address that is not the machine running the service. So the ping proves nothing about the service, and the 200 proves the entire path — DNS, routing, TCP, TLS, HTTP — works. See ping: What an Echo Actually Proves and Firewalls.

    What ping *does* prove: a reply means IP-level reachability in both directions and gives an RTT and loss estimate *for ICMP*. A timeout means only that an echo did not come back — the host may be down, or the echo may be filtered outbound, at the destination, or on the return path, or rate-limited. Routers commonly process ICMP on a slow control-plane path and rate-limit it, so ping RTT and loss can look worse than the forwarding plane actually is. The reverse case is equally common: ping succeeds and the service is down — the host is up but nothing listens (connection refused), or the port is filtered (timed out), or TLS fails, or the process is hung and accepts connections it never answers. Each of those is a different layer (Why Can’t I Connect?).

    The right tools test the layer you care about: nc -vz host 443 or curl -v --connect-timeout 3 for TCP reachability, openssl s_client for TLS, curl -sS -o /dev/null -w "%{http_code}" for HTTP, mtr -T -P 443 or tcptraceroute to trace the path *using TCP to the real port* so ICMP filters do not produce * * * at every hop, and nmap -Pn to skip the host-discovery ping that would otherwise report "host down". A monitoring check that pings hosts is measuring a different thing from the service it is meant to watch.

    Full interview question, with follow-ups and red flags →
  3. What happens if a /32 route to your DNS server points at a down interface?

    Show a strong answer

    It still wins the lookup; DNS traffic goes nowhere. Longest prefix does not consider whether the path works, only which matches.

    Full interview question, with follow-ups and red flags →