What is ICMP, and how do ping and traceroute work?
MediumConceptARP, DHCP & NAT
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 (
tracerton 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
| # | Problem | Platform | Difficulty | Open | 1st1st Visit | 2nd2nd Visit | RevRevise |
|---|---|---|---|---|---|---|---|
| 1 | How does DHCP assign an IP address to a device? Explain DORA. | Concept | Medium | Read the answer to How does DHCP assign an IP address to a device? Explain DORA. | |||
| 2 | How does ARP find the MAC address for an IP address? | Concept | Medium | Read the answer to How does ARP find the MAC address for an IP address? | |||
| 3 | What is NAT, and why is it used? | Concept | Medium | Read the answer to What is NAT, and why is it used? | |||
| 4 | What is ICMP, and how do ping and traceroute work? | Concept | Medium | Read the answer to What is ICMP, and how do ping and traceroute work? |