- IP
- ICMP
- ICMP Header and Message Formats
- ICMP Message Types
- Review Questions
ICMP Header and Message Formats
IP identifies ICMP messages contained within an IP datagram with protocol type 1. Figure 3.9 shows the general format of an ICMP echo message. The first four bytes (1-byte type field, 1-byte code field, and 2-byte checksum) have the same format for all message types. All other fields and information contained within the ICMP header vary depending on the message type being sent. We describe the various types, codes, and the checksum later in this chapter.
Hosts and gateways use ICMP as a messaging, control, and diagnostic protocol to alert a host of problems or test connectivity. Note the protocol value contained within the IP header is 1, indicating this is an ICMP message. To determine the type of ICMP message, look in the ICMP header at the type field. Once you determine the type of ICMP message, you can use the code field to further identify the purpose of the message. The type field identifies the particular ICMP messages. Some ICMP messages use different values in the code field to further specify the error condition. The checksum field covers the entire ICMP message.
Figure 3.9 ICMP messages have a registered value of 1. The type field within the ICMP header identifies the type of ICMP message being sent.
Codes
Many of the type fields contain more specific information about the error condition identified by a code value. ICMP messages have two types of codes:
- Query
- Error
Queries contain no additional information because they merely ask for information and will show a value of 0 in the code field. ICMP uses the following queries:
- Type 0 = Echo Reply
- Type 8 = Echo Request
- Type 9 = Router Advertisement
- Type 10 = Router Solicitation
- Type 13 = Timestamp Request
- Type 14 = Timestamp Reply
- Type 15 = Information Request (obsolete)
- Type 16 = Information Reply (obsolete)
- Type 17 = Address Mask Request
- Type 18 = Address Mask Reply
Error messages give specific information and will have varying values that further describe conditions. Error messages always include a copy of the offending IP header and up to 8 bytes of the data that caused the host or gateway to send the error message. The source host uses this information to identify and fix the problem reported via the ICMP error message. ICMP uses the following error messages:
- Type 3 = Destination Unreachable
- Type 4 = Source Quench
- Type 5 = Redirect
- Type 11 = Time Exceeded
- Type 12 = Parameter Problems
Table 3.1 lists all of the ICMP codes along with the ICMP message types. We will discuss error codes and the various ICMP message types to which they pertain later.
Checksum
The checksum verifies the validity of the ICMP header. The sending host performs the initial checksum calculation and places the results in this field. The receiving host performs the same calculations to assure that it does not receive data damaged in transit. If the checksum values do not match, it trashes the datagram.
Identifier
The user on the source host can set this optional value to match sent echo requests with received replies.
Sequence Number
The user on the source host can set this optional value to match sent echo requests with received replies.