Debuggingpingicmpechorttpacket loss

ping: What an Echo Actually Proves

ping sends an ICMP echo request and reports whether a reply came back and how long it took; that answers "does this host respond to ICMP right now" and nothing else — a failed ping does not mean a service is down and a successful ping does not mean it is up.

ConceptualLinuxWindowsIPv6
Interview question
Progress

You have not marked these as done yet. Read on anyway if they feel familiar; come back to them if something here does not land.

The problem

The runbook says "ping the server". It replies in 12 ms. The API is still returning connection refused. Or: ping gets no reply and the dashboard is green. What did the ping actually test?

What ICMP echo tests

ping builds an ICMP echo request (type 8) inside an IP packet, sends it to the destination, and waits for an echo reply (type 0). The reply is generated by the destination’s kernel — no process, no port, no listener is involved. So a reply proves exactly this: a route to the host exists in both directions, the host is powered on with a working IP stack, and nothing on the path filtered ICMP echo. Nothing else.

ICMP is not a transport. It has no ports, so it cannot address a service; it carries a sequence number and an identifier so that the sending ping can match replies to requests and detect loss and reordering. The round-trip time it reports is the time for a tiny packet — 64 bytes by default on Linux and macOS, 32 bytes of payload on Windows — to be routed there and back. It says nothing about bandwidth, and only a little about what a 100 kB HTTP response would experience.

That tiny scope is also what makes ping useful: because it needs nothing running on the far end, it is the cleanest test of the lower rungs of the Why Can’t I Connect? ladder — route and host — with no application in the way.

  • ICMP echo request = type 8, echo reply = type 0. Time Exceeded (type 11) and Destination Unreachable (type 3) are the other ICMP messages you will meet in traceroute: Discovering the Path Hop by Hop.
  • Replies come from the kernel; a host with every service crashed still answers.
  • Linux/macOS ping runs until interrupted; use -c 4. Windows sends four and stops; use -t for continuous.

A failed ping does not mean the service is down

Firewalls, cloud security groups and host firewalls routinely block ICMP echo while allowing TCP 443. AWS security groups have no ICMP rule by default; Windows Firewall blocks inbound echo by default on public profiles; many hardening guides drop ICMP wholesale. The result is a host that serves HTTPS flawlessly and never answers a ping. The correct reading of a failed ping is "ICMP echo is not reaching or not being answered", not "host down".

The confirmation is a probe at the layer you care about: nc -vz host 443, curl -sI https://host/, or Test-NetConnection host -Port 443. If the TCP probe connects, the host is up and the ping was filtered. If the TCP probe times out too, you now have two layers agreeing, which is much stronger evidence. The interview question "ping fails but the service works" is exactly this reasoning.

A rare inverse: ICMP is sometimes rate-limited rather than blocked, so a long ping shows sporadic loss that TCP never experiences. Routers and hosts cap ICMP generation on their control plane; a 2% ping loss to a router interface is normal, and means nothing about the data plane forwarding through it.

  • An explicit Destination host unreachable or communication administratively prohibited reply means a router or firewall rejected it; pure silence means dropped, or the host is off.
  • Locally, Destination Host Unreachable from your own IP usually means ARP/ND for the next hop failed — the gateway did not answer — see ARP and Neighbor Discovery: From an IP to a Local MAC.

A successful ping does not mean the service works

The reply is generated a few layers below any process. A server whose application crashed, whose listener is bound to 127.0.0.1, whose certificate expired last night, or whose disk is full still returns pings in 12 ms. Ping proves "host up", and "host up" is the fourth rung of a nine-rung ladder. The remaining five — port, handshake, TLS, HTTP, application — need their own tests, and each of them can fail with a perfect ping.

This is why production health checks are HTTP requests to a real endpoint, not pings. A load balancer that pinged its backends would happily send traffic to a machine whose web server was dead.

Reading the output: RTT, loss, jitter

Linux

