Home  >  Article  >  Operation and Maintenance  >  Internet Message Control Protocol ICMP: A Scout of Network Time

Internet Message Control Protocol ICMP: A Scout of Network Time

齐天大圣
齐天大圣Original
2020-12-13 19:11:431817browse

When we want to test the connectivity between two hosts, we often use the ping command to verify. But do you know the connection between this command and the icmp protocol?

ICMP is the Internet Message Control Protocol, which is used to report error conditions and related error information. The icmp data message is encapsulated in the ip datagram as its data part. However, like the ip protocol, icmp is also a network layer protocol. The following figure is an icmp message format diagram:

Internet Message Control Protocol ICMP: A Scout of Network Time

ICMP message type

ICMP message total are divided into two categories, namely error report messages and inquiry messages.

Error report messages mainly include the following types:

The destination is unreachable (type value is 3): When the host or router cannot deliver data, this message is sent to the source point.

Timeout (type value is 11): When the TTL value in the IP datagram is 0, or the delivery is not successful within the specified time, a timeout message is sent to the source point.

Parameter problem (type value is 12): When there are incorrect fields in the header of the received datagram, the data packet will be discarded and a parameter problem message will be sent to the source point.

Redirect (type value is 5): When the router receives the packet, it will be more efficient to know that the destination address should be forwarded from another router. Then after it forwards the packet, it also forwards the packet to the source. Click to send the redirect message. Then the next datagram with the same destination address will go from another router.

Next, let’s look at the inquiry message, which mainly falls into one category: response request message (type value is 8) and reply message (type value is 0). The host that receives the response request message must Return a reply message.

An application of ICMP: ping command

After understanding some knowledge of ICMP, let’s take a look at an example of applying ICMP— —ping command. This command is not only available on Linux systems, but also on Windows systems

ping baidu.com

正在 Ping baidu.com [220.181.38.148] 具有 32 字节的数据:
来自 220.181.38.148 的回复: 字节=32 时间=32ms TTL=52
来自 220.181.38.148 的回复: 字节=32 时间=29ms TTL=52
来自 220.181.38.148 的回复: 字节=32 时间=27ms TTL=52
来自 220.181.38.148 的回复: 字节=32 时间=35ms TTL=52
220.181.38.148 的 Ping 统计信息:
    数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失),
往返行程的估计时间(以毫秒为单位):
    最短 = 27ms,最长 = 35ms,平均 = 30ms

Let’s take a look at the workflow of the ping command: First, my host generates four ICMP messages, and these four ICMP messages are responses. request message and send these four ICMP messages to the Baidu server. If the Baidu server can receive these four ICMP messages, then it will also send four ICMP reply messages to my host. Therefore, my host can calculate the packet loss rate and round-trip time based on the number of ICMP datagrams returned and the return time.

Recommended: "linux video tutorial"

The above is the detailed content of Internet Message Control Protocol ICMP: A Scout of Network Time. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn