ICMPv4 Internet Control Message Protocol version 4 is definitely a Network layer protocol and its job is to report the error to the source if any problem arises while delivering the datagram from the source host to the destination host. The ICMPv4 is a message-oriented protocol. It’s a protocol of version of 4 of TCP/IP protocol suite.
In this section, we will discuss the ICMPv4 message along with its message format and types of messages.
Content: Internet Control Message Protocol version 4 (ICMPv4)
As we are aware that IPv4 protocol doesn’t have any mechanism to report error or correct error. So, IP functions in assistance with ICMP for reporting errors; ICMP never gets involved in correcting the errors, this task is taken care of by higher-level protocols. Every time, ICMPv4 deliver error report to the original source of the datagram.
There can be several reasons behind reporting the error like:
- A router with a datagram for a host in another network, may not find the next hop (router) to the final destination host.
- Datagram’s time-to-live field has become zero.
- There may be ambiguity in the header of IP datagram.
- It may happen that all the fragments of datagram if do not arrive within a time limit to the destination host.
And there can be several reasons to report the error.
Though ICMP is a Network layer protocol, it’s messages are not directly passed to the lower layer (i.e. data link layer). ICMP messages are encapsulated in the IP datagram and then they are passed to the lower layer.
ICMPv4 Message Format
Below we have the message format for ICMPv4 message. It has an 8-byte header and apart from this, it has a variable size data section. Though the header format gets changed for each type of message, still the first 4 bytes of each message remains the same.
Among these first 4 bytes, the first byte describes the ‘type‘ of the message the second byte clarifies the reason behind the ‘type’ of the message. The next two bytes define the checksum field of the message.
The rest 4 bytes defines the rest of the header which is specific for each message type. The data section varies according to the type of message. The data section of the error reporting message holds the information to identify the original datagram that has an error. The data section of the query message holds more information regarding the type of query.
Types of ICMPv4 Messages
The ICMPv4 messages are classified as:
Error Reporting Messages
The most important function of ICMPv4 is to report the error. Although it is not responsible to correct the errors, this task is given to higher-level protocols.
ICMPv4 always send the error report to the original source of the datagram as the datagram has only two addresses in its header, source address and destination address. So, ICMPv4 uses the source address for reporting the error.
There are some important characteristics of ICMPv4 message:
- ICMPv4 error message will not be generated in response to ICMP error messages as this can create infinite repetition.
- ICMPv4 error message will not be generated for the fragmented datagram if the fragment is not the first fragment.
- ICMPv4 error message is not generated for the datagram having the special address, 127.0.0.0 or 0.0.0.0.
- ICMPv4 messages are not generated for the datagrams with the broadcast address or a multicast address in its destination field.
ICMPv4 Error Reporting Messages are further classified as:
- Destination Unreachable
- Source Quench
- Time Exceeded
- Parameter Problems
If a host or a router is unable to deliver or route the datagram, they discard the datagram and sends a destination unreachable error message to the original source host where the datagram has originated.
Refer to the image above, you will observe that the Type section of destination unreachable error message is ‘3’. The Code section defines the reasons for discarding the message. For destination unreachable message code ranges from 0-15.
Code 0 – Network unreachable, possibility of hardware failure.
Code 1 – Destination host unreachable, possibility of hardware failure.
Code 2 – Protocol unreachable, i.e. the protocol may not be running for which the datagram is destined for.
Code 3 – Port unreachable, i.e. the process (application program) for which the datagram is destined may not be running.
Code 4 – If the sender has specified not to fragment datagram but routing can not be done without fragmentation.
Code 5 – Unable to accomplish source routing i.e. one or more router defined in source routing option is unreachable.
Code 6 – Router has no information regarding the destination host network.
Code 7 – Router doesn’t have any information about the existence of the destination host.
Code 8 – The originating source host is isolated.
Code 9 – Unable to communicate with the destination network due to administration prohibition.
Code 10 – Unable to communicate with the destination host due to administration prohibition.
Code 11 – For the specified service, the network is unreachable.
Code 12 – For the specified service, the host is unreachable.
Code 13 – The destination host couldn’t be reached as the administrator has put a filter over it.
Code 14 – Due to violation of host precedence, the host could not be reached.
Code 15 – Host could not be reached as its precedence was cut off.
The destination unreachable error message with the code as 2 or 3, can only be generated by the destination host and the message with rest of the codes are generated by the router.
The source quench error message is fabricated to inform the source that the datagram has been discarded due to congestion in router or destination host.
Every datagram has a field ‘time-to-live’, which is decremented by 1 every time it visits a router. There can be two reasons to send the time exceeded message to source host which is defined by code 0 and code 1.
Code 0 – When this time-to-live field decrements to zero the router discards the datagram and send a time exceeded error message to the originating source of the datagram.
Code 1 – If the destination host doesn’t receive all the fragments of a datagram in a set time, then it discards all the fragments and sends a time exceeded error message to the source host.
If the destination host or the router find any ambiguity in the header of IP datagram, then they discard the datagram and send a parameter problem error message to the originating source host of the datagram.
Code 0 defines that there is ambiguity in the header field of the datagram and the pointer field’s value of the parameter problem error message, points to the byte of datagram header, that has a problem.
Code 1 defines that the required part of the header is missing. Here, the pointer field is not used.
Redirection message is sent from router to the localhost in the same network to update its routing table. The router here does not discard the received datagram instead it forwards it to the appropriate router.
Code 0 – Message with this code redirects for the network-specific route.
Code 1 – Message with this code redirects for the host-specific route.
Code 2 – Message with this code redirects for the network-specific route for a specific type of service.
Code 3 – Message with this code redirects for the host-specific route for a specific type of service.
Query messages are used to identify network problems. Earlier there were five query messages among which three are deprecated. The two query messages that are being used today are:
Echo request and reply
When echo request and reply messages are exchanged from one host or a router to another host or a router, it confirms that the two hosts or routers can communicate with each other.
If a host or a router wants to communicate with another host or a router, then it sends the echo request message to the corresponding host or router with which it wants to communicate. The host or router receiving the echo request message prepares an echo reply message and send it to the original sender confirming that it is ready to communicate.
Timestamp request and reply
Timestamp request and reply messages are used to calculate the round trip time. It is the time required by an IP datagram to travel between two hosts or routers. This pair of messages are also used for synchronizing the clocks of two machines (hosts or routers).
- ICMPv4 protocol is a network layer protocol.
- ICMPv4 protocol is an error reporting protocol and it reports an error that occurs while IP datagram travels from source host to the destination host.
- ICMPv4 is a message-oriented protocol which is used in assistance with IP protocol as IP protocol lack in error reporting.
- ICMPv4 message is encapsulated in IP datagram before passing it to datalink layer.
- ICMPv4 is only responsible for reporting the error. It doesn’t get involved in correcting the error as this task is left for the higher-level protocol.
- ICMPv4 is classified into two types of error messages and query messages which are also further classified as you can see above.
In version 6 of TCP/IP protocol suite ICMPv4 is also revised and version 6 of ICMPv6 is introduced. The two internet debugging tools that utilize ICMPv4 are ping and traceroute.