当前位置:网站首页>Understand what ICMP Protocol is

Understand what ICMP Protocol is

2022-06-25 06:21:00 Programmer community

Messages on the network are not always transmitted and received smoothly , Sometimes it may be due to the gateway MTU It is too small and the message is not allowed to be fragmented, so the message cannot be forwarded by the gateway , Sometimes it may be due to TTL The value is reduced to 0 And cannot continue to send or receive , It is also possible that the message cannot be received by the receiver due to the problem of the header parameters , These problems , You can't simply discard the process . If you discard it without telling the source host , The source host will think that it was sent successfully , This will cause the information of communication parties to be out of sync , And then cause even greater failure . therefore , While discarding the message , The source host must also be informed of the reason for discarding , It is through ICMP The message carries relevant information

ICMP

ICMP

Internet Control Message Protocol, It's on the network layer , yes IP A component of a layer , It is mainly used to transmit error messages and other information that needs attention

 Understand what is ICMP Protocol illustration

icmp The protocol is an integral part of the network layer , therefore icmp Message has ip First floor , I didn't put icmp It's written in icmpHeader+icmpPayload, because icmp There are many types of messages , It's caused icmp The message structure is not identical

What's the difference ? Let's take a look first icmp message General format

 Understand what is ICMP Protocol illustration 1

All types of icmp All messages have 1 Bytes of Type、1 Bytes of Code and 2 Bytes of Checksum, And then according to Type and Code Values are different , To determine the Message Body Different

  • Type

Message type , Used to represent a message

  • Code

Code , Provide further information about the message type

  • Checksum

The checksum ,icmp Checksums only cover icmp message

  • Message Body

The length and content of the field , Depending on the type of message and the code

ICMP Message type

ICMP Echo Request/Response

Used to detect IP Of network connectivity Ping/Tracert, Is that we are cmd Window ping The operation of

ICMP Destination unreachable message

IP Is a best effort delivery mechanism , Datagrams are not easily discarded . When Routing devices Unable to forward or deliver IP The data tell the time , It will send a message unreachable to the destination station to the source station , Then discard the datagram

This is what we mentioned in the preface because of the routing device MTU It is too small and needs to be divided , However IP message DF Flag bit not allowed , This makes it impossible to forward , At this time, the route will discard the message and send a message to the source host at the same time ICMP Destination unreachable message

ICMP Redirect message

ICMP Redirect message is ICMP One of the control messages . Under certain circumstances , When the router detects that a host or network device uses a non optimized route , It sends a message to the host or network device ICMP Redirect message , Request the host or network device to change the route . The router will also forward the initial datagram to its destination

ICMP Time Exceeded

When I received TTL by 0 The message of , Network devices / The host will discard the message , And return a ICMP time exceeded message

ICMP Parameter problem message

If the received packet is found to have a problem with the header parameters , When packet parsing cannot be completed , The Internet / The host will discard the packets , And may return a ICMP The parameter problem message is sent to the source

When the IP Head , perhaps TCP Head , perhaps UDP A parameter error occurred in the header , The receiver is unable to complete the packet parsing , The packets will be discarded , And return a icmp Parameter problem message

ICMP The source side is closed

Used to indicate that the other party or the server in the middle is busy and cannot respond . If the network device does not have enough cache space to store messages to a destination host , These messages will be discarded by the device . here , The network device sends ICMP The source side is closed and the message is sent to the Destination host . If a packet arrives at a host too fast , Too late to be handled by the host , Then the host can also send ICMP The source side is closed , In order to reduce the packet rate

Last , All the above are ICMPv4 agreement , be based on IPv4 Agreed icmp message ,ICMPv6 It has its own definition and format


原网站

版权声明
本文为[Programmer community]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202201245251368.html