Examples of Ping Command

Ping command is used to check the network status between two nodes.

Developed by : Mike Muss

Abbreviation : Packet INternet Grouper

How it Works : Ping works by sending an ICMP Echo Request(Type 8) packet to the other node specifying that Iam Alive and asking about his status,if the other node receives the packet he will reply with an ICMP Echo Reply(Type 0) packet telling the node he is also Alive.

With this ICMP messages Ping gives us the time that takes to reach and get back the reply from a node(round trip time).

Syntax : ping <ip_address>

Example : ping 192.168.1.5

We will see different examples in which we can use ping


1.Setting the Interval:
     
       By default ping sends an Echo Request for every one second. If you want to change the interval you can do it by specifying with 'i' option. If you want to have anything beyond 200 ms you have to be in root permissions

      Suppose if we want to send an ICMP Echo Request every 500 ms then we have to use the following command:

        ping -i 0.5 192.168.1.5


2. Setting the Number of Packets :

      By default ping continuously sends the ICMP messages until you stop it by sending a signal(CTRL+C). Suppose if you want to ping to send only N number of packets,you will use the 'c' option

Eg: You want the ping to send only 25 packets

    ping -c 25 192.168.1.5


3. Setting the Packet Size:

   Whenever you do a ping command he will send the ICMP packet with 56 bytes of data. If you want to modify this,you can do it with the 's' option

Eg: For sending an Ping packet with 20 bytes

    ping -s 20 192.168.1.5

But in the ouptut you are going to see

28 bytes from 192.168.1.5 .

These additional 8 bytes are the ICMP Header

4. Setting the Interface :

    Suppose you have two interfaces : Ethernet and WLAN and you want to ping from a particular interface. You can do it with the 'I' Option

Eg: If you want to ping from WLAN(wlan0) interface


      ping -I wlan0 1920.168.1.5


5.  Setting the TimeOut:

    If we want to our ping command to stop after some time,say 10 seconds, we can do it by using the 'w' option

Eg: If we want to stop the ping after 10 seconds

     ping -w 10 192.168.1.5


6. Checking the Route of Ping Packet:

    If we want to know the route the packets take to reach the other node,we use 'R' command

Eg: ping -R 192.168.1.5


7. ping version:

 In order to check the ping version we can use 'V' option
Eg: ping -V

8. Flooding:

  In order to flood the network with hundreds of packets use 'f' option

Eg: ping -f 192.168.1.5

Comments

Post a Comment

Popular posts from this blog

bb.utils.contains yocto

Difference between RDEPENDS and DEPENDS in Yocto

make config vs oldconfig vs defconfig vs menuconfig vs savedefconfig