[ Bottom of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]

Commands Reference, Volume 4

ping Command

Purpose

Sends an echo request to a network host.

Syntax

ping [ -d] [ -D ] [  -n ] [  -q ] [ -r] [ -v] [  -R ] [ -a addr_family ] [  -c Count ] [ -w timeout ] [  -f -i Wait ] [  -l Preload ] [  -p Pattern ] [  -s PacketSize ] [ -S hostname/IPv6 addr ] [ -L ] [ - I a.b.c.d. ] [ -o interface ] [ -T ttl ] HostPacketSize Count ] ]

Description

The /usr/sbin/ping command sends an Internet Control Message Protocol (ICMP) ECHO_REQUEST to obtain an ICMP ECHO_RESPONSE from a host or gateway. The ping command is useful for:

If the host is operational and on the network, it responds to the echo. Each echo request contains an Internet Protocol (IP) and ICMP header, followed by a timeval structure, and enough bytes to fill out the packet. The default is to continuously send echo requests until an Interrupt is received (Ctrl-C).

The ping command sends one datagram per second and prints one line of output for every response received. The ping command calculates round-trip times and packet loss statistics, and displays a brief summary on completion. The ping command completes when the program times out or on receipt of a SIGINT signal. The Host parameter is either a valid host name or Internet address.

By default, the ping command will continue to send echo requests to the display until an Interrupt is received (Ctrl-C). The Interrupt key can be changed by using the stty command.

Because of the load that continuous echo requests can place on the system, repeated requests should be used primarily for problem isolation.

Flags

-c Count Specifies the number of echo requests, as indicated by the Count variable, to be sent (and received).
-w timeout This option works only with the -c option. It causes ping to wait for a maximum of 'timeout' seconds for a reply (after sending the last packet).
-d Starts socket-level debugging.
-D This option causes a hex dump to standard output of ICMP ECHO_REPLY packets.
-f Specifies flood-ping option. The -f flag "floods" or outputs packets as fast as they come back or one hundred times per second, whichever is more. 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 being dropped. Only the root user may use this option.

Note: This can be very hard on a network and should be used with caution. Flood pinging is only permitted by the root user. The -f flag is incompatible with the -i Wait flag.
-I a.b.c.d Specifies that the interface specified by a.b.c.d is to be used for outgoing IPv4 multicasts. The -I flag is an uppercase i.
-o interface Specifies that interface is to be used for outgoing IPv6 multicasts. The interface is specified in the form 'en0', 'tr0' etc.
-i Wait Waits the number of seconds specified by the Wait variable between the sending of each packet. The default is to wait for one second between each packet. This option is incompatible with the -f flag.
-L Disables local loopback for multicast pings.
-l Preload Sends the number of packets specified by the Preload variable as fast as possible before falling into normal mode of behavior (one per second). The -l flag is a lowercase l.
-n Specifies numeric output only. No attempt is made to look up symbolic names for host addresses.
-p Pattern Specifies up to 16 'pad' bytes to fill out the packet you send. This is useful for diagnosing data-dependent problems in a network. For example, -p ff fills the packet with all 1's.
-q Specifies quiet output. Nothing is displayed except the summary lines at startup time and when finished.
-r Bypasses the routing tables and sends directly to a host on an attached network. If the Host is not on a directly connected network, the ping command generates an error message. This option can be used to ping a local host through an interface that no longer has a route through it.
-R Specifies record route option. The -R flag includes the RECORD_ROUTE option in the ECHO_REQUEST packet and displays the route buffer on returned packets.

Note: The IP header is only large enough for nine such routes. Also, many hosts and gateways ignore this option.
-a addr_family Maps the destination address of the ICMP packets to IPv6 format if addr_family is equal to "inet6".
-s PacketSize Specifies the number of data bytes to be sent. The default is 56, which translates into 64 ICMP data bytes when combined with the 8 bytes of ICMP header data.
-S hostname/IPv6 addr This is an IPv6 option. It allows you to set the source address in the ICMP packets to your scope preference (i.e., link local, site local, etc.).
-T ttl Specifies that the time-to-live for a multicast packet is ttl seconds.
-v Requests verbose output, which lists ICMP packets that are received in addition to echo responses.

