Octet

How does traceroute work?

Show the answer

Say this first

It sends probes with TTL 1, then 2, then 3, and so on. Each router that decrements the TTL to zero drops the probe and returns ICMP time exceeded (type 11), which reveals its address. The destination answers differently: ICMP port unreachable for a UDP probe, or an echo reply for an ICMP probe, and that ends the trace. Linux, macOS and Cisco IOS send UDP to high ports starting at 33434. Windows tracert sends ICMP echo. Three probes per hop by default.

Go deeper

Step by step

  1. The first probe leaves with TTL 1. The first router decrements it to 0, drops it, and sends ICMP type 11 code 0 (TTL exceeded in transit) back from its own address, usually the interface facing you.
  2. The probe with TTL 2 expires at the second router, and so on.
  3. The destination gets a probe with TTL still above zero. For UDP to an unused high port it answers ICMP type 3 code 3 (port unreachable). For ICMP echo it sends an echo reply. Either one ends the trace.

Variants

ToolProbeEnd signal
Linux and macOS tracerouteUDP, port 33434 and upport unreachable
traceroute -IICMP echoecho reply
traceroute -T -p 443 (Linux, root)TCP SYNSYN-ACK or RST
Windows tracertICMP echoecho reply
Cisco IOS tracerouteUDP, port 33434 and upport unreachable

Reading a line

Each hop shows three round-trip times, one per probe. The time includes how long that router's CPU took to build the ICMP message. Cisco marks * for a timeout and codes such as !H (host unreachable), !N (network unreachable) and !A (administratively prohibited).

Traps

  • Saying traceroute shows the return path. It shows the forward path only.
  • Saying Windows tracert uses UDP. It uses ICMP echo.
How did you do?Book 3.3 Internet (IP)