Debugging is hard since the sender cannot find where the failure occurred
ICMP is the solution
ICMP messages(error, control) are carried in IP

ICMP is error-reporting mechanism, ICMP message informs the reason(of failure)
to the source
Recovery is left to higher level protocols
Error-reporting only to the source--why?
Because IP DG carries only source & dest addr(no info on intermediate nodes)
ICMP message

ICMP messages routed without additional reliability or priority
ICMP messages can get lost, discarded but no ICMP will be generated for "ICMP
message errors"
No ICMP error message will be generated for a fragmented datagram that is not the first fragment
No ICMP error message will be generated for a datagram having a multicast address
No ICMP error message will be generated for a datagram having a special address
such as 127.0.0.0 or 0.0.0.0.
ICMP message types
Type Message type
--------------------------------------------------------
0 Echo Reply
3 Dest. Unreachable
4 Source Quench
5 Redirect(change route)
8 Echo Request
11 Timer expired
12 Parameter prob. on DG
13 Timestamp Request
14 Timestamp Reply
15 Info. Request(obsolete)
16 Info. Reply(obsolete)
17 Addr Mask Request
18 Addr Mask Reply
Example usage of ICMP: Echo Request, Reply
Host/router sends Echo Request to a destination, Destination Replies
Ping uses Echo mechanism
Example:
Codes for the type "Destination Unreachable"
Code Meaning
-----------------------------------------------------------------------------
0 Network Unreachable
1 Host Unreachable
2 Protocol Unreachable
3 Port Unreachable
4 Fragmentation needed but DF bit is set
5 Source Route failed
6 Dest. network unknown
7 Dest. host unknown
8 Source host isolated
9 Comm. with dest. network prohibited administratively
10 Comm. with dest. host prohibited administratively
11 Network Unreachable for type of service
12 Host Unreachable for type of service
Another example: Source Quench
A source-quench message informs the source that a datagram has been discarded due to congestion in a router or the destination host.
The source must slow down the sending of datagrams until the congestion is relieved
Another example: Redirection
Redirection message is used when a host sends an IP to a router and the router finds that there is a better router then it sends "Redirect message(ICMP)" to the host so that the host will use the better route next henceforth.

See rfc 792 for details
TCP/IP Utility Programs that use ICMP
Ping(Packet Internet Groper)
Mostly frequently used tool for "Reachability" test.
Ping is an ICMP Echo request message.
Ping also measures the round-trip time to the host.
Ping 127.0.0.1 --Loopback testing-to test proper operation of TCP/IP software
on the local host
Ping Local host IP--To test proper operation of NIC(Network Interface Card)
Ping Gateway IP --To test the connection to a router
Ping Remote IP --To test Internet connection
Ping DNS name of a host --To test the proper operation of DNS service
Traceroute(Tracert on PC systems)
Traceroute program sends a series of Ping(ICMP Echo Request) messages and with
TTL field in IP header(starts with TTL=1 and increments by 1 for the subsequent
messages):
Ping(to a remote host) with TTL=1 will expire in the 1st router and the router
will send ICMP type 11 "Timer expired" message
2nd Ping(to a remote host) with TTL=2 will expire in the 2nd router and the
router will send ICMP type 11 "Timer expired" message
..
Traceroute will also invoke "Reverse DNS lookup" when it receives
an IP address of a router.