ARP: Address Resolution Protocol
In order for the ip communication to take place between 2 computers it is necessary that the MAC address should be known to each other. If device A with ip address "192.168.1.11" needs to communicate with device B with IP address "192.168.1.1" and transfer data, device A should know the MAC address of device B.
* Used to find unknown MAC address using a known IP address.
* Used to find IP conflicts in the network.
* It is generated in the network layer and covered by datalink layer.
ICMP: Internet Control Message Protocol
* ICMP is a protocol generated in the Network Layer.
* This is the protocol used when you a ping(Packet Internet Groper) an IP address.
* While we ping an ip address, it will check the routing table.
* It will send echo requests and reply and shows success message if it is reachable or an error messages if it is not reachable.
While pinging if you get a "Destination Host Unreachable" message it means that the routing table does not have the network for the ip address you pinged. In this case the ping packet will not go out of your network as there is no route to reach the destination.
If you get "Request Timed Out" it means that it does have a rout to reach the pinged ip address but it will not get a reply from the pinged ip address.
Below is an illustration to explain ARP.
Now that the source knows the destination MAC they both can communicate with each other. As part of the PING request, the source generates an ICMP packet and then the destination responds back making the PING successfull.
PING request (ICMP prototol)
PING response(ICMP protocol)
And you get