The Internet Control Message Protocol (ICMP) is a network-layer Internet protocol that provides message packets to report errors and other information regarding IP packet processing back to the source. ICMP is documented in RFC 792.The version of ICMP for Internet Protocol version 4 is also known as ICMPv4, as it is part of IPv4. IPv6 has an equivalent protocol, ICMPv6.Best know for its use by the "ping" and "traceroute" programs on IP enabled hosts/devices.
ICMP has several kinds of useful messages like Destination Unreachable, Echo Request and Reply, Redirect, Time Exceeded, and Router Advertisement and Router Solicitation.
When an ICMP destination-unreachable message is sent by a router, it means that the router is unable to send the package to its final destination. The router then discards the original packet.
Two reasons exist for why a destination might be unreachable. Most commonly, the source host has specified a nonexistent address. Less frequently, the router does not have a route to the destination. Destination-unreachable messages include four basic types: network unreachable, host unreachable, protocol unreachable, and port unreachable.
Network-unreachable messages usually mean that a failure has occurred in the routing or addressing of a packet. A host-unreachable message usually indicates delivery failure, such as a wrong subnet mask.
Protocol-unreachable messages generally mean that the destination does not support the upper-layer protocol specified in the packet. Port-unreachable messages imply that the TCP socket or port is not available.
An ICMP echo-request message, which is generated by the ping command, is sent by any host to test node reachability across an internetwork. The ICMP echo-reply message indicates that the node can be successfully reached.
An ICMP Redirect message is sent by the router to the source host to stimulate more efficient routing. The router still forwards the original packet to the destination. ICMP redirects allow host routing tables to remain small because it is necessary to know the address of only one router, even if that router does not provide the best path.
An ICMP Time-exceeded message is sent by the router if an IP packet’s Time-to-Live field reaches zero. The Time-to-Live field prevents packets from continuously circulating the internetwork if the internetwork contains a routing loop. The router then discards the original packet.
Like ICMP for IPv4, ICMPv6 provides messaging support for IPv6.It provides underlying services to IPv6 for neighbor discovery. It also provides many functions in error reporting and echo request. ICMPv6 is standardized in RFC 2463, which describe ICMPv6 messages into two groups; error reporting messages and informational messages.