ICMP Protocol Tutorial
The full form of ICMP is an internet control message protocol. ICMP is part of the internet protocol suite, along with TCP and IP. But the way it works is very different from the other protocols. Other protocols are used for transferring user data, while ICMP is only for the status of the network.
The protocol is for exchanging information among computers about routing. For example, a packet reaches the router over a link, but the router can not route further. In that case, the router originates an ICMP error to the sender node of the link. Without ICMP, the sender will never come to know that there is a network failure.
ICMP and OSI Model
As per the OSI model, ICMP is an example of a layer three protocol. But it differs in many ways. The ICMP does not assign any IP address similar to any other layer three (e.g Internet Protocol) protocol. As per the OSI model, there is an application layer over the ICMP protocol layer.
As a part of the internet protocol suite, ICMP is part of the internet layer. When the IP layer needs to send a network status event, it uses ICMP for the control message.
The ping application which is available with all operating system is an example of an ICMP application. When a network user needs to know if a destination (IP address) is reachable or not, he uses the ping (
ping ip_addr )command with the IP address. If the output is successful, the destination is reachable else not.
Ping command comes with many options. Few are below for all options you can refer to the ping man page.
- Ping an IP address from any of the interfaces.
- Check if an IP is reachable from a network interface.
- Use to ping an IP from a source IP.
- Specify the ping packet size. This is useful to check the MTU of the underlying network.
Why we need ICMP?
The answer is very simple, to know the error if there is any network problem. If we do not use ICMP, we will never know why and where the routing is failing.
ICMP Protocol Specification
The protocol specification is in RFC 792. In the section of the protocol tutorial, we will cover the specification is briefly. Covering message format, message types, and procedures.
The ICMP messages are only for error reporting and there is no further message for an ICMP response to avoid looping. The following is the protocol stack.
|Internet Protocol (IP)|
The ICMP messages carry as a payload for the IP layer. While transferring protocol messages, as a datagram, the value of protocol in the IP header is set to 1. Other fields are as per standard. Each ICMP message has a header and the actual payload. The first byte of the header has message type, code, and checksum. The remaining parameters depend on the message type.
|Message Type (8 bits) | Code (8 Bits) | <——————Checksum (16 bits) —————–>|
|Depends on Message Type|
|Depends on Message Type|
ICMP Message Types
- Echo Reply (0)
- Destination Unreachable(3)
- Source Quench (4)
- Redirect (5)
- Time Exceeded (11)
- Parameter Problem (12)
- TimeStamp (13)
- TimeStamp Reply (14)
- Information Request (15)
- Information Reply (16)