Using ping command
The ping command in Ubuntuis a network utility used to test the reachability of a host on an IP network. It also measures the round-trip time for messages sent from the source to the destination. The ping command works by sending Internet Control Message Protocol (ICMP) Echo Request messages to the target host and waiting for ICMP Echo Reply messages.
Basic usage
ping 8.8.8.8
Output of the command:
root@ubuntu-d-2022q1:~# ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=115 time=11.2 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=115 time=9.94 ms
^C
--- 8.8.8.8 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 9.936/10.574/11.213/0.638 ms
You can specify the following parameters for the ping command:
-i <interval>
: Sets the interval between sending each ping request (in seconds).
-c <count>: Specifies the number of ping requests to send.
-W <timeout>: Specifies a timeout in seconds for waiting for a reply. This can be useful to avoid waiting too long for a response.
-s <packetsize>: Sets the number of data bytes to be sent.
-t <ttl>: Sets the Time to Live (TTL) for packets. This limits the number of hops a packet can take before being discarded.
-v: Verbose output, providing more detailed information about the ping process.
-f: Flood ping, for every ECHO_REQUEST sent a period “.” is printed, while for every ECHO_REPLY received a backspace is printed. This provides a rapid display of how many packets are beingdropped. If interval is not given, it sets interval to zero and outputs packets as fast as they come back or one hundred times per second, whichever is more. Only the super-user may use this option with zero interval.
Example
Ping 8.8.8.8, 4 times every 2 seconds:
ping -c 4 -i 2 8.8.8.8