中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-08-25 17:07
47,812 topics / 349,910 posts / today 0 new / 48,263 members
其它操作系统综合讨论区 » Advanced uses of ping
Printable Version  1,491 / 0
Floor1 98wangxiao Posted 2002-12-18 00:00
中级用户 Posts 54 Credits 302
Advanced uses of ping
I believe everyone is already very familiar with the ping command under Windows, but not many people can really make the most of ping's functions. Of course, I'm not saying I can bring out ping's maximum potential either. I just happen to use this tool often and have summarized some small experiences, and now I'd like to share them with everyone.
Now I'll go through the ping command's help information and talk about some of the tricks I use when using ping. ping can only be used after the TCP/IP protocol has been installed:
ping │ destination-list
Options:
-t Ping the specified host until stopped.To see statistics and continue - type Control-Break;To stop - type Control-C.
Continuously ping the local host until you press Control-C.
There isn't any special trick to this function, but it can be used together with other parameters, which will be mentioned below.


-a Resolve addresses to hostnames.
Resolve the computer's NetBios name.
Example: C:\>ping -a 192.168.1.21
Pinging iceblood.yofor.com with 32 bytes of data:
Reply from 192.168.1.21: bytes=32 time<10ms TTL=254
Reply from 192.168.1.21: bytes=32 time<10ms TTL=254
Reply from 192.168.1.21: bytes=32 time<10ms TTL=254
Reply from 192.168.1.21: bytes=32 timeping -n 50 202.103.96.68
Pinging 202.103.96.68 with 32 bytes of data:
Reply from 202.103.96.68: bytes=32 time=50ms TTL=241
Reply from 202.103.96.68: bytes=32 time=50ms TTL=241
Reply from 202.103.96.68: bytes=32 time=50ms TTL=241
Request timed out.
………………
Reply from 202.103.96.68: bytes=32 time=50ms TTL=241
Reply from 202.103.96.68: bytes=32 time=50ms TTL=241
Ping statistics for 202.103.96.68:
Packets: Sent = 50, Received = 48, Lost = 2 (4% loss),Approximate round trip times in milli-seconds:
Minimum = 40ms, Maximum = 51ms, Average = 46ms
From the above, I can see that during the process of sending 50 data packets to 202.103.96.68, 48 were returned, and 2 were lost for unknown reasons. Among those 48 returned packets, the fastest return speed was 40ms, the slowest was 51ms, and the average speed was 46ms.


