ARP protocol basis

ARP

What is the ARP protocol

The ARP protocol is able to resolve an IP address from the IP address of the device's MAC address, called (Address Resolution Protocol) address resolution protocol

Workflow ARP address

  1. When one host to another host A wants to send to the B segment in (local area network) (network layer packets) such as IP datagram, it first queries the host an ARP cache table maintained - ARP cache table (IP - MAC mapping table), if there is no table entry the MAC address corresponding to the IP, it sends an ARP request packet (see below), and fill the sender MAC address and IP address of the sender, and the destination IP address, destination MAC address is then changed to ff: ff: ff: ff: ff: ff

    Scenario simulation: the equivalent of Host A: "My IP address is 10.0.0.1 MAC address is xxxx, may I ask what the MAC address of 10.0.0.2 is?"

  2. This message will be broadcast on the LAN, each host can receive the ARP packet, Host run ARP process receives the message, check

    If its own IP address and message in the same destination IP address, the datagram is received, rewrite the ARP packet in the field, fill in their own MAC address, put their address into the source IP address, as above, as ARP response message unicast to the source ARP sender.

    Scenario simulation: the equivalent of Host B: "I am my MAC address is 10.0.0.2 yyyy"

  3. ARP cache (ARP Cache) Each entry is survival time, because there may be one of the entries in the MAC address changes (such as changing the card), do not update, it is not correct. (30 - 20 minutes)

 

ARP request packets

 

Application in different LAN ARP

ARP application discussed above in the same local area network, because the same network segment, it is delivered directly.

When the two hosts in different LANs time, IP datagram to go through another router into the LAN.

  1. FIG: PC H1 -> Router R1 (Gateway) -> PC H3 -> Router R2 (Gateway) -> PC H4

  2. H1 want to send an IP datagram to H4, and then check the destination IP address is not found H4 themselves in this segment,

    So I want this datagram sent R1.

  3. H1 check their ARP cache, R1 is not found in the MAC address, but the IP address of R1 (gateway address settings),

    It sends an ARP request packet, and finally fill the MAC address destination MAC address of R1. The datagram is then sent to R1

  4. After R1 receiving this data packet, the data link layer processing this frame, the destination MAC address found in the frame of their own, so

    The header removed, remove the IP packet, the destination IP address, routing table, find the next hop router for this purpose networks.

    Then the datagram sent to that port out.

    Before sending, because only recognizes the link layer MAC address, so fill yourself this port to be sent in the source MAC address in

    MAC address, and receiving the query to the next hop router port MAC address with ARP, which fill one frame of the destination MAC address

  5. And finally to the R2 - during that period H4, R2 is directly delivered to the H4.

 

important question

Why IP address, MAC address can not be directly used to achieve communication between heterogeneous networks?

Answer: Because the MAC address is very complex, but also for users, the ability to identify this address unfriendly, but if the alternative IP to each MAC address, then the routing table becomes very large, very complex.

Think, with the IP address, I just need to send to the gateway, you can go out, and after they get out, to the next router, the router just need to find the next hop router, the rest on to the link layer switch go forward, and this layering, division of thought, in fact, is to simplify the complicated and big problem, so very reasonable.

 

Guess you like

Origin www.cnblogs.com/zhanp/p/10931650.html