← Module 03 · Layer 3: Network

ICMP: Ping & Traceroute Mechanics

Not TCP (Transmission Control Protocol), not UDP (User Datagram Protocol), no port numbers at all. ICMP is the network's own diagnostic and error-reporting channel, and it's the entire mechanism behind two of the most-used tools in networking.

What ICMP actually is

ICMP (Internet Control Message Protocol) rides directly inside IP (Internet Protocol; Protocol number 1, from the IPv4 header topic) rather than on top of TCP or UDP. It has no ports, no sessions, nothing to connect to. It exists purely to carry short, structured control and error messages between devices. Every ICMP message has a type and code that say exactly what it's reporting.

Ping: Echo request and reply

Ping is the simplest possible use of ICMP: send a type 8, Echo Request, and if the destination is reachable and willing to answer, it sends back a type 0, Echo Reply. No data exchanged beyond "are you there," and how long the round trip took.

Traceroute: Abusing TTL on purpose

Recall from the IPv4 header topic that every router decrements a packet's TTL (Time to Live) by one, and drops it with a type 11, Time Exceeded message if TTL hits zero. Traceroute turns that error condition into a mapping tool: it sends a packet with TTL=1, which dies at the very first router, revealing that router's address in the Time Exceeded reply. Then it sends one with TTL=2, which dies at the second router. It keeps incrementing until a packet finally survives all the way to the destination.

YOU R1 R2 DEST TTL=1 → dies here, "Time Exceeded" from R1 TTL=2 → dies here, "Time Exceeded" from R2 TTL=3 → survives, reaches the destination
Three probes, three increasing TTLs. Each Time Exceeded reply hands traceroute the address of one more hop along the path.

Each router's Time Exceeded reply comes from that router's own address, so by the time a probe finally survives to the destination, traceroute has assembled the full list of routers in between, one hop revealed per probe.

ICMP messageTypeMeaning
Echo Request8"Are you there?", what ping sends
Echo Reply0"Yes.", what ping receives back
Destination Unreachable3A router or host couldn't deliver the packet at all
Time Exceeded11TTL hit zero, the mechanism traceroute is built on

ICMP types and codes, in full

Every ICMP message carries both fields: type says the general category, code narrows it down within that category. Some types only ever have one code; others, like Destination Unreachable, use the code to say exactly why the packet couldn't be delivered.

TypeCodeMeaning
00Echo Reply
30Network Unreachable
1Host Unreachable
2Protocol Unreachable
3Port Unreachable
4Fragmentation Needed and DF set (see IPv4 Fragmentation)
50–3Redirect, "use this other gateway instead"
80Echo Request
110TTL exceeded in transit, what traceroute is built on
1Fragment reassembly time exceeded
120Parameter Problem, a malformed IP header field
A NO-REPLY DOESN'T MEAN A DEAD HOST

Firewalls very commonly block ICMP outright as a hardening measure, since it can also be used to probe or map a network. A host that never replies to ping might be perfectly reachable on every port that actually matters. Treat "no ping" as "ICMP is filtered," not proof the host is down.