ARP and the working principle in LAN

As we know at the Network layer of the OSI model, we often use conventional types of addresses such as IP, IPX . These addresses are divided into two separate parts: the network address (NetID). and machine address (HostID). Such an addressing scheme makes it easier to find links from one network to another. These addresses can be changed according to user preferences.

In fact, network cards (NICs) can only connect to each other according to the MAC address, fixed and unique addresses of the hardware. Therefore we must have a mechanism to convert these types of addresses back and forth. From there we have the address resolution protocol: Address Resolution Protocol (ARP).

Working principle of ARP in a LAN

Picture 1 of ARP and the working principle in LAN When a network device wants to know the MAC address of a network device that already knows the address at the network layer (IP, IPX .) it sends an ARP request including its MAC address and IP address. of the device it needs to know the MAC address across an entire broadcast domain. Each device that receives this request will compare the IP address in the request with its network layer address. If the address is the same, the device must send it back to the device to send a packet ARP request (which contains its MAC address). In a simple network, for example, PC A wants to send the packet to PC B and it only knows the IP address of PC B. Then PC A will have to send an ARP broadcast to the entire network to ask "where What is the PC's MAC with this IP address? " When the PC B receives this broadcast, it compares the IP address in this packet with its IP address. Realizing that the address is your address, PC B will return a packet to PC A which contains the MAC address of B. Then PC A will begin transmitting packets to B.

ARP operating principle in network environment:

The operation of ARP in a more complex environment is that the two networks are tied together by a Router C. Machine A of Network A wants to send packets to machine B of network B. Because the broadcast cannot be transmitted through the router. therefore, machine A will see Router C as a bridge or an intermediary (Agent) for data transmission. Previously, machine A will know the IP address of Router C (Gateway address) and know that to transmit packets to B must go through C. All such information will be contained in a table called a table routing (routing table). Routing table according to this mechanism is kept in each machine. The routing table contains information about the Gateway to access a certain network. The example in the above case in the table will indicate that to go to LAN B must go through port X of Router C. The routing table will contain the IP address of port X. Data transmission process follows:

  1. Machine A sends an ARP request (broadcast) to find the MAC address of port X.
  2. Router C answers, give the machine A MAC address of port X.
  3. Machine A transmits the packet to Router X port.
  4. The router receives the packet from host A, which transfers the packet to the router's Y port. The packet contains the IP address of machine B. The router sends an ARP request to find the MAC address of machine B.
  5. Machine B will respond to the router knowing its MAC address. After receiving the MAC address of machine B, Router C sends the packet of A to B.

In fact, in addition to this routing table format, the proxyARP method is also used, including a device that performs address resolution for all other devices. Accordingly, the workstations do not need to hold the routing table. again Router C will perform the task, responding to all ARP requests of all machines.