Techopedia explains
Internet Control Message Protocol (ICMP)
An ICMP message is created as a result of errors in an IP datagram or for diagnostic routing purposes. These errors are reported to the originating datagram's source IP address. An ICMP message is encapsulated directly within a single IP datagram and reports errors in the processing of datagrams.
An ICMP header begins after the IPv4 header. An ICMP packet has an eight-byte header, followed by a variable-sized data section. The first four bytes of the header are fixed:
- ICMP type
- ICMP code
- Checksum of the entire ICMP message
- Checksum of the entire ICMP message
The remaining four bytes of the header vary based on the ICMP type and code.
The error message associated with ICMP includes a data section that holds the entire IP header along with the first eight bytes of the packet that generated the error message. An ICMP datagram is then encapsulated in a new datagram.