Address Resolution Protocol (ARP) is used by IPv4 to find another device's hardware address on the same ethernet, given their IP address. When using Ethernet, we require the destination hardware address and ARP finds out exactly that.
An ARP request contains the following data
Property | Description |
---|---|
HW addr type | Mostly 01 to signify Ethernet |
Protocol addr type | Mostly 08 00 to signify IP as protocol |
HW addr length | 06 as MAC address is 6 bytes long |
Protocol addr length | 04 as IP address is 4 bytes long |
OP code | 01 for ARP request 02 for ARP reply |
HW addr of sender | MAC address of sender |
Protocol addr of sender | IP address of sender |
HW addr of target | 00 00 00 00 00 00 in an ARP request This is to be filled out by the target device and sent back in ARP reply |
Protocol addr of target | IP address of target |
The above payload is wrapped in an Ethernet frame and broadcasted to all devices. If a device with the target IP address exists, it sends back an ARP reply. BUT, in the ARP reply, the sender is the target device from the ARP request. So, once we receive an ARP reply, what we are interested in, is the HW address of sender, because our target device will have sent the ARP reply.