PING (Packet Inter-Network Groper) is a network utility used to test the reachability of a host (computer, server, router, etc.) on an IP network and measure the round-trip time (RTT) for messages sent from the source to the destination.
-
Purpose:
-
Check if a remote host is online.
-
Diagnose network connectivity issues.
-
Measure latency (delay) in communication.
-
-
Protocol Used:
-
Operates using ICMP (Internet Control Message Protocol) (Type 8 Echo Request, Type 0 Echo Reply).
-
Some variants use TCP/UDP (e.g.,
tcpingfor firewall-friendly checks).
-
How PING Works
-
Echo Request (PING):
-
The sender transmits an ICMP Echo Request packet to the target IP/hostname.
-
Example:
ping example.com
-
-
Echo Reply (PONG):
-
If the target is reachable, it responds with an ICMP Echo Reply.
-
-
Round-Trip Time (RTT) Calculation:
-
The time taken for the request to reach the destination and return is measured.
-
Example output:
64 bytes from 93.184.216.34: icmp_seq=0 ttl=56 time=11.3 ms
-
If no reply is received, it may indicate network issues (packet loss, firewall blocking ICMP, etc.).
-
3. PING Packet Structure
An ICMP Echo Request/Reply packet contains:
| Field | Description |
|---|---|
| Type | 8 (Echo Request), 0 (Echo Reply) |
| Code | 0 (always for Echo Request/Reply) |
| Checksum | Error-checking value |
| Identifier | Helps match requests with replies (often process ID) |
| Sequence Number | Tracks packet order (increments per request) |
| Payload | Optional data (often includes timestamps) |
4. Common PING Command Options
| Command | Description |
|---|---|
ping <host> |
Basic ping (infinite until stopped) |
ping -c 4 <host> |
Send only 4 packets |
ping -i 2 <host> |
Set interval between pings (2 sec) |
ping -s 1000 <host> |
Set packet size (1000 bytes) |
ping -t <host> (Windows) |
Continuous ping until stopped |
ping -f <host> (Linux) |
Flood ping (stress test, admin only) |
5. Advanced PING Uses
a) TTL (Time-To-Live) Analysis
-
The TTL value in the reply indicates how many hops the packet traversed.
-
Example:
-
If initial TTL = 64 and reply TTL = 56, the packet passed through 8 routers.
-
b) Path Discovery (Traceroute)
-
PING is the basis for
traceroute(Linux) /tracert(Windows), which maps the route packets take. -
Works by incrementing TTL and analyzing ICMP “Time Exceeded” messages.
c) Network Diagnostics
-
High Latency? → Indicates congestion or slow routing.
-
Packet Loss? → Suggests faulty hardware, ISP issues, or throttling.
-
No Reply? → Host is down, firewall blocks ICMP, or network misconfiguration.
d) Security Considerations
-
ICMP can be blocked by firewalls (e.g., Windows Defender, corporate networks).
-
PING floods can be used in DDoS attacks (hence
ping -fis restricted).
6. Fun Fact: Why “Gopher”?
-
The original term was “Packet Inter-Network Groper” (referring to “groping” for hosts).
-
Some jokingly call it “Packet Inter-Network Gopher” (like the animal digging for connectivity).
-
The name PING was inspired by sonar “pings” in submarines (echo location).