ARP (Address Resolution Protocol)

1. Introduction to ARP

The Address Resolution Protocol (ARP) is essential for local IPv4 communication.

Imagine this: You’re sitting behind PC1 and you want to ping your friend’s device, PC2, on the same network.

You already know PC2’s IP address (192.168.1.2), so you can send a ping request. But there’s a problem—your device doesn’t know PC2’s MAC address.

Now, take a moment to think. Why is the MAC address important?

Your device needs both the IP address and the MAC address of the destination device to send data. Without the MAC address, your message won’t know where to go at the data link layer.

This is exactly why the Address Resolution Protocol was created. ARP maps IP addresses to MAC addresses, allowing devices to communicate efficiently on local IPv4 networks.

In our case, it helps PC1 find the MAC address of PC2 (192.168.1.2) so they can exchange data successfully.

2. How ARP Works

Let’s break it down step by step. You’re about to send a ping from PC1 to PC2. What exactly happens?

Step 1: Checking the ARP Table

You type the command ping 192.168.1.2 and press Enter! The first thing your computer (PC1) does is check its ARP table.

The ARP table is a table stored in your computer that contains known IP-to-MAC address mappings.

Your device will search for the MAC address associated with 192.168.1.2 before sending the ping request.

To view the ARP table on Windows, open the terminal and type:

C:\> arp -a

Interface: 192.168.1.1  0xb
  Internet Address      Physical Address      Type

But in our case, the ARP table is empty—meaning PC1 doesn’t know the MAC address of PC2 (192.168.1.2).

At this point, we’re stuck. We need PC2’s MAC address to send the request and this is where the ARP protocol steps in to find it.

Step 2: ARP Request

If the MAC address is not found in the ARP table, your device will send an ARP Request, asking:

“Who has IP address 192.168.1.2? Please tell me your MAC address!”

This message is broadcasted to every device on the network because PC1 doesn’t know PC2’s MAC address yet.

Understanding the ARP Request Fields

The ARP Request contains multiple fields that help the receiver understand that we are trying to find its MAC address.

In the ARP Request, we have multiple fields filled to ensure the receiver knows we are trying to find its MAC address.

FieldValue
Source MACAA:AA:AA:AA:AA:AA (PC1’s MAC address)
Destination MACFF:FF:FF:FF:FF:FF (Broadcast address)
Source IP192.168.1.1 (PC1’s IP address)
Target IP192.168.1.2 (PC2’s IP address)
Target MAC00:00:00:00:00:00 (Unknown, because PC1 doesn’t know PC2’s MAC address yet)

Here’s what happens in this request:

  • Target IP: The IP address of PC2 (192.168.1.2), the device we are looking for.
  • Target MAC: Set to all zeros (00:00:00:00:00:00) because PC1 doesn’t know PC2’s MAC address yet.
  • Destination MAC: A broadcast address (FF:FF:FF:FF:FF:FF), meaning every device on the network receives the message.

Step 3: ARP Reply

Now, let’s switch to PC2’s perspective.

When PC2 receives the ARP Request, it checks if the Target IP field matches its own IP address (192.168.1.2).

If this is the case, that means someone is asking for its MAC address.

PC2 then sends an ARP Reply directly to PC1, announcing its MAC address !

Understanding the ARP Reply Fields

FieldValue
Source MACBB:BB:BB:BB:BB:BB (PC2’s MAC address)
Destination MACAA:AA:AA:AA:AA:AA (PC1’s MAC address)
Source IP192.168.1.2 (PC2’s IP address)
Target IP192.168.1.1 (PC1’s IP address)
Target MACAA:AA:AA:AA:AA:AA (PC1’s MAC address)
Here’s what happens in this request:
  • PC2 provides its MAC address (BB:BB:BB:BB:BB:BB) to PC1.
  • Unlike the ARP Request (which was broadcasted to all devices), the ARP Reply is a unicast message—meaning it is sent only to PC1.

Step 4: Updating the ARP Table

Once PC1 receives the ARP Reply, it updates its ARP table with PC2’s MAC address as you can see below.

C:\> arp -a

Interface: 192.168.1.1  0xb
  Internet Address      Physical Address      Type
  192.168.1.2           BB-BB-BB-BB-BB-BB     dynamic

This entry allows PC1 to communicate with PC2 without needing another ARP Request. However, ARP table entries are temporary and the MAC Address will be removed if they remain unused for a certain period.

3. Successful Ping

Now that PC1 has learned PC2’s MAC address, it can finally send the ping request.

When you ping 192.168.1.2, your device first checks its ARP table to retrieve PC2’s MAC address. Then, it sends the packet directly to PC2.

4. Conclusion

The Address Resolution Protocol (ARP) is a simple but essential mechanism in local networks. It allows devices to resolve an IP address into a MAC address, enabling communication at the data link layer.

Key points to remember:

✅ ARP bridges the gap between IP addresses (logical) and MAC addresses (physical).
✅ Without ARP, a device cannot send data over a local Ethernet network.
✅ If a device knows the IPv4 address but not the MAC address, ARP resolves it and enables communication.