I don't really understand Address Resolution Protocol (ARP). Why we need ARP when each device has its own IP address?
2 Answers
ARP, for IPv4, and NDP, for IPv6, are needed to get the layer-2 MAC address for a destination host where only the layer-3 IP address is known. There is no inherent relationship between the layer-2 and layer-3 addresses, and traffic is delivered on the local layer-2 LAN by the layer-2 address.
Ethernet and IP are two completely unrelated protocols that were created by different people, albeit around the same time, for different reasons, and they are maintained by different standards organizations. (See this answer.)
You need some method to discover the MAC address of your destination when you want to send something to it.
Every device has a layer 2 address called MAC address and layer 3 address called IP address.
Whenever you craft a packet, you need to enter a value for Destination MAC address and destination IP address. This is mandatory.
Your device knows the destination IP address as you provide it by explicit command.
for eg ping 1.2.3.4
So we are left with destination MAC address.
Now, If the source and destination IP address are in the same network the destination MAC would be the MAC address of the destination host.
If they are in different networks, you need to enter the MAC address of the 'gateway', in the dest MAC address field.
In either case, your device needs some mechanism to find out the required dest MAC address.
That mechanism is called ARP.
It basically says: I want the MAC address of the device who has IP address of x.x.x.x
-
2"Every device has a layer 2 address called MAC address" Only if it is using one of the IEEE LAN protocols (ethernet, token ring, FDDI, Wi-Fi, etc.). Other layer-2 protocols (PPP, HDLC, Frame Relay, ATM, etc.) either use other addressing (DLCI, VPI/VCI, etc.), or no addressing at all.– Ron Maupin ♦Feb 8, 2019 at 0:16