ICMP is often considered to be an integral part of the IP layer. It transmits error messages and other information that needs attention. ICMP packets are transmitted inside the IP datagram
ICMP format and type
Format of ICMP messages
Type and code determine the type of ICMP packet, such as
When sending an ICMP error message, the message always contains the IP header and the first 8 bytes of the IP datagram that generated the ICMP error message. In this way, the module that receives the ICMP error message will associate it with a specific protocol (as determined by the Protocol field in the IP datagram header) and the user process (judging by the TCP or UDP port number contained in the first 8 bytes of the IP datagram).
ICMP address mask request and reply
The ICMP address mask request is used for the diskless system to obtain its own subnet mask during the boot process. The system broadcasts its ICMP request message (this process is similar to the diskless system using RARP to obtain an IP address during the boot process).
Note that the type and code fields are consistent with the preceding descriptions, and the identifiers and serial number fields are set by the sending side arbitrarily, and these values are returned in the reply. In this way, the sender can match the answer to the request.
ICMP Port Unreachable Error
The Port Unreachable message is one of the destination unreachable messages, and we can look at the information attached to the ICMP error message.
To generate error messages, the UDP protocol can be used, if a UDP datagram is received and the destination port is not being used by a process, then UDP returns an ICMP unreachable message. The details are as follows:
Frame 12th represents ARP request and reply
The 34th frame indicates that BSDI sends a UDP request to port 8888, which SVR4 sends UDP, but the port does not have a process counterpart, so SVR4 returns an ICMP unreachable message
The following frames are similar to three or four frames. BSDI for unreachable messages ignored, repeated several times to send UDP requests, still unreachable.
View ICMP Unreachable messages in detail, such as
The ICMP error message must include the datagram IP header that generated the error message (including any options), and must include at least the first 8 bytes following the IP header. In our example, the first 8 bytes following the IP header contain the header of the UDP.
The IP header is included because ICMP knows which protocol uses IP, and then knows how to interpret the 8 bytes that follow. The content contained in the UDP header is the source port number and the destination port number. This is because the destination port number (8888) results in an ICMP Port unreachable error message. Systems that receive ICMP can associate error messages with a particular user process based on the source port number (2924).
The general format of ICMP Unreachable messages can be summed up
ICMP Internet Control Message Protocol