Home »
Computer Network
ICMP Messages: Types and Message Format
In this tutorial, we will learn about the types of ICMP messages, and its message format.
By Mahima Rao Last updated : May 04, 2023
Types of ICMP Messages
ICMP shares error reporting and devices status by messages. Messages created by ICMP are divided into 2 categories:
1. Error Reporting Messages
These are messages from which the ICMP reports to errors. The list of common error reporting messages is being given below.
1.1. Destination Unreachable (Code 3)
If a router cannot locate the path for a packet, then in such an event the packet is discarded and the destination is sent to the destination unreachable message.
1.2. Source Quench (Code 4)
As you know the IP does not have the flow control. The Sending device does not have any information about whether the speed forwarded by the data forwarded by the router forwarding and processing host is according to the host. The IP discards some packets when sending speed is high. In this situation ICMP provides flow control and sends source quench messages to source device.
1.3. Redirect (Code 5)
Because routing is a dynamic process and only routers participate in it, so a host has information about only one router (gateway). So when this host sends a data, then the data will go through that router to the correct router. In this situation, gateway router redirection message will send so that the host's routing information can be updated and the host can send data directly to the correct router.
1.4. Time Exceeded (Code 11)
A router uses the routing table to forward any packet. If the routing table is not correct and there are errors, then in such an event, the packet roaps only in the loop. To avoid this situation, every packet contains a time to live field. The value of this field decreases on every router. As soon as the value of this field is zero, this packet is discarded by the router. In this situation, the Time Exceeded message is sent to the router source.
1.5. Parameter Unintelligible (Code 12)
If a router or a destination host packet finds a field empty, then discards that packet and sends the parameter unintelligible message to the source.
2. Query Messages
These are the messages from which the ICMP queries for the status of a host. The list of common query messages is being given below with their code.
2.1. Echo Request (Code 8) & Echo reply (code 0)
This pair of Query Messages is used to diagnose problems in the network. Both of these messages determine whether two hosts can communicate with each other or not.
2.2. Time-stamp Request (Code 13) & Time stamp Reply (Code 14)
The time it takes to travel a host from one host to another host is detected by time stamp request & reply messages.
2.3. Address Mask Request (Code 17) & Address Mask Reply (Code 18)
A host may be aware of its own IP address but it is not necessary that it is aware of its own subnet mask. To know your subnet mask sends the address mask request to the host router and the router sends this host's subnet mask address as the mask reply message. If the host is aware of the router's address, then he sends the request directly to the router, otherwise this request is broadcast.
ICMP (Internet Control Message Protocol) Message Format
So far you learned about 2 types of messages sent by ICMP. Let's now try to know the format of ICMP messages. The format of the lower ICMP message is being showcased below:
Although ICMP header is different for each message type, 3 fields of the beginning are similar in all messages. The total size of these 3 fields is 4 byte. These fields are being given in detail.
i. Type
This defines the type of field message. For example, when doing any type of error report, the code related to that error is defined in this field. Similarly if there is a query message then this field will come in that query's code.
ii. Code
For error messages, this defines the sub type of field error. For example, if the destination unreachable error has occurred, then the code field will indicate what type of destination is unreachable error such as network unreachable (code 0), host unreachable (code 1) or protocol unreachable (code 2) error etc. These sub types of Errors are also defined by codes.
iii. Checksum
The checksum is calculated by the header and the data that is used to detect the errors.
iv. Rest of the Header
As you know the ICMP message is encapsulated in the IP datagram. Rest of the header section in the ICMP message shows the remaining IP header.
v. Data
In the context of error messages, the packet in this section contains the complete information of the packet.