Dynamic ARP
Definition
Dynamic ARP entries are automatically generated and maintained using ARP packets. They can be aged, updated, or overwritten by Static ARP entries.
Dynamic ARP applies to a network that has a complex topology and transmits delay-sensitive services.
Address Resolution Process
Dynamic ARP broadcasts ARP Request packets and unicasts ARP Reply packets to complete address resolution.
As shown in Figure 2-1, Host_1 and Host_3 are on the same network segment, and Host_1 needs to send data to Host_3.
- Host_1 searches its local ARP table for the ARP entry of Host_3. If the MAC address of Host_3 is found, Host_1 uses this MAC address to encapsulate the data packet into a frame and sends it to Host_3. If Host_1 does not find the MAC address of Host_3, Host_1 caches the data packet and broadcasts an ARP Request packet. In Figure 2-1, the value 1 of the OP field indicates an ARP Request packet. The source MAC and IP addresses in this packet belong to Host_1, the destination MAC address is all 0s, and the destination IP address belongs to Host_3. For details on the ARP packet format, see ARP Packet Format.
- Router_1 receives the ARP Request packet and forwards it in the same broadcast domain.
- Host_2 and Host_3 in the same broadcast domain can receive the ARP Request packet, but only the destination host (Host_3) processes the packet. Host_3 compares its IP address with the destination IP address in the ARP Request packet. If the IP addresses are the same, Host_3 adds the source IP and MAC addresses (IP and MAC addresses of Host_1) in the packet to the local ARP table, and then unicasts an ARP Reply packet to Host_1. In Figure 2-1, the value 2 of the OP field indicates an ARP Reply packet. The source MAC and IP addresses in this packet belong to Host_3, and the destination MAC and IP addresses belong to Host_1.
- Router_1 receives the ARP Reply packet and forwards it to Host_1. After receiving the ARP Reply packet, Host_1 adds the MAC address of Host_3 to the local ARP table. At the same time, Host_1 encapsulates the data packet in a frame and forwards it to Host_3.
When two hosts on different network segments need to communicate with each other (for example, Host_1 and Host_4 in Figure 2-1), and the default gateway address has been set on Host_1, Host_1 sends an ARP Request packet to request the MAC address mapping the router's IP address. After receiving an ARP Reply packet from the router, Host_1 encapsulates the data packet and sends it to the gateway. The gateway then forwards the data packet to the destination host (Host_4). The ARP address resolution procedures on Host_1, Host_4, and the gateway are the same as those on Host_1 and Host_3, and are not mentioned here.
ARP Aging Mechanism
If Host_1 broadcasts an ARP Request packet every time it sends data to Host_3, as shown in Figure 2-1, the communication traffic on the network will increase. In addition, all the devices in the same broadcast domain need to receive and process this ARP Request packet, greatly reducing the device running efficiency on the network. To solve the preceding problems, each host or device maintains a high-speed ARP cache, which is the key to the efficient ARP operations. This high-speed cache stores the mapping between IP and MAC addresses (that is, dynamic ARP entries) recently learned by the host or device.
A host or device first queries the local high-speed cache for the MAC address mapping the destination IP address every time it sends a packet. If the MAC address is found, the host or device no longer sends an ARP Request packet but directly sends the data packet to the MAC address. If the MAC address is not found, the host or device broadcasts an ARP Request packet for ARP address resolution.
The device ages and updates dynamic ARP entries to ensure that the capacity limit of the high-speed cache is not exceeded and the ARP entries in the cache are correct.
The aging parameters of a dynamic ARP entry include: aging time, number of aging probe attempts, and aging probe mode. After the aging time of a dynamic ARP entry expires, the device sends an aging probe packet (ARP Request packet) to detect whether the peer device is present. If the device receives an ARP Reply packet, it updates this dynamic ARP entry and the aging probe procedure ends. If the device does not receive an ARP Reply packet after the configured aging probe attempts, it deletes the dynamic ARP entry and the aging probe procedure ends.
The aging probe packet can be a unicast or broadcast packet.
The device deletes the corresponding dynamic ARP entries immediately when an interface goes Down.
ARP Packet Format
Figure 2-2 shows the format of an ARP Request or Reply packet.
The length of an ARP packet is 42 bytes. The first 14 bytes indicate the Ethernet frame header, and the last 28 bytes are the content of the ARP Request or Reply packet. Table 2-1 describes each field in an ARP packet.
Field |
Length |
Description |
---|---|---|
Ethernet destination MAC |
48 bits |
Ethernet destination MAC address. When the device sends an ARP Request packet, the value of this field is the broadcast MAC address 0xffff-ffff-ffff. |
Ethernet source MAC |
48 bits |
Ethernet source MAC address. |
Frame type |
16 bits |
Data type. The value of this field is 0x0806 in an ARP Request or Reply packet. |
Hardware type |
16 bits |
Type of the hardware address. The value of this field is 1 for an Ethernet. |
Protocol type |
16 bits |
Type of the protocol address to be mapped on the sender. The value of this field is 0x0800 for an IP address. |
Hardware address length |
8 bits |
Hardware address length. The value of this field in an ARP Request or Reply packet is 6. |
Protocol address length |
8 bits |
Protocol address length. The value of this field in an ARP Request or Reply packet is 4. |
OP |
16 bits |
Operation type. The values are as follows:
|
Source MAC |
48 bits |
Source MAC address. |
Source IP |
32 bits |
Source IP address. |
Destination MAC |
48 bits |
Destination MAC address. When the device sends an ARP Request packet, the value of this field is 0x0000-0000-0000. |
Destination IP |
32 bits |
Destination IP address. |