Each reply line carries the sequence number, the TTL of the reply (which hints at hop count: 64 − 54 = about 10 hops if the far end started at 64), and the RTT. The summary gives sent, received, loss percentage, and min/avg/max/mdev. mdev (standard deviation of RTT) is jitter; a low average with a high mdev means an unstable path or a congested queue somewhere — bad for real-time traffic even if the average looks fine. Missing sequence numbers are loss; the summary percentage is the headline.

Calibrate the RTT against geography: ~1 ms on a LAN, ~10–30 ms within a region, ~80 ms across a continent, ~150 ms transatlantic, ~250 ms+ to the antipodes, 600 ms via geostationary satellite. An RTT far above the geographic floor means a detour or a queue — Latency: Same Machine to Cross-Continent lets you build the intuition. Loss above ~1% on a wired path is abnormal and will cripple TCP throughput (Packet Loss: Duplicate ACKs, Fast Retransmit and the RTO).

  • icmp_seq gaps = loss; mdev = jitter; ttl hints at the hop count from the reply’s starting TTL (64 for Linux/macOS, 128 for Windows, 255 for many routers).
  • ping -s 1472 -M do host (Linux) sends a full 1500-byte frame with fragmentation forbidden — the MTU test behind the MTU black-hole challenge. macOS: ping -D -s 1472; Windows: ping -f -l 1472.
Linux ping: one lost reply, moderate jitter; Windows format shown below for comparison
$ ping -c 5 api.example.com
PING api.example.com (203.0.113.10) 56(84) bytes of data.
64 bytes from 203.0.113.10: icmp_seq=1 ttl=54 time=12.1 ms
64 bytes from 203.0.113.10: icmp_seq=2 ttl=54 time=11.9 ms
64 bytes from 203.0.113.10: icmp_seq=4 ttl=54 time=41.7 ms
64 bytes from 203.0.113.10: icmp_seq=5 ttl=54 time=12.3 ms

--- api.example.com ping statistics ---
5 packets transmitted, 4 received, 20% packet loss, time 4006ms
rtt min/avg/max/mdev = 11.900/19.500/41.700/12.820 ms

C:\> ping api.example.com
Reply from 203.0.113.10: bytes=32 time=12ms TTL=54
Request timed out.
Ping statistics for 203.0.113.10: Sent = 4, Received = 3, Lost = 1 (25% loss)

IPv6: ping6 and why ICMPv6 must not be blocked wholesale

IPv6

On IPv6 the tool is ping -6 or ping6 (macOS and older Linux), and the messages are ICMPv6 echo request (type 128) and reply (type 129). The important difference is what else ICMPv6 carries: neighbor discovery (the IPv6 replacement for ARP), router advertisements, and Packet Too Big — the message path-MTU discovery depends on, and which is mandatory in IPv6 because routers never fragment. A firewall that "blocks ICMP" on IPv6 the way it did on IPv4 breaks address resolution and MTU discovery, not just ping. RFC 4890 lists which ICMPv6 types must pass.

Practically: if a dual-stack host resolves to an AAAA record and IPv6 is half-configured on the client, the browser may spend seconds timing out on IPv6 before falling back (Happy Eyeballs limits this to a few hundred milliseconds in modern stacks, but curl and older clients may not). ping -6 and ping -4 separately tell you which family is actually broken.

  • ping -6 host / ping6 host; ping -4 forces IPv4 on a dual-stack name.
  • ICMPv6 echo is type 128/129; Packet Too Big is type 2 and must be allowed through firewalls.

Key points

  • ping tests ICMP echo answered by the destination kernel: route both ways, host up, ICMP not filtered. Nothing about ports or services.
  • A failed ping is inconclusive — probe TCP on the real port before calling a host down.
  • A successful ping proves only "host up"; five rungs of the ladder remain above it.
  • Read RTT against geography, mdev as jitter, and sequence gaps as loss; loss above ~1% on a wired path is abnormal.
  • On IPv6, ICMPv6 also carries neighbor discovery and Packet Too Big; blocking it wholesale breaks more than ping.

Why does this exist?

