# Ping
## What is Ping
Ping is a network diagnostic tool used to test the reachability of a host on an IP network and to measure the round-trip time for packets sent from the source to the destination. It works by sending ICMP echo request packets to the target host and waiting for ICMP echo reply packets to return. Ping is one of the most fundamental and commonly used network troubleshooting tools available on all operating systems.
## How Ping Works
When you run ping followed by an IP address or domain name, the ping utility sends ICMP echo request packets to the target. If the target is reachable and not configured to block ICMP, it responds with ICMP echo reply packets. Ping measures the time from when the echo request is sent to when the echo reply is received. This is the round-trip time. Ping also reports whether packets were lost, which indicates network problems.
## Ping Output
The ping output shows the destination address, the sequence number of each packet, the time to live of the received reply, and the round-trip time in milliseconds. At the end of the ping session, a summary shows the number of packets transmitted, the number received, the percentage of packet loss, and minimum, average, and maximum round-trip times. Zero percent packet loss and low, consistent round-trip times indicate a healthy connection.
## Using Ping for Troubleshooting
Ping is used systematically to isolate network problems. First ping the loopback address 127.0.0.1 to verify the local network stack is functioning. Then ping the default gateway to verify local network connectivity. Then ping a known internet IP address like 8.8.8.8 to verify internet connectivity without relying on DNS. Then ping a domain name to verify DNS resolution is working. This step-by-step approach helps identify exactly where a problem exists.
## Ping Options
Common ping options include the count option to specify how many packets to send, the size option to specify the packet size, the timeout option to specify how long to wait for each reply, and the continuous option to send packets indefinitely until stopped. On Windows ping sends four packets by default. On Linux and macOS ping sends packets continuously until stopped with Control-C.
## Limitations of Ping
Some hosts and firewalls block ICMP echo requests, causing ping to report failure even though the host is reachable. A failed ping does not necessarily mean the target is unreachable for other protocols. Ping measures the round-trip time for ICMP packets which may not accurately reflect the latency experienced by application traffic.Back to Subject