Ping or Packet Internet Groper is a network administration utility used to check the status of a connection between a source and destination computer / device over an IP network. It will also help you evaluate the time it takes to send and receive a response from the network.
We all have our favorite sites that we often visit; if any of this doesn’t load, we really want to know why this happened. This is due to the fact that we do not have an Internet connection, or due to problems with our Internet service provider that prevent us from accessing the website. Another reason may be the inaccessibility of the site itself. Whatever the reason, the Linux Ping team can provide you with all the answers.
Ping uses ICMP (Internet Control Message Protocol) to send and receive echo messages from and to the host computer and to them, respectively, to inform us of network performance. An ICMP request message is sent to the destination computer; if the destination IP address is available, it sends an ICMP response message to the host computer. This tells us about the status of the network connection, such as the transmit / receive time – the time required to send and receive a packet of information.
Using the Ping Command
In a Linux terminal, enter the following command:
This is the result you get:
Let’s describe (in alphabetical order) the frequently used options that you see above:
|Use this option to sound when a node is available.|
|b||Use this option to enable broadcast address ping.|
|IN||Use this option if you do not want ping to change the source address of the probe|
|s (quantity)||Use this option to set the number of times to send a ping request.|
|d||Use this option to set the SO-DEBUG option for the socket used.|
|e||Use this option to fill the network by sending hundreds or more packets per second.|
|me (interval)||Use this option to specify the interval between consecutive packet transfers. The default value for the interval is 1 second.|
|I (interface address)||Use this option to set the source address for the specified interface address. This parameter is required when checking the connection with the local IPv6 link address. Its argument can be an IP address or a device name.|
|l (preload)||Use this option to set the number of packets to send without waiting for a response. To select a value greater than 3, you need to be superuser.|
|N||Use this option to display network addresses as numbers rather than host names.|
|Q||Use this option to display silent output. This means that only a summary is displayed during start and end.|
|T (TTL)||Use this option to set the lifetime.|
|v||Use this option for verbose output.|
|IN||Use this option to display the version and exit.|
|w (deadline)||Use this option to specify the timeout in seconds to complete a connection check, regardless of how many packets were sent or received.|
|W (timeout)||Use this option to set the time (in seconds) to wait for a response.|
Some basic ping features
Here are some basic ping features that you will use to test your network performance:
Check host availability
You can check if the host is alive or not using the following ping command:
$ ping host-name/IP
Press Ctrl + C to abort the command
Increase / decrease the interval between ping packets
The default time interval between sending each packet is 1 second on Linux. You can increase the time interval by setting a value greater than 1, and decrease it by setting a value less than 1.
Here is an example of increasing the time interval between two pings:
$ ping -i 5 127.0.0.1
Here is an example of reducing the time interval between two pings:
$ ping -i 0.5 127.0.0.1
As you can see in the following figure, you must be superuser to set this time interval to less than 0.2 seconds:
Therefore, the command must be executed using sudo. It should look like this,
$ sudo ping -i 0.5 127.0.0.1
Enter the password when prompted, and the team should work.
Resize ping package
The default ping packet size is 56 bytes. You can change it with the following command:
$ ping -s packetsize hostname/IP
Here we set the package size to 100; you can see the value set to 100 in the first line of output:
Set ping to send the desired number of packets
You can set ping to send the desired number of packets as follows:
$ ping -c NumberOfPackets IP/hostname
In the following example, we set the number of packets to 5; after that the results will end:
The Ping command allows superusers to send 100 or more packets per second with the following command:
$ sudo ping -f hostname-IP
Ping prints “.” When sending ping and “/” when receiving it.
Set Ping Timeout
You can set a time limit after which the ping will exit; no matter how many ping packets are sent or received:
$ ping -w timeinseconds hostname/ip
Here we use 3 seconds as a timeout:
The ping command can be configured to play an audio signal to check host availability as follows:
$ ping -a hostname/ip
Practice with this tutorial will allow you to run ping commands to optimally test your network performance. You can also use pre-switches to configure your ping requests and responses.
Linux Ping Team