Network Layer – Address Resolution Protocol (ARP)
In the last post we have seen the routing procedures required to correctly send the packets of data to correct destination host. Now its time for us to learn the important protocols implemented in the network layer. The main protocols corresponding to the network layer in the TCP/IP suite as well as the Internet layer are : ARP, RARP, IP, ICMP, and IGMP .
We gonna learn these protocols in each of the subsequent posts. So let’s start with the first in the list i.e Address Resolution Protocol (ARP). Below you can see all the protocols used inside a network layer.
Out of these protocols IP is the most important protocol. It is responsible for the host to host the delivery of datagrams from a source to destination. But IP needs to take services of other protocols.
IP takes help from ARP in order to find the MAC (physical) address of the next hop. IP uses the services of ICMP during the delivery of the datagram packets to handle unusual situations such as presence of an error.
IPv4 is the current version of IP whereas IPv6 is the latest version of IP.
The Address Resolution Protocol (ARP) is mainly used to associate a logical address with a physical address. On a typical physical network, such as a LAN, each device on a link is identified by a physical or station address, usually imprinted on the network interface card (NIC).
ARP is used in order to find the physical address of the node when its Internet address is known.
Different networking technologies have different physical addressing mechanisms. A physical address is also known as the hardware address and there are three methods to assign the hardware address to a computer as follows:
- Static addresses : The static address is a physical address which is hardcoded in the Network Interface Card (NIC) of the computer.
- Configurable addresses : In this method. the physical address is configured inside a computer at the time of its first installation at its site.
- Dynamic addresses : In this method. a server computer dynamically assigns a physical address to a computer every time it boots. Thus the physical address of a computer changes every time it is switch off and on.
What is an ARP (Address Resolution Protocol) in the network layer?
ARP provides service to IP, which make us think that it is in the data link layer (DLL) TCP/IP model. But it’s messages are carried by DLL (data link layer) protocol and are not capsulated within IP datagrams.
That is why it can be called a network layer protocol as well. Thus ARP occupies an unusual place in TCP/IP suite. ARP as defined in RFC 826 is Ethernet Address Resolution Protocol.
Internet consists of various types of networks and connecting devices like routers. A packet starts from the source host, passes through many physical networks and finally reaches the destination host. At the network level, the hosts and routers are recognized by their IP addresses.
Note : The packets from source to destination hosts pass through physical networks. At the physical level, the IP address is not useful but the hosts and routers are addressed by their MAC addresses.
Mapping of IP Address into a MAC Address
There are mainly two types of mapping :
- Static mapping : In static mapping a table is created and stored in each machine. This table associates an IP address with a MAC address. If a machine knows the IP address of another machine then it can search for the corresponding MAC address in its table.
- Dynamic mapping : In dynamic mapping technique a protocol is used for finding the other address when one type of address is known. There are two protocols used for carrying out the dynamic mapping i.e Address Resolution Protocol (ARP) and Reverse Address Resolution Protocol (RARP).
The ARP is mainly used for mapping an IP address to a MAC address whereas the RARP protocol is used for mapping a MAC address to an IP address.
Address Resolution Protocol (ARP) Operation
ARP is basically used for mapping an IP address to its MAC address. For any LAN, each device has its own physical or station address as its identification mark.
This address is stored on the NIC (Network Interface Card) of that machine. When a router or a host (A) needs to find the MAC address of another host (B) the sequence of events taking place is as follows:
The router or host A who wants to find the MAC address of some other router, sends an ARP request packet. This packet consists of IP and MAC addresses of the sender A and the IP address of the receiver (B).
This request packet is broadcasted over the network.
Every host and router on the network will receive the ARP request packet and process it. But only the intended receiver (B) will recognize its IP address in the request packet and will send an ARP response packet back to A.
The ARP response packet has the IP and physical addresses of the receiver (B) in it. This packet is delivered only to A (unicast) using A’s physical address in the ARP request packet.
ARP Cache Memory
The use of ARP would be inefficient if A needs to broadcast an ARP request for each IP packet that is to be sent to B, because instead of broadcasting the request it could have broadcast the IP packet itself. So ARP is efficient only if the ARP reply is stored in cache memory (cached) for a while.
This is due to the fact that a system generally sends hundreds of packets to the same destination. Thus the system that receives an ARP reply store the mapping in the cache memory and keeps it for 20 to 30 minutes.
ARP Packet Format
The various fields in it are as follows :
HTYPE (Hardware Type) : This 16 bit field defines the type of network on which ARP is being run. ARP is capable of running on any physical network.
PTYPE (Protocol Type) : This 16 bit field is used to define the protocol using ARP. Note that we can use ARP with any higher·level protocol such as IPv4.
HLEN (Hardware length) : It is an 8 bit field that is used for defining the length of the physical address in bytes For example this value is 6 for Ethernet.
PLEN (protocol Length) : This field is 8 bit long and it defines the length of the IP address in bytes. For IPv4 this value is 4.
OPER (Operation) : It is a 16 bit field that defines the type of packet. The two possible types of packets are ARP request (I) and ARP reply (2).
SHA (Sender Hardware Address) : This field is used for defining the physical address of the sender. The length of this field is variable.
SPA (Sender Protocol Address) : This field defines the logical address of the sender. The length of this field is variable.
THA (Target Hardware Address) : It d.efines the physical address of the target. It is a variable length field. This field contains all zeros for the ARP request packet, because the receivers physical address is not known to the sender.
TPA (Target Protocol Address) : This field defines the logical address of the target. It is a variable-length field.
An ARP packet (request or reply) is inserted directly into the data link frame. Such insertion is known as encapsulation. Below an ARP packet (request or reply) is inserted directly into the data link frame. Such insertion is known as encapsulation.
IP orders ARP to create an ARP request message. The request packet consists of senders’ physical and IP addresses plus the IP address of the target but the physical address of the target is not known.
This ARP request packet is sent to the data link layer. Here the ARP request packet is inserted in a frame.
Every router or host receives this frame because it is broadcast. All the machines except the target drop this packet as discussed earlier.
The target machine sends back a reply packet that contains the target’s physical address. This reply is unicast and addressed only to the sender.
The sender receives the reply packet. Hence the physical address of the target has been obtained.
The IP datagram carrying data for the target machine is inserted in a frame and the frame is unicast to the target machine.
Finally we reach the end of this post. Stay tuned for more interesting stuff in this series .
Aric is a tech enthusiast , who love to write about the tech related products and ‘How To’ blogs . IT Engineer by profession , right now working in the Automation field in a Software product company . The other hobbies includes singing , trekking and writing blogs .