ARP Address Resolution Process (the same subnet and different subnets)

Source: Internet
Author: User

During ARP Address Resolution (the same subnet and different subnets), the most familiar network can be said to be Ethernet, and people know that each network card has a number, that is, the NIC address (MAC address) represents the physical address of the computer. In addition, each computer in the network is assigned an IP address, so that each computer has two addresses, IP address and MAC address. The IP address cannot replace the MAC address. The former is used to facilitate host locating in the large network. If the network size is small, the IP address is completely unavailable. However, no matter what network environment physical address is used. Because the physical address corresponds to the interface of the network card, it can only be found to truly reach the destination. IP addresses are used to facilitate addressing of artificially divided address formats. Therefore, IP addresses are also known as logical addresses because these structured addresses are defined at the OSI Layer 3rd, it is also called a layer-3 address. Correspondingly, physical addresses are defined at Layer 2. An IP address is a common format. No matter what type of physical address is next to it, it can be unified to the same IP address format. Therefore, the IP address shields the differences between the physical addresses at the lower layer. Since the IP address cannot replace the physical address, it only logically represents a host, and the physical address corresponds to the interface of the NIC. Only when it is found can the data be sent to the destination. How to match the two is the first problem to be solved, because they represent the same machine. For this reason, we have developed the Address Resolution Protocol (ARP), which maps IP addresses to physical addresses. The following describes how ARP works: arp in the same subnet and arp between different subnets. (1) ARP host A (172.16.20.20/24) in the same subnet communicates with host B. Assume that the IP address 172.16.20.5/24 of host B is pinged on server. To send test information to host B and host A, IP packets about Ping are constructed. You can confirm that the source IP address in the header is 172.16.20.20 and the destination address is 172.16.20.5. After the IP packet is constructed, it needs to be sent from the NIC. Before that, the two-layer frame header must be encapsulated. In this example, the two layers are Ethernet environments, therefore, an Ethernet frame header must be constructed. Analyze the MAC address in the frame header. The source address should be 00-0C-04-18-19-aa. This address is easy to obtain. host a can directly obtain it from its Nic, the destination MAC address in the frame header should be 00-0C-04-38-39-bb, which corresponds to the MAC address of host B. How does host A know the MAC address of host B? This is A problem that must be solved when host A encapsulates the two-layer frame header; otherwise, the frame cannot be sent out. The only way for host A is to ask host B, ask host B to answer what its MAC address is. ARP is responsible for this task, that is, obtaining the corresponding physical address from the IP address of the target node. The ARP operation procedure is as follows. ① Host A sends an ARP request. The data in the request Frame includes the sender's MAC address 00-0C-04-18-19-aa, the sender's IP address 172.16.20.20, and the target MAC address. All the data in the request frame is filled with 0, because it is unknown (this is what ARP is going to ask), the target IP address is 172.16.20.5. ② In the frame header of the Request frame, the target MAC address is the broadcast address. Therefore, all the websites (including host B) that receive the request open the frame to view the content of the data part. ③ Only host B that meets the target IP address 172.16.20.5 will respond to this ARP request. Other Sites will ignore this request. ④ Host B writes its MAC address to the "target address" field and sends it to host. Host A obtains the MAC address of host B through ARP operations. It can continue to complete its encapsulation process and finally perform the Ping operation. After receiving a response, the ARP requestor constructs an ARP table in the cache and caches the obtained address information for future connection to the ARP table, avoid Multiple broadcast requests. In fact, the complete operation process is: When host A is preparing to construct A two-layer frame header, it first searches for the ARP table based on the destination IP address. If the corresponding item is found, the target MAC address is obtained directly, if not found, execute the ARP broadcast request mentioned above. This is done to minimize the number of broadcasts. (2) ARP between different subnets assumes that the IP address of host B is pinged to 172.16.20.5/24 on host A (172.16.10.10/24). Then host A constructs IP packets for Ping, this process is the same as the previous one, but the destination address is in another sub-network. Host A still faces the problem of how to determine the target MAC address in the two-layer frame header. If the target node is still in the same subnet as the source node, the target MAC address should be the MAC address of host B Nic. Follow these steps to see what will happen. Because host B is located on the other side of the router, if host B wants to receive the Ethernet frame sent by host A through the router forwarding, will the router forward it? The answer is no. After A vromac receives an Ethernet frame, it first checks the target MAC address. Assume that the destination MAC address in the frame sent by A is the NIC address of B. After the vroethernet receives the frame from the Ethernet 0 interface, view the target MAC address and find that it is not your own MAC address, and then discard it. In this case, the target MAC address cannot be the physical address of the target host during communication between hosts in different subnets. In fact, host communication between different subnets goes through the routing process. In this case, vroa A is required for forwarding. Therefore, when host A finds that the target host is not in the same subnet as itself, it must use A router. It needs to send the data frame to the router, and then the router will continue to forward to the target node. In this example, when host A finds that host B is in A different subnet, it must send the data frame to the router, therefore, you need to write the MAC address of Ethernet 0 on the "Destination Address" Field of the frame header. Therefore, host A needs to use ARP to query the MAC address of the Ethernet 0 interface of the router. There are still two operations, one is ARP request, and the other is ARP response. However, in the request frame of ARP, the target IP address will be the IP address of the router Ethernet 0 interface, which is actually the default gateway of the host in the subnet 172.16.10.0/24. After receiving the ARP request, the router answers the MAC address of its Ethernet 0 interface, so that host A obtains the MAC address of its default gateway. Host A constructs A complete data frame and sends it to the router. After the router receives data from host A, it sends the data to host B from the other interface Ethernet 1 according to the route table instructions. Similarly, the router also needs to encapsulate a layer-2 frame header before sending, and also needs to know the MAC address of host B. The router also obtains the MAC address of host B through ARP. Based on the above two cases, the complete operation process of host A is as follows: host A first compares whether the destination IP address and its own IP address are in the same subnet. If it is in the same subnet, send an ARP broadcast to this website to obtain the MAC address corresponding to the target IP address. If the IP address is not in the same subnet, use ARP to ask the MAC address of the default gateway.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.