The ping command checks whether the network connectivity is normal and the host is reachable.
ping [ ip ] [ -a source-ip-address | -c count | -d | { -f | ignore-mtu } | -h ttl-value | { [ -nexthop nexthop-address ] [ -i interface-type interface-number ] } | -m time | -n | -name | -p pattern | -q | -r | { -s packetsize | -range [ min min-size | max max-size | step step-size ] * } | -system-time | -t timeout | { -tos tos-value | -dscp dscp-value } | -v | -vpn-instance vpn-instance-name | -ri | -8021p 8021p-value ] * host [ ip-forwarding ]
| Parameter | Description | Value |
|---|---|---|
ip |
Indicates that IP is used. |
- |
-a source-ip-address |
Indicates the source IP address of the Internet Control Message Protocol (ICMP) Echo Request message. If the source IP address is not specified, the IP address of the outbound interface is used as the source IP address of the ICMP Echo Request message. |
The source IP address should be a valid address in Class A, Class B, and Class C. |
-c count |
Indicates the number of ICMP Echo Request messages to be sent. ping command is run, an ICMP Echo Request message carrying a sequence number is sent. The sequence number of the ICMP Echo Request message starts from 1 and is increased by 1. By default, a maximum of five ICMP Echo Request messages are sent. You can set the number of ICMP Echo Request messages to be sent through the parameter count. If the destination is reachable, the source can receive five ICMP Echo Reply messages from the destination, with sequence numbers corresponding to those of ICMP Echo Request messages. In the case of a poor network quality, you can set this parameter to a comparatively large value so as to check the network quality according to the packet loss percentage. |
The value is an integer ranging from 1 to 4294967295. The default value is 5. |
-d |
Indicates that the socket to works in debug mode. |
By default, the socket works in non-debug mode. |
-f |
Indicates that packets are not fragmented during transmission. This parameter does not take effect on the FW. NOTE:
The FW fragments packets exceeding the MTU value. The FW properly processes packets smaller than the MTU value. |
- |
ignore-mtu |
Indicates that the system does not check the interface Maximum Transmission Unit (MTU) when a packet is sent. |
- |
-h ttl-value |
Specifies the value of the TTL. Each time the TTL field is decreased to 0 during message forwarding, the router that the message reaches sends an ICMP timeout message to the source, indicating that the destination is unreachable. |
The value is an integer ranging from 1 to 255. The default value is 255. |
-h hop-limit-value |
Specifies the maximum number of hops for forwarding ICMP Echo Response packets. |
The value is an integer ranging from 1 to 255. The default value is the same as the maximum number of hops specified in the ipv6 nd hop-limit command. |
-nexthop nexthop-address |
Specifies an IP address for the next hop. If you have specified this parameter, the device no longer searches the routing table before sending ICMP Echo Response packets. This process prevents ping failures caused by incorrect routing entries. |
The value is in dotted decimal notation. NOTE:
|
-i interface-type interface-number |
Sets the interface for sending ICMP Echo Request messages. NOTE:
In the case of the broadcast links (on the Ethernet), the destination address is the next hop address of the ICMP Echo Request message. |
- |
-m time |
Specifies the period for waiting for the next ICMP Echo Request message. Each time the source sends an ICMP Echo Request message through the ping command, it waits a period of time (500 ms by default) before sending the next ICMP Echo Request message. You can set the period for waiting for the next ICMP Echo Request message through the parameter time. In the case of poor network condition, the value should be greater than 500, in ms. |
The value is an integer ranging from 1 to 10000, in ms. The default value is 500. |
-n |
Uses the value of host as the IP address to spare domain name resolution. |
- |
-name |
Displays the host name of the destination address. |
- |
-p pattern |
Specifies pad characters for ICMP Echo Request messages. By configuring pad characters for ICMP Echo Request messages, you can identify a specific message among the large number of received ICMP Echo Response messages. |
The value is a hexadecimal integer ranging from 0 to FFFFFFFF. By default, the padding starts from 0x00, and continues in ascending order. |
-q |
Displays only the statistics. If the ping command carries this parameter, the system displays only the statistics information such as the number of sent and received packets, packet loss percentage, and minimum, average, and maximum RTTs of the packet. |
By default, the system displays all statistics information. |
-r |
Indicates that the route along which an IP packet is forwarded is recorded. If -r is configured, during the transmission of an IP packet, the IP address of each router that the IP packet passes through is added to the Options field. When the IP packet reaches the destination, all IP addresses recorded in the Options field are copied to the ICMP Echo Response message. In addition, the IP address of each router that the returned IP packet passes is added to the message. When the ping program receives the ICMP Echo Response message, IP addresses of the passed routers are displayed. |
By default, the route along which an IP packet is forwarded is not recorded. |
-s packetsize |
Indicates the length of an ICMP Echo Request message, excluding the IP header and ICMP header. |
The value is an integer ranging from 20 to 9600, in bytes. The default value is 56. |
-range |
Enables the device to send ICMP Echo Request messages with variable payload lengths. |
|
min min-size |
Specifies the minimum payload length of an ICMP Echo Request message. |
The value is an integer ranging from 20 to 9600, in bytes. The default value is 56. |
max max-size |
Specifies the maximum payload length of an ICMP Echo Request message. |
The value is an integer ranging from 20 to 9600, in bytes. The default value is 9600. |
step step-size |
Specifies the step length of an ICMP Echo Request message. |
The value is an integer ranging from 1 to 1000, in bytes. The default value is 1. |
-system-time |
Displays the system time when the ping packet is sent. |
- |
-t timeout |
Indicates the timeout period for waiting for an ICMP Echo Response message after an ICMP Echo Request message is sent. After the ping command is run, the source sends an ICMP Echo Request message to a destination and then waits for an ICMP Echo Response message. If the destination, after receiving the ICMP Echo Request message, returns an ICMP Echo Response message to the source within the period specified by the parameter timeout, it indicates that the destination is reachable. If the destination does not returns an ICMP Echo Response message within the specified period, the source displays that the message times out. Normally, the source receives an ICMP Echo Response message 1 to 10 seconds after sending an ICMP Echo Request message. If the transmission speed is not satisfying, you can use this parameter to increase the timeout period for waiting for an ICMP Echo Response message after an ICMP Echo Request message is sent. |
The value is an integer ranging from 0 to 65535, in ms. The default value is 2000. |
-tos tos-value |
Specifies the ToS value of the sent ICMP Echo Request messages. The Type of Service (ToS) value is used to set the packet priority. |
The value is an integer ranging from 0 to 255. The default value is 0. |
-dscp dscp-value |
Specifies the DiffServ Code Point (DSCP) value of the sent ICMP Echo Request messages. |
The value is an integer ranging from 0 to 63. The default value is 0. |
-v |
Displays ICMP Echo Response messages not for the local user.
|
By default, only ICMP Echo Response messages for the local user are displayed. |
-vpn-instance vpn-instance-name |
Indicates the name of a VPN instance. |
The value is a string of 1 to 31 case-sensitive characters, spaces not supported. When double quotation marks are used around the string, spaces are allowed in the string. |
-ri |
Displays the interface that receives ICMP Echo Response messages. |
By default, no interface that receives ICMP Echo Response messages is displayed. |
-8021p 8021p-value |
Specifies the 8021p value of the sent ICMP Echo Request messages. NOTE:
The 8021p value specified by ping -8021p marks the priority of packets carrying VLAN tags on the Ethernet. The interface sending packets must be an Ethernet interface that encapsulates VLAN tags into packets. Otherwise, the specified 8021p value does not take effect. |
The value is an integer ranging from 0 to 7. The default value is 0. |
host |
Indicates the domain name or IP address of the destination host. |
The value is a string of 1 to 255 case-sensitive characters with spaces not supported. Alternatively, the value can be a legal IPv4 address in dotted decimal notation. |
ip-forwarding |
Indicates that the ping packets are forcibly forwarded through IP on the first node. |
- |
-tc traffic-class-value |
Indicates the traffic classification in the ICMP Echo Request message. |
The value is an integer that ranges from 0 to 255. The default value is 0. |
Applicable Environment
Ping is a common debugging tool for testing the network connectivity by transmitting ICMP Echo messages. It can detect the following items:
Prerequisite
Effect
Note
# Check whether the host with the IP address of 10.1.1.2 is reachable.
<sysname> ping 10.1.1.2
PING 10.1.1.2: 56 data bytes, press CTRL_C to break
Reply from 10.1.1.2: bytes=56 Sequence=1 ttl=255 time=2 ms
Reply from 10.1.1.2: bytes=56 Sequence=2 ttl=255 time=1 ms
Reply from 10.1.1.2: bytes=56 Sequence=3 ttl=255 time=1 ms
Reply from 10.1.1.2: bytes=56 Sequence=4 ttl=255 time=1 ms
Reply from 10.1.1.2: bytes=56 Sequence=5 ttl=255 time=1 ms
--- 10.1.1.2 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 1/1/2 ms
# Check whether the host with the IP address of 10.1.1.2 is reachable. Set the source address to 10.10.10.110 and the number of ICMP Echo Request messages to be sent to 8.
<sysname> ping -a 10.10.10.110 -c 8 10.1.1.2
PING 10.1.1.2: 56 data bytes, press CTRL_C to break
Reply from 10.1.1.2: bytes=56 Sequence=1 ttl=255 time=32 ms
Reply from 10.1.1.2: bytes=56 Sequence=2 ttl=255 time=32 ms
Reply from 10.1.1.2: bytes=56 Sequence=3 ttl=255 time=32 ms
Reply from 10.1.1.2: bytes=56 Sequence=4 ttl=255 time=32 ms
Reply from 10.1.1.2: bytes=56 Sequence=5 ttl=255 time=32 ms
Reply from 10.1.1.2: bytes=56 Sequence=6 ttl=255 time=32 ms
Reply from 10.1.1.2: bytes=56 Sequence=7 ttl=255 time=32 ms
Reply from 10.1.1.2: bytes=56 Sequence=8 ttl=255 time=32 ms
--- 10.1.1.2 ping statistics ---
8 packet(s) transmitted
8 packet(s) received
0.00% packet loss
round-trip min/avg/max = 32/32/32 ms
# Check whether the host with the IP address of 10.1.1.2 is reachable. Set the length of the ICMP Echo Request message to be sent to 300 bytes and the period of time for waiting for the next ICMP Echo Request message to 3000 ms.
<sysname> ping -m 3000 -s 300 10.1.1.2
PING 10.1.1.2: 300 data bytes, press CTRL_C to break
Reply from 10.1.1.2: bytes=300 Sequence=1 ttl=255 time=31 ms
Reply from 10.1.1.2: bytes=300 Sequence=2 ttl=255 time=31 ms
Reply from 10.1.1.2: bytes=300 Sequence=3 ttl=255 time=31 ms
Reply from 10.1.1.2: bytes=300 Sequence=4 ttl=255 time=31 ms
Reply from 10.1.1.2: bytes=300 Sequence=5 ttl=255 time=31 ms
--- 10.1.1.2 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 31/31/31 ms
Item |
Description |
|---|---|
ping x.x.x.x |
Indicates the IP address of the destination host. |
x data bytes |
Indicates the length of data in a sent packet. |
press CTRL_C to break |
Indicates that you can terminate the ongoing ping test by pressing Ctrl+C. |
Reply from x.x.x.x |
Indicates that the destination host responds to the ICMP Echo Request message with an ICMP Echo Response message, which contains the following items:
|
x.x.x.x ping statistics |
Indicates the statistics collected after the ping test on the destination host. The statistics include the following information:
|