All About PING Command

All network administrators and IT professionals are well known with the ping command. It’s a life saving command to check the basic connectivity between two hosts like host to server or host to host.

Let’s jump into it and know more in details.

What is Ping & how it works

PING stands for Packet InterNet Groper. A utility or program to determine whether a specific IP address or host / server is accessible from your network or not. The ping utility is commonly used to check for network errors & to diagnosis that problem. It’s working mechanism is simple but life saving. It works by sending a packet to the specified IP address / host / server address and waiting for a reply from that host and measured the delay of that response. This is also known as latency.

So, you can know whether a host is reachable from your network and how fast you get a response from that host after you’ve sent out a PING request. A fast ping or low latency means a more responsive connection, especially in applications where time is everything (like online web games). Normally, ping is measured in milliseconds (ms). higher latency means you have some problem with your network for sure. Though this latency varies a lot depending or routing and Geo location. If you are in USA and you are pinging a host of USA then the delay will be lower. But if you are in USA and you are pining a host of Bangladesh then definitely your latency will be higher due to Geo location and number of HOPs for that routing.

PING is the primary troubleshoot technique for any connections. It will reply or echo for a response. Ping send a message to a server / host that contains the message “PING” and receive a copy of the message back from that host / server. Ping calculate the “Round Trip Time” (or RTT) that it takes a packet to reach a particular server / host.

Every modern operating system has this ping tool pre installed. So, you can find this utility program on every OS just from the terminal ( If you are running like UNIX / Linux operating System ) or from the ( Command prompt / MS DOS Prompt ) if you are running a MS Windows operating system.

Note: Some host or server may block or not allow any ping or ICMP request for security.

Here, I will show you ping examples by using an Ubuntu 14.04.3 LTS Linux OS. You can use whatever Linux distribution you have.

Getting ping version

To know the version, open a terminal and issue the below command.

sudo ping -V

It will give you the currently installed ping versions to you.

Ping Execution

There are few differences while you are performing a ping test or pining from a MS Windows based OS and UNIX / Linux like OS.

Simple ping command takes only one parameter and the parameter is the host name or the host IP address that you want to ping. A simple ping example is just like below. Open a terminal and type the following

ping unixmen.com

Here unixmen.com is the host name or a host.

With the above command you will see something like this

You need to stop the ping command by pressing CTRL+C. Else it will ping for infinite time until you stopped it. After every ping commands, it will display a summery report with these following.

Min: Minimum time that takes to get a respond from the host that has been pinged from your end.

Avg: Average time that takes to get a respond from the host that has been pinged from your end.

Max: Maximum time that takes to get a respond from the host that has been pinged from your end.

Also you will see TTL which stands for Time To Live. Ping use a numerical TTL value to attempt to reach a given host computer via the route path. This is also known as hop limit. TTL limits the time of data over a network for different purposes such as DNS records, HTTP, ICMP etc.

Ping from local / private network

To ping a host of your local / private network , you need to type the IP address of that host

ping 192.168.1.5 -c 5

Here, 192.168.1.5 is the host that I want to ping from my local network. This is a host of my local network. I hope that you know all the blocks of private network and those hosts as well.

You will see something like this.

Ping count / numbers

Normally, when you run a simple ping command without passing any additional parameters, it will ping that host for infinite time while you are using any Linux OS.

So say, I want ping a host for 10 times, so I will type the following on my terminal.

ping -c 10 unixmen.com

You will see something like below image.

Here you can see that it ping 10 times and then it displays the ping summary report to you.

If you are running from a MS Windows OS, type this on the command prompt

ping -n 10 unixmen.com

Different packet size

By default, it sends 64 bytes of a ping request to a host if you are using any Linux OS and it will send 32 bytes if you used any MS Windows OS. If you want to change it and want to send heavy packet then do the following

ping -s 100 -c 6 unixmen.com

Here, you can see that It is not sending 64 bytes. It is sending 108 bytes.

or

From MS Windows OS , type the following

ping -l 100 unixmen.com

Increase or decrease the time interval

By default ping waits for 1 second before sending the next packet towards the destination host. You can increase or decrease this using option -i if you wish according to meet your requirements.

Let’s Increase ping time interval by 3 seconds so that it send ping request after each 3 seconds

ping -i 3 unixmen.com

It will send a ping request with a 3 seconds interval time.

If you want to decrease ping time interval, issue the below command

sudo ping -i 0.2 unixmen.com

Flood with ping

This is used to send packets soonest. This is used to test network performance. To do so, issue the below command in the terminal.

sudo ping -f unixmen.com

Press CTRL+C to stop this. You will see something like this and it may differ one host to another and how good your internet connection is.

Ping with summary statistics

If you want to see the ping summary statistics report only then use the following method. Use option -q to view only the ping statistics summary.

ping -c 5 -q unixmen.com

You will see something like this just below image.

Here, you can see that it is not echoing or replying the acknowledgment from the host. It’s just showing the report.

Ping timeout

If you pass the parameter -w with your ping command then it will specifies the deadline to terminate the ping output. This specifies the total number of seconds the ping command should send packets to that remote host.

ping -w 6 unixmen.com

So, the above command will ping the host for 6 seconds and then it will be terminated automatically and will display the result.

Ping output explanation

While pining a host you will find different output from the ping results.

Destination Host Unreachable

If the message is simply “Destination Host Unreachable,” then possible best reason is there is no route from the local host system and between the packets that has been sent to the destination desired destination host or a remote router reports that it has no route to the destination host.

Request timed out

If you see Request timed out it means or indicates that no Echo Reply messages were received within the default time of 1 second or the time that you set while you are pining that host. This can be due to many different causes; the most common include network congestion, failure of the ARP request, packet filtering / firewall, routing error, cable fault or switch / router port problem etc etc.

Unknown host / Ping Request Could Not Find Host

ping unixmens.com

May be you misspelled the host name or the host does not exits at all in the real internet cloud. Note that, I intentionally misspelled the host name while I ping.

For every ping results you must have 0% packet loss with a good latency or lower response time. Depending of which transmission medium ( UTP, Fiber Optics Cable, Wi-Fi ) you are using your latency will differ.