Thursday, December 9, 2021

Ethernet switching - The working mechanism of a layer 3 switch

In the current live network environment, we can always see that it is the core switch like Huawei CE6800 switch that processing the data forwarding. You might be curious about that, isn't the switch forwarding Layer 2 data packets? Why are switches used at the core layer to forward data packets? Can the switch also handle IP packets? In this chapter, we will give you a detailed introduction to the working mechanism of the three-layer exchange.

As mentioned above, switches can be divided into layer 2 switches such as Huawei S1700 S2700 series and layer 3 switches, and Layer 3 switches can also forward IP packets based on the routing table, the same as routers. Is the working mechanism the same as that of routers? Obviously, the answer is no. Before comparing the forwarding process of the two in detail, let's briefly introduce the forwarding process of the three-layer switch, so that everyone can understand the forwarding process of the data packet in the layer 3 switches in more detail. For the forwarding of Layer 2 packets in the same network segment, the processing mechanism of the Layer 3 switch is the same as that of the Layer 2 switch, which is based on the destination MAC address. We will skip that part in this chapter. We are mainly concerned about the layer 3 IP packet forwarding across the network segment.

Brief architecture of the layer 3 switch

Figure 1: Brief architecture of the layer 3 switch

ASIC: Charge in layer 2 and layer 3 forwarding functions, including the MAC address table for layer 3 forwarding and the layer 3 forwarding table for IP forwarding;

CPU: Used for forwarding control. It mainly maintains software entries (including software routing tables, software ARP tables, etc.), and configures the ASIC's hardware layer 3 forwarding table according to the forwarding information of the software entries. Of course, the CPU itself can also complete the software three-layer forwarding.

Brief architecture of the layer 3 switch

Figure 2PC A and PC B communicate across network segments

Assuming that PC A wants to communicate with PC B that is not on the same network segment, we will introduce the entire communication process in detail as follows:

  1. PC A realizes that PC B is not in the same network segment as itself, and it will send an ARP request message to request the MAC address of the gateway, that is, the MAC address of the switch.

  2. After receiving the ARP request, the switch responds with an ARP reply message to PC A. At the same time, it will also record the MAC address and IP address of PC A in the ARP table.

  3. PC A encapsulates the data packet (source IP: PC A, destination IP: PCB, source MAC: PC A, destination MAC: switch) and sends it to the switch.

  4. After the switch receives the modified message, it looks up the source MAC of the message and the VLAN where the port is located to update the MAC address table and then looks up the MAC table according to the destination MAC and VLAN number for forwarding (this is a layer 2 forwarding mechanism). But the switch discovers that the destination MAC is the MAC table of its own Layer 3 interface, and the switch realizes that this packet is either sent to itself or needs to be forwarded at Layer 3. Therefore, the switch searches for the three-layer table entry of the switching chip according to the destination IP. Since notable entry has been created before, the search fails. Then, the switch sends the message to the CPU for processing.

  5. The CPU searches the routing table according to the destination IP of the message, finds the matching item (if there is no match, the message will be discarded), and continues to look up the software ARP table, but the corresponding entry is not found.

  6. The switch sends ARP request packets on all interfaces of the VLAN corresponding to the destination IP, requesting the MAC address of the destination IP.

  7. PC B responds to the ARP reply message after receiving the request. After the switch learns the MAC, it will also record the corresponding data and send the message from PC A to PC B to complete the transfer from PC A to PC B. Communication.

From PC B to PC A, since the forwarding entry has been established on the switch, subsequent messages will not be sent to the CPU, and the table lookup and forwarding process will be completed directly on the forwarding chip.

It can be known from the above process that ASIC plays an extremely important role in the forwarding process of the layer 3 switches. It can realize fast forwarding after establishing the layer 3 forwarding entry after the first communication process, thereby eliminating the need for continuous lookup of the routing table. The mechanism not only speeds up the forwarding process but also saves the occupation of system CPU resources. This is also a huge difference compared to router layer three forwardings.

Back to the question at the beginning of this chapter, why the core device of the network is often the core switch because the destination IP address of the devices in the same network to exchange data with each other is very limited, when the establishment of the layer 3 forwarding table is completed, the core switch Data will be forwarded very efficiently. For data accessing the Internet, routers will have better processing capabilities than Layer 3 switches due to the vastly different destination addresses.

No comments:

Post a Comment