One of the main purposes of ICMP is error reporting.
1. Destination Unreachable:-
A packet is discarded when the destination is not found. These messages are created by the host itself or the router.
2. Source Quench:-
There is no flow control in IP protocols and because of this, there is no way to handle congestion in route. So a router or host discards some IP datagram to handle congestion.
When a packet is discarded, an ICMP packet is sent to the source informing two things:-
- The packet is discarded.
- There is some congestion in the path or processing at the receiver side is slow.
3. Time To Live:-
- It is not time.
- It is the total number of hops or host that a packet has to pass before it reaches to destination.
- When the packet reaches to host or destination that host will decrease its value by 1.
- If the value of TTL =0 after reaching a host and that host is not the destination then that packets will be discarded and an ICMP packet is generated.
4. Parameter Problem:-
When a router or any host found that some value is missing in IP datagram, it discards that packets.
Suppose there is a host A wants to sends data to host B.
The best way to send data to B is through router R2 but A chooses to send through R3 which is wrong.
When packet will reach to R3 it will come to know that the best path is through R2. So it will update the path and also informs A that optimal path is R2 for sending packets to B.