Saturday, 27 May 2017

ARP and RARP

 

ARP (address resolution protocol) and RARP (reverse address resolution protocol) are important topics and are required in every aspect of computer networks. Let's first talk about ARP.

ARP (Address Resolution Protocol):

As the name suggest it is a protocol used to resolve an address. Given an IP address, ARP is used to get corresponding MAC address. ARP can be used in all the following situations.

  • When a host wants MAC address of another host.
  • When a host wants MAC address of a router.
  • When a router wants MAC address of another router.
There are two different cases depending on which the usage of the ARP changes.

  1. Both source and destination in the same network.
  2. Source and destination are in different network.
There are ways to find out whether a host is on our network or not?

1. Both source and destination on the same network:

In this case, the source (node A in the diagram below) finds out that the destination (node D) is on the same network and therefore need not cross the network boundary to deliver its message.


But node A has IP address D, not the MAC address. So to find out the MAC address of D, node A creates an IP packet and gives it to ARP. ARP creates an ARP packet and transmits it.


The ARP packet has the following content when it is broadcasted:
Source IP: IP address of A
Destination IP: IP address of D
Source MAC: MAC address of A
Destination MAC: LBA (255.255.255.255)

The packet travels through the network and is seen by everyone in the network after looking at the destination MAC address. Every host in the network looks at the destination IP address and decides whether the packet is for them or not. When the packet reaches the router, router finds out that it is a limited broadcasting packet and should not be allowed on the internet. So it destroys the packet. Meanwhile, host D looks at the destination IP and finds out that the packet is for him. He also finds out that it's an ARP packet and in return, he also creates an ARP reply packet. The packet contains the MAC address of host D. The ARP reply packet is an unicast packet and so it is sent only to host A.

2. Source and destination are on a different network:


When A and D are not in the same network, then A sends and ARP broadcasting message. The content of the packet is as follows.

Source IP: IP address of A
Destination IP: IP address of nearest/default router
Source MAC: MAC address of A
Destination MAC: 255.255.255.255

When the packet reaches the default router it finds out that the packet is for him and it's an ARP packet. The router makes an ARP unicast packet with the following content.

Source IP: IP address of router
Destination IP: IP address of A
Source MAC: MAC address of router
Destination MAC: MAC address of A

After getting the MAC address of router node A transmits the packet to the router. Now its router's responsibility to forward the router to its intended destination. So to do so it follows the same strategy as followed by node A, and forwards it to the destination or to next router. After the packet reaches the destination, the destination makes an ARP reply packet and unicast it to node A.

Important points:

  • ARP is used to get MAC address of machine whose IP is given.
  • ARP request is broadcasted.
  • ARP reply is unicast.
  • If both source and destination are on the same network ARP packet can be directly sent to destination without involving intermediate routers.
  • If source and destination are on a different network the ARP packet needs to travel through intermediate router/s to reach the destination.

RARP (Reverse Address Resolution Protocol):

Given the definition of ARP, it's easy to find out what RARP does. Given a MAC address it's used to find out corresponding IP address. But I will tell a bit more about this which is often not taught by professors in college. 
Let's start with the question that who needs RARP?
  • A host who doesn't have secondary storage.
  • A host who has newly joined the network.
  • A host who has MAC address of other host and wants its IP address.

When RARP was introduced we didn't have DHCP or BOOTP. People used RARP servers. And every individual network had their own RARP server. RARP servers were the machines which were used to assign IP addresses to the other machines/nodes in their own network.
The server contains a mapping table, which had MAC addresses of every host on the network and their corresponding IP addresses.

                                                                Mapping table   

MAC Address
IP Address
Node A
E4:78:A8:9D:34:67
Node A
178.113.89.20
Node B
F4:78:A8:4D:39:60
Node B
178.113.89.21
.
.
.
.
.
.
.
.



Why didn't the nodes store their IP addresses with them?. It was because these kinds of machines didn't have secondary storage. Whenever the machines were turned OFF the IP address was lost and so next time when it was turned ON, it had to ask RARP server for IP address. (You would still find these kinds of machines in your colleges).

RARP servers were also used when a new node wanted to join the network. The node sends an RARP request packet to RARP server with following packet structure:

Source IP: 0.0.0.0 (Remember it's called a what is my IP?)
Destination IP: IP address of RARP server
Source MAC: MAC address of node A
Destination MAC: FF:FF:FF:FF:FF:FF (This means it's a broadcasting packet)

The packet is seen by all the nodes on the network, but only the RARP server replies to the request. It looks at the mapping table, find out the corresponding IP and sends back an RARP reply packet (which is an unicast packet). 
These IP's are given to these nodes for a fixed amount of time called as leased time. After the leased time is over the IP's are pulled back. The nodes have to make a renewal requests before the leased time gets over to retain their IP's.


There was a problem with RARP servers. Can you guess it?. Since every network had its own RARP server inconsistencies could arrive. Two different nodes of two different networks can have same IP addresses. This problem arrived because RARP servers of the networks didn't communicate with each other and no server had any information about the mapping tables of other servers. And also the mapping table was static, it means if we had 100 nodes than we needed at least 100 IP addresses. To overcome this we used BOOTP and DHCP servers.



Hope this was helpful, share your thoughts in the comment section below. Click the follow button to get latest updates.

Thank you!