ICMP (Internet Control Message Protocol) is a sub-protocol used for the control and error reporting of the Internet Protocol (IP) and is used to generate and send error messages indicating whether a particular service is available or a router and host cannot be found.
What is the ICMP Protocol?
ICMP is generally not used directly by user applications on a network and is quite different from the way TCP and UDP work.
In short, the main purpose of ICMP is the Ping or Trace tool that sends Echo ICMP request messages to calculate and determine whether a computer on the network is available, the time it takes packets to travel to and from this computer, and the number of computers they pass through.
ICMP is part of an IP protocol package defined in RFC 792. These messages are generated in response to errors in an IP datagram or for diagnostics and routing.
There are two basic versions of ICMP messages generated at the network layer level. The version used for the IPv4 protocol is ICMPv4. For the IPv6 protocol, it is the ICMPv6 version.
The messages created are encapsulated by the IP protocol with a new IP header and transmitted as datagrams. Thus, every device that sent an IP datagram packet had a TTL (Time-to-Live) value. If the TTL value is 0, a Time Exceeded message is sent to the datagram source sending the ICMP packet and the connection is verified.
However, not every ICMP message in the IP datagram guarantees that the packets are delivered. Usually, the application that wants to review and send the content of the message must forward the appropriate error message.
The only benefit of this process is to check whether a packet can reach its destination when its TTL is full.
It is used to generate ICMP, error, and control messages in computer local network systems and acts as an auxiliary tool for preventing and correcting problems detected. Most 3rd party software used to control devices on the network is based on ICMP messages.
Ping and Traceroute commands are used to detect some problems in computer operating systems.
The ping command checks a device in the network using Echo Request and Echo Reply messages and performs control with Time to Live in Transit and Destination Unreachable message types using UDP datagrams.
The traceroute command is used to determine the number of routers and hosts between the source and target device and to check which device has a problem on the target route. In short, it controls the Hop count of the path to the destination and through which devices the packet goes.
ICMP only reports to system administrators and does not fix errors.
Echo Request / Echo Reply
Echo messages can be used to determine if a device on the network is working.
The local computer sends an ICMP Echo Request message to the target computer, and the receiving computer responds using the Echo Reply message.
The Destination Unreachable message can be used to inform the computer that the destination or service is unreachable.
When a computer receives a packet that it cannot send, it sends a Destination Unreachable message to the computer that created the packet, and codes will be generated to indicate why the packet could not be sent.
These codes will be Destination Unreachable: 0, Network Unreachable: 1, Host Unreachable: 2, Protocol Unreachable: 3.
Network Unreachable and Host Unreachable messages are responses from a router that cannot send packets. If any router or server on the path from a source to a destination receives a packet that does not have a route, it can respond with a Destination Unreachable message indicating that the network is inaccessible.
When the last router on the path to a source-destination receives a packet that has a route but cannot send the packet to the destination computer on the network, it may respond with the message that the network is known but the destination computer is inaccessible.
The IP header has a TTL value to limit the number of routers a packet will pass through to reach its destination.
If the TTL value did not limit the number of devices through which the packet would pass, a router would send packets to other devices continuously and this would create an endless loop in the network.
So when a router receives a packet, it decreases the value of the packet’s TTL field by one value, and if the value of the TTL is zero, the router will release the packet.
Therefore, the router sends a Time Exceeded message to the source computer indicating that the packet could not be sent because the TTL of the packet has expired.
A router can use a Redirect message to inform computers on a network of the optimal route to a particular destination.
When a router receives a packet with a route from the target device, the router can inform about the next hop by sending an ICMP to redirect the message to the source computer.
The Source Quench message is used to implement a basic flow control mechanism and notify the source to stop sending packets for a period of time.
This message informs the datagram packets to be transmitted fast on the network and slow down the packet transmission to the source device if the resource is busy.
When a computer receives a Source Quench message, it reports it to the transport layer and uses the TCP flow control mechanism.
cannot reach the network
cannot reach the destination host or application
the destination does not have the requested protocol
the destination port cannot be reached or the destination application is not free
fragmentation is needed, but the corresponding flag indicates otherwise
the source path is not correct
the destination network is not known
the destination host is unknown
source host is isolated
communication with the destination network is prohibited for administrative reasons
communication with the destination host is prohibited for administrative reasons
the destination network cannot be reached due to the type of service
the destination host cannot be reached due to the Type of Service