Routing & Switching

What is Ping? How It Works, Command Options and Reading the Output

J Jaspreet Singh April 24, 2024 6 min read
Animated diagram for What is Ping? How It Works, Command Options and Reading the Output, showing a client and a server exchanging request, acknowledgement, data and close messages in sequence

Ping sends an ICMP Echo Request to a target and waits for an Echo Reply, measuring how long the round trip took. It is the first command almost every network problem gets diagnosed with, because it answers two questions at once: is the destination reachable, and how long does traffic take to get there and back.

It was written in 1983 by Mike Muuss and named after sonar, you send a pulse out and listen for the echo.

How Ping Works

  1. You run ping 8.8.8.8. Your host builds an ICMP Echo Request (type 8, code 0) containing a sequence number, an identifier, and a block of padding data.
  2. The packet is routed to the destination like any other IP packet.
  3. The destination’s IP stack answers with an ICMP Echo Reply (type 0, code 0), copying the payload back unchanged.
  4. Your host matches the reply to the request using the sequence number and reports the elapsed time.

Because ICMP is handled inside the IP stack rather than by an application, it has no port numbers at all, which is why “ICMP port” is a misnomer, a successful ping proves Layer 3 reachability, it says nothing about whether the web server, database or file share on that host is actually working.

Reading Ping Output

$ ping -c 4 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=118 time=12.4 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=118 time=11.9 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=118 time=13.1 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=118 time=12.0 ms

--- 8.8.8.8 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3005ms
rtt min/avg/max/mdev = 11.912/12.362/13.148/0.472 ms
FieldMeaning
64 bytesReply size. Linux defaults to a 56-byte payload; the 64 includes the 8-byte ICMP header.
icmp_seqSequence number. Gaps here mean lost packets, watch for which ones are missing, not just the total.
ttl=118Time To Live remaining. Most stacks start at 64, 128 or 255, so 118 suggests the reply crossed 10 hops from a start of 128.
time=12.4 msRound-trip time. Not one-way latency, halve it for a rough one-way figure.
mdev / stddevVariation in round-trip time. This is jitter, and it matters more than average latency for voice and video.

What the numbers should look like

TargetHealthy RTTInvestigate above
Default gateway on the LAN< 1 ms5 ms
Over Wi-Fi to the gateway1–5 ms30 ms
ISP first hop5–20 ms50 ms
Same-country server10–40 ms80 ms
Intercontinental100–250 ms350 ms
Satellite (geostationary)500–700 ms

Any packet loss to your own gateway is a fault. Loss to a distant host may just be rate limiting on an intermediate router.

Ping Command Options

Windows

CommandPurpose
ping -t 8.8.8.8Ping continuously until Ctrl+C. Ctrl+Break prints running statistics without stopping.
ping -n 10 8.8.8.8Send exactly 10 requests.
ping -l 1472 8.8.8.8Set payload size, used for MTU testing.
ping -f -l 1472 8.8.8.8Set the Don’t Fragment bit. Essential for finding path MTU.
ping -a 192.168.1.10Resolve the address to a hostname.
ping -4 / -6Force IPv4 or IPv6.

Linux and macOS

CommandPurpose
ping -c 10 8.8.8.8Send 10 requests then stop. (Linux pings forever by default.)
ping -i 0.2 8.8.8.8Interval between packets in seconds.
ping -s 1472 8.8.8.8Payload size.
ping -M do -s 1472 8.8.8.8Don’t Fragment, for MTU discovery.
ping -I eth1 8.8.8.8Source from a specific interface, useful on multi-homed hosts.
ping -W 1 8.8.8.8Reply timeout in seconds.

Finding your path MTU with ping

Send a Don’t Fragment packet and shrink it until it gets through. On Windows, ping -f -l 1472 tests a 1500-byte MTU (1472 payload + 8 ICMP header + 20 IP header). If you get “Packet needs to be fragmented but DF set”, reduce the size. This is how you diagnose the MTU problems that break VPNs and PPPoE links while ordinary ping works fine.

Common Ping Errors and What They Mean

