ICMP // RFC 792

The control and error plane of IPv4. ICMP has an eight-byte common header and a type-specific body: echo requests keep latency probes simple, while unreachable and time-exceeded messages quote the packet that caused them. No ports, no pseudo-header, and no security beyond the checksum.

layer internet control header 8 B + type-specific body checksum entire ICMP message wrapper IPv4 protocol 1

01Message layout

common header · 8 bytes

Every ICMPv4 message starts with Type, Code and a 16-bit Checksum. The next four bytes are the rest of header: their meaning is fixed by the type and code, not by the common header. Everything after byte eight is the message body. The checksum covers the complete ICMP message, including the body, and not the IPv4 header that carries it.

no pseudo-header, no ports

ICMPv4 is a network-layer protocol, not a transport protocol. It has no source or destination ports and its checksum does not include an IPv4 pseudo-header. ICMPv6 is different: it uses next header 58, a separate type space and a checksum that includes the IPv6 pseudo-header.

02Types & codes

information, errors and diagnostics

The 8-bit type selects the message class; the 8-bit code refines it. Echo and timestamp messages are informational, while unreachable, redirect, time-exceeded and parameter-problem messages report errors. A handful of old types are formally deprecated and should be ignored or filtered.

type & code explorerselect a combination
08 00
name 8 · Echo Request code 0 · No code
Identifier (16) + Sequence Number (16)
Echo payload (arbitrary length)

RFC 792

TypeMessageCommon codesRest of headerBodyReference
0Echo Reply0Identifier + SequenceEchoed payloadRFC 792
3Destination Unreachable0 net · 1 host · 2 protocol · 3 port · 4 frag neededUnused + Length + MTU/unusedOriginal IPv4 header + 8+ bytesRFC 792 · RFC 1191 · RFC 4884
4Source Quench0UnusedOriginal datagramRFC 792 · deprecated
5Redirect0 net · 1 host · 2 TOS+net · 3 TOS+hostGateway IPv4 addressOriginal datagramRFC 792
8Echo Request0Identifier + SequenceEcho payloadRFC 792
9Router Advertisement0Num Addrs + Entry Size + LifetimeRouter entriesRFC 1256
10Router Solicitation0ReservedNo bodyRFC 1256
11Time Exceeded0 TTL · 1 reassemblyUnused + Length + unusedOriginal datagramRFC 792 · RFC 4884
12Parameter Problem0 pointer · 1 missing option · 2 bad lengthPointer + Length + unusedOriginal datagramRFC 792 · RFC 4884
13Timestamp Request0Identifier + SequenceThree 32-bit timestampsRFC 792
14Timestamp Reply0Identifier + SequenceThree 32-bit timestampsRFC 792
17Address Mask Request0Identifier + Sequence4-byte subnet maskRFC 950 · deprecated
18Address Mask Reply0Identifier + Sequence4-byte subnet maskRFC 950 · deprecated
30Traceroute0ID + hop countsType-specificRFC 1393 · obsolete
42Extended Echo Request0Identifier + Sequence + LRFC 4884 extensionRFC 8335
43Extended Echo Reply0–4Identifier + Sequence + flagsRFC 4884 extensionRFC 8335

Common code values

TypeCodeMeaningWhy it matters
30Network UnreachableNo route to the destination network.
31Host UnreachableThe last-hop network cannot reach the host.
32Protocol UnreachableNo upper-layer protocol handler on the target.
33Port UnreachableUDP port closed; also used by some TCP stacks.
34Fragmentation Needed and DF SetPath-MTU Discovery; the rest-of-header carries the next-hop MTU.
39/10Network / host administratively prohibitedA firewall or routing policy rejected the packet.
313Communication Administratively ProhibitedCommon firewall rejection code.
50–3Redirect for network / host / TOS variantsRouter suggests a better next hop; usually ignored for security.
110TTL Exceeded in TransitThe building block of traceroute.
111Fragment Reassembly Time ExceededA fragmented datagram did not arrive in time.
120Pointer Indicates ErrorThe pointer names the malformed octet in the original header.
121Missing Required OptionAn option required by the type or code was absent.
122Bad LengthThe original datagram's length field is inconsistent.
Pingtype 8 / code 0Echo request; the reply is type 0 with the same identifier, sequence and payload.
Traceroutetype 11 / code 0Routers report TTL expiry. The quoted original datagram identifies the probe.
Path-MTU Discoverytype 3 / code 4“Fragmentation needed and DF set” carries the next-hop MTU. Blocking it can black-hole TCP.
Port unreachabletype 3 / code 3UDP has no handshake; this is often the only signal that a service is closed.
Parameter problemtype 12 / code 0The pointer identifies the offending octet. Useful when an option or length field is malformed.
Redirecttype 5 / code 1An ICMP redirect points at another gateway. Most hosts ignore redirects by default.
ICMP is unauthenticated control traffic

Any host that can reach the path can send an ICMP error. The checksum protects against accidental corruption, not forgery. Validate quoted datagrams before changing connection state, rate-limit ICMP generation, and do not blanket-drop all ICMP: path-MTU discovery and IPv6 depend on it.

03Rest-of-header formats

