One of the main protocols in a computer network is Address Resolution Protocol (ARP). If you understand this protocol well enough, you can do network troubleshooting much faster and easier.
To be concise, ARP’s job is to discover layer 2 MAC address when the destination IP address is available and known. Let’s go through how this protocol works in the network.
In order to analyze the ARP protocol, you need to first understand different types of addresses.
In a computer network we deal with three kinds of addresses as below:
Type of addresses
In a computer network we deal with three kinds of addresses as below :
- Unicast: This address is used when you want to send data from one computer to another unidirectional. It means that we have only one source and one destination address.
- Multicast: This address is used when you want to send data from one computer to a multiple computers (receivers) simultaneously. For example imagine that your company has several departments and you want to send data to accounting department only which has more that one employer. In this case the data that you send will reach to a group of people in the accounting department.
- Broadcast: This address is used when you want to send some data with the intention that everybody who is working in your company receives the same piece of information simultaneously. This is technically called “broadcasting” and Radio technology is a well-known example that’s utilizing this method. The radio station sends out the radio signals in all directions and anybody who has their radio tuned in a particular frequency will receive an instance of the data that’s being broadcasted.
Why you need to know ARP protocol
OK, After you understand the purpose of different addresses, let’s describe why network requires ARP protocol at all.
As you know, layer 3 IP addresses are configured by a network administrator but Layer 2 MAC address is a pre-configured address by the manufacturer of the hardware. When sending data inside the network, The sender knows the destination layer 3 IP address of the receiver but layer 2 MAC address is unknown.
The sender must have a way to find the MAC address of the destination in order to complete the layer 2 encapsulation process. Now it’s the job of the ARP protocol to discover the layer 2 MAC address of the destination node from the IP address. In the illustration below, you can get a better grasp of how the ARP protocol functions.
How ARP finds the Layer 2 address
Well, ARP protocol must go through three steps to find the destination MAC address.
1- The sender generates data and puts it’s own MAC address in layer 2 header as the source MAC address. Then it puts FF:FF:FF:FF:FF:FF as the destination MAC address. This is the format of a broadcast address in layer 2. For layer 3 address, the sender knows the source and destination address because it is configured manually.
2-The packet generated in step one is now going to be sent to all nodes in the network but just one node will open this packet and that’s the computer whose destination IP address is mentioned in layer 3 section of the packet. Although other nodes will also receive this packet, they are going to drop it because they see a different Layer 3 address in L3 section of the packet than their own address.
3- In the third step, the node who has opened the packet in step 2 will answer the question in the last part of the packet and will forward it to the sender who asked for the MAC address.
Now that the sender has acquired the receiver’s MAC address, it can send data to the receiver without needing to repeat these three steps because now it has both layer 2 and layer 3 addresses for the destination.
If there’s no communication between the sender and the receiver for 300 seconds, the MAC addresses will be flushed out of the cache and the sender must repeat the previous three steps again in order to find the destination MAC address.