Mechanisms are answers to constraints. Open each question before reading the answer.

▸Why does ping not use a port?

It is deliberately below the transport layer so it can test reachability without depending on any service. That independence is the feature; the price is that it cannot say anything about services.

▸Why do operators block ICMP echo?

Reconnaissance: an answered ping confirms a live host. The security gain is small, but the habit is widespread, so debugging must assume a silent ping may be a filtered one.

▸Why is ping still worth running first?

It is the cheapest test of route and host, needs nothing on the far end, and its RTT calibrates every later timing. A 150 ms ping explains a "slow" API before you look at the API.

How it fails

What the failure looks like from inside real software.
Reference · show
  • Alerting on ping and paging at 3 a.m. because a firewall rule changed, while every real request succeeded.
  • Marking a host healthy from a ping while its web server has been dead for an hour.
  • Reading 2% ping loss to a router hop as path loss, when the router merely rate-limits ICMP generation on its CPU.
  • Blocking all ICMPv6 "for security" and breaking neighbor discovery and path-MTU discovery on the IPv6 side.
  • Comparing a Windows time=12ms with a Linux time=12.1 ms and missing that payload sizes differ (32 vs 56 bytes) — harmless here, but not for MTU tests.

Check yourself

Answer out loud or on paper first, then compare. These come from the interview questions linked to this lesson.

  1. ping api.example.com times out, but curl https://api.example.com/ returns 200 from the same machine. Explain how both can be true, and what ping actually proves in each direction.

    Show a strong answer

    ping sends an ICMP Echo Request (protocol 1 on IPv4, ICMPv6 type 128 on IPv6) and waits for an Echo Reply; curl opens a TCP connection to port 443 (protocol 6). These are different IP protocols, and every filter on the path — host firewall, cloud security group, network ACL, the load balancer’s own stack — decides about them separately. An AWS security group that allows TCP 443 and says nothing about ICMP drops the echo silently; Windows blocks incoming echo by default; many load balancer VIPs and anycast addresses never answer ICMP at all because nothing behind the VIP is a "host". The name may also resolve to a CDN or LB address that is not the machine running the service. So the ping proves nothing about the service, and the 200 proves the entire path — DNS, routing, TCP, TLS, HTTP — works. See ping: What an Echo Actually Proves and Firewalls.

    What ping *does* prove: a reply means IP-level reachability in both directions and gives an RTT and loss estimate *for ICMP*. A timeout means only that an echo did not come back — the host may be down, or the echo may be filtered outbound, at the destination, or on the return path, or rate-limited. Routers commonly process ICMP on a slow control-plane path and rate-limit it, so ping RTT and loss can look worse than the forwarding plane actually is. The reverse case is equally common: ping succeeds and the service is down — the host is up but nothing listens (connection refused), or the port is filtered (timed out), or TLS fails, or the process is hung and accepts connections it never answers. Each of those is a different layer (Why Can’t I Connect?).

    The right tools test the layer you care about: nc -vz host 443 or curl -v --connect-timeout 3 for TCP reachability, openssl s_client for TLS, curl -sS -o /dev/null -w "%{http_code}" for HTTP, mtr -T -P 443 or tcptraceroute to trace the path *using TCP to the real port* so ICMP filters do not produce * * * at every hop, and nmap -Pn to skip the host-discovery ping that would otherwise report "host down". A monitoring check that pings hosts is measuring a different thing from the service it is meant to watch.

    Full interview question, with follow-ups and red flags →
  2. Ping works and curl hangs at "Connected to … Trying" then times out. Which layer?

    Show a strong answer

    TCP: the SYN is dropped by a firewall or nothing answers on that port with a drop policy. Host is reachable; the port is filtered.

    Full interview question, with follow-ups and red flags →
  3. Ping works, small API calls work, but downloads over ~1 kB hang. Which ICMP message is being blocked?

    Show a strong answer

    Fragmentation Needed / Packet Too Big — PMTUD is broken, a black-hole MTU on the path.

    Full interview question, with follow-ups and red flags →