The Internet Control Message Protocol (ICMP) is a network layer protocol used by network devices such as routers to diagnose network communication issues with other IP addresses.

The main use cases for ICMP are error reporting, network diagnostics and control purposes. When two devices connect over the internet, ICMP generates error messages and sends them back to the sender if any of the data packets didn’t reach their destinations.

Popular network tools such as traceroute use ICMP and the hop limit together to map out the route between two devices. First it sends a packet to the destination with a TTL (hop limit) of one. When the packet reaches the first hop router, the TTL is decreased by one - resulting in a value of zero. This causes the router to discard the packet and send an ICMP Time Exceeded error message back to the source (hopefully). Packets are then sent with a TTL of two, and so on, until they eventually make it to the destination. traceroute uses the information from the ICMP messages to work out the route and present the information in a logical format. Not all devices on the internet are configured to return ICMP messages; ICMP blocking or rate limiting can render ICMP unusable.

Unlike TCP or UDP, ICMP is a connectionless protocol. It doesn’t open a connection between the sender and its destination.