What is ARP protocol? Resolves an IP address to the MAC address.
The full form of ARP is Address Resolution Protocol. From full form says that the protocol is to resolve an address of a network packet. To understand the purpose of the ARP protocol, we need to understand how a packet routes over the internet or IP network.
For example, if you are using a computer that is connected to the LAN over the wifi router. The router assigns a LAN IP address (e.g 192.168.1.4) to the computer connected to LAN via DHCP (maybe a static IP as well). Similarly, other devices on the LAN get addresses.
You can consider a connection between the computer and the wifi router as a communication link. So there may be multiple links, the number of links depends on the connected devices to the router. If you browse a website from the web browser. The request is sent to the router and in response, the router sends the request to the public server, which hosts the website.
Upon response, the router knows the IP address of your LAN computer but does not know which physical device to send. Here comes the ARP protocol. From ARP, the router gets the physical address of the device. The router sends the response to the device to which the message needs to deliver.
From the above example, it is clear what is the role of ARP in computer networks. Now how the translation is done we will discuss. When the sending device needs to send a message, it broadcast the ARP request with the destination IP address. All devices over LAN gets the request. But the device/computer whose IP address matches with the address in the ARP request. Only sends an ARP response back to the sending device with its own MAC address.
In computer networks, there are various layers of protocols. Each layer has an address for communication over the network. ARP is the protocol that works as layer 2 of the OSI model. Means ARP works on the data link layer. It has an interface with the network layer, which initiates the ARP request.