Parameters

PacketSize Specifies the number of data bytes to be sent. The default is 56, which translates into 64 ICMP data bytes when combined with the 8 bytes of ICMP header data. This parameter is included for compatibility with previous versions of the ping command.
Count Specifies the number of echo requests to be sent (and received). This parameter is included for compatibility with previous versions of the ping command.

Examples

  1. To check the network connection to host canopus and specify the number of echo requests to send, enter:
    ping -c 5 canopus
    OR
    ping canopus 56 5
    Information similar to the following is displayed:

    PING canopus.austin.century.com: (128.116.1.5): 56 data bytes
    64 bytes from 128.116.1.5: icmp_seq=0 ttl=255 time=2 ms
    64 bytes from 128.116.1.5: icmp_seq=1 ttl=255 time=2 ms
    64 bytes from 128.116.1.5: icmp_seq=2 ttl=255 time=3 ms
    64 bytes from 128.116.1.5: icmp_seq=3 ttl=255 time=2 ms
    64 bytes from 128.116.1.5: icmp_seq=4 ttl=255 time=2 ms
    
    ----canopus.austin.century.com PING Statistics----
    5 packets transmitted, 5 packets received, 0% packet loss
    round-trip min/avg/max = 2/2/3 ms
  2. To get information about host lear and start socket-level debugging, enter:
    ping  -d lear
    Information similar to the following is displayed:

    PING lear.austin.century.com: (128.114.4.18) 56 data bytes
    64 bytes from 128.114.4.18: icmp_seq=0 ttl=255 time=6 ms
    64 bytes from 128.114.4.18: icmp_seq=1 ttl=255 time=17 ms
    64 bytes from 128.114.4.18: icmp_seq=2 ttl=255 time=6 ms
    64 bytes from 128.114.4.18: icmp_seq=3 ttl=255 time=6 ms
    64 bytes from 128.114.4.18: icmp_seq=4 ttl=255 time=6 ms
    ^C
    ----lear.austin.century.com PING Statistics ----
    5 packets transmitted, 5 packets received, 0% packet loss
    round-trip min/avg/max = 6/8/17 ms

    Note: The output is repeated until an Interrupt (Ctrl-C) is received.
  3. To obtain information about host opus and specify the number of data bytes to be sent, enter:
    ping -s 2000 opus
    OR
    ping opus 2000
    Information similar to the following is displayed:

    PING opus.austin.century.com: (129.35.34.234): 2000 data bytes
    2008 bytes from 129.35.34.234: icmp_seq=0 ttl=255 time=20 ms
    2008 bytes from 129.35.34.234: icmp_seq=1 ttl=255 time=19 ms
    2008 bytes from 129.35.34.234: icmp_seq=2 ttl=255 time=20 ms
    2008 bytes from 129.35.34.234: icmp_seq=3 ttl=255 time=20 ms
    2008 bytes from 129.35.34.234: icmp_seq=4 ttl=255 time=20 ms
    2008 bytes from 129.35.34.234: icmp_seq=5 ttl=255 time=19 ms
    2008 bytes from 129.35.34.234: icmp_seq=6 ttl=255 time=19 ms
    ^C
    ----opus.austin.century.com PING Statistics----
    7 packets transmitted, 7 packets received, 0% packet loss
    round-trip min/avg/max = 19/19/20 ms

    Note: The output is repeated until an Interrupt (Ctrl-C) is received.
  4. To invoke the flood-ping option to host stlopnor, enter:
    ping  -f stlopnor
    Information similar to the following is displayed:

    Ping stlopnor.austin.century.com: (129.35.34.234): 56 data bytes
    .^C
    ----stlopnor.austin.century.com PING Statistics ----
    1098 packets transmitted, 1097 packets received, 0% packet loss
    round-trip min/avg/max = 4/4/11

    Note: The flood-ping output continues until an Interrupt (Ctrl-C) is received.
  5. To specify an interval of five seconds between packets sent to host opus, enter:
    ping  -i5 opus
    Information similar to the following is displayed:

    PING opus.austin.century.com: (129.35.34.234): 56 data bytes
    64 bytes from 129.35.34.234: icmp_seq=0 ttl=255 time=5 ms
    64 bytes from 129.35.34.234: icmp_seq=1 ttl=255 time=5 ms
    64 bytes from 129.35.34.234: icmp_seq=2 ttl=255 time=6 ms
    ^C
    ----opus.austin.century.com PING Statistics----
    3 packets transmitted, 3 packets received, 0% packet loss
    round-trip min/avg/max = 5/5/6 ms

    Note: The output is repeated until an Interrupt (Ctrl-C) is received.
  6. To send the number of packets specified by the Preload variable as fast as possible before falling into normal mode of behavior to host opus, enter:
    ping  -l 10 opus
    Information similar to the following is displayed:

    PING opus.austin.century.com: (129.35.34.234): 56 data bytes
    64 bytes from 129.35.34.234: icmp_seq=0 ttl=255 time=9 ms
    64 bytes from 129.35.34.234: icmp_seq=1 ttl=255 time=11 ms
    64 bytes from 129.35.34.234: icmp_seq=2 ttl=255 time=16 ms
    64 bytes from 129.35.34.234: icmp_seq=3 ttl=255 time=22 ms
    64 bytes from 129.35.34.234: icmp_seq=4 ttl=255 time=26 ms
    64 bytes from 129.35.34.234: icmp_seq=5 ttl=255 time=27 ms
    64 bytes from 129.35.34.234: icmp_seq=6 ttl=255 time=30 ms
    64 bytes from 129.35.34.234: icmp_seq=7 ttl=255 time=31 ms
    64 bytes from 129.35.34.234: icmp_seq=8 ttl=255 time=33 ms
    64 bytes from 129.35.34.234: icmp_seq=9 ttl=255 time=35 ms
    64 bytes from 129.35.34.234: icmp_seq=10 ttl=255 time=36 ms
    64 bytes from 129.35.34.234: icmp_seq=11 ttl=255 time=6 ms
    64 bytes from 129.35.34.234: icmp_seq=12 ttl=255 time=6 ms
    64 bytes from 129.35.34.234: icmp_seq=13 ttl=255 time=6 ms
    64 bytes from 129.35.34.234: icmp_seq=14 ttl=255 time=7 ms
    64 bytes from 129.35.34.234: icmp_seq=15 ttl=255 time=6 ms
    ^C
    ----opus.austin.century.com PING Statistics----
    16 packets transmitted, 16 packets received, 0% packet loss
    round-trip min/avg/max = 6/19/36 ms

    Note: The output is repeated until an Interrupt (Ctrl-C) is received.
  7. To diagnose data-dependent problems in a network, enter:
    ping  -p ff opus
    This command sends packets with a pad-pattern of all 1's to host opus. Information similar to the following is displayed:

    PATTERN: 0xff
    PING opus.austin.century.com: (129.35.34.234): 56 data bytes
    64 bytes from 129.35.34.234: icmp_seq=0 ttl=255 time=5 ms
    64 bytes from 129.35.34.234: icmp_seq=1 ttl=255 time=5 ms
    64 bytes from 129.35.34.234: icmp_seq=2 ttl=255 time=5 ms
    64 bytes from 129.35.34.234: icmp_seq=3 ttl=255 time=6 ms
    64 bytes from 129.35.34.234: icmp_seq=4 ttl=255 time=5 ms
    ^C
    ----opus.austin.century.com PING Statistics----
    5 packets transmitted, 5 packets received, 0% packet loss
    round-trip min/avg/max = 5/5/6 ms

    Note: The output is repeated until an Interrupt (Ctrl-C) is received.
  8. To specify quiet output, enter:
    ping  -q bach
    Only summary information similar to the following is displayed:

    PING bach.austin.century.com: (129.35.34.234): 56 data bytes
    ^C
    ----bach.austin.century.com PING Statistics----
    5 packets transmitted, 5 packets received, 0% packet loss
    round-trip min/avg/max = 5/5/8 ms

    Note: Although not displayed, the output of packets continues until an Interrupt (Ctrl-C) is received.

Related Information

The ifconfig command, netstat command.

Network Overview in AIX 5L Version 5.2 System Management Guide: Communications and Networks.

[ Top of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]