Ping command – Definition
The Ping command is a small and simple utility tool with a command-line interface (CLI). It is very helpful for network diagnosing and probing a specific host or IP address (IPv4 address or IPv6 address). When you use the Ping command, you actually send data packets utilizing the ICMP (internet control message protocol) from your computer to a target. By default, the packets are going to be 4 each with a 32-byte size. Moreover, you will receive the time it was needed for each of them to reach the target. The statistics will also show you the minimum, maximum, and average time (in milliseconds) required for the road. Another interesting piece of information is the portion of lost packets, and of course, you will receive the IP address of the target.
In brief, the Ping command transfers data packets from your computer to a target and expects the packets to bounce. When they come back, you can see the statistics.
How to use it?
Here are some examples which will help you use the Ping command.
First, you have to open the Terminal application on Linux or macOS. In case you are a Windows user, you should open the Command Prompt.
*In these examples, we will use IP addresses, just for illustration, and example.com. Feel free to replace them with the domain or device (IP address) you need.
Basic Ping command – With it, you can see if you, or the machine you are testing, are connected and can reach the target. As a result, you will see constant ping on Linux or macOS. To stop it, use the combination Ctrl-C. For Windows, you will receive 4 responses and statistics in case there are no difficulties.
For constant ping on Windows, you should apply an extra option “-t.” Type the following:
ping -t example.com
For a custom number of requests. For Windows, you can make more than 4 requests, and for macOS/Linux, a custom amount of requests.
ping –c 8 example.com
ping –n 8 example.com
The interval between the pings. Between the requests, you are able to determine the time in seconds.
ping -i 20 22.214.171.124
Timeout period. You can set it in seconds, usually to stop the ping command on macOS/Linux.
ping –w 50 example.com
Get the statistics only on your ping request. That way, it won’t reveal the individual pings.
ping –q example.com
Determine the packet’s size. By default, on Linux and macOS, it is 56 bytes. For Windows, it is 32 bytes. Let’s place in, for instance, 112.
ping -s 112 example.com
Usages of the Ping command
- Troubleshooting. Echo answers give hints for identifying and solving problems. For illustration, if one echo answer takes longer to reach, this could show a routing problem or sluggishness on the network.
- Check connectivity. If the ping is fast, that could simply prove the two devices can communicate successfully.
- Monitoring. With the Ping command, you can check the availability of the devices on a network and your network performance.