ARP (Address Resolution Protocol) is a protocol for translating network addresses into link layer addresses. Most commonly it’s used for mapping an IPv4 address to a MAC address.
ARP maps a <protocol, address> pair to a link layer address .
ARP builds and maintains a table of <protocol type, sender protocol address, sender hardware address>, which is used to resolve addresses quickly.
Most commonly, ARP is used to translate an IPv4 address to a MAC address.
When a host wants to translate an IPv4 address to a MAC address, the host calls the Address Resolution module. The Address Resolution module checks its table for the <protocol type, target protocol address> pair. If the table contains the mapping, it will return the MAC address for the IPv4 address.
If the Address Resolution module unable to find the pair, it must send an ARP request packet. In this case, the host will broadcast an ARP request packet over Ethernet .
Each host on the LAN will check to see if their address matches the target IP address in the ARP request. If a host has the target protocol address, it updates its table with the details of the request sender, and sends an ARP reply to the sender .
ARP packets are sent in Ethernet frames, with the protocol version set to ARP .
An ARP packet comes in two forms: request and reply. Both share the same format:
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Hardware type | Protocol type | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | HAL | PAL | Operation | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Sender hardware Address | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Sender protocol Address | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Target hardware Address | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Target protocol Address | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
In ARP, a protocol address is the address of the protocol that is being resolved (e.g. IPv4). The hardware address is the address of the link layer protocol (e.g. Ethernet).
The Hardware type field specifies the hardware protocol type (Ethernet is 1).
Protocol type specifies the protocol type of the protocol addresses (IPv4 is 0x0800).
HAL (Hardware address length) is the length in octets of the hardware address.
PAL (Protocol address length) is the length in octets of the protocol address.
Operation is the operation that the sender is performing. request is 1, reply is 2.
Sender hardware address is the hardware address of the sender. In a reply, this is the hardware address of the host that the original sender was looking for.
Sender protocol address is the protocol address of the sender.
Target hardware address is the hardware address of the target protocol address. This is blank when the sender sends a request.
Target protocol address is the protocol address that is being resolved.
-  “An Ethernet Address Resolution Protocol: Or Converting Network Protocol Addresses to 48.bit Ethernet Address for Transmission on Ethernet Hardware,” no. 826. RFC Editor, Nov-1982.