Skip to main content
  1. Network Articles/
  2. IPv4 Articles/

What is ICMP (Internet Control Message Protocol)

Table of Contents

What is ICMP

ICMP (Internet Control Message Protocol) is a protocol used to exchange control messages and error notifications for IPv4 communication. It is defined in RFC 792.

IP itself has no mechanism to guarantee reliability, and no way to notify the sender when a packet fails to reach its destination. ICMP is an auxiliary protocol designed to report on the status of IP communication — unreachable destinations, errors encountered along the path, connectivity checks, and so on — and is never used to carry user data.

ICMP is carried as the payload of an IP packet, immediately following the IP header, and is identified by IP header protocol number 1. Like TCP and UDP, it sits above IP, but in practice it is often treated as part of the IP stack itself rather than as an independent transport-layer protocol. The equivalent function in IPv6 is provided by ICMPv6, which is redefined as a separate protocol that also absorbs ARP’s address resolution role (via NDP).

Position of ICMP within an Ethernet Frame

Because ICMP is carried as the payload (data portion) of an IP packet, on an Ethernet frame it is placed after the Ethernet header (destination/source MAC addresses, etc.), following the IP header. Note that ICMP itself has no Ethernet header or FCS (Frame Check Sequence) of its own — it is treated purely as part of the contents of the IP packet.

The destination host uses the Ethernet header’s Type field (0x0800 = IPv4) to determine that the payload is an IP packet, and then the IP header’s Protocol field (1) to determine that its data portion is an ICMP message, before processing it as ICMP.

ICMP Packet Format

Every ICMP message begins with a common 8-byte header. The first 4 bytes follow the same format across all messages, but the structure of the following 4 bytes (Rest of Header) and the subsequent Data section varies depending on the message type (Type/Code).

Field NameSizeDescription
Type1 byteThe message type. Echo Request (8), Echo Reply (0), Destination Unreachable (3), Time Exceeded (11), etc.
Code1 byteA sub-type defined per Type. The same Type can have different detailed meanings depending on the Code value.
Checksum2 bytesAn error-detection checksum covering the entire ICMP message (header + data).
Rest of Header4 bytesA field whose contents vary by message type. For Echo, it holds the Identifier and Sequence Number; for Destination Unreachable and Time Exceeded, it is unused (zero-filled).
DataVariableData depending on the message type. For Echo, arbitrary padding data; for error messages, a portion of the original IP packet that caused the problem.

Common ICMP Message Types

Many message types are defined for ICMP, but the ones most commonly encountered in practice are:

TypeNameCommon CodesOverview
0Echo Reply0Response to an Echo Request (ping)
3Destination Unreachable0-15Notification that the destination cannot be reached
5Redirect0-3Notification that a better route (next hop) exists
8Echo Request0Connectivity check request (ping)
11Time Exceeded0, 1Notification that a packet was discarded, e.g. due to TTL expiry
12Parameter Problem0-2Notification of a problem with an IP header parameter

The full list of types and codes is maintained by IANA.

Constraints on Generating ICMP Messages (RFC 1122)

If ICMP error messages were generated without limit, it could trigger a chain reaction of errors on the network (an ICMP error itself triggering another ICMP error, and so on). To prevent this, RFC 1122 defines constraints such as:

  • Do not generate a new ICMP error message in response to an ICMP error message (an error response to an ICMP query message such as Echo Reply may be an exception).
  • Do not generate an ICMP error message for a second or later fragment (a packet whose fragment offset is not 0).
  • As a rule, do not generate an ICMP error message for a packet whose destination is a broadcast or multicast address.
Because of these constraints, ICMP is designed so that reporting an error never triggers a further chain of errors, even though it does report errors.

References

RFCTitleOverview
RFC 792Internet Control Message ProtocolThe original ICMP specification, defining the basic message format and types.
RFC 1122Requirements for Internet Hosts – Communication LayersDefines host requirements, including constraints on generating ICMP messages.

Related Articles