Articles

ARP Protocol, Address Resolution Protocol (ARP), Computer network

ARP Protocol:

ARP Protocol- In this article we will talk in detail about the ARP Protocol, Address Resolution Protocol. So, let’s start suppose a source computer wants to send some data to a target computer. Both machines are connected to a network switch via an Ethernet cable for sending data. The source must know the Ethernet address of the target device which is also called the mac address. However, the source computer only knows the IP address of the target and not its Ethernet  address, here ARP address resolution protocol helps to obtain the Ethernet  address of the target computer so that the source can send data. Let’s understand this process in detail.

ARP Protocol



With an example, as soon as we connect our computer to a local area network with an Ethernet  cable, dhcp protocol allocates an IP address to the computer system. dhcp also provides some additional information to the computer including the IP address of the gateway router and that of the dns server. Now we type www.55terms.com in the web browser’s url bar but the browser does not know what www.55terms.com is. It must be translated to browser understandable IP address and the DNS server does this translation. For this translation the computer’s operating system creates a DNS query message enter www.55terms.com in the question section of the packet and place it in a UDP segment with destination port 53 and source port as a random UDP port opened by TCP IP protocol stack on the DNS client. The UDP segment is then placed in an IP datagram note that the source of the DNS query message is our computer and its destination is the DNS server. So, in the IP packet the source IP address is the IP address of computer and destination IP address is the IP address of the DNS server. But how the computer knows these two addresses these are obtained with the help of dhcp protocol. So, the source IP address is set to IP(S) and destination 1 is set to IP(DNS) the IP packet is then placed in an Ethernet  frame this frame contains the DNS query packet and it needs to be delivered first to the gateway router, for it the Ethernet  address of the gateway router must be known. However dhcp protocol has only provided the IP address of the gateway router and not its Ethernet address. So how to obtain the Ethernet  address of the gateway router? it is the place where ARP address resolution protocol comes into action which helps to get the Ethernet  address of the gateway router with the help of its IP address.

ARP Protocol




ARP Address resolution protocol:      

The address resolution protocol creates an r request packet containing following fields. Hardware type defines the type of the physical network on which ARP address resolution protocol is running for Ethernet it is set to 1. Protocol type defines the protocol that is being used for ipv4 it is set to 0 8 0 0 represented in hexadecimal hardware length defines the length of the physical address in bytes  for Ethernet  it is set to 6 which means the physical address is 6 bytes or 48 bits long.  Protocol length defines the length of logical address in bytes for Ethernet. It is set to 4 which mean the protocol address is 4 bytes or 32 bits long operation field defines whether the ARP address resolution protocol packet is a request or reply for request, it is set to 1 and for reply it is set to 2. The remaining 4 fields as the name suggests stores the physical and logical addresses of the sender and receiver, here logical address is the IP address and the physical address is the Ethernet address. The sender is our computer and the target is the gateway router. So, the sender protocol address is IP(S) and the target protocol address is IP(R). The sender hardware address is the Ethernet  address of the computer, since Ethernet  address of the gateway router is unknown. The target hardware address is filled with zeros. Note that the Ethernet address use hexadecimal notation which means each character is represented with 4 bits since there are 12 characters in total. So, the Ethernet address is 48 bits or 6 bytes long. It is same as is filled in the hardware length field. Similarly, IP address use dotted decimal notation to represent an IP address which means each symbol is represented by 8 bits since there are 4 symbols in total.  So, the IP address is 32 bits or 4 bytes long it is same as is filled in the protocol length field.

ARP Protocol



Now, our request packet is encapsulated in an Ethernet  frame where the type field indicates the data carried by this frame is an r packet. It is set to 0806 in case of ARP address resolution protocol the source mac address is set to the computer’s Ethernet  address and the destination mac address is set to the Ethernet  broadcast address, because the Ethernet  address of the gateway router is unknown. Tthe frame is then transmitted in the transmission medium by the physical layer of the computer. The switch receives the frame and checks the destination hardware address as it is Ethernet  broadcast address, the switch forwards the frame to all of its ports,  all connected computers along with the gateway router receives the frame. Ethernet  drivers in each device checks the type field and pass the ARP request packet to the ARP module which then examines the target IP address if it matches with its IP address. The device sends an r reply packet otherwise the devices drop the ARP request packet. In the current case, the gateway router sends an ARP reply packet in the rp reply packet it fills its IP address and Ethernet  address in the centers field and the destination fields are filled with the address details of the computer, operation field is set to 2 representing it to be a reply packet.

ARP Protocol



Finally, the ARP reply packet is encapsulated in an internet frame with source mac address as the router’s Ethernet address and the destination mac address as the computer’s Ethernet address. The computer receives the Ethernet frame, the computer’s Ethernet driver then checks the type field and forwards the ARP reply packet to the ARP module, ARP module checks the packet and adds the sender’s IP address and Ethernet address. In the computer’s ARP table these two addresses are the addresses of the gateway router. Initially, the computer knew only the IP address of the gateway router and not its Ethernet address, that’s why the IP datagram containing DNS query packet was queued, however now the address resolution protocol has provided the router’s Ethernet address as well, and is updated in the ARP table. The computer uses the ARP table to translate the router’s IP address to its Ethernet address, update the same in the Ethernet frame and packs the queued IP packet. Finally, the Ethernet frame containing the DNS query message is transmitted to the gateway router. The gateway router then forwards the DNS query to the dns server using its routing table. In summary when the ARP table is missing any required IP to ethernet address translation the IP packet is queued address resolution protocol runs and quickly fills the needed IP to Ethernet address translation in the ARP table the updated entry is then used to create an Ethernet  frame and transmit the queued IP packet.

ARP Protocol

Please note some important points about address resolution protocol. ARP request is broadcast while ARP reply is unicast address resolution protocol operates within the subnet. The target protocol address is necessary in the request packet, because it tells the host whether or not to send a reply. The sender hardware address and the sender protocol address are mandatory fields because they are going to be updated on the ARP table. We can see the computers are table or ARP cache using cmd command “arp –a” static ones are the entries maintained manually on the other hand dynamic ones are learned by the computer itself.




Watch the Video Tutorial:

Credit:

TechTerms YouTube Channel

https://www.youtube.com/watch?v=EC1slXCT3bg

Engr Fahad

My name is Shahzada Fahad and I am an Electrical Engineer. I have been doing Job in UAE as a site engineer in an Electrical Construction Company. Currently, I am running my own YouTube channel "Electronic Clinic", and managing this Website. My Hobbies are * Watching Movies * Music * Martial Arts * Photography * Travelling * Make Sketches and so on...

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button