the same 32 bits, different meanings

The second 32-bit word — the four bytes after the checksum — is where most ICMP parsers go wrong. Echo uses an identifier and sequence; redirect carries a gateway address; Parameter Problem carries a pointer. The error types that quote an original datagram also use the sixth octet for an RFC 4884 Length field when an extension structure is present.

Type(s)Bits 32–63Body interpretationReference
0, 8, 13, 14, 15, 16, 17, 18Identifier (16) · Sequence (16)Echo payload, timestamp fields or subnet mask.RFC 792 · RFC 950
3Unused (8) · Length (8) · Next-Hop MTU or unused (16)Original IPv4 header plus quoted payload; code 4 supplies the MTU.RFC 792 · RFC 1191 · RFC 4884
4Unused (32)Deprecated Source Quench.RFC 792 · RFC 6633
5Gateway IPv4 address (32)Original datagram after the ICMP header.RFC 792
9Num Addrs (8) · Addr Entry Size (8) · Lifetime (16)Router address and preference entries.RFC 1256
10Reserved (32)No body.RFC 1256
11Unused (8) · Length (8) · unused (16)Original datagram plus optional RFC 4884 extensions.RFC 792 · RFC 4884
12Pointer (8) · Length (8) · unused (16)Original datagram; pointer identifies the malformed octet.RFC 792 · RFC 4884
42Identifier (16) · Sequence (8) · Reserved (7) · L (1)RFC 4884 extension structure identifying the probed interface.RFC 8335
43Identifier (16) · Sequence (8) · State (3) · Res (2) · A · 4 · 6Extended Echo Reply flags and state.RFC 8335
RFC 4884 reused a reserved octet

Before extensions, the sixth octet of Destination Unreachable, Time Exceeded and Parameter Problem was “unused.” RFC 4884 redefined it as the length of the original datagram in 32-bit words. A value of zero means no extension structure. When it is non-zero, the original datagram is padded to a 32-bit boundary and an extension header (version 2) follows it.

04Encoder

checksum computed over the full message

Build an ICMPv4 message with the type-specific rest-of-header. The checksum is calculated after the header and body are assembled. Optionally wrap the message in a minimal IPv4 packet so you can paste a complete on-wire unit into a lab tool or capture.

ICMP parameters

RFC 792
8 · Echo Request
0 · No code
Identifier (16) + Sequence Number (16).

The encoder computes the ICMP checksum first, then the IPv4 header checksum when wrapping. It does not add Ethernet framing or an FCS; use the Ethernet explorer for that layer.

wire output

waiting
Set the fields and press Build ICMP.
message / packet hex
no bytes built yet
valid bytes, not trusted control traffic

A correct checksum only means the bytes arrived intact. A forged ICMP redirect or unreachable message is still a valid ICMP message; the receiver must decide whether the sender is credible.

05Decoder

raw ICMP, IPv4 packet or Ethernet frame

Paste an ICMP message, an IPv4 packet with Protocol 1, or an Ethernet II frame carrying IPv4. The decoder validates both checksums, follows the type-specific rest-of-header, and parses quoted original datagrams and RFC 4884 extensions. Raw ICMP is accepted directly, which is useful when your capture tool strips the IP header.

parse bytes

RFC 792 · type-specific body
No ICMP message decoded yet.

06Wire notes

what the pcap does not tell you
ICMPv6 is not ICMPv4

ICMPv6 is IPv6 next header 58 and is defined by RFC 4443. It has a different type/code space, includes Neighbor Discovery (RFC 4861) and uses an IPv6 pseudo-header in its checksum. Do not reuse an ICMPv4 checksum routine or type table for ICMPv6. The IPv6 explorer covers the base header and next-header chain.

  • The checksum covers only ICMP. For ICMPv4, sum the eight-byte header and the entire body. There is no pseudo-header. A receiver summing the message including the checksum should get 0xFFFF.
  • Error messages quote the trigger. Destination Unreachable, Redirect, Source Quench, Time Exceeded and Parameter Problem carry the original IPv4 header and at least eight bytes of its payload. The quote may be truncated or rewritten by NAT.
  • Length is in 32-bit words. RFC 4884 reuses the sixth octet for the length of the original datagram when an extension structure is present. Zero means no extension. The quoted datagram is padded to a 4-byte boundary.
  • Type 3 code 4 is path-MTU discovery. The next-hop MTU in the rest-of-header tells the sender how small to fragment. Filtering this message can cause TCP black holes, especially with DF set.
  • TTL expiry is not an error in the transport sense. Time Exceeded is normal traceroute behavior. The quoted datagram is how the sender knows which probe expired.
  • Redirects are a security liability. A host that accepts ICMP redirects can be steered through an attacker. Most modern stacks ignore redirects by default or require strict source/interface checks.
  • No authentication. ICMP has no signature, nonce or source authentication. The checksum detects accidental corruption only. ICMP filtering, rate limiting and quoted-packet validation are operational controls, not protocol guarantees.
  • Deprecated does not mean absent. RFC 6633 deprecates Source Quench; RFC 6918 deprecates types 6, 15, 16, 17, 18 and 30–39. Old devices and lab traffic still emit them.

References