Most of the computer programs/applications use logical address (IP address) to send/receive messages, however the actual communication happens over the physical address (MAC address) i.e from layer 2 of OSI model. So our mission is to get the destination MAC address which helps in communicating with other devices. This is where ARP comes into picture, its functionality is to translate IP address to physical address.
The acronym ARP stands for Address Resolution Protocol which is one of the most important protocol of the Data Link Layer. Let’s look at how ARP works.
Imagine a device wants to communicate with the other over the internet. What ARP does? Is it broadcast a packet to all the devices of the source network.
The devices of the network peel the header of the data link layer from the protocol data unit (PDU) called frame and transfers the packet to the network layer (layer 3 of OSI) where the network ID of the packet is validated with the destination IP’s network ID of the packet and if it’s equal then it responds to the source with the MAC address of the destination,else the packet reaches the gateway of the network and broadcasts packet to the devices it is connected with and validates their network ID
The above process continues till the second last network device in the path to reach the destination where it gets validated and ARP in turn responds with the destination MAC address.
The important terms associated with ARP are :
- ARP Cache: After resolving MAC address, the ARP sends it to the source where it stores in a table for future reference. The subsequent communications can use the MAC address from the table
- ARP Cache Timeout: It indicates the time for which the MAC address in the ARP cache can reside
- ARP request: This is nothing but broadcasting a packet over the network to validate whether we came across destination MAC address or not
- ARP response: It is the MAC address response that the source receives from the destination which aids in further communication of the data
Test Yourself :
Connect two PC, say A and B with cross cable. Now you can see the working of ARP by typing these commands:
1. A > arp -a
There will be no entry in table because they never communicated with each other.
2. A > ping 192.168.1.2 IP address of destination is 192.168.1.2 Reply comes from destination but one packet is lost because of ARP processing.
Now, entries of ARP table can be seen by typing the command.
This is how ARP table looks like:
This article is contributed by Vivek Reddy. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
- Computer Network | ARP, Reverse ARP(RARP), Inverse ARP(InARP), Proxy ARP and Gratuitous ARP
- What’s difference between Ping and Traceroute?
- Computer Network | Circuit Switching VS Packet Switching
- Computer Network | Dynamic Host Configuration Protocol (DHCP)
- Computer Network | Difference between Unicast, Broadcast and Multicast
- Differences between TCP and UDP
- Asynchronous serial data transfer
- Computer Network | Bit Stuffing
- Bit stuffing using Java | Computer Networks
- Computer Network | Difference between layer-2 and layer-3 switches