-l size Send buffer size.
Define the size of the echo packet.
By default, Windows ping sends packets of size 32byt. We can also define the size ourselves, but there is a size limit: the maximum is only 65500byt. Some people may ask why it is limited to 65500byt. The reason is that Windows series systems all have a security vulnerability (possibly other systems too): when the data packet sent to the other side at one time is greater than or equal to 65532, the other side will very likely hang, so in order to fix this security hole, Microsoft limited the size of ping packets. Although Microsoft has already imposed this limit, this parameter can still be very harmful when combined with other parameters. For example, by combining it with the -t parameter, we can create a command with offensive behavior: (the following is potentially dangerous, for testing only, please do not casually use it on someone else's machine, otherwise you bear the consequences yourself)
C:\>ping -l 65500 -t 192.168.1.21
Pinging 192.168.1.21 with 65500 bytes of data:
Reply from 192.168.1.21: bytes=65500 time<10ms TTL=254
Reply from 192.168.1.21: bytes=65500 timeping -n 1 -r 9 202.96.105.101 (send one data packet and record at most 9 routes)

Pinging 202.96.105.101 with 32 bytes of data:

Reply from 202.96.105.101: bytes=32 time=10ms TTL=249
Route: 202.107.208.187 ->
202.107.210.214 ->
61.153.112.70 ->
61.153.112.89 ->
202.96.105.149 ->
202.96.105.97 ->
202.96.105.101 ->
202.96.105.150 ->
61.153.112.90

Ping statistics for 202.96.105.101:
Packets: Sent = 1, Received = 1, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 10ms, Maximum = 10ms, Average = 10ms
From the above I can see that from my computer to 202.96.105.101, it went through the routes 202.107.208.187, 202.107.210.214, 61.153.112.70, 61.153.112.89, 202.96.105.149, and 202.96.105.97.


-s count Timestamp for count hops.
Specify timestamps for the hop count specified by count.
This parameter is similar to -r, except that it does not record the route taken by the returned packet, and it can record only up to 4 at most.


-j host-list Loose source route along host-list.
Route the packet using the computer list specified by computer-list. Consecutive computers may be separated by intermediate gateways (loose source route). The maximum number of IPs allowed is 9.


-k host-list Strict source route along host-list.
Route the packet using the computer list specified by computer-list. Consecutive computers cannot be separated by intermediate gateways (strict source route). The maximum number of IPs allowed is 9.


-w timeout Timeout in milliseconds to wait for each reply.
Specify the timeout interval in milliseconds.
This parameter has no other special tricks.

Other ping command tricks: under normal circumstances, you can also use ping to get the TTL value returned by the other side and roughly judge whether the target host's system type is from the Windows series or the UNIX/Linux series. Generally speaking, Windows series systems return TTL values between 100-130, while UNIX/Linux series systems return TTL values between 240-255. Of course, the TTL value can be modified on the other host. On Windows series systems it can be done by modifying the following registry key:

"DefaultTTL"=dword:000000ff
255---FF
  128---80
  64----40
  32----20
Alright, I've basically COPYed over the ping command too. If you have any questions, just reply to the thread.

★PING parameters (repost)

ping parameters

-a convert the target machine identifier into an ip address
-t keep pinging continuously unless the user manually interrupts it
-c count requires the ping command to continuously send packets until count requests have been sent and received
-d turn on debug status for the socket being used
-f a fast way to ping. It makes ping output packets as fast as packets return from the remote host, or even faster, up to 100 times per second. In this mode, each request is shown by a period. A space is printed for each response.
-i seconds set a certain number of seconds between sending two packets. Cannot be used together with -f.
-n use numeric mode only. Under normal circumstances ping will try to convert the IP address into a hostname. This option requires ping to print the IP address without looking up the symbolic name. This option is very important if the local DNS server cannot be used for some reason.
-p pattern the user can use this option to specify 16 pad bytes and append these bytes to the packet. This is very useful when diagnosing data-related errors on the network.
-q make ping print only some summary information at the beginning and end.
-R add the ICMP RECORD-ROUTE option to the ECHO_REQUEST packet and require the route to be recorded in the packet, so that when the packet returns ping can print the route information. Each packet can record only 9 routing nodes. Many hosts ignore or discard this option.
-r make the ping command bypass the normal routing table used to send packets.
-s packetsize lets the user specify the number of bytes of data to send. The default is 56 characters, plus an 8-byte ICMP header, for a total of 64 ICMP data bytes.
-v make ping run in verbose mode. This requires ping to print not only ECHO-RESPONSE packets but also all other returned ICMP packets.
Supplement again

ping command -- detailed help
Check the connection with a remote computer or the local computer. This command can be used only after the TCP/IP protocol is installed.
ping │ destination-list
Parameters
-t
Check the connection with the specified computer until the user interrupts it.
-a
Resolve the address into a computer name.
-n count
Send the number of ECHO messages specified by count; the default is 4.
-l length
Send ECHO messages containing the data length specified by length. The default is 64 bytes, and the maximum is 8192 bytes.
-f
Send the "Do not fragment" flag in the packet. The packet will not be fragmented by gateways on the route.
-i ttl
Set the "time to live" field to the value specified by ttl.
-v tos
Set the "type of service" field to the value specified by tos.
-r count
Record the routes of outgoing and returning messages in the "record route" field. The specified Count value can be at least 1 and at most 9.
-s count
Specify the timestamp for the number of forwards specified by count.
-j computer-list
Route messages through the list of computers specified by computer-list. Intermediate gateways may separate consecutive computers (loose source route). The maximum number of IP addresses allowed is 9.
-k computer-list
Route messages through the list of computers specified by computer-list. Intermediate gateways may separate consecutive computers (strict source route). The maximum number of IP addresses allowed is 9.
-w timeout
Specify the timeout interval in milliseconds.
destination-list
Specify the remote computer whose connection is to be checked.
Detailed information about Ping
Ping -- Notes
The Ping command checks the connection with a remote computer or local computer by sending ICMP reply messages to the computer and listening for returned reply messages. For each sent message, Ping waits at most 1 second and prints the number of sent and received messages. It compares each received message with the sent message to verify its validity. By default, four reply messages are sent, each containing 64 bytes of data (a periodic uppercase letter sequence).
You can use the Ping utility to test computer names and IP addresses. If the IP address can be checked successfully but the computer name cannot, that means there is a problem with name resolution. In that case, make sure the computer name being queried exists in the local HOSTS file or in the DNS
database.
Below is an example of Ping output: (Windows users can use: Start -> Run, enter "command" to bring up the command window and use this command)
C:\>ping ds.internic.net
Pinging ds.internic.net with 32 bytes of data:
Reply from 192.20.239.132: bytes=32 time=101ms TTL=243
Reply from 192.20.239.132: bytes=32 time=100ms TTL=243
Reply from 192.20.239.132: bytes=32 time=120ms TTL=243
Reply from 192.20.239.132: bytes=32 time=120ms TTL=243

[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023