ICMP (Internet Control Message Protocol) is the companion protocol of the Internet Protocol that carries error reports and diagnostic messages between hosts and routers, such as notices that a destination is unreachable or that a packet’s lifetime expired. Among Internet protocols, it is the network layer’s feedback channel: it does not move application data, but it tells senders why their packets did not arrive.
ICMP for IPv4 is defined in RFC 792, and ICMPv6 in RFC 4443. The version for IPv6 is far more central, because it also handles neighbor discovery and address autoconfiguration, functions that IPv4 delegates to ARP and DHCP.
How ICMP messages are built and carried
An ICMP message travels directly inside an IP packet, identified by protocol number 1 for IPv4 and next header value 58 for IPv6; it uses no ports and no transport layer. Every message starts with an 8-bit type, an 8-bit code that refines the type, and a 16-bit checksum, followed by type-specific fields.
Error messages include the IP header and at least the first 8 bytes of the offending packet, and ICMPv6 includes as much of it as fits in the minimum MTU of 1,280 bytes. This quoted fragment lets the original sender match the error to a specific TCP or UDP connection through its port numbers.
Several rules prevent error storms. A host never sends an ICMP error about another ICMP error, about a broadcast or multicast packet in most cases, or about a non-initial fragment. Routers also rate-limit ICMP generation so that a flood of bad packets cannot turn them into amplifiers.
ICMP messages also have no delivery guarantee of their own. They are ordinary IP packets that can be lost, filtered or rate-limited along the return path, so a sender must treat the absence of an ICMP error as no information rather than proof of success. Well-designed protocols therefore combine ICMP feedback with their own timeouts and retransmissions.
Main ICMP message types
ICMP messages fall into error messages and informational messages, and a small set of types accounts for nearly all traffic seen in practice. The table lists the IPv4 values with their ICMPv6 counterparts.
| Message | ICMPv4 type | ICMPv6 type | Purpose |
|---|---|---|---|
| Echo request | 8 | 128 | Ask a host to reply, used by ping |
| Echo reply | 0 | 129 | Answer to an echo request |
| Destination unreachable | 3 | 1 | Report that a packet could not be delivered |
| Time exceeded | 11 | 3 | Report that TTL or hop limit reached zero |
| Packet too big | 3, code 4 | 2 | Report the next-hop MTU for path discovery |
| Redirect | 5 | 137 | Point a host to a better first-hop router |
| Parameter problem | 12 | 4 | Report a malformed header field |
In IPv4, the packet-too-big signal is destination unreachable with code 4, “fragmentation needed and DF set”. ICMPv6 gives it a separate type because IPv6 routers never fragment packets in transit, which makes the message indispensable.
Diagnostic tools built on ICMP
The best-known network tools are thin wrappers around ICMP messages, which is why ICMP is often the first thing administrators reach for when a connection fails. Each tool reveals a different property of the path.
| Tool | What it sends | What it learns |
|---|---|---|
| ping | Echo requests | Reachability, round-trip time and loss |
| traceroute | Probes with rising TTL | Each router that returns time exceeded |
| Path MTU Discovery | Packets with DF set | Largest packet size the path accepts |
| mtr | Repeated TTL-limited probes | Per-hop loss and latency over time |
Results need careful reading. A router that deprioritizes ICMP replies on its control plane can show high latency or loss at one hop while traffic passing through it is unaffected. Only loss that persists to the final hop indicates a real forwarding problem.
ICMP compared with neighboring protocols
ICMP is part of the IP layer rather than a transport protocol, even though it is encapsulated in IP like TCP and UDP. The comparison clarifies where it fits.
| Protocol | Layer | Carries application data | Main role |
|---|---|---|---|
| ICMP | Network, alongside IP | No | Errors and diagnostics |
| TCP | Transport | Yes | Reliable ordered byte streams |
| UDP | Transport | Yes | Simple datagrams with ports |
| ARP | Link and network boundary | No | IPv4 address to MAC resolution |
| ICMPv6 NDP | Network, alongside IPv6 | No | Neighbor and router discovery |
Higher-level protocols depend on ICMP feedback. TCP reacts to destination unreachable messages and uses packet-too-big signals to size segments, and QUIC performs its own path MTU probing partly because ICMP is unreliable across many networks.
Filtering ICMP safely and common misconceptions
Blocking all ICMP is a long-standing misconfiguration that breaks networks in subtle ways. The most damaging effect is the Path MTU Discovery black hole: when packet-too-big messages are dropped, large TCP segments vanish silently, so small requests succeed while large pages or file transfers hang.
- Always permit packet too big and IPv4 fragmentation-needed messages, as RFC 4890 recommends for ICMPv6 firewalls.
- Never filter ICMPv6 neighbor and router discovery on local links, because IPv6 addressing stops working without it.
- Permit time exceeded and destination unreachable, which carry little risk and speed up failure detection.
- Rate-limit echo requests at the edge if desired, rather than blocking them, to keep basic reachability tests working.
Historic attacks such as the ping of death, Smurf amplification and forged redirects shaped this caution, but modern operating systems resist them. The real residual risks are reconnaissance and volumetric floods, both handled better by rate limits than by blanket denial. Another misconception is that a host that does not answer ping is offline; many hosts simply drop echo requests by policy.
The idea in brief
Data on the internet travels in small parcels. ICMP is the postal service’s system of returned-mail notices. When a parcel cannot be delivered, because the address does not exist, the route is too long or the parcel is too big for a narrow road, a short note goes back to the sender saying what happened.
The same system also lets you ask a computer “are you there?” and wait for a reply, which is what the ping command does. Without these notes, senders would be left guessing why their messages disappeared.
A practical scenario
A company connects a branch office through a VPN tunnel that adds about 60 bytes of overhead, reducing the path MTU to about 1,440 bytes. Users at the branch can open simple web pages, but uploads stall and some sites load only partially. Ping works, so the link appears healthy.
A network engineer runs ping with the do-not-fragment flag and increasing packet sizes and finds that anything above 1,440 bytes disappears without a reply. The headquarters firewall has a rule that drops all inbound ICMP, including fragmentation-needed messages. After the rule is changed to permit those messages and to rate-limit echo requests, Path MTU Discovery works again, and uploads and page loads return to normal the same afternoon.