What is ping Utility?
Before going through some real world examples of the ping utility, let me explain what this commandline tool is and its purpose. The ping utility is used to test the reachability of a host on an Internet Protocol (IP) network. Its names comes from the active sonar method which is used to create a pulse of sound (ping) under the water and listening to echo requests from surrounding objects. This method is the best way to explain how the network ping utility works. The ping utility sends echo requests to a host and waits for an ICMP response.
Some Examples Of The ping Utility In Practice:
Find Out The Ip Address Of A Host
Sometimes you need the ip address of a host, you can use the ping tool like shown in Figure 1. Just type the ping command and after it type the hostname.
Find Out The Version Of The ping Utility You Are Using
The -V flag can be used to find out which version of the ping tool you have. Type the following command and it will display the current version of the ping utility.
As you can see from Figure 2, I am using ping utility, iputils-sss20101006.
When you ping a machine with the ‘ping host’ command, pinging doesn’t stop and you have to pres CTRL+C to stop it, or you can use the -c (count) option to send a specified number of packets. When using the -c option, after the number of packets specified by the network admin (user whatever) is sent, the pinging process stops automatically instead of pressing CTRL+C.
ping -c 13 127.0.0.1
The above command is used to send 13 packets to my localhost.
As you can see from Figure 3 i did not press CTRL+C to exit pinging,it stopped automatically.
Specify The Interval Between Packets
Did you know that ping sends a packet every second? Do you like to speed up or slow down? The -i option can be used to specify the interval between packets. Use the following commands to send packets very fast or very slow.
Send A Packet Every 0.13 Seconds
ping -i 0.13
Send A Packet Every 13 Seconds
ping -i 13
Combine the -i option with -c option
ping -c 13 -i 3
It will take 39 seconds to send 13 packets with the specified interval of 3 seconds.