The main functions associated with ICMP are as follows:
1.       Error reporting
2.      Reach-ability testing
3.      Congestion control
4.      Route change notification
5.      Performance measuring
6.      Subnet addressing
ICMP message format:
          Type (8-bit): Defines the type of the message.
         Code (8-bit): This field specifies the reason for the particular message type.
                  Rest of the header: It is specific for each message type.
                  Data section in error messages carries information for finding the original packet that had the  error. In query messages, the data section carries extra information based on the type of the query.
                 Checksum(16-bit):
·         A simple error detection scheme in which each transmitted message is accompanied by a numerical value based on no. of set bits in the message.
·         The receiving station then applies same formula to the message and checks to make sure accompanying numerical value is same.
·         If not, then receiver can assume that message has been garbled.
                    Following is a brief description of some of the error reporting messages defined by ICMP protocol
          a)    Source Quench Message:
·         It is request to decrease  traffic rate for messages sending to the host (destination) or we can say ,when receiving host detects that rate of sending packets (traffic rate) to it is too fast ,it sends the source quench message to source to slow the pace down so that no packet can be lost
·         ICMP will take source IP from discarded packet and informs to source by sending source quench message.
·         Then source will reduce the speed of transmission so that router will free for congestion
         b)    Parameter Problem:
·         Whenever packets come to the router then calculated header checksum should be equal to received header checksum then only packet is accepted by the router.
·         If there is mismatch packet will be dropped by the router.
·         ICMP will take source IP from discarded packet and informs to source by sending parameter problem message. 
         c)    Time exceed message:
·         When some fragments are lost in a network then holding fragment by the router will be dropped then ICMP will take source IP from discarded packet  and informs to source  “Time exceeded message” due to time to live (life time of datagram) field reaches to 0
         d)   Destination unreachable:
·         It is generated by the host or its inbound gateway to inform the client that the destination is unreachable for some reasons (link failure , H/w failure ,Port failure etc.)
         e)    Redirection Message:
·         Redirect requests data packets be sent on an alternate route.
·         The message informs to a host to update its routing information ( to send packets on an alternate route)
·         For example; if host tries to send data through a router R1 and R1 sends data on a router R2 and there is direct way from host to R2.Then R1 will send a redirect message to inform the host that there is a best way to the destination directly through R2 available. The host then sends data packets for destination directly to R2.
·         The router R2 will send original datagram to intended destination but if datagram contains routing information then this message will not be sent even if a better route is available as redirects should only be sent by gateways and should not be sent by internet hosts.
          f)      Echo Request /Echo Reply:
·         These two messages are exchanged to check connectivity between source and destination.
·         The Ping command is an example of diagnostic command commonly used by network users to check for reachability of a certain host.
·         Whenever Ping is invoked at command line, ICMP echo request message is sent to target host.

·         If target host is operational and connected to network ,it responds with echo reply message as proof of reachability

Search related post on google