Skip to content
We areTOP 1%

What is ICMP, and how do ping and traceroute work?

MediumConceptARP, DHCP & NAT
Track your progress
First attempt
Re-solve after a few days
Final pass before interviews

Answer

ICMP (Internet Control Message Protocol) is a network-layer helper protocol that carries error and diagnostic messages for IP, such as "destination unreachable" and "time exceeded". It carries no application data, and the tools ping and traceroute are built on it.

  • ping sends ICMP Echo Request messages and waits for Echo Replies, showing whether a host is reachable and the round-trip time (RTT).
  • traceroute (tracert on Windows) uses the TTL (time to live) field of the IP header. Every router decreases TTL by 1, and a router that brings it to 0 drops the packet and returns an ICMP Time Exceeded message, revealing its address. Probes are sent with TTL 1, 2, 3 and so on, so each round reveals one more hop.
  • Many firewalls block ICMP, so a failed ping does not always mean that the host is down.

Example: Tracing the path to a sample server (notes on the right are explanations, not tool output):

$ traceroute example.com
 1  192.168.1.1      1.2 ms    TTL 1 expires at the home router
 2  10.20.0.1        8.5 ms    TTL 2 expires at the ISP router
 3  203.0.113.9     21.7 ms    TTL 3 expires further along
 4  198.51.100.20   25.3 ms    the destination itself replies

More in ARP, DHCP & NAT

Sign in to track your progress

Your checkboxes, streak and activity heatmap are saved to your account and sync across devices. It is free.
Sign in with email

New here? Create an account