LABS · PROTOCOLS · NET PATH

ICMP: what's behind ping and traceroute

ping and traceroute are the first troubleshooting tools, and both use ICMP. See what each one sends, who answers, what each error message says and how to read the output on a Cisco router.

Level: beginner · 12 minutes

Interactive simulation

The animation needs JavaScript. The full lesson is written out below.

Download the capture and open it in Wireshark to keep exploring.

What ICMP is

ICMP (Internet Control Message Protocol, RFC 792) is IPv4's control message protocol. It carries no user data: it reports errors, like an unreachable destination or an expired TTL, and answers queries, like ping's echo. It travels inside IP with protocol number 1.

Routers and hosts generate it on their own when something happens to a packet. That's why it's the basis of troubleshooting: with ping you check there's a round trip, and with traceroute you see where the path goes and where it breaks.

The most common messages

TypeCodeMessageWho sends it
00Echo ReplyThe target of a ping
30Network UnreachableA router with no route (rarely used today)
31Host UnreachableA router with no route (Cisco IOS) or no ARP reply
33Port UnreachableThe destination: nothing listens on that UDP port
34Fragmentation NeededA router: the packet doesn't fit and has DF
313Communication Administratively ProhibitedA router with an ACL that blocks it
51RedirectA router: there's a better path on the same network
80Echo RequestWhoever runs ping
110Time ExceededA router: the TTL reached 0

Error messages copy the IP header of the packet that caused them and at least its first 8 bytes, so the source knows what they refer to. An error is never sent because of another ICMP error.

How it works: ping, traceroute and an unreachable destination

Six steps: a ping, three traceroute hops, a destination with no route and the Cisco IOS symbols.

  1. Ping: Echo Request and Echo Reply

    ping sends an ICMP Echo Request (type 8) with an identifier, a sequence number and some data; the server returns an Echo Reply (type 0) with the same values. The laptop measures the round-trip time: 62 ms. The reply's TTL, 62, also says there are two routers on the path: the server sent it with 64.

  2. traceroute: TTL 1

    Linux traceroute sends UDP probes to port 33434 and up, raising the TTL one at a time. The first one carries TTL 1: R1 receives it, subtracts 1, the TTL hits 0 and it drops it. Before that, it sends the laptop an ICMP Time Exceeded (type 11) from 192.168.10.1, with the probe's header inside. traceroute now knows hop 1.

  3. traceroute: TTL 2

    The TTL 2 probe crosses R1 (which leaves it at 1) and dies at R2. R2 sends the Time Exceeded from 10.0.12.2, the interface it arrived on. Since R2 generates it with TTL 255 and R1 subtracts 1, it reaches the laptop with 254. Hop 2 takes 31 ms: that's the WAN link.

  4. traceroute reaches the destination

    The TTL 3 probe reaches the server with TTL 1. Nothing listens on UDP port 33440, so the server answers with an ICMP Destination Unreachable, code 3 (Port Unreachable). For traceroute that's the sign it arrived: hop 3 is the destination, 62 ms away. Each hop is tested with three probes; here you see the first of each.

  5. Unreachable destination

    Ana pings 10.20.99.5. R1 forwards it, since it matches 10.20.0.0/16, but R2 has no route at all to 10.20.99.0. It drops the packet and answers with an ICMP Destination Unreachable, code 1 (Host Unreachable), the one Cisco IOS uses when there's no route. The error comes from the router where the problem is: that tells you where to look.

  6. Ping and traceroute on Cisco IOS

    On a Cisco router, ping shows one symbol per packet: ! is a reply, . means nothing came back within 2 seconds and U is a Destination Unreachable. Toward 10.20.99.5 the result is U.U.U: R2 sends at most one unreachable every 500 ms (ip icmp rate-limit), so one ping in two gets no answer. traceroute marks probes with no answer with *.

How traceroute works

  • It sends probes with TTL 1, 2, 3… Each router that brings the TTL to 0 drops the probe and answers with Time Exceeded: that's how it reveals its address.
  • By default it tests each hop with three probes and shows the three times.
  • Linux and Cisco IOS send UDP probes to high ports (from 33434); the destination answers Port Unreachable and it ends there. Windows (tracert) uses Echo Request and ends with an Echo Reply.
  • A * is a probe with no answer: a firewall filtering ICMP, a rate limit or a broken path.
  • Each router usually answers from the interface the probe came in on: you see one IP per hop, not the device's name.

Ping and traceroute on Cisco IOS

SymbolMeaning
!Echo Reply received
.No answer within the timeout (2 s)
UDestination Unreachable received
QSource Quench (deprecated)
MCould not fragment (DF)
?Unknown packet type
&Packet lifetime (TTL) exceeded

Useful commands: ping 10.20.30.40 source Gi0/0/1 repeat 100 size 1500 (extended ping: source, count and size), traceroute 10.20.30.40 numeric, show ip icmp rate-limit and debug ip icmp. In traceroute, a * marks a probe with no answer.

What happens when it fails

  • Ping fails but the application works: many firewalls block ICMP. Test the application's port too.
  • Request timed out (or .....): no answer came back. The outbound path, the return path or a filter may be failing; an extended ping from the router helps tell them apart.
  • Destination host unreachable: a router has no route, or the host itself can't get the MAC through ARP on its network.
  • traceroute stops with *: the last hop that answers is the last one that works; the problem is right after it.
  • TTL expired in transit: there's a routing loop; traceroute shows the same IPs repeating.
  • Blocking all ICMP breaks things: MTU discovery needs Fragmentation Needed (type 3, code 4).

Frequently asked questions

Does ICMP use ports?

No. ICMP travels directly inside IP (protocol 1) and is identified by type and code. Ping's identifier and sequence aren't ports, although they play a similar role.

Why does a Cisco router's first ping sometimes show .!!!!?

Because the router has to resolve the next hop's MAC with ARP and drops the first packet while it waits. The rest go out fine.

What does U.U.U mean?

That a router answers with Destination Unreachable, but only one every 500 ms: the dots are the pings left unanswered because of that limit.

Why does traceroute give different results on Windows and Linux?

Windows (tracert) uses Echo Request and Linux uses UDP. A firewall may let one through and block the other.

Is it dangerous to leave ICMP open?

Blocking it all causes problems: without Fragmentation Needed, MTU discovery fails. The recommended approach is to rate-limit it and filter specific types with ACLs, not block it entirely.

Key takeaways

  • ICMP travels inside IP (protocol 1) and is identified by type and code.
  • ping uses Echo Request (8) and Echo Reply (0); the reply's TTL reveals how many routers there are.
  • traceroute raises the TTL one at a time: each router answers Time Exceeded (11) and the destination, Port Unreachable (3/3).
  • Cisco IOS answers Host Unreachable (3/1) when it has no route, at most one every 500 ms: hence U.U.U.
  • In Cisco's ping: ! is a reply, . is no answer and U is unreachable.

NEXT STEP

From this lesson to the Canadá Logística network

In the CCNA 2.0 Course you troubleshoot real faults on the Canadá Logística network with show, ping, extended ping, traceroute and captures, in Packet Tracer or CML. We'll let you know when it opens.

Upcoming labs

Sources

Lesson prepared with AI assistance and checked against the sources cited. The bytes of every packet are generated according to the standard and verified with an independent tool.