ping
Syntax
ping [ ip ] [ -a source-ip | -c count | -f | -h ttl | -i interface-type interface-number | -m interval | -n | -p pad | -q | -r | -s packet-size | -t timeout | -tos tos | -v ] * host
View
Any view
Default level
0: Visit level
Parameters
ip: Distinguishes between a destination host name and the ping command keywords if the name of the destination host is i, ip, ipv, or ipv6. For example, you must use the command in the form of ping ip ip instead of ping ip if the destination host name is ip.
-a source-ip: Specifies the source IP address of an ICMP echo request (ECHO-REQUEST). It must be an IP address configured on the device. If this option is not specified, the source IP address of an ICMP echo request is the primary IP address of the outbound interface of the request.
-c count: Specifies the number of times that an ICMP echo request is sent, which is in the range of 1 to 4294967295 and defaults to 5.
-f: Discards packets larger than the MTU of a given interface, which means the ICMP echo request is not allowed to be fragmented.
-h ttl: Specifies the TTL value for an ICMP echo request, which is in the range of 1 to 255 and defaults to 255.
-i interface-type interface-number: Specifies the ICMP echo request sending interface by its type and number. If this option is not specified, the ICMP echo request sending interface is determined by searching the routing table or forwarding table according to the destination IP address.
-m interval: Specifies the interval (in milliseconds) to send an ICMP echo request, which is in the range of 1 to 65535 and defaults to 200.
If a response from the destination is received within the timeout time, the interval to send the next echo request equals the actual response period plus the value of interval.
If no response from the destination is received within the timeout time, the interval to send the next echo request equals the timeout value plus the value of interval.
-n: Disables domain name resolution for the host argument. When this keyword is not specified, if the host argument represents the host name of the destination, the device translates host into an address.
-p pad: Specifies the value of the pad field in an ICMP echo request, in hexadecimal format, 1 to 8 bits, in the range of 0 to ffffffff. If the specified value is less than 8 bits, 0s are added in front of the value to extend it to 8 bits. For example, if pad is configured as 0x2f, then the packets are padded with 0x0000002f repeatedly to make the total length of the packet meet the requirements of the device. By default, the padded value starts from 0x01 up to 0xff, where another round starts again if necessary, like 0x010203…feff01….
-q: Specifies that only statistics are displayed. Absence of this keyword indicates that all information is displayed.
-r: Specifies the recording routing information. If this keyword is not specified, routes are not recorded.
-s packet-size: Specifies the length (in bytes) of an ICMP echo request, which is in the range of 20 to 8100 and defaults to 56.
-t timeout: Specifies the timeout value (in milliseconds) of an ICMP echo reply (ECHO-REPLY). If the source does not receive an ICMP echo reply within the timeout, it considers the ICMP echo reply timed out. The value is in the range of 0 to 65535 and defaults to 2000.
-tos tos: Specifies the ToS value for an echo request, which is in the range of 0 to 255 and defaults to 0.
-v: Displays the non-ICMP echo reply received. If this keyword is not specified, the system does not display non ICMP echo reply.
host: Specifies the IP address or host name (a string of 1 to 255 characters) for the destination.
Description
Use ping to verify whether the destination in an IP network is reachable, and to display the related statistics.
With the ping command executed, the source sends an ICMP echo request to the destination:
If the destination name is unrecognizable, the system outputs "Error: Ping: Unknown host host-name."
If the source receives an ICMP echo reply from the destination within the timeout, the system outputs the related information of the reply.
If the source does not receive an ICMP echo reply from the destination within the timeout, the system outputs "Request time out."
To use the name of the destination host to perform the ping operation, you must configure the Domain Name System (DNS) on the device first. Otherwise, the ping operation fails.
To abort the ping operation during the execution of the command, press Ctrl+C.
Examples
# Test whether the device with an IP address of 1.1.2.2 is reachable.
<Sysname> ping 1.1.2.2 PING 1.1.2.2: 56 data bytes, press CTRL_C to break Reply from 1.1.2.2: bytes=56 Sequence=1 ttl=254 time=205 ms Reply from 1.1.2.2: bytes=56 Sequence=2 ttl=254 time=1 ms Reply from 1.1.2.2: bytes=56 Sequence=3 ttl=254 time=1 ms Reply from 1.1.2.2: bytes=56 Sequence=4 ttl=254 time=1 ms Reply from 1.1.2.2: bytes=56 Sequence=5 ttl=254 time=1 ms --- 1.1.2.2 ping statistics --- 5 packet(s) transmitted 5 packet(s) received 0.00% packet loss round-trip min/avg/max = 1/41/205 ms
The output shows the following:
The destination is reachable.
All ICMP echo requests sent by the source have got responses.
The minimum time, average time, and maximum time for the packet’s roundtrip time are 1 ms, 41 ms, and 205 ms respectively.
# Test whether the device with an IP address of 1.1.2.2 is reachable. Only the check results are displayed.
<Sysname> ping -q 1.1.2.2 PING 1.1.2.2: 56 data bytes, press CTRL_C to break --- 1.1.2.2 ping statistics --- 5 packet(s) transmitted 4 packet(s) received 20.00% packet loss round-trip min/avg/max = 1/12/29 ms
# Test whether the device with an IP address of 1.1.2.2 is reachable. The route information is displayed.
<Sysname> ping -r 1.1.2.2 PING 1.1.2.2: 56 data bytes, press CTRL_C to break Reply from 1.1.2.2: bytes=56 Sequence=1 ttl=254 time=53 ms Record Route: 1.1.2.1 1.1.2.2 1.1.1.2 1.1.1.1 Reply from 1.1.2.2: bytes=56 Sequence=2 ttl=254 time=1 ms Record Route: 1.1.2.1 1.1.2.2 1.1.1.2 1.1.1.1 Reply from 1.1.2.2: bytes=56 Sequence=3 ttl=254 time=1 ms Record Route: 1.1.2.1 1.1.2.2 1.1.1.2 1.1.1.1 Reply from 1.1.2.2: bytes=56 Sequence=4 ttl=254 time=1 ms Record Route: 1.1.2.1 1.1.2.2 1.1.1.2 1.1.1.1 Reply from 1.1.2.2: bytes=56 Sequence=5 ttl=254 time=1 ms Record Route: 1.1.2.1 1.1.2.2 1.1.1.2 1.1.1.1 --- 1.1.2.2 ping statistics --- 5 packet(s) transmitted 5 packet(s) received 0.00% packet loss round-trip min/avg/max = 1/11/53 ms
The output shows the following:
The destination is reachable.
The route is 1.1.1.1 <-> {1.1.1.2; 1.1.2.1} <-> 1.1.2.2.
Table 1: Command output
Field | Description |
---|---|
PING 1.1.2.2 | Test whether the device with IP address 1.1.2.2 is reachable. |
56 data bytes | Number of data bytes in each ICMP echo request. |
press CTRL_C to break | During the execution of the command, you can press Ctrl+C to abort the ping operation. |
Reply from 1.1.2.2 : bytes=56 Sequence=1 ttl=255 time=1 ms | Received the ICMP reply from the device whose IP address is 1.1.2.2. If no reply is received during the timeout period, "Request time out" is displayed.
|
Record Route: | Routers through which the ICMP echo request passed. They are displayed in inversed order. The router with a smaller distance to the destination is displayed first. |
--- 1.1.2.2 ping statistics --- | Statistics on data received and sent in the ping operation. |
5 packet(s) transmitted | Number of ICMP echo requests sent. |
5 packet(s) received | Number of ICMP echo requests received. |
0.00% packet loss | Percentage of packets not responded to the total packets sent. |
round-trip min/avg/max = 0/4/20 ms | Minimum/average/maximum response time, in ms. The field is not available for failed ping attempts in an IPv4 network. In an IPv6 network, however, the field is available and set to 0/0/0 ms. |