MessageMeaningWhere to look
Request timed outNo reply arrived. The host may be down, ICMP may be filtered, or the reply may be lost.Firewall rules, then the host itself
Destination host unreachableA router on the path has no route to the destination, the error came from the router, not the target.Routing table, default gateway
Destination net unreachableSame, but for the whole network.Upstream routing
TTL expired in transitThe packet exceeded its hop limit. Usually a routing loop.Run traceroute, you will see hops repeating
General failureLocal stack problem, no valid address, or the interface is down.ipconfig / ip addr
Ping request could not find hostDNS failed. The network may be fine.Try pinging an IP address directly
Packet needs to be fragmented but DF setPayload exceeds the path MTU.MTU on the tunnel or WAN interface

Why a Failed Ping Does Not Mean the Host Is Down

This is the most common misreading of ping. Many hosts and networks deliberately drop ICMP:

  • Windows Firewall blocks inbound ICMP Echo by default on public and often private profiles. A perfectly healthy Windows machine will not answer a ping until you allow “File and Printer Sharing (Echo Request)”. Adding a rule is always better than disabling the firewall outright, and the Windows Firewall logs will confirm whether it is the one dropping your pings.
  • Cloud security groups commonly permit only TCP 22, 80 and 443, ICMP is simply not in the rule set.
  • Edge firewalls drop ICMP from the internet as a matter of policy.
  • Routers rate-limit ICMP directed at their own control plane, so a hop showing loss in a traceroute is often fine at forwarding traffic.

When ping fails but you need to know whether a service is alive, test the port instead:

# Windows
Test-NetConnection example.com -Port 443

# Linux / macOS
nc -zv example.com 443

Ping vs Traceroute vs Pathping

ToolAnswers
pingIs the destination reachable, and how fast?
tracert / tracerouteWhich path does traffic take, and where does it break?
pathping (Windows) / mtr (Linux)Which specific hop is losing packets, measured over time?

mtr is the one to reach for on an intermittent problem, it runs continuously and shows per-hop loss and latency, which a single traceroute cannot.

Practical Troubleshooting Order

  1. ping 127.0.0.1, proves your own TCP/IP stack works.
  2. ping your own IP address, proves the NIC is configured.
  3. ping your default gateway, proves the local network works.
  4. ping 8.8.8.8, proves internet routing works.
  5. ping google.com, proves DNS works. If step 4 succeeds and step 5 fails, it is DNS, not connectivity.

More diagnostics in our network troubleshooting commands guide.

Frequently Asked Questions

What is a good ping for gaming?

Under 30 ms feels instant, 30–60 ms is fine for most games, 60–100 ms is playable, and above 100 ms is noticeable in fast-paced titles. Consistency matters as much as the average, 40 ms with heavy jitter plays worse than a steady 70 ms.

Does ping measure download speed?

No. Ping measures latency, which is independent of bandwidth. A satellite link can have gigabit throughput and 600 ms ping; a slow DSL line can have 10 ms ping.

Why is my ping to the gateway high?

Over Wi-Fi, usually interference, distance or channel congestion, the same causes behind a laptop repeatedly disconnecting. Over Ethernet, anything above a couple of milliseconds points at a faulty cable, a duplex mismatch, or a badly overloaded switch.

Can ping be used to attack a host?

ICMP floods and the historic “ping of death” (an oversized fragmented packet) both used ping, which is part of why ICMP is filtered so widely. Modern stacks are not vulnerable to the ping of death, and volumetric ICMP floods are handled by rate limiting.

What TTL should I expect?

Initial TTL is 64 on Linux and macOS, 128 on Windows, 255 on most network devices. Subtract the value you see from the nearest of those to estimate the hop count.

JA
Written by

Jaspreet Singh

Hey! I'm Jaspreet Singh and I completed a degree in Bachelor of Computer Applications. I have 7+ years of experience in the Network & Security Domain as well as the Cloud Infra Domain. So I love to explore my technical knowledge with you.

One response to “What is Ping? How It Works, Command Options and Reading the Output”

  1. […] Ping: Ping is a basic command that can be used to test connectivity to a remote host. This command will send ICMP Echo Request packets to the target host and wait for an ICMP Echo Reply. If the target host responds, then it is considered reachable. […]

Leave a Reply

Your email address will not be published. Required fields are marked *