Estimated time: 35 minutes.
ICMP Echo Request / Reply (Type 8/0)
Why: RFC792 defines ICMP Echo Request (Type 8) and Echo Reply (Type 0) as the message pair used to check L3 reachability. ping sends an ICMP Echo
Request and measures the RTT until it receives the Echo Reply.
ICMP uses no ports and needs no listening process — it only checks whether the IP stack responds.
A firewall can block ICMP independently of TCP/UDP — a successful ping does not mean the service works.
When it breaks: A firewall blocks inbound ICMP → ping fails but the service keeps running normally. Use ping for monitoring → constant false alarms.
The reverse: the firewall allows ICMP but blocks TCP 80 → ping succeeds but the web is dead → you mistake it for 'server down'.
In real deployments: Use ping for the initial L3 reachability check when troubleshooting. Then use nc -zv host port to test L4.
In the cloud: security groups usually block ICMP by default — enable ICMP separately if you need ping for debugging.
ICMP Time Exceeded (Type 11)
Why: RFC 792 requires a router that receives a packet with TTL=0 to send an ICMP Time Exceeded (Type 11) back to the sender, carrying the router's own IP in the source address.
This is a mandatory mechanism — traceroute exploits it by sending packets with an increasing TTL (1, 2, 3...) to coax each router in turn into revealing its IP.
When it breaks: A firewall blocks outbound ICMP from a router → those hops stay silent (shown as * in traceroute).
If the whole path is * but the final destination responds → all the intermediate routers block Time Exceeded — the path is still working.
In real deployments: When debugging a latency spike between a VPS and a user: traceroute pinpoints which hop has the sudden RTT jump.
A hop inside a datacenter is usually <1ms; an ISP hop 5-20ms; an intercontinental hop 80-200ms. An outlier = the problem is at that router.
ICMP Destination Unreachable (Type 3)
Why: RFC 792 defines ICMP Destination Unreachable (Type 3) with several codes: code 0 = Network Unreachable (routing failure),
code 1 = Host Unreachable, code 3 = Port Unreachable (UDP port closed), code 4 = Fragmentation Needed (PMTU Discovery).
A router sends Type 3 to report the specific reason a packet cannot be forwarded.
When it breaks: A firewall DROP (silent) vs REJECT (returns ICMP Unreachable) gives users a different experience: DROP → the connection times out after 30-60s; REJECT → it fails immediately.
From a UX standpoint REJECT is worse (a visible error), but from a debugging standpoint REJECT is faster.
In real deployments: iptables -j REJECT returns ICMP Unreachable → the client fails fast. iptables -j DROP → the client waits for the timeout.
In a production firewall: use DROP for ports you do not want to expose (security), REJECT for internal ports (easier debugging).
The TTL (Time To Live) trick in traceroute
Why: RFC 791 §3.2 defines TTL (Time To Live) as a hop counter — each router decrements TTL by 1 when forwarding a packet; when TTL=0 it drops the packet and sends an ICMP Time Exceeded.
TTL has nothing to do with real time. traceroute uses TTL to map the path: TTL=1 makes the first router report its IP, TTL=2 makes the second router report its IP, and so on.
When it breaks: The default TTL is 64 on Linux and 128 on Windows. If the destination is more than 64 hops away (rare) → the packet dies before it arrives.
More common: a misconfigured router decrements TTL incorrectly → false loop detection → strange traceroute output.
In real deployments: Use mtr (My TraceRoute) instead of traceroute for continuous monitoring: mtr --report 8.8.8.8 — it shows packet loss and RTT avg/best/worst for each hop.
Useful when reporting a network problem to an ISP.
A successful ping ≠ a working service
Why: Ping only tests ICMP echo at L3. If the server disables ICMP → ping fails but the web is fine. Conversely, if a firewall blocks TCP:80 → ping succeeds but the web is dead.
Do not use ping to conclude 'server down'.
When it breaks: Many cloud VPSes disable inbound ICMP by default (GCP, AWS security groups). Ping from outside fails → the dev thinks the VPS is down → panic.
In reality the VPS runs fine and only ICMP is blocked.
In real deployments: The right way to do a health check: curl -sf http://host/health (L7), nc -zv host port (L4), ping host (L3). When debugging, go bottom-up: L3 first → L4 → L7.
Each layer narrows down the scope of the problem.
What does RTT (Round Trip Time) measure?
Why: RTT = the time from sending the ICMP Echo Request to receiving the Echo Reply. It measures latency between 2 points at L3.
If RTT jumps at some hop → the problem is concentrated there (congestion/long path).
When it breaks: A sudden RTT spike does not necessarily mean that hop has a problem — routers prioritize forwarding traffic over handling ICMP (ICMP rate limiting).
High RTT at a middle hop while the last hop is normal = that router de-prioritizes ICMP, it is not a real bottleneck.
In real deployments: Baseline the RTT from the VPS → the user region to set sensible timeouts. If ping Singapore→Europe is ~200ms, a cross-region database query timeout should be at least 500ms.
Use ping with -i 0.2 to stress test and find jitter.
tcpdump
Why: The standard CLI sniffer for debugging Linux networking.
It uses BPF filters (icmp, tcp port 80, host X); common flags: -i interface, -n no DNS, -X hex+ASCII, -w write a pcap, -r read a pcap. Output columns: timestamp/proto/src→dst
When it breaks: Wrong -i flag → you see no packets. Forget -n → a DNS lookup per packet slows things down and clutters the output. Permission denied → you need sudo or setcap CAP_NET_RAW.
Many people mistake ping for a 'TCP connectivity test'. In fact ping only works at L3 (IP), needs no port, and needs no listening process.
A successful ping only means the IP is reachable — it says nothing about the service.
When it breaks: ping succeeds but curl fails → the service is not running or a firewall blocks the port.
You need to tell them apart: ping tests L3 (ICMP), nc -zv tests L4 (TCP), curl tests L7 (HTTP). Skipping steps usually bypasses the layer that has the problem.
# Basic ping — send 4 ICMP Echo Requests
ping -c 4 8.8.8.8
# Look at the TTL of the reply — TTL decreases with the number of hops
# If the reply TTL=117 then the source TTL was 128, through 11 hops
ping -c 1 -v 8.8.8.8
Observe with:
sudo tcpdump -i any -n icmp # See ICMP packets: Type 8 (request), Type 0 (reply)
# In the ping output: the reply TTL tells you the hop count on the way back
# Linux original TTL=64: reply TTL=54 → passed through 10 hops
Capturing packets with tcpdump (or Wireshark) shows that ping is really a pair of ICMP packets: an Echo Request (Type 8) leaving your machine and an Echo Reply (Type 0) coming back from the destination.
Seeing both directions in the capture helps you identify where ICMP is blocked: a request with no reply means the remote side blocks inbound ICMP, while seeing neither the request nor the reply means it is blocked outbound right at the local firewall.
This is how you turn a vague 'ping doesn't work' into a concrete diagnosis.
When it breaks: You capture ICMP but see no reply → ICMP is blocked in one direction. You see the request go out but no reply → the remote side blocks inbound ICMP.
You see neither request nor reply → blocked outbound at the local firewall.
# Capture ICMP in Wireshark (Linux)
sudo tcpdump -i any -n icmp
# In another terminal:
ping -c 3 8.8.8.8
# The tcpdump output will look like:
# IP 192.168.x.x > 8.8.8.8: ICMP echo request
# IP 8.8.8.8 > 192.168.x.x: ICMP echo reply
Observe with:
sudo tcpdump -i any -n -v icmp # -v to see type/code
# To tell them apart:
# 'ICMP echo request' = Type 8 (sent by the host)
# 'ICMP echo reply' = Type 0 (returned by the remote)
# If you only see the request with no reply = the remote blocks ICMP
Understanding the TTL trick means understanding how traceroute 'hacks' the routing mechanism to reveal the path.
Every router must report back when it drops a TTL=0 packet — this is an obligation under RFC 792.
No extra software is needed, only a feature already built into the IP stack.
When it breaks: An outbound firewall blocks high UDP ports (33434+) → UDP traceroute does not work (all * and the destination is * as well). Switch to ICMP traceroute -I or TCP traceroute.
Know all 3 flavors so you can pick the right one when you are blocked.
# Standard traceroute (uses UDP on Linux)
traceroute 8.8.8.8
# Traceroute using ICMP (like Windows tracert)
traceroute -I 8.8.8.8
# Windows:
tracert 8.8.8.8
Observe with:
sudo tcpdump -i any -n icmp # Capture in parallel while running traceroute
# You will see: ICMP time-exceeded from each intermediate router
# Each router reveals its own IP via the Time Exceeded source address
mtr -n 8.8.8.8 # A better alternative: real-time continuous trace
A * appears when a router does not return ICMP Time Exceeded — a firewall may be blocking ICMP, or the router is configured not to send it. It does NOT mean the network is broken there.
If the following hops respond normally → the path is still working and that router is just 'silent'.
When it breaks: Wrongly concluding 'the network is broken at hop X' when you see * → escalating incorrectly → wasted time.
Rule: only conclude 'broken' when all the hops after that hop are * AND the destination does not respond.
# Example output:
# 1 192.168.1.1 1.2 ms — home router
# 2 10.0.0.1 5.1 ms — ISP router
# 3 * * * — router does not return ICMP
# 4 72.14.198.108 18.3 ms — Google backbone
# 5 8.8.8.8 19.1 ms — destination
# * = the router does not send Time Exceeded
# It does not mean the path is broken — look at the next hop
Observe with:
traceroute -n 8.8.8.8 # -n: do not resolve hostnames, faster
# After a * hop: if the next hop has a normal RTT → the router is silent, the path is fine
mtr --report -n 8.8.8.8 # Report mode: summarizes loss% and avg RTT for each hop
RFC 792 defines ICMP Destination Unreachable Type 3 with codes that distinguish the reason: code 0 = net unreachable (the routing table has no route),
code 1 = host unreachable, code 3 = port unreachable (UDP port closed — traceroute uses this to detect the destination).
A firewall that silently DROPs instead of REJECTing with ICMP Unreachable → the UDP client has to wait for a timeout instead of failing immediately.
When it breaks: You see 'ICMP port unreachable' while debugging a UDP service → you are using the wrong port or the service is not running.
Unlike TCP: TCP returns an RST when a port is closed, UDP returns ICMP Port Unreachable. When a firewall blocks ICMP → the UDP client waits for a timeout instead of failing immediately.
# UDP traceroute exploits Port Unreachable:
# Send UDP to a high port (33434+), each router returns Time Exceeded
# On reaching the destination: the host returns Port Unreachable (because nothing listens on that port)
# → traceroute knows it has arrived!
# ICMP traceroute (-I) uses Echo Request instead
# When the destination returns an Echo Reply → it finishes
Observe with:
sudo tcpdump -i any -n icmp # Look for Type 3 Code X
# Code 0=net unreachable, 1=host unreachable, 3=port unreachable
# Test: nc -u 127.0.0.1 9999 # send UDP to a closed port → ICMP port unreachable
Symptoms when it breaks:
A UDP client hangs indefinitely instead of reporting an error right away: tcpdump: ICMP type 3 code 3 is DROPped by an iptables INPUT rule
TCP applications work, UDP-based apps (DNS, NTP) time out: dig @8.8.8.8 example.com → 'connection timed out; no servers could be reached' even though the route is OK
Fix:
Allow ICMP type 3 (Destination Unreachable) on the firewall — REQUIRED for PMTU Discovery + UDP error handling
sudo iptables -A INPUT -p icmp --icmp-type destination-unreachable -j ACCEPT
Verify by using nc to send UDP to a closed port; you should see the unreachable packet come back
nc -u -w2 127.0.0.1 9999; echo "exit=$?" # exit != 0 if an ICMP unreachable is received
RTT = the round-trip time from sending the ICMP Echo Request to receiving the Echo Reply, measured in milliseconds.
A high RTT at an intermediate hop is not necessarily a bottleneck —
routers prioritize forwarding traffic over handling ICMP (rate limiting/deprioritization). ping -s 1472 -M do (DF bit set) failing with 'Frag needed' per RFC 1191 → an MTU mismatch along the path,
not a firewall block.
When it breaks: ping -s 1472 fails but ping -s 100 is OK → an MTU mismatch along the path (common with a VPN or tunnel). Large packets need fragmentation or PMTUD.
The telltale signs: the DF (Don't Fragment) bit is set + an ICMP 'Fragmentation needed' from a router.
# Ping continuously, look at the min/avg/max RTT
ping 8.8.8.8
# Ctrl+C to stop, then read the summary
# Test with a larger packet (detects MTU issues)
ping -s 1400 8.8.8.8
# If ping with a large size fails but a small size is OK
# → there may be an MTU mismatch along the path
Observe with:
ping -c 10 8.8.8.8 # See packet loss % and rtt min/avg/max/mdev
mtr --report -c 20 8.8.8.8 # Measures jitter and loss more reliably
ping -s 1472 -M do 8.8.8.8 # MTU test: -M do = Don't Fragment, fails if MTU < 1500
Symptoms when it breaks:
SSH/HTTPS stalls after authenticating, downloads a few MB and then hangs: ping -s 1472 -M do <server> → 'Frag needed and DF set (mtu = 1400)'
The internal network is OK, but over the VPN there are sudden lag spikes and 5-20% packet loss: mtr report: high loss% at one fixed hop (usually the VPN gateway)
Fix:
Lower the interface MTU when the VPN/tunnel inserts headers (IPsec, WireGuard, GRE) → avoids fragmentation at distant routers
sudo ip link set dev eth0 mtu 1400
For TCP: clamp the MSS down to MTU-40 so the protocol does not have to depend on PMTUD
sudo iptables -t mangle -A POSTROUTING -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu
Scripting it: Cron entry: */5 * * * * /usr/local/bin/net-probe.sh 8.8.8.8 → alert when loss > 5% or RTT avg > 100ms.
#!/usr/bin/env bash
# Monitor RTT + loss; alert if a threshold is exceeded. Run via cron */5.
TARGET="${1:-8.8.8.8}"
STATS=$(ping -c 20 -W 2 "$TARGET" | tail -2)
LOSS=$(echo "$STATS" | grep -oP '\d+(?=% packet loss)')
AVG=$(echo "$STATS" | grep -oP 'rtt [^=]+=\K[\d.]+(?=/[\d.]+/[\d.]+/[\d.]+)' | cut -d/ -f2)
LOSS=${LOSS:-100}; AVG=${AVG:-9999}
if (( LOSS > 5 )) || (( $(echo "$AVG > 100" | bc -l) )); then
echo "ALERT: $TARGET loss=$LOSS%, rtt=${AVG}ms" | logger -t net-probe
fi
Run tcpdump -i any -n icmp and then ping -c 1 8.8.8.8 in another terminal. Map the tcpdump columns ↔ the IP/ICMP header fields (timestamp / src→dst / type echo request or reply / id+seq).
Observe with:
Match the id and seq columns between the request and the reply — they must pair up one to one
Wrong: Ping fails = the server is down
Right: Ping tests ICMP Echo (L3 reachability only); a firewall can block inbound ICMP (GCP and AWS security groups block ICMP by default) → ping fails but TCP/UDP services keep working normally.
RFC 792 does not require a host to reply to ICMP Echo.
Monitoring based on ping alone → constant false alarms with cloud VPSes. The correct check: curl -sf http://host/health (L7) or nc -zv host port (L4) to confirm the service is really down.
Wrong: A * in traceroute means the network is broken at that hop
Right: * means that router did not send ICMP Time Exceeded — possibly because of a firewall policy or because the router is configured not to reply; it does not mean the packet was dropped.
If the hops after it respond normally → the path is fine, and that router is just silent per RFC 792.
Wrongly concluding 'the network is broken at hop X' when you see * → incorrect escalation, raising the incident to the wrong place.
Only conclude it is broken when all the hops after that hop are * AND the destination does not respond.
Wrong: The TTL in ping output is a lifetime measured in seconds
Right: RFC 791 §3.2 defines TTL as a hop counter — each router decrements it by 1 when forwarding, and it has nothing to do with real time.
The TTL in a ping reply is the remaining TTL of the returning packet — subtract it from the original TTL of the destination's operating system (Linux=64, Windows=128) to get the hop count.
Misreading TTL leads to misreading traceroute output and getting the hop count wrong when debugging. For example: reply TTL=54 from a Linux host → 64-54=10 hops on the way back.
Wrong: A high RTT at a middle hop in traceroute = a bottleneck at that router
Right: Routers prioritize forwarding traffic over handling ICMP — many routers rate-limit or de-prioritize ICMP.
A high RTT at an intermediate hop but a normal last hop → that router is just slow at handling ICMP, not truly congested.
Escalating a network problem to a router that is not the real bottleneck is the wrong direction.
A real bottleneck: the high RTT starts at hop X and stays high for all the following hops, not just a single hop.
Wrong: ping -s 1500 failing = a firewall blocks ICMP
Right: ping -s 1472 -M do failing with 'Frag needed and DF set' → ICMP Type 3 Code 4 per RFC 1191 (PMTU Discovery) — an MTU mismatch along the path, not a firewall blocking ICMP.
Common with a VPN/tunnel whose extra header overhead lowers the effective MTU.
Misdiagnosing it as a firewall → opening an ICMP rule does not solve the problem.
The correct fix: lower the interface MTU (sudo ip link set dev eth0 mtu 1400) or clamp the TCP MSS to avoid fragmentation.
Wrong: tcpdump automatically captures every interface
Right: By default it captures only the first interface (tcpdump -D to list them); you need -i any to capture them all
libpcap requires an explicit interface; any is a Linux-specific pseudo-device and may not exist on macOS/BSD
Wrong: tcpdump captures loopback out of the box
Right: Loopback needs -i lo or -i any; -i eth0 will not see ping 127.0.0.1
Loopback traffic goes through the lo interface (a kernel virtual interface), not through a physical NIC
1. See ICMP Echo Request/Reply with your own eyes — confirm that ping uses no port and there is no TCP handshake
# Terminal 1: capture ICMP
sudo tcpdump -i any -n -v icmp
# Terminal 2: send pings
ping -c 3 8.8.8.8
# Observe: Type 8 (request) and Type 0 (reply)
Observation: # In tcpdump: 'ICMP echo request' and 'ICMP echo reply'
2. See the whole path hop by hop — understand the traceroute TTL trick in practice
# Linux (UDP mode)
traceroute -n 8.8.8.8
# Linux (ICMP mode - like Windows)
traceroute -I -n 8.8.8.8
# Windows
tracert 8.8.8.8
Observation: # Compare UDP vs ICMP mode: is the number of * different? mtr -n --report 8.8.8.8 # See packet loss % for each hop — more useful than a one-shot traceroute
3. Prove that ping OK ≠ service OK — a firewall can allow ICMP but block TCP
# Ping succeeds:
ping -c 3 8.8.8.8
# Check TCP ports (needs telnet or nc)
nc -vz 8.8.8.8 80 # Google HTTP
nc -vz 8.8.8.8 22 # Google SSH (usually blocked)
# Compare the results: which port is open vs closed
Observation: # ping OK + nc port fails = a firewall blocks that TCP port
4. Capture ICMP Time Exceeded from traceroute — see each router send an ICMP when the TTL expires
# Terminal 1: capture all ICMP
sudo tcpdump -i any -n icmp
# Terminal 2: run traceroute
traceroute -n -m 5 8.8.8.8
# Observe: ICMP time-exceeded from each intermediate router
Observation: # In tcpdump: 'ICMP time exceeded in-transit' from the IP of each router
5. Test MTU path discovery — detect an MTU mismatch using the ping packet size
# Ping with different packet sizes
ping -c 3 -s 1400 8.8.8.8 # 1400 bytes
ping -c 3 -s 1450 8.8.8.8 # 1450 bytes
ping -c 3 -s 1472 8.8.8.8 # Max Ethernet (1472 + 28 hdr = 1500)
# If a large size fails: 'Frag needed' = an MTU issue along the path
Observation: # If 1400 is OK but 1472 fails: sudo tcpdump -i any icmp # Look for 'ICMP frag needed' — it tells you the path's maximum MTU ping -s 1472 -M do 8.8.8.8 # -M do = Don't Fragment bit, fails more clearly if the MTU is low
6. Capture every ICMP packet on every interface, without resolving DNS (-n)
tcpdump -i any -n icmp
Observation: Run ping 8.8.8.8 in another terminal — watch the echo request/reply pair
7. The -X flag prints the payload as hex+ASCII, so you can see the ping data with its timestamp pattern
tcpdump -i any -n -X icmp
Observation: Compare the payload bytes between the request and the reply — the content is copied verbatim
8. Combined BPF filter: only ICMP to/from 8.8.8.8 (less noise)
tcpdump -i any -n 'icmp and host 8.8.8.8'
Observation: Verify that request → reply run as a proper pair, with the source/destination IPs swapped
Question 1. A ping to the server 8.8.8.8 succeeds but curl reports 'connection refused port 80'. What is the cause?
ICMP is blocked at the firewall
Ping OK means L3 is working — but nothing is listening on TCP port 80, or a firewall blocks it (L4)
DNS resolution failed
The packet TTL is too low
Answer: Ping OK means L3 is working — but nothing is listening on TCP port 80, or a firewall blocks it (L4). Ping uses ICMP at L3 — it needs no port and no listening process.
Ping OK only means the IP is reachable. 'Connection refused' = the TCP SYN arrived but no process is listening on port 80. The two are completely independent.
ICMP is blocked at the firewall: If ICMP were blocked, ping would FAIL, not succeed.
DNS resolution failed: If DNS failed, ping would report 'cannot resolve hostname'. Here the ping goes straight to the IP and succeeds.
The packet TTL is too low: If the TTL were too low, ping would fail with 'TTL exceeded', not curl failing with 'connection refused'.
Question 2. How does traceroute work to learn the IP of each router along the path?
Traceroute asks each router's routing table
It sends packets with an increasing TTL (1,2,3...) — each router drops the packet when TTL=0 and sends an ICMP Time Exceeded carrying its own IP
It uses a DNS reverse lookup for each hop
It sends a TCP SYN to every IP in the subnet range
Answer: It sends packets with an increasing TTL (1,2,3...) — each router drops the packet when TTL=0 and sends an ICMP Time Exceeded carrying its own IP.
This is the TTL trick: TTL=1 → the packet dies at hop 1, and hop 1 sends an ICMP Time Exceeded with its source IP. TTL=2 → it dies at hop 2, and you get hop 2's IP. And so on until the destination.
Every router is required to send Time Exceeded under RFC 792.
Traceroute asks each router's routing table: Traceroute has no access to a remote router's routing table.
It uses a DNS reverse lookup for each hop: A DNS reverse lookup is optional and only used to display names — it is not the hop discovery mechanism.
It sends a TCP SYN to every IP in the subnet range: Scanning a subnet is port scanning — unrelated to traceroute.
Question 3. In traceroute output you see 'hop 5: * * *' followed by 'hop 6: 72.14.x.x (18ms)'. What does this mean?
The network is broken at hop 5, and hop 6 is reached by another path
Hop 5 timed out completely, and the connection was dropped
The router at hop 5 does not send ICMP Time Exceeded (firewall/config) but still forwards packets — hop 6 proves the path is still working
The TTL was miscalculated, and hop 5 does not exist
Answer: The router at hop 5 does not send ICMP Time Exceeded (firewall/config) but still forwards packets — hop 6 proves the path is still working.
A * means the router at that hop does not return ICMP Time Exceeded — a firewall may be blocking ICMP or the router may be configured to rate-limit.
BUT it still forwards packets (because hop 6 and the ones after it respond normally). The path is still working.
The network is broken at hop 5, and hop 6 is reached by another path: There is no 'other path' in traceroute — it is a single linear path. Hop 6 responding proves the packet went through hop 5.
Hop 5 timed out completely, and the connection was dropped: If it were a real timeout, hop 6 and the following hops would also be * or time out.
The TTL was miscalculated, and hop 5 does not exist: The TTL was counted correctly — hop 5 is simply silent and sends no reply.
Question 4. Which layer of the OSI model does ICMP sit at?
L4 Transport — because it is used to test connectivity
L3 Network — ICMP is encapsulated in an IP packet (protocol number 1)
L2 Data Link — because routers process ICMP
L7 Application — because ping is an application
Answer: L3 Network — ICMP is encapsulated in an IP packet (protocol number 1). ICMP is an L3 protocol: it lives in the IP payload with IP protocol number = 1. Routers (L3 devices) process ICMP.
It has no ports (L4) and no MAC (L2). Ping is merely an application that uses ICMP — it does not make ICMP an L7 protocol.
L4 Transport — because it is used to test connectivity: L4 is TCP/UDP, which have ports. ICMP has no ports — proof that ICMP is not L4.
L2 Data Link — because routers process ICMP: L2 uses MAC addresses and only within a LAN. Routers work at L3, not L2.
L7 Application — because ping is an application: Ping is an application that calls ICMP, but ICMP itself is an L3 protocol — not L7.
Question 5. Why does UDP traceroute stop when it receives an 'ICMP Port Unreachable' from the destination?
Because port unreachable means the server is busy
Because UDP traceroute sends to a high port (33434+) on which the destination host has no service listening — the host returns Port Unreachable, and traceroute understands it has arrived
Because port 33434 is a special port of the traceroute protocol
Because ICMP Port Unreachable has TTL=0
Answer: Because UDP traceroute sends to a high port (33434+) on which the destination host has no service listening — the host returns Port Unreachable, and traceroute understands it has arrived.
UDP traceroute uses a clever design: it sends UDP to a very high port (33434+) to make sure no service is listening.
When the packet reaches the destination, the host returns ICMP Type 3 Code 3 (Port Unreachable). Traceroute receiving this = it has reached the destination.
Intermediate hops return Time Exceeded instead.
Because port unreachable means the server is busy: 'Busy' is not an ICMP concept. A busy server returns TCP errors, not ICMP.
Because port 33434 is a special port of the traceroute protocol: There is no special port. Port 33434 is just an arbitrary high number that is unlikely to be used by any service.
Because ICMP Port Unreachable has TTL=0: ICMP Port Unreachable has no concept of TTL=0 — the TTL belongs to the original IP packet.
Question 6. The TTL value in a ping reply is 117. What does this tell you?
The packet has passed through 117 routers
The server's initial TTL is configured as 117
If the server's default TTL=128, the packet has passed through 128-117=11 hops
TTL carries no information about the hop count
Answer: If the server's default TTL=128, the packet has passed through 128-117=11 hops. Operating systems have fixed default TTLs: Linux=64, Windows=128, Cisco=255.
When you receive a reply with TTL=117 and know the server runs Windows (original TTL=128), you can compute 128-117=11 hops. This is a way to estimate distance without traceroute.
The packet has passed through 117 routers: If it had passed through 117 routers, the reply TTL would be (original TTL - 117), which could be very low or 0.
The server's initial TTL is configured as 117: A TTL of 117 is a value already reduced by the hops along the way, not the original value.
TTL carries no information about the hop count: TTL carries very valuable information — it helps you estimate the hop count from the sender.
Question 7. Which BPF filter captures BOTH ICMP echo request and echo reply?
icmp
icmp[icmptype] == 8
icmp[icmptype] == 0
host 8.8.8.8 and tcp
Answer: icmp. icmp does not filter by type → it captures all ICMP packets (request type 8, reply type 0, and other types such as unreachable).
icmp[icmptype] == 8: icmptype == 8 matches only requests
icmp[icmptype] == 0: icmptype == 0 matches only replies
host 8.8.8.8 and tcp: A TCP filter, completely unrelated to ICMP
What does ping actually check?
ICMP Echo Request/Reply — it only checks L3 IP reachability. It does not check ports, services or applications. *A common mix-up: 'ping OK = server OK'. Wrong.
The web server can be dead while ping still answers, because they are 2 different mechanisms. *
What is TTL in an IP packet? What are the default values?
Time To Live = the maximum number of hops a packet may pass through. Each router decrements it by 1. TTL=0 → drop + send an ICMP Time Exceeded. Defaults: Linux=64, Windows=128, Cisco=255.
*TTL prevents packets from looping forever when a routing table is broken. Traceroute exploits this mechanism to 'coax' each router into revealing its IP. *
When is ICMP Time Exceeded sent?
When a router receives a packet with TTL=1, decrements it to 0, it must drop the packet and send an ICMP Type 11 (Time Exceeded) carrying that router's source IP back to the sender.
*This is the foundation of traceroute.
Routers MUST do this per RFC 792 — they have no right to stay silent (unless configured to or blocked by a firewall). *
How does the traceroute TTL trick work?
Send a packet with TTL=1: it dies at hop 1, and you get hop 1's IP. TTL=2: it dies at hop 2, and you get hop 2's IP. Keep increasing the TTL until you reach the destination.
*No special privileges or software on the intermediate routers are needed. It leverages a standard RFC — every router must comply. *
What does a * in traceroute mean?
The router at that hop did not send ICMP Time Exceeded back (blocked by a firewall or rate-limited). It does NOT mean the network is broken there — if the next hops respond, the path is still working.
*Many production routers deliberately disable ICMP to reduce load and hide the topology. Do not draw the wrong conclusion when you see a *. *
ICMP Destination Unreachable Type 3 — which codes matter?
Code 0: Network unreachable. Code 1: Host unreachable. Code 3: Port unreachable (UDP traceroute uses it to know it has arrived). Code 4: Fragmentation needed (MTU discovery).
*The code distinguishes the cause: routing failure vs host failure vs app failure. Debugging at the right layer saves time. *
When and how does UDP traceroute finish?
It sends UDP to port 33434+ (nobody listens). Intermediate hops return Time Exceeded.
On reaching the destination, the host returns Port Unreachable (no service on that port) → traceroute knows it has arrived.
*A clever design: it uses 2 different kinds of ICMP to distinguish 'still on the way' from 'arrived at the destination'. *
Which Type is ICMP Echo Request? Which Type is the Reply?
Echo Request: Type 8. Echo Reply: Type 0. (Remember: 8 goes out, 0 is the quiet one/the reply). *Knowing the type numbers helps you read Wireshark/tcpdump.
The filter 'icmp.type == 8' is the ping request filter. *
A ping with reply TTL=54 — which OS does the server run and how many hops did it pass through?
Linux default TTL=64. Reply TTL=54 → 64-54=10 hops. If the reply TTL=118 → Windows (128), through 10 hops. *Counting the TTL backwards lets you estimate distance quickly, without a full traceroute.
It also helps fingerprint the target's OS. *
Why does a successful ping not guarantee the web app works?
Ping uses ICMP (L3), the web uses TCP port 80/443 (L4+). A firewall can: let ICMP through + block TCP. Or the reverse. The two protocols are completely independent. *Debug in order: ping checks L3.
If OK → test the port (nc/telnet). If the port is OK → test the app (curl). Each step narrows down the scope of the fault. *
What does the -X flag in tcpdump do?
It prints the payload as hex + ASCII next to the header summary, useful for debugging empty/noisy/ASCII-text content.