← Interview Prep

Ping & Traceroute

The two tools every network engineer reaches for first — and every field, every character, and every quirk an interviewer can ask you to explain.

Ping and traceroute look trivial from the CLI, but they are dense with detail: two ICMP message types, a fistful of header fields, and a set of output characters that each encode a precise failure mode. This page walks both tools field by field, decodes the Cisco IOS output alphabet, and explains the patterns interviewers love to probe — starting with the famous .!!!!.

Ping answers “is it reachable, and how fast?” Traceroute answers “which path does it take, and where does it break?” Both are built on the same primitive — ICMP running directly over IP — but they exploit different fields: ping uses Echo, traceroute weaponizes TTL.

How ping works

Ping sends an ICMP Echo Request and waits for the matching ICMP Echo Reply. ICMP is protocol number 1, carried directly inside an IP packet (there is no TCP or UDP layer — EtherType 0x0800 → IP proto 1).

The two message types

DirectionTypeCodeMeaning
Request (sent by pinger)80Echo Request
Reply (sent by target)00Echo Reply

A common gotcha: the Echo Reply is type 0, not type 8. The responder copies the payload back verbatim and flips the type field from 8 to 0.

The ICMP Echo header, field by field

FieldSizePurpose
Type1 byte8 request / 0 reply
Code1 byte0 for echo
Checksum2 bytesCovers the ICMP header + payload
Identifier2 bytesDemultiplexes replies to the right process/socket. On Unix it is often the sending process's PID; behind NAT it doubles as the session key (ICMP has no ports).
Sequence Number2 bytesIncrements per probe (1, 2, 3…). Lets the sender match each reply to its request and detect loss / reordering / duplicates.
PayloadvariableArbitrary data, echoed back unchanged. Used to measure RTT and to test specific sizes/patterns.

Identifier + Sequence: how replies are matched

Because ICMP has no port numbers, the kernel needs another way to know which reply belongs to which request. The Identifier distinguishes one ping instance from another (and one host from another behind NAT), while the Sequence Number distinguishes the individual probes within that instance. When a reply arrives, the sender looks up the (Identifier, Sequence) tuple to find the timestamp it recorded at send time.

Payload and pattern

The payload is arbitrary but meaningful in practice. Linux ping stuffs a timestamp into the first bytes so RTT can be computed even if no local table is kept; the rest is a fixed incrementing pattern (0x10 0x11 0x12 …). Cisco IOS defaults to a 100-byte packet with a repeating 0xABCD pattern. You can change size and pattern to hunt for MTU issues or pattern-sensitive faults (e.g. ping ip 10.0.0.1 size 1500 df-bit).

TTL and RTT

A successful exchange, end to end

  1. Sender builds an Echo Request: type 8, code 0, a chosen Identifier, Sequence 1, a payload with a timestamp.
  2. Records the send time keyed by (Identifier, 1).
  3. Packet is routed to the target (ARP for next-hop, TTL−1 at each router, as usual).
  4. Target receives it, swaps type 8 → 0, keeps Identifier/Sequence/payload, recomputes the ICMP checksum, and sends the Echo Reply back to the source.
  5. Reply routes home; the sender matches (Identifier, 1), computes RTT = now − send time, prints one ! (or one line on Unix).
  6. Repeat with Sequence 2, 3, … until the count is exhausted.
$ ping -c 4 10.0.30.22
64 bytes from 10.0.30.22: icmp_seq=1 ttl=61 time=2.11 ms
64 bytes from 10.0.30.22: icmp_seq=2 ttl=61 time=1.83 ms
64 bytes from 10.0.30.22: icmp_seq=3 ttl=61 time=1.90 ms
64 bytes from 10.0.30.22: icmp_seq=4 ttl=61 time=1.88 ms

--- 10.0.30.22 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss
rtt min/avg/max/mdev = 1.83/1.93/2.11/0.10 ms

Cisco IOS ping output characters

Cisco IOS prints one character per probe. Memorize this table — it is a classic quick-fire interview question, and each symbol maps to a specific ICMP event.

