Address Resolution Protocol (ARP) is the dynamic address mapping protocol that is used to identify the physical address (MAC address) of the device whose logical address is known. ARP is a network layer protocol.
Address Resolution Protocol (ARP)
Requirement of ARP
We know that when a sender host has some datagram or IP packet to deliver it to the destination host, it determines the logical address of the destination host by DNS server. We will talk about how DNS provides the logical addresses in some other content.
Now by knowing the logical address of the receiver host the sender host updates the packet header with the destination address as the logical address of the receiver host. Then this packet is delivered to the data link layer where the packet will be encapsulated in frames so that it can pass through the physical network.
We know that at the physical network or at the physical level the host is recognized by its physical address, not by its logical address. This is where we require ARP protocol which will map the logical address of the receiver host to the physical address of the receiver host.
In the section below we will discuss four scenarios where the ARP protocol is used:
- The host has an IP packet to deliver it to the receiver host present in the same network.
- The host has an IP packet to deliver it to the receiver host which is present in the different networks as of host.
- The router receives an IP packet to deliver it to the receiver host is present in the same network
- The router receives the IP packet to deliver it to the receiver host in a different network.
Functioning of ARP
As we have seen above the sender host determines the logical address of the receiver host using DNS. Now knowing the logical address of the receiver host the network layer prepares the IP packet with the receiver’s logical address. This IP packet is then encapsulated into the frame which then has to travel through the physical network and in the physical network the receiver will be identified by its physical address.
So, to recognize the physical address of the receiver, the IP protocol lets the ARP protocol prepare a query packet that has the physical and logical address of the sender and the logical address of the receiver. ARP protocol then broadcast this packet to all the host and routers o the network.
The receiver host recognizes its logical address in the ARP query packet and prepares an ARP reply packet and sends it to the physical address of the sender host present in the ARP query packet.
The other hosts in the network that has received the ARP request packet discard it knowing it doesn’t have their logical address in it. This is how ARP protocols work.
ARP Packet Format
ARP packet format describes the fields of the ARP packet.
- Hardware Type: This field is of 16 bits and defines the network on which ARP protocol is running. As each network type is identified by the integer assigned to it.
- Protocol Type: Being a 16-bit field, it defines the protocol which is using the ARP protocol.
- Hardware Length: This is an 8-bit field and it defines the length of the physical address of the device on which ARP is running.
- Protocol Length: Being an 8-bit field, it defines the length of the IP address expressed in bytes.
- Operation: This field defines whether the ARP packet is a query packet or a reply packet.
- Sender Hardware Address: This field defines the physical address of the host sending the ARP packet.
- Sender Protocol Address: This field defines the logical address of the sender.
- Target Hardware Address: This field defines the physical address of the receiver host.
- Target Protocol Address: This field defines the logical address of the receiver host.
In this way, the ARP protocol is used to identify the physical address of the intended receiver. ARP protocol is used with other high-level protocols.