Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to understand the ping command of Linux system

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article is to share with you about how to understand the ping command of the Linux system. The editor thinks it is very practical, so I share it with you. I hope you can get something after reading this article.

The ping command is the most commonly used command to test the condition of the network. The execution of the ping instruction will use the ICMP transport protocol to send a message requesting a response. If there is no problem with the network function of the remote host, it will respond to the information and know that the host is operating normally.

First, ping usage: the ping command runs at the command prompt terminal, and the usage is: "ping parameter target host". The parameters range from zero to more, and the target host can be IP or domain name.

Usage: ping [- aAbBdDfhLnOqrRUvV] [- c count] [- I interval] [- I interface] [- m mark] [- M pmtudisc_option] [- l preload] [- p pattern] [- Q tos] [- s packetsize] [- S sndbuf] [- t ttl] [- T timestamp_option] [- w deadline] [- W timeout] [hop1...] Destination II. Detailed explanation of ping parameters: the following are the ping detailed parameters collected and sorted out by Ai E (aiezu.com), which may be partially incomplete or mistranslated. Welcome to correct:

Parameter details-aAudible ping.-An adaptive ping, determine the speed of ping based on ping packet round-trip time;-b allow ping a broadcast address;-B do not allow ping to change the source address of the packet header;-c countping stop ping;-d to use Socket's SO_DEBUG function after specified times;-F flow_label assigns a 20-bit "flow label" to ping echo request. If not set, the kernel will randomly assign ping. -f limit detection, fast continuous ping a host, ping speed up to 100bpm;-I interval sets an interval of several seconds to send a ping packet, default ping once a second;-I interface specifies the network card interface, or the specified local address to send out the packet;-l preload sets the packet sent before sending the request information. -L suppresses multicast packet loopback, only for ping destinations of one multicast address-n do not convert ip addresses to hostnames;-p pattern specifies the hexadecimal content of ping packets, which is useful when diagnosing data-related network errors, such as "- p ff" -Q does not display any information about the transmission packet, only the final result-Q tos sets Qos (Quality of Service), which is the ICMP Datagram correlation bit; it can be a decimal or hexadecimal number, as detailed in the rfc1349 and rfc2474 documentation;-R records the routing process of ping (IPv4 only); note: due to the limitation of the IP header, a maximum of 9 routes can be recorded and the rest will be ignored -r ignore the normal routing table and send the packet directly to the remote host, usually to see if there is a problem with the local network interface; if the host is not directly connected to the network, an error is returned. -S sndbufSet socket sndbuf. If not specified, it is selected to buffer not more than one packet.-s packetsize specifies the number of data bytes each time ping sends, default is "56 bytes" + "28 bytes" ICMP header, a total of 84 bytes; packet header + content cannot be greater than 65535, so the maximum value is 65507 (linux:65507, windows:65500);-t ttl sets TTL (Time To Live) to the specified value. This field specifies the maximum number of network segments that an IP packet is allowed to pass through before it is discarded by the router;-T timestamp_option sets the IP timestamp option, which can be any of the following: 'tsonly' (only timestamps)' tsandaddr' (timestamps and addresses) 'tsprespec host1 [host2 [host3]]' (timestamp prespecified hops).-M hint sets the MTU (maximum transmission unit) fragmentation policy. Can be set to: 'do': forbids sharding, even if the packet is discarded;' want': sharding when the packet is too large; 'dont': does not set the sharding flag (DF flag);-m mark sets mark;-v to make ping in verbose mode, which requires the ping command to print all returned ICMP packets except ECHO-RESPONSE packets;-UPrint full user-to-user latency (the old behaviour). Normally ping prints network round trip time, which can be different f.e. Due to DNS failures.-W timeout sets the timeout for ping in milliseconds;-w deadlinedeadline; displays details

3. Output format:

The following figure shows the response content generated by a simple ping. The specific meaning of the returned content is as follows:

Domain name and IP of the ① ping target host (ping automatically converts the domain name to IP)

② packet size without header and packet size with header (see "- s" parameter)

③ icmp_seq:ping sequence, starting with 1

Ttl: remaining ttl

Time: response time. The smaller the value, the faster the speed of Unicom.

Number of packets sent out by ④, number of packets returned, packet loss rate, time spent

⑤ minimum / maximum / average response time and native hardware elapsed time

4. Simple examples: 1. Ping every 0.6 seconds for a total of 5 ping times:

[root@aiezu.com] # ping-c 5-I 0.6 qq.com PING qq.com (14.17.32.211) 56 (84) bytes of data. 64 bytes from 14.17.32.211: icmp_seq=1 ttl=54 time=16.5 ms 64 bytes from 14.17.32.211: icmp_seq=2 ttl=54 time=17.0 ms 64 bytes from 14.17.32.211: icmp_seq=3 ttl=54 time=16.6 ms 64 bytes from 14.17.32.211: icmp_seq=4 ttl=54 time=18.3 ms 64 bytes from 14.17.32.211: icmp_seq=5 ttl=54 time=19.9 ms-qq.com ping statistics-5 packets transmitted, 5 received, 0 packet loss Time 2405ms rtt min/avg/max/mdev = 16.520, 17.692, 19.919, 1.293 ms2, extreme fast use of large packets ping: at the fastest speed Use the largest package for ping, which can be used to test the pressure bearing capacity of the target host:

[root@aiezu] # ping-f-s 65507 10.0.0.52 PING 10.0.0.52 (10.0.0.52) 65507 (65535) bytes of data. . ^-10.0.0.52 ping statistics-646 packets transmitted, 646 received, 0 packet loss, time 1675ms rtt min/avg/max/mdev = 1.202 ms 2.406 8.253max 0.507 ms, ipg/ewma 2.598 ms Note: this usage is very dangerous, 100 (header + content) * 100 packets per second = 6.25MB, which is equivalent to the bandwidth of 50Mbps, which may lead to a denial of service on the target host. Please do not use it for illegal purposes and bear the adverse consequences.

3. China Unicom is unstable and packet loss is serious: the following ping sends 17 ping icmp packets, but only the packets with serial numbers 8, 9 and 12 receive the response message. The packet loss rate is 82%. China Unicom is very unstable:

[root@aiezu.com] # ping 8.8.8.8 PING 8.8.8.8 (8.8.8.8) 56 (84) bytes of data. 64 bytes from 8.8.8.8: icmp_seq=8 ttl=43 time=32.3 ms 64 bytes from 8.8.8.8: icmp_seq=9 ttl=43 time=32.2 ms 64 bytes from 8.8.8.8: icmp_seq=12 ttl=43 time=32.0 ms ^ C-- 8.8.8.8 ping statistics-- 17 packets transmitted, 3 received, 82% packet loss, time 16003ms rtt min/avg/max/mdev = 32.038 packet loss 32.208 ms4, totally unable to ping:

[root@aiezu.com] # ping-c 39.9.9.9 PING 9.9.9 (9.9.9.9) 56 (84) bytes of data. -9.9.9.9 ping statistics-3 packets transmitted, 0 received, 100% packet loss, time 1999ms 5. Common errors: 1. Error 1:

Ping: packet size too large: 70000 WARNING: packet size 65508 is too large. Maximum is 65507 PING 10.0.0.52 (10.0.0.52) 65508 (65536) bytes of data. Ping: local error: Message too long, mtu=1500 ping: local error: Message too long, mtu=1500 solution: set the "- s" parameter of ping to a smaller value, the maximum value of windows is "65500" and the maximum value of linux is "65507".

The above is how to understand the ping command of the Linux system. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report