networking, updated

ICMP and ICMPv6

The Internet Control Message Protocol carries error and diagnostic messages for IP: ping, traceroute, unreachable and 'packet too big'. In IPv6 it also does neighbour discovery.

OSI layer
3 Network
Carried in
IPv4 / IPv6
Identified by
IP protocol 1 (ICMPv6: next header 58)
Specs
RFC 792, RFC 4443, RFC 1191, RFC 4890
Wireshark filter
icmp || icmpv6
Encrypted
no

Packet structure

ICMP echo (ping)8 bytes + variable

Select a field to see what it does.

RFC 792. Every ICMP message starts with Type, Code and Checksum; the next 4 bytes depend on the type (here: echo request/reply).

ICMP rides inside IP like a transport protocol but belongs to layer 3: it reports on IP itself. There are no ports; Type and Code say what the message is.

How it works

Ping: echo request (type 8) and echo reply (type 0) with matching Identifier and Sequence. Many hosts (Windows firewall by default) do not answer.

Errors: routers and hosts send ICMP back to the source when a packet cannot be delivered. The error contains the IP header and first 8 bytes of the original packet, enough to see the ports, so the sender can match it to a connection.

Traceroute uses TTL expiry:

sequenceDiagram
    participant H as Host
    participant R1 as Router 1
    participant R2 as Router 2
    participant T as Target
    H->>R1: probe, TTL 1
    R1-->>H: ICMP 11/0 time exceeded
    H->>R2: probe, TTL 2 (via R1)
    R2-->>H: ICMP 11/0 time exceeded
    H->>T: probe, TTL 3
    T-->>H: echo reply (Windows tracert) or ICMP 3/3 port unreachable (Linux UDP traceroute)

Path MTU Discovery: with DF set, a router that cannot forward a packet sends type 3 code 4 (IPv6: type 2 “packet too big”) with the MTU. Firewalls that drop all ICMP break this and cause hanging connections (large packets disappear, small ones work).

ICMPv6 typePurpose
1, 2, 3, 4Unreachable, packet too big, time exceeded, parameter problem
128, 129Echo request, reply
133, 134Router Solicitation, Router Advertisement
135, 136Neighbor Solicitation, Advertisement (replaces ARP)
137Redirect
143MLDv2 report (multicast group membership)

In Wireshark

FilterShows
icmp || icmpv6All ICMP
icmp.type == 8 || icmp.type == 0Ping
icmp.type == 3Unreachables; add && icmp.code == 3 for closed UDP ports
icmp.type == 3 && icmp.code == 4Fragmentation needed (PMTUD)
icmp.type == 11TTL exceeded (traceroute, routing loops)
icmp.type == 5Redirects (suspicious on most networks)
icmp.resp_not_foundRequests without a reply
data.len > 64 && icmpBig ICMP payloads (tunnels, exfiltration)

What normal looks like: small echo payloads with standard patterns (56 bytes on Linux, 32 bytes of the alphabet on Windows), occasional unreachables, Neighbor Discovery on IPv6.

Security notes

References

§ home
~/knubertus/home/
1,1 Top