All the network and IT professionals need to be familiar with the ping command, so hopefully today’s article will teach you something new about it and its best practices.
The name PING actually comes from active sonar terminology that sends a pulse of sound and listens for the echo to detect objects underwater, though sometimes it’s interpreted as a backronym to Packet InterNet Groper.
Ping is usually measured in milliseconds (ms), and It’s the main troubleshooting technique for an IP network used to find out whether the host or gateway is reachable or not. It will also calculate the RTT (Round Trip Time) for the packet to reach its destination.
I am using UBUNTU 14.04.03 LTS Linux OS here to show you some ping examples, but this will work on any other Linux distro you have.
Check Ping Version
Open terminal and write the following command
It will return the currently installed ping version on your system.
Simple Ping Test
The ping command takes only one parameter: hostname or host IP address. To check this simply open terminal and type the following command
To stop the ping you need to press CTRL+C in Linux. Without doing so, it will ping for indefinitely which can be useful if you’re trying to find the rate of packet loss and don’t know the average rate ahead of time. After execution of every ping command, it will display a summary report with following outputs.
min: it will show minimum time taken to get a response from host that is pinged from your side.
avg: it will show average time taken to get a response from host that is pinged from your side.
max: it will show maximum time taken to get a response from host that is pinged from your side.
mdev: this is the moving standard deviation, sometimes also abbreviated "MSTD".
Also there is a TTL field which stands for Time to Live. It is also known as hop count.
As in the previous example, using the ping command without passing any parameters will ping infinitely on Linux. Fortunately you can define the count limit for ping command. The command is as follows:
ping -c 6 serversuit.com
Change the Time interval of Ping Command
By default, ping waits for 1 second before sending the next packet towards the destination host. You can change this time by using parameter -i. If you, for example, want to change time from 1 second to 5 seconds, the command will look like this:
ping -i 5 serversuit.com
If you want to decrease the time interval, this is the command
ping -i 0.4 serversuit.com
Changing Packet Size
The ping command sends 64 bytes request to a host by default, where 56 bytes are data along with 8 bytes of ICMP header. If you want to change the sizes of packets then you can use this command like so
ping -s 200 -c 2 serversuit.com
Flooding is to test the network performance and send packets as soon as possible. Here’s the command
ping -f serversuit.com
To stop flooding, use the CTRL+C command as this flooding will also run indefinitely if it’s not stopped manually.
If you want, you can actually get a summary statistics report without seeing the ping requests execution in terminal. This is the command:
ping -c 4 -q serversuit.com
To specify ping response while setting time limit you can use the -w parameter. This is the command:
ping -w 3 serversuit.com
As you can see, the ping command terminates after 3 packets like we specified.
Ping outputs Explanations
“Destination Net Unreachable” - if you see “Destination Net Unreachable” it means that your server can't route traffic to the specified network or some other router located after your gateway can't do the same. You can consider check your routing table first, and then use the 'traceroute' command for troubleshooting in this situation.
“Destination Host Unreachable” - that means there’s no route to this host, whether due to an incorrect address, or the host is offline/drops your requests.
“Unknown Host” - most likely means that you misspelled in your domain name when write it.
That about does it for the ping command. Ping is a very simple tool, but it has a vast number of uses when it comes to troubleshooting network issues so it's pretty important to know about. If you have any questions about this article, or any other article we post for that matter, feel free to hit us up on @serversuit, comment on Facebook! Watch out for our articles released regularly from ServerSuit!
Until next time!