USING ICMP TO TEST REACHABILITY:
ICMP can also be used to test several tools. An Internet host A, is reachable from another host B, if data packets can be send from A to B. Ping function tests reachability. It transmit datagram from B to A, that sends back to B. it uses ICMP echo reply and echo request messages. Internet layer added code to reply to incoming ICMP echo request messages.
USING ICMP TO TRACE A ROUTE:
List of all routers on path from A to B is known the route from A to B. The intermediate routers transmit ICMP time exceeded message to the host and receiver transmits an ICMP destination unreachable message to the host.
Tracert (Windows version) gives ICMP echo messages with increasing TTL. Router that decrements TTL to 0 provides ICMP time exceeded message, with router's address as host address. First, with TTL 1, gets to first router, which discards and transmits time exceeded message. Next, with TTL 2 goes through first router to second router. It continues until an ICMP echo reply data packet from destination is received.
USING ICMP FOR PATH MTU:
Fragmentation should be removed. Source can manage outgoing datagrams to avoid fragmentation. Source calculates path MTU- smallest network MTU on path from host to destination. Source probes path using IP packet message with don't fragment flag. Router acts with ICMP fragmentation needed message. Source transmits smaller probes until destination reached.