Data link layer arp protocol


  Introduction to ARP protocol arp protocol: Computer communication relies on broadcasting, all upper layer packets must be encapsulated with Ethernet headers at the end, and then sent through Ethernet protocol. Communication is based on the broadcast method of mac, but when the computer sends a packet, how to obtain the mac of the target host needs to pass the arp protocol.

  Arp protocol function: send data packets in broadcast mode to obtain the mac address of the target host.

  Protocol working mode: each host IP is known

  In the Ethernet environment, in order to correctly transmit packets to the destination host, the 32-bit IP address of the destination host must be converted into the 48-bit Ethernet address (MAC address) of the destination host. This requires a service or function at the interconnection layer to convert the IP address to the corresponding physical address (MAC address). This service or function is the ARP protocol.

  The so-called "address resolution" is the process that the host converts the target IP address to the target MAC address before sending the frame. The basic function of the ARP protocol is to query the MA address of the target device through the IP address of the target device to ensure the smooth communication between the hosts.

(1) Working example of ARP
  For example: host 172.16.10.10/24 access 172.16.10.11/24

  First distinguish the subnet you are in by ip address and subnet mask

Scenes Packet address
Same subnet Target host mac, target host ip
Different subnets Gateway mac, target host ip

 

 

 

 

 

Then analyze that 172.16.10.10/24 and 172.16.10.11/24 are on the same network (if not the same network, then the target ip in the table below is 172.16.10.1, and the gateway mac is obtained through arp)

 Finally, this packet will be transmitted in the self-network of the sending end in a broadcast manner. After receiving all the hosts, the packet will be unpacked, and if the target ip is found to be its own, it will respond and return to its mac.

Excerpt from blog

Guess you like

Origin www.cnblogs.com/seyOrd/p/12693461.html