ping command

Using the ping command

Ping is one of the most commonly used and known commands. Administration utility is used to test whether a particular host is reachable across an Internet Protocol (IP) network and to measure the round-trip time for packets sent from the local host to a destination host, including the local host's own interfaces.

Ping uses Internet Control Message Protocol (ICMP) protocol for echo response and echo request. Ping sends ICMP echo request packets to the target host and waits for an ICMP response. Ping output displays the minimum, average and maximum times used for a ping packet to find a specified system and return.

From PC:

Windows:

C:\>ping 10.255.255.4
 Pinging 10.255.255.4 with 32 bytes of data:
Reply from 10.255.255.4: bytes=32 time=1ms TTL=61
Reply from 10.255.255.4: bytes=32 time<1ms TTL=61
Reply from 10.255.255.4: bytes=32 time<1ms TTL=61
Reply from 10.255.255.4: bytes=32 time<1ms TTL=61
Ping statistics for 10.255.255.4:
    Packets: Sent = 4, Received = 4, Lost = 0 (0%
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 1ms, Average = 0ms


Unix-like:

andris@andris-desktop:/$ ping 10.255.255.6
PING 10.255.255.6 (10.255.255.6) 56(84) bytes of data.
64 bytes from 10.255.255.6: icmp_seq=1 ttl=61 time=1.23 ms
64 bytes from 10.255.255.6: icmp_seq=2 ttl=61 time=0.904 ms
64 bytes from 10.255.255.6: icmp_seq=3 ttl=61 time=0.780 ms
64 bytes from 10.255.255.6: icmp_seq=4 ttl=61 time=0.879 ms
^C
--- 10.255.255.6 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 2999ms
rtt min/avg/max/mdev = 0.780/0.948/1.232/0.174 ms

Press Ctrl-C to stop ping process.


From MikroTik:

[admin@MikroTik] > ping 10.255.255.4
10.255.255.4 64 byte ping: ttl=62 time=2 ms
10.255.255.4 64 byte ping: ttl=62 time=8 ms
10.255.255.4 64 byte ping: ttl=62 time=1 ms
10.255.255.4 64 byte ping: ttl=62 time=10 ms
4 packets transmitted, 4 packets received, 0% packet loss
round-trip min/avg/max = 1/5.2/10 ms

Press Ctrl-C to stop ping process.


Using the traceroute command

Traceroute displays the list of the routers that the packet travels through to get to a remote host. The traceroute or tracepath tool is available on practically all Unix-like operating systems and tracert on Microsoft Windows operating systems.

Traceroute operation is based on TTL value and ICMP “Time Exceeded” message. Remember that TTL value in IP header is used to avoid routing loops. Each hop decrements TTL value by 1. If the TTL reaches zero, the packet is discarded and ICMP Time Exceeded message is sent back to the sender when this occurs.

Initially, by traceroute, the TTL value is set to 1 when the next router finds a packet with TTL = 1 it sets TTL value to zero, and responds with an ICMP "time exceeded" message to the source. This message lets the source know that the packet traverses that particular router as a hop. Next time TTL value is incremented by 1 and so on. Typically, each router in the path towards the destination decrements the TTL field by one unit TTL reaches zero.

Using this command you can see how packets travel through the network and where it may fail or slow down. Using this information you can determine the computer, router, switch or another network device that possibly causes network issues or failures.

From Personal computer:

Windows:

C:\>tracert 10.255.255.2
Tracing route to 10.255.255.2 over a maximum of 30 hops
  1    <1 ms    <1 ms    <1 ms  10.13.13.1
  2     1 ms     1 ms     1 ms  10.255.255.2
Trace complete.


Unix-like:

Traceroute and tracepath is similar, only tracepath does not require superuser privileges.

andris@andris-desktop:~$ tracepath 10.255.255.6
 1:  andris-desktop.local (192.168.10.4)                  0.123ms pmtu 1500
 1:  192.168.10.1 (192.168.10.1)                          0.542ms 
 1:  192.168.10.1 (192.168.10.1)                          0.557ms 
 2:  192.168.1.2 (192.168.1.2)                            1.213ms 
 3:  no reply
 4:  10.255.255.6 (10.255.255.6)                          2.301ms reached
     Resume: pmtu 1500 hops 4 back 61


From MikroTik:

[admin@MikroTik] > tool traceroute 10.255.255.1
     ADDRESS                                    STATUS
   1       10.0.1.17 2ms 1ms 1ms 
   2    10.255.255.1 5ms 1ms 1ms
[admin@MikroTik] >