Computer network total five ARP and RARP

Introduction

ARP and RARP are both network layer protocols, but they are to solve the problem of frame forwarding at the link layer. The function of ARP is to resolve IP into MAC addresses, while RARP is the opposite.
Insert picture description here

In the ps textbook, the ARP protocol is assigned to the network layer because the ARP protocol belongs to the TCP/IP protocol suite. In the TCP/IP model, all its defined protocols are on the Internet layer. According to the OSI standard, each layer will add its own information when the data is transmitted. When the IP packet of the network layer enters the link layer, the link layer adds link information through the ARP protocol, which is not a function of the network layer. So many people say that ARP is at the link layer.
This can be done. In the OSI model, the ARP protocol belongs to the link layer; in the TCP/IP model, the ARP protocol belongs to the network layer. We have to do the exam according to the textbook and connect to the network layer.
It doesn't make any sense to talk about what layer the ARP protocol belongs to.

One ARP

Address Resolution Protocol (Address Resolution Protocol), its basic function is to query the MAC address of the target device through the IP address of the target device.

  1. First, each host has an ARP list to cache the correspondence between IP addresses and MAC addresses.
  2. When the source host wants to send data, it first checks whether there is the MAC address of the host corresponding to the destination address of the IP address in the ARP list, and if so, it sends the data directly. If not, send an ARP data packet to all hosts in this subnet in the form of broadcast . The data packet includes: source host IP address, source host MAC address, and destination host IP address.
  3. When all hosts on this network segment receive the ARP packet, they first check whether the IP address in the packet has its own IP address, if not, ignore the packet. If so, first take out the IP and MAC address of the source host from the data packet and write it into the ARP list. If it already exists, overwrite it, and then write its own MAC address into the ARP response packet to tell the source host that it is it. The MAC address you want to find.
  4. After the source host receives the ARP response packet, it writes the IP and MAC addresses of the destination host to the ARP list, and uses this information to send data. If the source host has not received the corresponding ARP packet, it means that the ARP query has failed. The ARP request is sent by broadcast, and the ARP response is sent by unicast.

Four typical situations of using ARP protocol

(1) The sender is the host, and the IP data needs to be sent to another host on the local network. At this time, use ARP to obtain the MAC address of the destination host.
(2) The sender is a host. To send IP data to a host on another network, you need to use ARP to obtain the MAC address of the router and send the data to the router. The router completes the network crossing between different routers. The data transmission is in situation (4) at this time, and when it reaches the router of the target network, it is in situation (3).
(3) The sender is a router, and the IP data needs to be sent to a host on the local network. At this time, ARP is used to find the IP address of the target host.
(4) The sender is a router and needs to forward the IP data packet to a host on another network. At this time, ARP is used to find the next hop router to the host, and the subsequent work is completed by the next router.
(When the router receives ARP, it chooses which port to transmit, and it uses the router's routing algorithm to judge)

Two RARP

RARP is to convert the MAC physical address into an IP address. RARP also has request and reply, and RARP request is also broadcast without a target address; RARP reply also has a target address, which is also unicast . These two points are the same as ARP. It seems that although it is only the reverse operation of the ARP protocol, the complexity of the design of the RARP server far exceeds that of the ARP server. First of all, the ARP server exists in the kernel, and the RARP server is only a user process, and RARP is somewhat "innately deficient". Secondly, RARP is to find the IP address corresponding to the physical address, which shows that there is no IP address in the RARP request packet packet, and naturally it cannot be forwarded through the router. Because the router works at the network layer, the protocol of the network layer is the IP protocol. ARP request can be forwarded by the router because there is an IP address field in the ARP request packet, but the RARP request packet does not, so the router does not have RARP. Helped.

RARP also has a mechanism, that is, there are multiple RARPservers in each network. I guess this may be to increase the reliability, it is the design concept of the master-slave server. The source address generally only accepts the first RARP reply. With multiple servers, conflicts may naturally occur. Therefore, the RARP server is designed like this: Generally, there is a main server that sends RARP reply immediately after receiving the request, without sending delay; and even if other servers receive the request, they will send the reply after a random sending delay, and Generally, the reply can be sent only after receiving the repeated second request within a short period of time. Because if these secondary servers all receive the same request for the second time, then the primary server is generally down in this case.

The working principle of RARP:

1) Set the MAC address fields of the source device and the target device to the MAC address and IP address of the sender, and the sending host sends a local RARP broadcast that can reach all devices on the network. In this broadcast packet, declare your own and requests the MAC address of the RARP server receives any request to assign an IP address;
2) after the RARP server on the local network receives this request, check the RARP list, find the IP address corresponding to the MAC address;
3) If present, RARP server give the source host sends a response packet and the IP address provided to the other host used; if not, RARP server which is not any response;
4) from the source host receives the RARP server In response to the information, use the obtained IP address for communication; if the response information from the RARP server has not been received, it indicates that the initialization has failed.

Guess you like

Origin blog.csdn.net/GreedySnaker/article/details/115063741