ARP: Address Resolution Protocols
It maps logical address to physical address.
Why we need ARP:
An IP datagram has to pass through the physical layer and that's why we need to wrap or encapsulate an IP datagram inside a frame. A Physical address is a MAC address. This is the reason why the sender needs to know the MAC address of the receiver.
ARP Request Packet:-
This request packet contains:
The IP address of the sender.
MAC address of the sender.
The IP address of the receiver. and at the destination MAC address field FF:FF:FF:FF:FF: FF
So every host or sender needs to send an ARP request packet and that request is a broadcast message so that each device will see the request packets but only the intended device will reply.
ARP Reply Packet:-
ARP reply is UNICAST Message because the destination already knows the MAC address of the sender so it sends the reply directly to the sender.
REPLY Message contains the IP address of receiver and MAC address of the receiver.
let me give you an example:-
Here host A wants to send some packets to B but Host A doesn't know the MAC address of host B So, it will Broadcast An ARP Request Packets and each and every device (like C and D ) in the network will see the Request Packet but only B will reply because, at the destination address field, B's IP address is mentioned . Since B already knows the MAC address of A it will directly reply to A with B's mac address and IP address.
One point you should remember broadcasting is always done at the data link layer so it can't cross network boundaries.
Broadcasting MAC address is FF:FF:FF:FF:FF: FF
Some other concepts:
A has to broadcast ARP Request for every packet it wants to send to B so cache memory concept is used here. A will save MAC address of B in its cache and when it has to send any packet it first checks in to its cache buffer. if proper MAC address is found then it will take that address, else it will again broadcast ARP Request Packet.