CharMeaningWhat it really indicates
!Reply receivedAn Echo Reply came back in time — success.
.Timed outNo reply within the timeout window (default 2 s). Loss, filtering, or slow resolution — see below.
UDestination unreachableA router returned ICMP Destination Unreachable (type 3) — no route, host down, or admin filter.
QSource quenchReceived an ICMP Source Quench (type 4) — a legacy congestion signal, now deprecated.
MCould not fragmentICMP type 3 code 4: packet too big and the DF bit was set, so a router had to drop it. The MTU black-hole symptom.
?Unknown packet typeAn ICMP message IOS didn't recognize / couldn't classify.
&Packet lifetime exceededTTL hit 0 in transit — a router returned ICMP Time Exceeded (type 11). Usually a routing loop or a too-low initial TTL.
IInterruptedThe operator aborted the ping (Ctrl-Shift-6 / break sequence).

The classic .!!!! pattern

You run a five-probe ping from a Cisco router and see:

R1# ping 10.0.30.22

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.0.30.22, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 1/2/4 ms

The first probe timed out (.), the next four succeeded (!!!!), giving 80 percent (4/5). This is normal, not a fault — and being able to explain why is the whole point of the question.

Why the first packet (or two) is dropped

When the router originates the very first Echo Request, it frequently does not yet have the L2 rewrite information it needs to forward the packet:

By the time probe 2 is sent, the ARP entry and CEF adjacency are fully populated, the packet is hardware/CEF-switched in the data plane, and every subsequent probe returns !. On a multi-hop path you may see ..!!! instead: the first probe can trigger resolution on more than one segment (or hit a control-plane punt at more than one device), so occasionally the first two probes are lost.

The one-liner for the interview: the first ping seeds the ARP/CEF adjacency; it is punted/process-switched while resolution completes and times out, then the populated entry lets the rest fly. An 80 percent success rate on the first ping to a new destination is expected behavior, not a problem.

How to prove it isn't a real fault

Why . appears intermittently later

A dropped probe in the middle of a run is a different story — the adjacency already exists, so it points to a genuine issue:

Position matters. Loss at the start of a ping = resolution/punt, benign. Loss in the middle/steady state = real drops, rate-limiting, or CoPP. Always say which one you're looking at.

How traceroute works

Traceroute maps the path hop by hop by abusing the TTL field. It sends probes with deliberately small, incrementing TTLs and collects the ICMP errors each router returns.

The TTL trick

  1. Send a probe with TTL = 1. The first router decrements it to 0, drops the packet, and returns ICMP Time Exceeded (type 11, code 0) — sourced from its own address. Hop 1 revealed.
  2. Send TTL = 2. It survives hop 1 (TTL→1), dies at hop 2 (TTL→0), which returns Time Exceeded. Hop 2 revealed.
  3. Increment TTL (3, 4, 5…) until a probe finally reaches the destination.
  4. Typically three probes per TTL, so you see three latency samples per hop.

How the destination is detected

The Time Exceeded trick reveals intermediate hops, but the final hop is signalled differently depending on probe type:

Probe types compared

ProbeDefault onIntermediate hop signalDestination signalFirewall friendliness
UDP high portsLinux/macOS tracerouteTime Exceeded (11/0)Port Unreachable (3/3)Often blocked; ports vary per probe
ICMP EchoWindows tracert, traceroute -ITime Exceeded (11/0)Echo Reply (0/0)Blocked wherever ICMP is filtered
TCP SYNtraceroute -T, tcptracerouteTime Exceeded (11/0)SYN-ACK / RSTBest — targets a real open port (e.g. 80/443) to slip through firewalls

Windows tracert vs Unix traceroute — the port question

A common interview framing: "can you point traceroute at a specific port?" — and the answer follows from which layer the probe lives at:

All three probe types still use the same TTL trick for intermediate hops; only the transport (and thus port-addressability + how the destination is detected) differs. Note Unix traceroute can also send ICMP with -I, so "traceroute = UDP" is only the default, not a hard rule.

A sample traceroute

$ traceroute 93.184.216.34
traceroute to 93.184.216.34, 30 hops max, 60 byte packets
 1  10.0.10.1      0.412 ms  0.388 ms  0.377 ms
 2  10.0.255.1     1.02 ms   0.98 ms   1.10 ms
 3  100.64.0.1     3.4 ms    3.2 ms    3.6 ms
 4  * * *
 5  203.0.113.9    12.1 ms   11.8 ms   12.4 ms
 6  198.51.100.6   14.9 ms   40.2 ms   14.7 ms
 7  93.184.216.34  15.1 ms   14.9 ms   15.0 ms

Reading the output like an engineer

Going deeper / follow-up questions

Interview Prep · Ping & Traceroute. Pair this with Life of a Packet for the underlying hop-by-hop forwarding model that both tools depend on.