[Repost] ping command fully explains the role of ping
Ping is a dedicated term for submarine staff, indicating a responsed sonar pulse, and ping in the network is a very good TCP / IP tool. Its main function is to detect communication and analysis network speeds.
Ping has a good side of a good side. Let's talk about a good side. The use of ping has been used to detect the connection between the network and analyze the network speed, but what is it displayed? This first is to understand some of the parameters of ping and return information.
The following is some of the parameters:
Ping [-t] [-A] [-n count] [-l length] [-f] [-i ttl] [-V TOS] [-r count] [-s count] [-j computer-list] | [-k computer-list] [-w Timeout] destination-List
-t
Ping specified computer until the interrupt.
-A
Resolve the address as the computer name.
-n count
Send count of the ECHO packet specified by COUNT. The default is 4.
-l Length
Send an Echo packet containing the amount of data specified by Length. The default is 32 bytes; the maximum is 65, 527.
-f
Send a "Do not segment" flag in the packet. The packet will not be segmented by the gateway on the route.
-i TTL
Set the "Survival Time" field to the value specified by TTL.
-V TOS
Set the Service Type field to the value specified by TOS.
-r count
Record the routing of the outgoing and returning packets in the Record Routing field. COUNT can specify at least 1 set, up to 9 computers.
-s count
Specifies the timestamp of the number of hops specified by count.
-j Computer-List
Routing the packet using the computer list specified using computer-list. A continuous computer can be separated by the intermediate gateway (routing sparse source) IP allowed to be 9.
-k computer-list
Routing the packet using the computer list specified using computer-list. Continuous computers cannot be separated by intermediate gateway (routing strict source) IP allowed to 9.
-w Timeout
Specifies a timeshoot, unit is millisecond.
Destination-List
Specifies the remote computer to be ping.
Ping's return information has "Request Timed Out", "Destination Net Unreachable" and "Bad IP Address" and "Source Quench Received".
"Request Timed Out" information indicates that the other party can reach time OUT, which is usually the packet loss for the other party to reject the packet you sent to it. Most of the reasons may be that the other party is installed with a firewall or offline.
"Destination Net Unreachable" This information indicates that the other host does not exist or does not establish a connection with the other party. Here is the difference between "Destination Host Unreachable" and "Time Out", if the router has arrived in the routing table of the router, the target is not arrived by other reasons, if it appears "Time Out" at this time, if There is no route to the target in the routing table, and "Destination Host Unreachable" will appear.
"Bad IP Address" information indicates that you may not connect to the DNS server so you can't resolve this IP address, or it may be that the IP address does not exist.
"Source quench received" information is special, and it has little probability. It means that the other party or the middle of the server is busy and unable to respond. How to use ping this command to test the network?
The communication problem is caused by many reasons, such as local configuration errors, remote host protocol failure, etc., of course, also include faults caused by devices.
First we told the steps to use the ping command.
There are five steps to check the connectivity using ping:
1. Observe whether or not the local network settings are correct using IPConfig / ALL;
2. PING 127.0.0.1, 127.0.0.1 Return address ping The return address is to check the local TCP / IP protocol is set;
3. Ping the native IP address, which is to check if the IP address of the unit is set;
4. Ping this network gateway or this network IP address, which is to check if there is a problem with the hardware device, or check whether the local network connection is normal; (this step can be ignored in non-LAN)
5. Ping remote IP address, which is mainly to check if the network or the local connection is normal.
There may be some errors in the process of checking the network communication, and these errors are divided into two most common.
Request Timed Out
"Request Time OUT" reminder In addition to the other party mentioned in "Ping (1)" may have a firewall or shutdown, it is the ip incorrect and gateway setting error.
1, IP is incorrect:
The IP is incorrect is mainly an IP address setting error or an IP address conflict, which can be checked by using ipconfig / all this command. The situation in the IP conflict under Win2000 is rarely caused because the system automatically detects whether there is the same IP address in the network and reminds you to set it correctly. In NT, "Request Time Out" will not only appear, but "Hardware Error" will appear to be confused by a prompt for it.
2, gateway setting error: This error may appear in the fourth step. The gateway setting error is mainly the gateway address setting is incorrect or the gateway does not help you forward the data, and there is a possible remote gateway to fail. Here is mainly wrong when you ping external network addresses. Error performance is unable to ping the external host to return information "Request Timeout".
2. Destination Host Unreachable
When you start ping network computers If the network device error it returns information will prompt "Destination Host Unreachable". If you use DHCP to allocate IP in the LAN, it happens to DHCP failure, then this error will be generated using the ping command. Because the client cannot assign it to the IP system when DHCP is invalid, it is often set to IP of different subnets. So "Destination Host Unreachable" will appear. This error will occur if the subnet mask setting error will also appear.
There is also a more special way to return to the error message, which generally adds the IP address before "Destination Host Unreachable" which route cannot reach the target host. This shows that your machine has no problem with external network connections, but there is a problem with a host connection.
For example.
I managed the network with 19 sets, connected by a 100M hub connection server, using DHCP dynamically assigned IP addresses.
Once my colleague hurriedly told me "My Outlook can't be opened", I went to his machine to check, first, I checked the local network settings, I used IPConfig / ALL to see IP allocation all normal. Then I started one of the machines in the PING network. The first ping results are normal, but Outlook can still use other network software and COPY network files, but the network speed is very slow, I have used one for the second time. Parameters - T (-T can not interrupt the other party, then I want ping, I can't find a problem, I found that there is Time = 30ms and Request Time Out, more interesting from the server ping, Request Time OUT is more data More, there is a Time = 30ms and Request Time OUT too abnormal in the local area. I beg I think is a network card problem, but the fault is still behind the network card, and the network cable is still can't solve the problem. This is really interesting! Finally, I can't put it in the other end of the other end of the hub port, ha! The fault is solved. It turned out that the hub port was broken. How to use the ping command to determine the speed of a link?
Ping This command can check the connection between the network and the detection failure, there is a more interesting use, that is, you can use some of its return data to estimate how many bytes of the speed between the hosts.
Let's first take a look at it has those returning data.
Pinging 202.105.136.105 with 32 bytes of data:
Reply from 202.105.136.105: Bytes = 32 TIME = 590ms TTL = 114
Reply from 202.105.136.105: Bytes = 32 TIME = 590ms TTL = 114
Reply from 202.105.136.105: Bytes = 32 TIME = 590ms TTL = 114
Reply from 202.105.136.105: Bytes = 32 TIME = 601ms TTL = 114
Ping statistics for 202.105.136.105:
Packets: Sent = 4, Received = 4, LOST = 0 (0% LOSS),
Approximate Round Trip Times in Milli-Seconds:
Minimum = 590ms, maximum = 601ms, average = 593ms
In the example "Bytes = 32" indicates that 32 bytes of test data in the ICMP packet (this is the key data of the estimated speed), "TIME = 590ms" is round-trip time.
How to estimate the speed of the link? For example. We set between A and B to PPP links.
From the above PING example, it can be noted that the ICMP packet sent by default has 32 bytes. In addition to these 32 bytes, add 20 bytes of IP headers and 8 bytes of ICMP headers, the total length of the entire IP data packet is 60 bytes (because IP and ICMP are the main use of the ping command. The agreement, so the entire data packet should be plus them). In addition, another protocol is used to transmit, which is the PPP protocol (point-to-point protocol), so add 8 bytes in the beginning and end of the data. During transmission, since each byte contains 8bit data, 1 bit start bit and 1bit end bit, the transfer rate is 2.98ms per byte. From this we can estimate 405ms. That is, 68 * 2.98 * 2 (multiplication because we have to calculate its round trip time). Let's test the link of 33600 B / S:
Pinging 202.105.36.125 with 32 bytes of data:
Reply from 202.105.36.125: Bytes = 32 TIME = 415ms TTL = 114
Reply from 202.105.36.125: Bytes = 32 TIME = 415ms TTL = 114
Reply from 202.105.36.125: Bytes = 32 TIME = 415ms TTL = 114
Reply from 202.105.36.125: Bytes = 32 TIME = 421ms TTL = 114
Ping statistics for 202.105.36.125:
Packets: Sent = 4, Received = 4, LOST = 0 (0% LOSS),
Approximate Round Trip Times in Milli-Seconds:
Minimum = 415ms, maximum = 421ms, average = 417ms
See if it is almost. ^ _ ^
Everyone may have to pay attention to this estimate is an error with the actual value. Why? Because we are now estimated a theoretical value, there are still something we have not considered. For example, other interferences in the network, these interference mainly comes with other computers. Because it is impossible to stop using the network when you test, it is not practical. Alternatively, the transmission device, because some devices such as MODEMs are transmitted and then transmitted, which greatly reduces the transmission time. We cannot avoid this error, but the value is approximately 5%, we can accept (using Modem Transport exceptions), but can reduce the generation of errors. For example, the compression function of MODEM is turned off and the network is not so busy. Sometimes the error is not required. Because we need these errors to compare the theoretical value to find out to find out the defects of the network. At this time, all the data of the test network includes errors that become the basis for our optimization.
It is also important to note that this algorithm is not applicable in the LAN because the speed is very less than 1 ms in the local area network, and the minimum time resolution of ping is 1 ms, so it is not possible to detect the speed with the ping command. If you want to test speed, you must use a special instrument to detect.
In general, the ping command is a tool for troubleshooting and very convenient tools, you should not ignore its existence.
I believe that everyone has been familiar with it, but it is not a lot of people who can play ping's functionality. Of course, I don't say that I can let Ping play the biggest function. I just use ping this. Tools, also summarized some small experiences, now share with you.
Now I will give you a trick that I will use when I use ping, and Ping can only be used after installation of the TCP / IP Communication protocol: ping [-t] [-a] [-n count] [-l length] [-f] [-i ttl] [-V TOS] [-r count] [-s count] [[-j computer-list] | [-k computer-list]] [- W Timeout] destination-list
Options:
-t ping the specified host uncle stopped.to see statistics and continue - Type Control-Break; to Stop - Type Control-C.
Keep Ping Local Host until you press Control-C.
This feature? What special skills can be used in conjunction with other parameters, will be mentioned below.
-a resolve addresss to hostnames.
Analyze computer NetBIOS name.
Example: C: \> ping -a 192.168.1.21
Pinging Iceblood.yofor.com [192.168.1.21] 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 TIME <10MS TTL = 254
Ping Statistics for 192.168.1.21:
Packets: SENT = 4, Received = 4, Lost = 0 (0% Loss), Approximate Round Trip Times in Milli-Seconds:
Minimum = 0ms, maximum = 0ms, Average = 0ms
From the above, you can know the computer NetBIOS named Iceblood.Yofor.com with IP 192.168.1.21.
--N Count Number of echo requests to send.
Send count of the ECHO packet specified by COUNT.
By default, only four packets are usually sent. You can define the number of sent by this command. It is very helpful to measure the network speed. For example, I want to test the average time of the return of 50 packets, how much time is How much is the fastest time, the slowest time can pass the following? Know:
C: \> ping -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 = 241PING 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 know that in the process of sending 50 packets to 202.103.96.68, it returns 48, two of which are lost due to unknown reasons, the 48 packets return speed is the fastest 40MS, the slowest 51MS, the average speed is 46ms.
-l size send buffer size.
Define the ECHO packet size.
In the default situation? The packet size sent by Windows is 32Byt, we can also define its size, but there is a size limit, that is, the maximum can only send 65500BYT, maybe someone will ask why it is limited to 65500Byt, Because the system of the Windows series has a security vulnerability (perhaps other systems) is that when the data package sent by the other party is greater than or equal to 65532, the other party is very likely to be machine, so Microsoft has solved this security vulnerability. Limits ping packet size. Although Microsoft has made this limit, this parameter is still very powerful after the parameters, such as we can implement an aggressive instruction by mating -t parameters: (The following introduction is dangerous, only In the test, do not apply to someone in the computer, no? Concert
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 Time <10ms TTL = 254
..................
This will send a size of 65500BYT to 192.168.1.21, if you have only one computer, but if you have a lot of computers, you can make the other party completely paralyzed, I used to do it. In this trial, when I use more than 10 computer PING PING PING a WIN2000PRO system, less than 5 minutes, the network has been completely paralyzed, the network is seriously blocked, the HTTP and FTP services are completely stopped, thereby visible that the power is not small .
-f set don't fragment flag in packet.
Send a "Do not segment" flag in the packet.
In the general packet you send, you will be sent to the other party via routing segmentation, plus the route will not reside again.
-i TTL TIME TO LIVE.
Specifies the time to stay in the system in the other party.
This parameter also helps you check the network operation.
-V TOS TYPE OF Service.
Set the Service Type field to the value specified by TOS.
-r Count Record Route for Count HOPS.
Record the routing of the packet in the Record Routing field.
In general, the packet you sent is to the other party through a route, but what is the route? With this parameter, you can set the number of routes that you want to detect, but the limit is 9, that is, you can only track 9 routes. If you want to detect more, you can implement it through other commands, I will Explain to everyone in future articles. The following is: C: \> ping -n 1 -r 9 202.96.105.101 (send a packet, record up to 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 above I can know that from my computer to 202.96.105.101, I passed 202.107.214, 61.2.107.210, 6153.112.89, 202.96.105.149, 202.96.105.97 These routes.
-s Count Timestamp for Count HOPS.
Specifies the timestamp of the number of points specified by count.
This parameter and -R are similar, but this parameter does not record the route passed by the packet, and only 4 is recorded.
-j host-list loose source route along host-list.
Routing the packet using the computer list specified using computer-list. The continuous computer can be intermediate-off network? Separate (routing sparse source) IP allowed to 9.
-k Host-List strict source route along host-list.
Routing the packet using the computer list specified using computer-list. The continuous computer cannot be subject to the middle network? Separate (routing grid source) IP allowed to be 9.
-w Timeout Timeout in MilliseConds to wait for each reply.
Specifies a timeshoot, unit is millisecond.
This parameter? What other techniques are available.
Other techniques for the Ping Directive: In general, the other party can return to your TTL value size, rough judgment target host's system type is the Windows series or the Unix / Linux series, in general, WINDOWS series? The returned TTL value is between 100-130, and the TTL value returned by the UNIX / Linux series is between 240-255, and of course the value of TTL can be modified in the other's host, the WINDOWS series? Can pass Modify note? Table The following key value is implemented:
[HKEY_LOCAL_MACHINE \System \CurrentControlset \Services\tcpip \parameters]
"Defaultttl" = dword: 000000FF255 --- FF
128 --- 80
64 ---- 40
32 ---- 20
Ok, the ping command is basically completely explained, and there are -J, -K parameters I have not explained in detail, because some reasons also include the information I have collected too much? Have a detailed introduction, Please forgive me, if you have a friend who knows more than me, and other skills, you can tell me, and thank you here.
- = - = Transfer from the original SC teaching document to this = - = - Original publication: KTB
C: /> ping /?
USAGE: PING [-T] [-a] [-n count] [-l size] [-f] [-i ttl] [-V TOS]
[-r count] [-j host-list] | [-k host-list]]
[-w Timeout] Destination-List
Options:
-t ping the specified host unsteil stopped.
TO SEE Statistics and Continue - Type Control-Break;
TO Stop - Type Control-C.
-a resolve addresss to hostnames.
--N Count Number of echo requests to send.
-l size send buffer size.
-f set don't fragment flag in packet.
-i TTL TIME TO LIVE.
-V TOS TYPE OF Service.
-r Count Record Route for Count HOPS.
-s Count Timestamp for Count HOPS.
-j host-list loose source route along host-list.
-k Host-List strict source route along host-list.
-w Timeout Timeout in MilliseConds to Wait for Each Reply
---------------------
supplement:
Traceroute uses it to detect the network to know that the network link has a problem, which is conducive to network personnel check, repair. Specific usage: Look with MAN.