How ARP works between Host A and Host B

ARP stands for Address Resolution Protocol. It is used to associate a Layer 3 (Network Layer such as IP address) address to a Layer 2 (Data-link Layer MAC address) address.


Fig 1.1- ARP Request

Consider the following- Host A would like to send some data to Host B. Assuming ARP Cache is clear on hosts.

  • Host A creates an IP Packet with Source Address as itself and Destination Address as the IP address of Host B. The payload contains the actual data.
  • Host A then sends the IP packet to the data-link layer where it puts the Source and Destination MAC addresses.
  • Based on the IP Address and Subnet Mask of Host B, Host A will realize that Host B is not connected to the same local network. It realises it needs to forward the packet to Router-A as it is the default-gateway.
  • Host A sends an ARP Request broadcast frame for 10.1.1.2- its default-gateway. The ARP Request is encapsulated in Ethernet Frame with Source MAC address as Host's MAC address and Destination MAC address as FF:FF:FF:FF:FF:FF. The actual ARP Request contains Source Address as its IP address, Source MAC address as its own MAC address, Target IP Address as the Default-Gateway IP address (Router-A) and Target MAC address as 00:00:00:00:00:00
  • Router-A will respond with an ARP Reply to ARP query by sending its own MAC address of the interface connected to Host A network, encapsulated in an Ethernet frame.
  • Host A caches this entry in its ARP Cache and uses this MAC address for every new IP destination prefix.
  • Host A sends the frame to Router-A.
  • Router-A receives the frame with Destination MAC address for it. Router-A decapsulates the frame and figures out the Destination IP address. It realises that the packet is suppose to be routed.
  • Router-A checks its routing table for the closest match to find out the outgoing interface for the packet.
  • Router-A creates a new data-link frame addressed for the packet's next-hop. Router-A will use the appropriate data-link addresses depending on the type of connection.
  • The same process continues until the last-hop to the destination. Router-C receives the packet.
  • Router-C will realise that the packet is meant for Host B directly connected to its local network.
  • If Router-C is not aware of the MAC address of Host-B, it will send out ARP request for Host-B's MAC address.
  • Once Host-B replies with the MAC address, Router-C forwards the frame to Host B.