All About ARP
All About ARP
All About ARP
ARP:--
Address Resolution Protocol (ARP) is one of the major protocol in the TCP/IP suit and
the purpose of Address Resolution Protocol (ARP) is to resolve an IPv4 address (32
bit Logical Address) to the physical address (48 bit MAC Address).
Network Applications at the Application Layer use IPv4 Address to communicate with
another device. But at the Datalink layer, the addressing is MAC address (48 bit Physical
Address), and this address is burned into the network card permanently. You can view your
network card’s hardware address by typing the command "ipconfig /all" at the command
prompt (Without double quotes using Windows Operating Systems).
The purpose of Address Resolution Protocol (ARP) is to find out the MAC address of a
device in your Local Area Network (LAN), for the corresponding IPv4 address, which
network application is trying to communicate.
Hardware Type [2 bytes]: It specifies the type of hardware used for the local network
transmitting the ARP message. Ethernet is the common Hardware Type and he value is 1.
The size of this field is 2 bytes.
Protocol Type [2 bytes]: Each protocol is assigned a number used in this field, IPv4 is 2048
(0x0800 in Hexa).
RAKESH https://www.linkedin.com/in/rakesh-sa-b2b664167
Page |2
Hardware Address Length: Hardware Address Length in the ARP Message is length in bytes
of a hardware (MAC) address. Ethernet MAC addresses are 6 bytes long.
Protocol Address Length: Length in bytes of a logical address (IPv4 Address). IPv4
addresses are 4 bytes long.
Opcode [Operation] [2 bytes]: Opcode field in the Address Resolution Protocol (ARP)
Message specifies the nature of the ARP message. 1 for ARP request and 2 for ARP reply.
Sender Hardware Address [4 bytes]: Layer 2 [MAC] address of the device sending the
message.
Sender IP Address [4bytes]: The protocol address (IPv4 address) of the device sending the
message
Target Hardware Address [6 bytes]: Layer 2 [MAC] address of the intended receiver. This
field is ignored in requests.
Target IP Address [4 bytes]: The protocol address (IPv4 Address) of the intended receiver.
ARP Table
RAKESH https://www.linkedin.com/in/rakesh-sa-b2b664167
Page |3
• A host will exhaust its ARP cache with a lot of unused ARP entries, so it is critical
that the cache entries are set to expire periodically.
• Static entries remain in the table forever and are not timed out.
• If a dynamic ARP entry is not used a specific amount of time called the ARP timeout
the entry is removed from the caching table.
• The default timeout timer is 4 hours.
• If a ARP request packet is received and the mapping already exists in the ARP
cache, it will be overwritten with the values present in the request.
Working:
=======
Step 1: When a source device want to communicate with another device, source device
checks its ARP cache to find if it has already a resolved MAC Address of the destination
device. If present, it will use that MAC Address for communication. To view your Local ARP
cache, Open Command Prompt and type command "arp -a” in windows.
Any machine in the LAN has an ARP cache table. This cache table holds multiple ARP
entries. Each ARP entry consists of an ip address and a mac address.
Here, let's stop and think about why there is this cache table? What if not?
ARP cache table operation:--
View current cache table information:
RAKESH https://www.linkedin.com/in/rakesh-sa-b2b664167
Page |4
At the same time, the arp command can also perform delete and add operations
RAKESH https://www.linkedin.com/in/rakesh-sa-b2b664167
Page |5
Step 2: If ARP resolution is not there in local cache, the source machine will generate an
ARP request message, it puts its own MAC address as the Sender Hardware Address and
its own IPv4 Address as the Sender Protocol Address. It fills the destination IPv4 Address as
the Target Protocol Address. The Target Hardware Address will be left blank, since the
machine is trying to find that.
Step 3: The source broadcast the Address Resolution Protocol (ARP) request message to
the local network.
Step 4: The message is received by each device on the LAN since it is a broadcast. Each
device compare the Target Protocol Address (IPv4 Address of the machine to which the
source is trying to communicate) with its own Protocol Address (IPv4 Address). Those who
do not match will drop the packet without any action.
Step 5: When the targeted device checks the Target Protocol Address, it will find a match
and will generate an Address Resolution Protocol (ARP) reply message. It takes the Sender
Hardware Address and the Sender Protocol Address fields from the Address Resolution
Protocol (ARP) request message and uses these values for the Targeted Hardware Address
and Targeted Protocol Address of the reply message.
Step 6: The destination device will update its Address Resolution Protocol (ARP) cache,
since it need to contact the sender machine soon.
Step 7: Destination device send the Address Resolution Protocol (ARP) reply message and
it will NOT be a broadcast, but a unicast.
Step 8: The source machine will process the Address Resolution Protocol (ARP) reply from
destination, it store the Sender Hardware Address as the layer 2 address of the destination.
Step 9: The source machine will update its Address Resolution Protocol (ARP) cache with
the Sender Hardware Address and Sender Protocol Address it received from the Address
Resolution Protocol (ARP) reply message.
RAKESH https://www.linkedin.com/in/rakesh-sa-b2b664167
Page |6
RAKESH https://www.linkedin.com/in/rakesh-sa-b2b664167
Page |7
Step 1: Before resolving the Destination MAC Address corresponding to the IP Address
192.168.0.109, using ARP, source device checks its ARP cache to find if it already has a
resolved MAC Address of the destination device. We can view the ARP cache by using the
command arp –a. Suppose that the ARP cache is empty.
Step 2: Computer [.93] need to resolve the destination MAC address using ARP. It will
prepare an ARP Request message and send it with a Destination MAC Address as
FF:FF:FF:FF:FF:FF (Broadcast MAC Address) to LAN Switch.
If we capture the packet with Wireshark of ARP request Message. We see the below values.
Hardware Type: Ethernet (1)
Protocol Type: IP (0x0800)
Hardware size: 6
Protocol size: 4
Opcode: request (1) ------------------- Means ARP Request
Sender Mac-Address: 00:00:00:00:00:33
Sender IP Address: 192.168.0.93
Target Mac-Address: 00:00:00:00:00:00 -------------- This is all Zero
Target IP Address: 192.168.0.109
We see from the above values that the Destination MAC Address is FF:FF:FF:FF:FF:FF
(Broadcast MAC Address), ARP opcode is 1 (for ARP Request), and the Target MAC
Address is 00:00:00:00:00:00, which is unknown at this instance, the Source IP Address is
192.168.0.93, Destination IP Address is 192.168.0.109, Source MAC Address
00:00:00:00:00:33 and Destination MAC Address is 00:00:00:00:00:00.
RAKESH https://www.linkedin.com/in/rakesh-sa-b2b664167
Page |8
Step 4: The ARP Request message is received by each device on the LAN since it is a
broadcast. Each device compare the Target Protocol Address (192.168.0.109), with its own
IP Address. Those who do not match will drop the packet without any action.
Step 5: When the computer with the IP Address 192.168.0.109 receives the ARP Request, it
must prepare an ARP Reply and send back to the computer who sent the ARP
Request. ARP Reply will be a unicast, to save Network Resources.
If we capture the packet with Wireshark of ARP reply Message. We see the below values.
Hardware Type: Ethernet (1)
Protocol Type: IP (0x0800)
Hardware size: 6
Protocol size: 4
Opcode: request (2) ------------------- Means ARP Reply
Sender Mac-Address: 00:00:00:00:00:44
Sender IP Address: 192.168.0.109
Target Mac-Address: 00:00:00:00:00:33
Target IP Address: 192.168.0.93
Now both the computers can update their ARP cache, so that the MAC Address to IP
Address mappings can be used for a future communication.
ARP - Q&A
----------
What is ARP?
Address Resolution Protocol (ARP) is a network protocol, which maps a network layer
protocol address to a data link layer hardware address. For example, ARP is used to resolve
IP address to the corresponding Ethernet address.
RAKESH https://www.linkedin.com/in/rakesh-sa-b2b664167
Page |9
Why an IP address needs to be mapped to a MAC address, why can't the MAC
address itself is represented using the IP address?
The length of a MAC address is 6 bytes and the length of an IP address is 4 bytes.
Obviously, the MAC address cannot be represented using the IP address. So an IP address
must be mapped to the corresponding MAC address.
RAKESH https://www.linkedin.com/in/rakesh-sa-b2b664167
P a g e | 10
If the IP address to be resolved is for this host, then the ARP module sends an ARP reply
packet with its Ethernet MAC address.
If the IP address to be resolved is for this host, then the ARP module updates its ARP cache
with the source Ethernet MAC address to source IP address mapping present in the ARP
request packet. If the entry is already present in the cache, it is overwritten. If it is not
present, it is added.
If the IP address to be resolved is not for this host, then the ARP module discards the ARP
request packet.
Will a host update its ARP cache upon receiving any ARP request?
A host will update its ARP cache, only if the ARP request is for its IP address. Otherwise, it
will discard the ARP request.
What is the disadvantage if a host updates its ARP cache upon receiving any ARP
request?
The host will exhaust the ARP cache with a lot of unused ARP entries, if it updates the ARP
cache for any ARP request.
Is there a separate packet format for ARP request and ARP reply?
No. Both the ARP request and ARP reply packets use the same format.
If a host is not able to get the MAC address of a host, how it knows about its IP
address?
A host will either use a static file like /etc/hosts or DNS protocol to get the IP address of
another host.
What will happen if an ARP reply is not received for an ARP request?
If an ARP reply is not received, then that IP address cannot be resolved to an Ethernet
address. Without a Ethernet address, the packets cannot be transmitted.
What will happen if a new ARP request packet is received, but the MAC address to IP
address is already present in the ARP cache?
If a ARP request packet is received and the mapping already exists in the ARP cache, it will
be overwritten with the values present in the request.
RAKESH https://www.linkedin.com/in/rakesh-sa-b2b664167
P a g e | 11
Why is the hardware MAC address present in both the Ethernet header and the ARP
packet (request and reply)?
The Ethernet header is processed by the data link driver and removed from the packet.
When the ARP layer gets the packet, it needs to know the hardware and protocol addresses
in order to update the table. That is why the hardware MAC address is present in both the
Ethernet header and the ARP packet.
RAKESH https://www.linkedin.com/in/rakesh-sa-b2b664167
P a g e | 12
When the network interface card in a system is changed, the MAC address to its IP address
mapping is changed. In this case, when the host is rebooted, it will send an ARP request
packet for its own IP address. As this is a broadcast packet, all the hosts in the network will
receive and process this packet. They will update their old mapping in the ARP cache with
this new mapping.
Switches SW1,SW2 and SW3 are interconnected and STP deployed on the switches. PC1
is on SW1 PC2 is on SW2 and PC3 is connected to SW3. All the PC’s are on the same
network address of 192.168.1.0/24. PC1 triggers ARP to find the mac-address of PC3. Will
the ARP packet reach the PC3
All the PC’s are on the same network address. The PC’s are on 3 switches which makes it one
large Layer 2 broadcast domain. So an ARP request which is a layer 2 broadcast will be received
on all the ports on all the switches and correspondingly the PC’s
Some Questions:-
Let's suppose that your router must send a packet to a destination, you have a route
toward the destination in your routing table and this route points to a next hop. For
re-writing the L2 header your router must know the mac address of your next-hop.
Your router will send out an arp request asking for the mac address of the next-hop.
If the next-hop is not answering you will get an incomplete entry in your arp table.
RAKESH https://www.linkedin.com/in/rakesh-sa-b2b664167
P a g e | 13
The bold next-hop does not exist, is a fictive one, let's start a debug and ping
192.168.1.1
R1#ping 192.168.1.1
Type escape sequence to abort.
*Mar 1 00:02:01.971: IP: s=10.10.10.1 (local), d=192.168.1.1 (FastEthernet0/0), len 100, sending
*Mar 1 00:02:03.967: IP: tableid=0, s=10.10.10.1 (local), d=192.168.1.1 (FastEthernet0/0), routed via
RIB
*Mar 1 00:02:03.971: IP: s=10.10.10.1 (local), d=192.168.1.1 (FastEthernet0/0), len 100, sending
*Mar 1 00:02:05.967: IP: tableid=0, s=10.10.10.1 (local), d=192.168.1.1 (FastEthernet0/0), routed via
RIB
*Mar 1 00:02:05.971: IP: s=10.10.10.1 (local), d=192.168.1.1 (FastEthernet0/0), len 100, sending
*Mar 1 00:02:07.967: IP: tableid=0, s=10.10.10.1 (local), d=192.168.1.1 (FastEthernet0/0), routed via
RIB
*Mar 1 00:02:07.971: IP: s=10.10.10.1 (local), d=192.168.1.1 (FastEthernet0/0), len 100, sending
*Mar 1 00:02:09.967: IP: tableid=0, s=10.10.10.1 (local), d=192.168.1.1 (FastEthernet0/0), routed via
RIB
*Mar 1 00:02:09.971: IP: s=10.10.10.1 (local), d=192.168.1.1 (FastEthernet0/0), len 100, sending
RAKESH https://www.linkedin.com/in/rakesh-sa-b2b664167
P a g e | 14
You can see that the router has an incomplete ARP entry, the ping is not working
because the next-hop is not answering and the message "encapsulation failed"
appear in router debug output.
You should check also this link for another case where the proxy arp on the
neighboring router is not enabled (enabled by default) and you have some static
routes that points only to the exit interface instead of next-hop where the medium is
ethernet.
The difference between these 2 is obvious. If no output (anyway you will have at
least some entries due to directly connected interfaces and enabled with an ip
address) means that the router did not had any attempt to find out a mac address of
a neighboring router or some arp entries already expired and you will not see them in
the output. But if the router had tried to find out but no response you will get the
incomplete entry.
3. sh arp Vs sh ip arp
R1#sh arp
Protocol Address Age (min) Hardware Addr Type Interface
Internet 10.10.10.1 - cc00.33b4.0000 ARPA FastEthernet0/0
RAKESH https://www.linkedin.com/in/rakesh-sa-b2b664167
P a g e | 15
R1#sh ip arp
Protocol Address Age (min) Hardware Addr Type Interface
Internet 10.10.10.1 - cc00.33b4.0000 ARPA FastEthernet0/0
sh arp will show you your IP-MAC bindings and as well other bindings if you are
using let's say AppleTalk.
sh ip arp will show you only IP-MAC binding exclusing any other bindings from
another L3 suite like AppleTalk.
But because on most routers you will have only IPv4 enabled both command will
show you the same information.
Check this:
R1#show ?
.
.
.
arp ARP table ------ > the entire ARP table from all L3 suite protocols
R1#show ip ?
access-lists List IP access lists
accounting The active IP accounting database
admission Network Admission Control information
aliases IP alias table
arp IP ARP table ------------ > only IP-MAC bindings
4. In L2 switch, we can give single ip. If we don't give that single ip or simply
we don't have any ip on the switch. So, how ARP works on this L2 switch. what
is the mechanism
If you don't have any ip address on a vlan interface the switch will not use ARP. The
switch will forward information only based on L2 header, it will not touch the L3 so no
need for ARP, thus no need for arp table.
THANK YOU
Rakesh A
RAKESH https://www.linkedin.com/in/rakesh-sa-b2b664167