linuxlab.io
Tutorials▾
  • Linux & networking
    File system, processes, TCP/IP, BGP and OSPF
    →
  • Terraform & IaC
    HCL, state, plan/apply on a LocalStack sandbox
    →
  • Git & GitHub
    Object model, plumbing, branching, GitHub Actions
    →
All tutorials →
PricingAboutSign inCreate account
/
  • Introduction
  • Lessons
  • How it works
  • Simulator
  • Knowledge base
  • Interview prep
Index
Categories
All entries
Footer
linuxlab-TutorialsPricingAboutPrivacy & cookies
Copyright © 2026 LinuxLab. All rights reserved.
home/linux/kb/Networking: L2 / L3/icmp

kb/network-l2-l3 ── Networking: L2 / L3 ── beginner

ICMP: Internet Control Message Protocol

ICMP is the control protocol on top of IP for control messages: echo (ping), destination-unreachable, time-exceeded (used by traceroute), MTU discovery. Not for data.

view as markdownaka: ping, icmp-echo

What ICMP is

ICMP (Internet Control Message Protocol, RFC 792) is a layer on top of IP for control messages: notifications about delivery errors, diagnostics, MTU discovery. It is not a transport for application data (TCP/UDP handle that).

An ICMP packet is an IP packet with protocol number 1. The payload holds the ICMP header (type + code + checksum) and type-specific data.

The most important types

typecodenamepurpose
00echo-replyreply to ping
30destination-unreachable: netnetwork unreachable
31destination-unreachable: hosthost unreachable (ARP did not resolve)
33destination-unreachable: portport closed (UDP trick)
34fragmentation-neededpacket > MTU + DF (PMTU discovery)
50redirectrouter reports "your route is bad, use Y"
80echo-requestping request
110time-exceeded: TTL=0the basis of traceroute
111time-exceeded: frag-reassemblyfragment reassembly timeout

ping = ICMP echo

The ping command sends type=8 (echo-request) and receives type=0 (echo-reply). The payload carries an increasing seq and a timestamp; comparing them lets you measure RTT and loss.

Fields that help with diagnostics:

64 bytes from 8.8.8.8: icmp_seq=1 ttl=119 time=8.45 ms
  • icmp_seq is the packet number (missing = loss)
  • ttl is how many hops the reply has left; different ttl values = ECMP load balancing
  • time is the RTT (full round trip)

traceroute via time-exceeded

A classic traceroute:

  1. Sends a UDP packet (or ICMP echo, or TCP SYN) with TTL=1
  2. The first router decrements TTL to 0, drops the packet, sends ICMP type=11 (time-exceeded). The source sees the IP of the first hop
  3. Sends again with TTL=2 → you see the second hop, and so on

When ICMP is blocked

Paranoid firewalls like to drop ICMP. This is an antipattern:

  • Without ICMP, PMTU discovery does not work → packets larger than the MTU are dropped silently → the application "hangs" on large responses
  • Without traceroute, network problems are harder to diagnose
  • Without ping, it is harder to check whether a host is alive

At worst, drop only echo and keep type=3 and type=11.

§ команды

bash
ping -c 4 8.8.8.8

Send 4 echo-requests and show statistics

bash
ping -M do -s 1500 1.1.1.1

DF + payload 1500: a PMTU check; an ICMP frag-needed comes back if the MTU is smaller

bash
traceroute -I 8.8.8.8

-I: use ICMP (not UDP) for probing. Better when UDP is filtered

bash
mtr 8.8.8.8

Live traceroute that accumulates loss statistics per hop

bash
tcpdump -i any 'icmp' -c 10

Capture any ICMP packets (see [[#cmd-tcpdump|tcpdump]])

§ см. также

  • ipv4-addressingIPv4: Addressing and CIDRAn IPv4 address is 32 bits written as `a.b.c.d`. The **/N** suffix is the prefix length: `/24` fixes the first 24 bits for the network and leaves 8 bits for hosts (256 addresses).
  • tracerouteTraceroute: How to See the Path a Packet Takes Across the InternetTraceroute shows every router on the path to a remote host. It works by sending packets with **increasing TTL** values (1, 2, 3, ...) and collecting "time exceeded" replies from routers that drop those packets.
  • cmd-mtrmtr: traceroute + ping in one toolmtr = traceroute + ping. It probes every hop continuously and shows loss% and latency. Use it to find where packets are being dropped or where latency spikes in a matter of seconds.

§ упоминается в уроках

  • ›intermediate-02-tcp-handshake
Footer
linuxlab-
Copyright © 2026 LinuxLab. All rights reserved.
Tutorials
Pricing
About
Privacy & cookies