ICMP (Internet Control Message Protocol) carries control and error messages in IP packets (protocol 1). The most important ones:
Type
Name
when
8 / 0
echo request / reply
ping
3
destination unreachable
no route to the network, host unreachable, port closed
11
time exceeded
the TTL dropped to 0 on the way
The ICMP header
ICMP sits directly in the IP packet (protocol 1). The first 4 bytes are the same for all messages; what follows depends on the type. For ping it is identifier and sequence number.
ICMPMessage · RFC 792
0481216202428
Type8 bits8
Code8 bits0
Checksum16 bits0x4d5a
Identifier16 bits0x0001
Sequence number16 bits1
Datavariable32 Byte
Each row has 32 bits (4 bytes), bit 0 on the left, as the RFCs draw their headers. Dashed: variable or optional. Point at a field for an explanation.
More precise reason, e.g. for type 3: 0 net, 1 host, 3 port unreachable.
Checksum
16 bits (2 bytes)
0x4d5a
Checksum over the whole ICMP message (RFC 1071).
Identifier
16 bits (2 bytes)
0x0001
For echo: identifier of the ping program, the reply carries the same. Other types use these 4 bytes differently.
Sequence number
16 bits (2 bytes)
1
For echo: counts the pings 1, 2, 3 …
Data
variable
32 Byte
Arbitrary data returned by the reply (Windows: 32 bytes). For error messages, the start of the packet that caused it.
Values: Real frame from the demo “Router on a stick” (no. 7, 82 bytes), exactly as the packet list in leyoNET shows it.
Ping
ping 192.168.2.10 sends four echo requests. Every reply shows the time and the TTL of the reply packet; from the TTL you can estimate how many routers lie in between. “Request timed out” means: no reply, but no error message either, often a missing return path.
The options are named as on Windows (and -c as on Linux):
Option
Effect
-t
continuous ping until Ctrl+C; you see live when a connection drops and comes back
-n 10 or -c 10
ten instead of four requests
-i 1
choose the TTL of the request yourself (1 to 255)
What happens at TTL 0?
Every router decreases the TTL by 1 before it forwards. If it becomes 0, the router drops the packet and sends “TTL expired” (type 11) to the sender. So a packet with TTL 0 never travels over a link. Try it with a target behind two routers: ping -i 1 is answered by the first router, ping -i 2 by the second, ping -i 3 arrives.
Traceroute
tracert (Windows) uses the TTL cleverly: the first packet has TTL 1 and is already dropped by the first router, which sends back “TTL expired”. The second has TTL 2, and so on. This way every router on the path reports.
For IPv6 there is ICMPv6 with the same tasks plus neighbor discovery (IPv6).
MTU and path MTU discovery
Every link has an MTU (maximum transmission unit), 1500 bytes for the IP packet on Ethernet. If a packet is larger than the MTU of the next link, there are two ways:
IPv4 may fragment on the way, unless the DF bit (don't fragment) is set. Then the router drops the packet and reports destination unreachable, fragmentation needed with the right MTU back (RFC 1191).
IPv6never fragments on the way. The router reports packet too big (ICMPv6 type 2, RFC 4443), and the sender makes its packets smaller (path MTU discovery, RFC 8201). Every IPv6 link must carry at least 1280 bytes (RFC 8200, Section 5).
If a firewall blocks these ICMP messages, large packets simply get stuck while small ones (like a ping) get through: a hard-to-find fault. That is why ICMP should never be blocked across the board.
See an example
Slow motion This is how it looks in the simulation: every dot is a frame on the cable.ARP and ping in the LAN
Three computers on a switch, all in 192.168.1.0/24.
PC 1 asks for PC 2's MAC with an ARP broadcast, then four ICMP echoes follow. The switch learns its MAC table.
★★☆☆☆Two networks with a router· 4 goals · Worksheet (German)
In leyoNET under Tools → Exercise catalogue. Every exercise checks itself.
What leyoNET simplifies
Protocol
Layer
Simplification in the simulation
ICMP
3
Echo, destination unreachable, time exceeded
ICMPv6, Neighbor Discovery
3
Echo, destination unreachable, time exceeded; neighbor and router solicitation/advertisement instead of ARP; no MLD (multicast groups without registration), no redirect; router advertisements every 30 s
RFC 8200 – Internet Protocol, Version 6 (IPv6) Specification
Read on
IPv4Addresses, masks and the IPv4 header: how a packet finds its destination across many networks, with TTL, checksum and private addresses.
How routing worksDefault gateway, routing table, longest prefix and administrative distance – and when to route statically, automatically or dynamically.
ARPHow a device finds the MAC address for an IP address in its own network – with a broadcast request, a reply and a cache.