Location>code7788 >text

ARP protocol

Popularity:612 ℃/2025-04-25 22:16:52

concept

ARP (Address Resolution Protocol) is one of the core protocols in the TCP/IP protocol stack, used to resolve IP addresses to MAC addresses, allowing devices to communicate directly in a local area network (LAN). It works at the data link layer (L2) of the OSI model, but directly serves the network layer (L3)

The core role of ARP

In Ethernet, data frame transmission depends on the MAC address (physical address), but applications usually use IP addresses (logical addresses). ARP is responsible for dynamically mapping the IP address to the MAC address to ensure that the data can be delivered to the target device correctly.

Its core role isMap IP to MAC address

ARP workflow

ARP Request (Broadcast)

The source host sends a broadcast frame and asks the MAC corresponding to the target IP
All hosts on LANs will receive requests, but only hosts with IP matching respond

ARP corresponding (unicast)

The target host unicast reply to its own MAC address
After the source host receives the response, update the local ARP cache table (the cache validity period is usually 2 minutes)

ARP cache

Each host maintains the ARP cache table and stores known IP-MAC maps
View ARP cache

[root@lb ~]# apt install net-tools -y
 [root@lb ~]# arp -n
 Address HWtype HWaddress Flags Mask Ifeface
 10.0.0.2 ether 00:50:56:ec:90:06 C ens33
 223.6.6.6 (incomplete) ens33
 10.0.0.1 ether 00:50:56:c0:00:08 C ens33

 # View via cat /proc/net/arp
 [root@lb ~]# cat /proc/net/arp
 IP address HW type Flags HW address Mask Device
 10.0.0.2 0x1 0x2 00:50:56:ec:90:06 * ens33
 223.6.6.6 0x1 0x0 00:00:00:00:00:00 * ens33
 10.0.0.1 0x1 0x2 00:50:56:c0:00:08 * ens33