ICMP Message Format: Type/Code, Error Messages, and Query Messages

ICMP Message Format: Type/Code, Error Messages, and Query Messages

Verified Sources
Nov 3, 2026

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

  1. 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

  1. 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. ↩ ↩2 ↩3

  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

  1. 1
    Step 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

    1. 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. 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. 2
    Step 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

    1. 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. ↩

  3. 3
    Step 3

    Error messages commonly include the original IP header plus at least the first 64 bits of the original datagram.

    Footnotes

    1. 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. ↩

  4. 4
    Step 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

    1. 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)NameTypical meaningCode usage
3Destination UnreachableDestination not reachableCode specifies net/host/protocol/port/etc.2
5RedirectHost should use a better routerCode selects redirect scope (e.g., network vs host) (per RFC 792 definitions)2
11Time ExceededTTL expired or reassembly timeoutCode distinguishes “in transit” vs “fragment reassembly” (IANA lists codes 0/1).2
12Parameter ProblemError in IP header fieldsCode identifies whether pointer indicates error, etc.2

The Destination Unreachable structure in RFC 792 includes:

  • Type/Code/Checksum
  • unused
  • Internet Header + 64 bits of Original Data Datagram.

Footnotes

  1. 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

  2. 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

  3. 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

  1. 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

  1. 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. 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

  1. 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. ↩

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:

  • Type 8: Echo Request
  • Type 0: Echo Reply

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:

  • Type 13: Timestamp
  • Type 14: Timestamp Reply

RFC 792 includes Timestamp and also older “Information request/reply” types marked as deprecated/obsolete in IANA’s registry (Type 15/16).2

Footnotes

  1. 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

  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. ↩ ↩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 CodeMeaning
0Net Unreachable
1Host Unreachable
2Protocol Unreachable
3Port Unreachable
4Fragmentation Needed and DF Set
5Source 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 CodeMeaning
0Time to Live exceeded in Transit
1Fragment 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 CodeMeaning
0Pointer 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

  1. Internet Control Message Protocol (ICMP) Parameters (IANA) - Destination Unreachable Codes - Lists Destination Unreachable (Type 3) Code meanings and references RFC 792. ↩ ↩2 ↩3

  2. 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. 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 datagram

The sender emits an IP packet that may be routed through multiple hops."

ICMP error generation

2. A hop detects an issue

If a router/host detects failure (unreachable, TTL expired, header error), it generates an ICMP error message (Type/Code + original header excerpt)."

Footnotes

  1. 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 ICMP

The original sender uses the ICMP Type/Code and embedded excerpt to correlate the error to its transmission attempt."

Footnotes

  1. 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 diagnostics

For testing/measurement (e.g., Echo Request/Reply; Timestamp), endpoints exchange informational messages instead of error reporting."

Footnotes

  1. 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)

1 / 5
Question · Term

ICMP header: fields order?

Click to reveal
Answer · Definition

Type (8), Code (8), Checksum (16), then message-specific fields; errors often carry Internet header + first 64 bits of original datagram.

Footnotes

  1. 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. ↩

Knowledge Check

Question 1 of 4
Q1Single choice

In ICMP, the message is primarily identified by which fields?