What the heck is ARP and how does it work?

Juhel PhanjuJuhel Phanju
3 min read

When host A needs to send a package to host B. Host A needs to know the IP address of host B. That is enough for the end users but that is not enough for the host. The host needs to know the MAC address as well which happens under the shadows. So, to know the MAC address of the recipient the ARP is used.

ARP

ARP (Address Resolution Protocol) is a communication protocol used for discovering the link address i.e. MAC address, associated with the internet layer address i.e. IP address. The mapping between MAC address and IP address is critical in the internet protocol suite. The ARP is a request-response protocol whose messages are encapsulated by a link-layer address i.e. a host request for the MAC address associated with the IP address and the respective host response to the request. The ARP is used within the boundaries of a single network, never routed across inter-networking nodes.

The request in ARP is a broadcast packet and the response is a unicast packet. The ARP's main task is to convert a 32-bit IP address (for IPv4) to a 48-bit MAC address. It is used when one device wants to communicate with some other device on a local network.

How does ARP work?

So how does the ARP work? It's pretty easy let me explain. All OS in an IPv4 network keeps an ARP cache (ARP table). The ARP cache can be dynamic or static. The static ARP cache is the manually set bindings between the MAC address and IP address. The dynamic ARP cache is set by the device itself which expires after some specified time. When the host requires a MAC address to send packets to another host in the LAN, it checks its ARP cache to check if the MAC address translation is already present or not. If it isn't present in the cache then, the following three steps are performed to get the MAC address from the IP address:

  1. The host broadcast the ARP request. In the request header, there consists of protocol, self IP address, self MAC address, destination IP address, and broadcast MAC address which is usually (ff:ff:ff:ff:ff:ff).

  2. Every host connected to the same network gets the request and checks if the destination IP address matches or not. If it is a match then the respective device responds to uni-casts with its MAC address.

  3. The source host gets the response then saves the MAC address in the ARP cache for future use and sends a packet dedicated to the MAC address.

This is how ARP works.

Important ARP terms:

  1. ARP Cache: After resolving the MAC address, the ARP sends MAC binding to the cache stored in a table for future reference. The subsequent communication can use the MAC address from the table.

  2. ARP Cache Timeout: It is the time for which the MAC binding in the ARP cache can reside.

  3. ARP request: Broadcasting a packet over the network to validate whether we came across the destination MAC address or not.

  4. ARP response: The MAC address response that the source receives from the destination, aids in further communication of the data.

Conclusion

ARP (Address Resolution Protocol) is used for finding out the corresponding MAC address of the device with the specific IP address.

0
Subscribe to my newsletter

Read articles from Juhel Phanju directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Juhel Phanju
Juhel Phanju

Someone whose existence is insignificant