ICMP is often considered an integral part of the IP layer. It transmits error messages and other information that requires attention. ICMP packets are usually used by the IP layer or higher layer protocol (TCP or UDP. Some ICMP messages return error messages to the user process.
ICMP packets are transmitted within the IP datagram, as shown in Figure 6-1. For more information about ICMP specifications, see rfc792 [posterl1981b]. The ICMP Message format is 6-2. The first four bytes of all packets are the same, but the remaining four bytes are different. Next we will introduce various message formats one by one. Type fields can have 15 different values to describe specific types of ICMP packets. Some ICMP packets are also usedCodeField Value to further describe different conditions. The test and field overwrite the entire ICMP packet. UsedAlgorithmThis is the same as the IP header test and algorithm we described in section 3.2. ICMP check is required.
Figure 6-1 ICMP encapsulation inside IP Datagram
Figure 6-2 ICMP Packets