Linux Network Architecture

   

As mentioned above, the Address Resolution Protocol (ARP) is a decentralized protocol to resolve address mappings between layer-3 addresses and layer-2 addresses in local area networks. Figure 15-1 shows how ARP works. When computer A wants to send a packet to router R in the same LAN, then it needs the layer-2 address, in addition to the IP address, to be able to tell the data link layer which computer is supposed to get this packet. For this purpose, computer A sends an ARP Request to all computers connected to the LAN. This request is generally sent in a MAC broadcast message by using the MAC broadcast address (FF:FF:FF:FF:FF:FF). The intended computer can see from the destination IP address in the ARP PDU that this request is for itself, so this computer returns a reply to the requesting computer, A, including its MAC address. Computer A now learns the MAC address of R and can instruct its data-link layer to deliver the packet.

Figure 15-1. Example showing how ARP resolves addresses.

To avoid having to request the MAC address again for subsequent packets, A stores the MAC address of R in a local table the ARP cache. (See Section 15.3.) Computer R can also extract the MAC address of A from A's request and store that in its own ARP cache. It can be seen from A's request that A and R will communicate soon, which means that the MAC address of A will be needed. In this case, we avoid one ARP request, because the mapping will have been previously stored.

15.1.1 The Structure of ARP Protocol Data Units

Figure 15-2 shows how an ARP PDU is structured; this PDU is used for the two protocol data units defined in the ARP protocol, ARP Request and ARP Reply. The only difference between these two types is in the Operation field.

Figure 15-2. Format of the ARP Request and ARP Reply PDUs.

Figure 15-3 uses the above example to show how values can be assigned to the two PDUs. Computer A sends a request to router R, as shown in Figure 15-1, asking for that computer's 48-bit MAC address (say 129.25.10.11) in the local Ethernet segment.

Figure 15-3. Example with values in the ARP Request and ARP Reply PDUs from Figure 15-1 (not considering the network byte order).

The fields of an ARP PDU and their meanings are as follows:

  • ARP packets are transported in the payload field of MAC protocols. The identification as an ARP PDU is done specifically by the MAC protocol (e.g., in the Protocol field for Ethernet or by an appropriate identifier in the SNAP header).

  • Hardware Type specifies the layer-2 protocol used (e.g., 1 for an Ethernet network).

  • Protocol Type specifies the layer-3 protocol used (e.g., 0x0800 for the Internet Protocol).

  • Layer-2 Address Length: n specifies the length of the layer-2 address used (in bytes). This field takes the value 6 for an 48-bit MAC address. Specifying the address length enables the use of different protocols with specific address formats.

  • Layer-3 Address Length: m specifies the length of the layer-3 address. The field takes the value 4 for 32-bit Internet addresses.

  • The Operation field specifies the type of ARP PDU? for ARP Request, 2 for ARP Reply. In addition, the PDU types RARP Request (3) and RARP Reply (4) were defined for RARP [FMMT84]).

  • The fields Layer-2 Sender Address and Layer-2 Destination Address consist of n bytes and include the appropriate layer-2 addresses.

  • The fields Layer-3 Sender Address and Layer-3 Destination Address have the length m bytes and include the layer-3 addresses of the requesting and the receiving station.

15.1.2 Receiving an ARP Packet and Replying

As was mentioned earlier, ARP Request and ARP Reply PDUs have the same packet format; they differ only in their Operation fields. An ARP Request packet also differs from a subsequent reply by the missing layer-2 address of the destination, so that it is easy to create a reply to a request. When receiving a request packet, in which the desired station finds its layer-3 address, the following steps are completed:

  • The layer-2 address of the network adapter is inserted in the field Layer-2 Destination Address.

  • The two address fields for the sender and the destination are swapped.

  • The Operation field takes value 2 to mark the PDU as ARP Reply.

  • Finally, the reply packet is sent.

An ARP request includes a valid mapping between the layer-3 address and the layer-2 address of the request initiator, in addition to the layer-3 address looked for, so one entry for the initiator is created in the ARP cache when the request is received.


       

    Категории