ICMP Protocol

ICMP (Internet Control Message Protocol) reports errors and diagnostic information about IP packet delivery instead of carrying application data. Routers send ICMP messages such as Destination Unreachable or Time Exceeded back to the sender, and the ping and traceroute tools use ICMP to test reachability, measure round-trip time and map a packet's path.

3 min read

ICMP (Internet Control Message Protocol) is used to report errors and diagnostic information about the delivery of IP packets, rather than carrying application data itself. It's the mechanism routers and hosts use to say "this didn't work, and here's why," and it directly powers two of the most commonly used network diagnostic tools.

What ICMP messages actually communicate

If a router can't deliver a packet toward its destination (say, there's no route to that network) or a packet's Time To Live (a counter that decrements at each router hop, preventing packets from looping forever) reaches zero, the router sends an ICMP message back to the original sender explaining what happened, rather than silently dropping the packet with no explanation.

Common ICMP message types include Echo Request/Echo Reply (used by ping), Destination Unreachable (the packet couldn't be delivered), and Time Exceeded (the packet's TTL hit zero before reaching its destination).

How ping actually works

The ping command sends an ICMP Echo Request to a target host and waits for an ICMP Echo Reply. If a reply comes back, the host is reachable, and the round-trip time gives a real measurement of latency to that host. If no reply arrives within a timeout, ping reports the request as lost or the host as unreachable.

How traceroute actually works

Traceroute uses ICMP's Time Exceeded message cleverly: it sends a series of packets with progressively increasing TTL values, starting at 1. The first packet (TTL 1) expires at the very first router hop, which sends back a Time Exceeded message, revealing that router's address. The next packet (TTL 2) expires at the second hop, revealing its address, and so on. By incrementing the TTL one hop at a time and recording each ICMP Time Exceeded response, traceroute maps out the entire path (every router hop) a packet takes to reach its destination.

A worked example

Running ping example.com sends ICMP Echo Requests; if replies come back with a round-trip time of, say, 45ms, that confirms the server is reachable and gives a real latency measurement. Running traceroute example.com afterward might reveal the packet passes through 12 intermediate routers before reaching the destination, showing exactly which hop (if any) is introducing unusual delay or where a connection is actually failing, information ping alone can't provide.

Where this matters in real systems

Both ping and traceroute are among the very first tools any network engineer reaches for when diagnosing "why can't I reach this server," precisely because they're built directly on ICMP's error-reporting design and require no special setup. As mentioned in the context of ARP and general IP protocols, some networks and firewalls deliberately block or rate-limit ICMP traffic (since ICMP floods have historically been used in denial-of-service attacks), which is a real, common reason a genuinely healthy, reachable server might not respond to ping.

What interviewers actually ask about ICMP

  • "What does ICMP actually do?" Reports errors and diagnostic information about IP packet delivery, rather than carrying application data; it's how routers and hosts communicate "this failed, here's why."
  • "How does ping use ICMP?" It sends ICMP Echo Request messages and waits for ICMP Echo Reply messages, using the round trip to determine reachability and measure latency.
  • "How does traceroute discover each router along a path?" It sends packets with progressively increasing TTL values; each packet expires at the next hop along the path, triggering an ICMP Time Exceeded message that reveals that hop's address.
  • "Why might a server not respond to ping even though it's actually online?" A firewall or the server itself may be deliberately blocking or rate-limiting ICMP traffic, a common security measure since ICMP has been used in denial-of-service attacks.

Key takeaways

  • ICMP reports errors and diagnostic information about IP packet delivery, rather than carrying application data.
  • Ping uses ICMP Echo Request/Reply messages to test reachability and measure round-trip latency.
  • Traceroute uses ICMP Time Exceeded messages, triggered by progressively increasing TTL values, to map out every router hop along a path.
  • ICMP is often blocked or rate-limited by firewalls as a security measure, which can make a healthy server appear unreachable to ping.
All 101 Computer Networks interview questions

Log in to save which topics you've read across every subject.

Frequently asked questions

What does ICMP actually do?

Reports errors and diagnostic information about IP packet delivery, rather than carrying application data; it's how routers and hosts communicate "this failed, here's why."

How does ping use ICMP?

It sends ICMP Echo Request messages and waits for ICMP Echo Reply messages, using the round trip to determine reachability and measure latency.

How does traceroute discover each router along a path?

It sends packets with progressively increasing TTL values; each packet expires at the next hop along the path, triggering an ICMP Time Exceeded message that reveals that hop's address.

Why might a server not respond to ping even though it's actually online?

A firewall or the server itself may be deliberately blocking or rate-limiting ICMP traffic, a common security measure since ICMP has been used in denial-of-service attacks.