ICMP Message Format: Type/Code, Error Messages, and Query Messages
ICMP (keyword), defined in RFC 792, uses a common header and a message-specific payload. Each ICMP message is identified by two 8-bit fields: keyword Type and keyword Code, followed by a keyword Checksum. Error messages also embed part of the offending (original) datagram to help the sender diagnose what went wrong.
Neat labeled diagram of the ICMP message (IPv4)
More explicitly, RFC 792 describes the base layout as:
- Type (8 bits)
- Code (8 bits)
- Checksum (16 bits) — one’s complement checksum computed over the ICMP message, starting at the Type field (with the checksum field treated as zero during computation)
- Rest of header / body — depends on the Type/Code
- For many error messages: includes Internet header + first 64 bits of the original datagram’s data.
Footnotes
-
RFC 792 - Internet Control Message Protocol - Defines ICMP message format (Type/Code/Checksum) and error payload (Internet header + 64 bits of original data), plus checksum rules. ↩ ↩2
ICMP packet types (request/reply, destination unreachable, time exceeded) explained
Key fields: Type, Code, Checksum, and payload
Type and Code are the primary dispatch mechanism:
- Type is an 8-bit value that identifies the category of ICMP message (e.g., Echo, Destination Unreachable, Time Exceeded). Common values from IANA include Type 0 (Echo Reply), 3 (Destination Unreachable), 8 (Echo), 11 (Time Exceeded), 12 (Parameter Problem).
- Code is an 8-bit value that provides more specific reason within that Type. For example, Destination Unreachable (Type 3) uses multiple Code values like “net unreachable”, “host unreachable”, “protocol unreachable”, “port unreachable”, etc.2
- Checksum: RFC 792 specifies the 16-bit one’s-complement checksum of the ICMP message starting at the Type field; when computing, the checksum field should be zero.
For many ICMP error messages, RFC 792 also defines that the payload includes:
- Internet Header + 64 bits of Original Data Datagram (used to match the message to the appropriate process, and to include relevant initial payload bytes such as transport-layer ports when applicable).
Footnotes
-
Internet Control Message Protocol (ICMP) Parameters (IANA) - Canonical registry of ICMP Type numbers and meanings (e.g., Echo=8, Echo Reply=0, Destination Unreachable=3, Time Exceeded=11, Parameter Problem=12, Redirect=5). ↩
-
RFC 792 - Internet Control Message Protocol - Defines ICMP message format (Type/Code/Checksum) and error payload (Internet header + 64 bits of original data), plus checksum rules. ↩ ↩2 ↩3
-
Internet Control Message Protocol (ICMP) Parameters (IANA) - Destination Unreachable Codes - Lists Destination Unreachable (Type 3) Code meanings and references RFC 792. ↩
How to interpret an ICMP packet using Type and Code
- 1Step 1
Extract the first two fields: Type (8 bits) and Code (8 bits). Their combination selects the exact meaning of the ICMP message.2
Footnotes
-
RFC 792 - Internet Control Message Protocol - Defines ICMP message format (Type/Code/Checksum) and error payload (Internet header + 64 bits of original data), plus checksum rules. ↩
-
Internet Control Message Protocol (ICMP) Parameters (IANA) - Canonical registry of ICMP Type numbers and meanings (e.g., Echo=8, Echo Reply=0, Destination Unreachable=3, Time Exceeded=11, Parameter Problem=12, Redirect=5). ↩
-
- 2Step 2
Compute/verify the 16-bit one’s-complement checksum over the ICMP message, starting at the Type field; treat the checksum field as zero during computation.
Footnotes
-
RFC 792 - Internet Control Message Protocol - Defines ICMP message format (Type/Code/Checksum) and error payload (Internet header + 64 bits of original data), plus checksum rules. ↩
-
- 3Step 3
Error messages commonly include the original IP header plus at least the first 64 bits of the original datagram.
Footnotes
-
RFC 792 - Internet Control Message Protocol - Defines ICMP message format (Type/Code/Checksum) and error payload (Internet header + 64 bits of original data), plus checksum rules. ↩
-
- 4Step 4
The remaining fields depend on the Type/Code (e.g., Echo uses Identifier/Sequence; errors include the original packet excerpt; Parameter Problem uses a Pointer field).
Footnotes
-
RFC 792 - Internet Control Message Protocol - Defines ICMP message format (Type/Code/Checksum) and error payload (Internet header + 64 bits of original data), plus checksum rules. ↩
-
Error ICMP messages: what they mean and common Types
ICMP error messages report problems detected during IP processing (e.g., unreachable destination, TTL expiration, malformed header). RFC 792 gives the core types and their structures, while IANA provides the canonical Type/Code numbering.2
Common ICMPv4 error message types (RFC 792 / IANA)
| ICMP Type (decimal) | Name | Typical meaning | Code usage |
|---|---|---|---|
| 3 | Destination Unreachable | Destination not reachable | Code specifies net/host/protocol/port/etc.2 |
| 5 | Redirect | Host should use a better router | Code selects redirect scope (e.g., network vs host) (per RFC 792 definitions)2 |
| 11 | Time Exceeded | TTL expired or reassembly timeout | Code distinguishes “in transit” vs “fragment reassembly” (IANA lists codes 0/1).2 |
| 12 | Parameter Problem | Error in IP header fields | Code identifies whether pointer indicates error, etc.2 |
The Destination Unreachable structure in RFC 792 includes:
Footnotes
-
RFC 792 - Internet Control Message Protocol - Defines ICMP message format (Type/Code/Checksum) and error payload (Internet header + 64 bits of original data), plus checksum rules. ↩ ↩2 ↩3 ↩4 ↩5 ↩6
-
Internet Control Message Protocol (ICMP) Parameters (IANA) - Canonical registry of ICMP Type numbers and meanings (e.g., Echo=8, Echo Reply=0, Destination Unreachable=3, Time Exceeded=11, Parameter Problem=12, Redirect=5). ↩ ↩2 ↩3 ↩4
-
Internet Control Message Protocol (ICMP) Parameters (IANA) - Destination Unreachable Codes - Lists Destination Unreachable (Type 3) Code meanings and references RFC 792. ↩
ICMP error message “excerpt” in one labeled diagram
This “original datagram excerpt” is described by RFC 792 as Internet header + 64 bits of original data included in the ICMP error message payload.
Footnotes
-
RFC 792 - Internet Control Message Protocol - Defines ICMP message format (Type/Code/Checksum) and error payload (Internet header + 64 bits of original data), plus checksum rules. ↩
type="tip" title="How Code helps" content="Type tells you the category (e.g., Destination Unreachable). Code tells you the specific cause (e.g., net unreachable vs port unreachable), which is crucial for accurate diagnostics and automated handling.2"
Footnotes
-
RFC 792 - Internet Control Message Protocol - Defines ICMP message format (Type/Code/Checksum) and error payload (Internet header + 64 bits of original data), plus checksum rules. ↩
-
Internet Control Message Protocol (ICMP) Parameters (IANA) - Destination Unreachable Codes - Lists Destination Unreachable (Type 3) Code meanings and references RFC 792. ↩
type="warning" title="Redirect (Type 5) is security-sensitive" content="ICMP Redirect informs a host about a supposed better next hop. Because such messages can be abused to influence routing, many networks restrict or disable accepting redirects (common defensive practice, though policy is deployment-specific). The protocol-defined Type 5 remains: “Redirect”.2"
Footnotes
-
Internet Control Message Protocol (ICMP) Parameters (IANA) - Canonical registry of ICMP Type numbers and meanings (e.g., Echo=8, Echo Reply=0, Destination Unreachable=3, Time Exceeded=11, Parameter Problem=12, Redirect=5). ↩
-
RFC 792 - Internet Control Message Protocol - Defines ICMP message format (Type/Code/Checksum) and error payload (Internet header + 64 bits of original data), plus checksum rules. ↩
Query / informational ICMP messages (diagnostics)
Query messages (informational/diagnostic) are used to test connectivity or obtain timing information, rather than reporting delivery failures.
A widely known example is Echo:
Echo Request/Reply pairs are the basis of the familiar ping diagnostic tool; the sender issues Echo, and the responder replies with Echo Reply when reachable.2
Other informational categories listed by IANA include Timestamp:
RFC 792 includes Timestamp and also older “Information request/reply” types marked as deprecated/obsolete in IANA’s registry (Type 15/16).2
Footnotes
-
Internet Control Message Protocol (ICMP) Parameters (IANA) - Canonical registry of ICMP Type numbers and meanings (e.g., Echo=8, Echo Reply=0, Destination Unreachable=3, Time Exceeded=11, Parameter Problem=12, Redirect=5). ↩ ↩2 ↩3 ↩4
-
RFC 792 - Internet Control Message Protocol - Defines ICMP message format (Type/Code/Checksum) and error payload (Internet header + 64 bits of original data), plus checksum rules. ↩ ↩2
Mapping “Type & Code” to the right ICMP meaning (mini cheat sheet)
Destination Unreachable (Type 3) — example Codes
IANA lists the Destination Unreachable codes and their meanings, referencing RFC 792.
| Type 3 Code | Meaning |
|---|---|
| 0 | Net Unreachable |
| 1 | Host Unreachable |
| 2 | Protocol Unreachable |
| 3 | Port Unreachable |
| 4 | Fragmentation Needed and DF Set |
| 5 | Source Route Failed |
These Code meanings are part of the official ICMP Parameterization registry and reference RFC 792.
Time Exceeded (Type 11) — example Codes
IANA lists Time Exceeded codes (RFC 792):
| Type 11 Code | Meaning |
|---|---|
| 0 | Time to Live exceeded in Transit |
| 1 | Fragment Reassembly Time Exceeded |
The codes distinguish the TTL-expired case from the fragment reassembly timeout case.
Parameter Problem (Type 12) — example Codes
IANA lists Parameter Problem codes (RFC 792):
| Type 12 Code | Meaning |
|---|---|
| 0 | Pointer indicates the error |
(Additional codes exist in the registry such as “missing a required option” and “bad length”, depending on the RFC extensions/updates.)2
RFC 792 also describes the presence of a Pointer field for Parameter Problem messages.
Footnotes
-
Internet Control Message Protocol (ICMP) Parameters (IANA) - Destination Unreachable Codes - Lists Destination Unreachable (Type 3) Code meanings and references RFC 792. ↩ ↩2 ↩3
-
Internet Control Message Protocol (ICMP) Parameters (IANA) - Canonical registry of ICMP Type numbers and meanings (e.g., Echo=8, Echo Reply=0, Destination Unreachable=3, Time Exceeded=11, Parameter Problem=12, Redirect=5). ↩ ↩2
-
RFC 792 - Internet Control Message Protocol - Defines ICMP message format (Type/Code/Checksum) and error payload (Internet header + 64 bits of original data), plus checksum rules. ↩
Where ICMP errors and queries fit in IP processing
Datagram transmission
1. Sender sends an IP datagramThe sender emits an IP packet that may be routed through multiple hops."
ICMP error generation
2. A hop detects an issueIf a router/host detects failure (unreachable, TTL expired, header error), it generates an ICMP error message (Type/Code + original header excerpt)."
Footnotes
-
RFC 792 - Internet Control Message Protocol - Defines ICMP message format (Type/Code/Checksum) and error payload (Internet header + 64 bits of original data), plus checksum rules. ↩
Diagnostic/reporting
3. Receiver (or original sender) receives ICMPThe original sender uses the ICMP Type/Code and embedded excerpt to correlate the error to its transmission attempt."
Footnotes
-
RFC 792 - Internet Control Message Protocol - Defines ICMP message format (Type/Code/Checksum) and error payload (Internet header + 64 bits of original data), plus checksum rules. ↩
ICMP query/echo
4. Optional diagnosticsFor testing/measurement (e.g., Echo Request/Reply; Timestamp), endpoints exchange informational messages instead of error reporting."
Footnotes
-
Internet Control Message Protocol (ICMP) Parameters (IANA) - Canonical registry of ICMP Type numbers and meanings (e.g., Echo=8, Echo Reply=0, Destination Unreachable=3, Time Exceeded=11, Parameter Problem=12, Redirect=5). ↩
Common ICMP message categories by Type
A conceptual view of typical ICMP message types used for errors vs queries
Common exam-style points to remember
ICMP quick recall (Type/Code + structure)
Knowledge Check
In ICMP, the message is primarily identified by which fields?