In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >
Share
Shulou(Shulou.com)06/01 Report--
1: Introduction
When a network device wants to send data to another device, it must know the network layer address (i.e. IP address) of the other device. IP addresses are provided by the network layer, but IP addresses alone are not enough; IP packets must be encapsulated into frames before they can be sent over the data link. The data frame must contain the destination MAC address, so the sender must also obtain the destination MAC address. The process of obtaining the destination MAC address from the destination IP address is implemented by the ARP protocol.
ARP protocol is an important part of TCP/IP protocol cluster. ARP can discover MAC address of target device through destination IP address, thus realizing reachability of data link layer.
2: ARP packet format
Note: ARP packets cannot traverse routers and cannot be forwarded to other broadcast domains.
Meaning of each field:
Hardware Type indicates the hardware address type, usually Ethernet
Protocol Type indicates the type of Layer 3 protocol address, usually IP.
Hardware Length and Protocol Length are the length of MAC address and IP address in bytes.
OPeration Code specifies ARP message types, including ARP request and ARP reply.
Source Hardware Address refers to the MAC address of the device sending the ARP message.
Source Protocol Address refers to the IP address of the device sending the ARP message.
Destination Hardware Address refers to the MAC address of the receiver. In ARPrequest message, this field value is 0.
Destination Protocol Address refers to the IP address of the recipient.
III: ARP's working process
ARP Simple Request Reply
When two computers communicate on the same local area network, we take the ping command as an example, which uses the ICMP protocol
PC1 encapsulates the data from top to bottom according to OSI model ①, including the encapsulation of ICMP Date plus IP header, but when it comes to encapsulating MAC address, ② PC1 first queries its ARP cache table and finds that there is no mapping between IP2 and its MAC address. At this time, MAC data frame encapsulation fails. When we use the ping command, it specifies IP2 of PC2. The computer knows the IP address of the destination host and can complete the data encapsulation at the network layer. Because the device communication also needs the MAC address of the other party, but PC1 does not have it in the cache table, so the destination MAC address cannot be filled in when MAC encapsulation is performed.
Then, in order for PC1 to obtain the MAC address of PC2, ③ PC1 needs to send inquiry information to inquire about the MAC address of PC2. The inquiry information includes the IP and MAC address of PC1 and the IP address of PC2. Here, we think of a question. Even if it is inquiry information, it is also necessary to encapsulate MAC data frames. What is the destination MAC address of this inquiry information? It is stipulated that when the destination MAC address is ff-ff-ff-ff, it means that this is inquiry information, even if it is broadcast that I will talk about later.
After PC2 receives this query message, it adds IP1 and MAC1 (IP and MAC of PC1) to the local ARP cache table, and then PC2 sends a response message to encapsulate the data with IP and MAC and send it to PC2, because the cache table already has the mapping of IP and MAC of PC1. This response message contains IP2 and MAC2 for PC2. PC1 receives this response message, and as a matter of course, it obtains the MAC address of PC2 and adds it to its cache table.
After this interactive question-and-answer, PC1 and PC2 both obtain the MAC address of the other party. It is worth noting that the destination host completes the ARP cache first, and then the source host completes the ARP cache. PC1 and PC2 can communicate.
ARP Broadcast Request Unicast Response
The diagram above is an incomplete ARP protocol, because there will not be only two hosts in the local area network. Here, we must consider how to obtain the MAC of the destination host among the many hosts in the local area network.
As above, PC1 does not know the MAC address of PC2 at first, so it also needs to send ARP request. However, there are many hosts in this local area network. How can we only get the MAC address of PC2? ① We think that we can communicate with a group of strangers one by one. This is what we want to say. First, PC1 broadcasts and sends inquiry information (the information is the same as that introduced in the previous picture). Devices connected to this ordinary switch will receive the inquiry information sent by PC1.
(2) Next, all devices on the switch need to judge the query information. If their respective IP is inconsistent with the IP to be queried, they discard the query information, as shown in Figure PC3 and Route, while PC2 judges that the query information meets the consistent requirements, accepts it, and similarly writes the IP and MAC of PC1 into its own ARP mapping table.
Finally, PC2 unicasts a response message to PC1, telling PC1 its IP and MAC addresses.
IV: ARP proxy
In the above figure, when host A needs to communicate with host B, the destination IP address and host IP address are located in different networks, but since host A does not have a gateway, it will send an ARP Request message in the form of broadcast to request the MAC address of host B. However, the broadcast message cannot be forwarded by the router, so host B cannot receive the request message from host A.
This problem can be resolved by enabling proxy ARP on the router. When the proxy is enabled, the router receives such a request and looks up the routing table. If there is a routing table entry for host B, the router will reply to the ARP requester with the MAC address of its G0/0/0 interface. After receiving the ARP Reply, host A forwards the data using the MAC address of the G0/0/0 interface with paint on one path as the destination MAC address.
Summary: 1 If two hosts are on the same network segment, send an ARP Request message directly.
2 If in different network segments,(1) Host A set up a gateway, ARP protocol can be used normally.
(2) Host A does not have a gateway. In this case, we need to turn on ARP proxy, and the router will re-encapsulate and forward the packet.
5: Free ARP
Host A sets the destination IP address field in the ARP Request broadcast message to its own IP address, and all hosts in the network will receive this message. When the destination IP address has been identified by a host or network management roommate, the host or gateway will respond with an ARP reply message. In this way, host A can detect the IP address collision.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.