The principle of three-layer switching

1. Three-layer switching technology

1. What is a Layer 3 switch?

To achieve inter-VLAN communication, routing is required. The solution is either to use a layer 2 switch plus a router to form a single-arm routing, or to directly use a layer 3 switch.

①What is single-arm routing:

②The principle of single-arm routing to achieve communication between different vlans:

The router re-encapsulates the mac address and converts the vlan label

③Disadvantages of single-arm routing:

① The "single arm" is the backbone link of the network and can easily form a network bottleneck.

②The sub-interface relies on the physical interface and is inflexible in application.

③Forwarding between VLANs requires checking the routing table, which wastes resources.

2. Layer 3 switch

Layer 3 switch: essentially a "(layer 2) switch with routing function". Routing belongs to the third layer network layer function in the OSI reference model, so it is called a "layer three switch".

①Principle of three-layer switch

Use three-layer switching technology to realize communication between different vlans

Layer 3 switching = Layer 2 switching + Layer 3 forwarding

Principle: When a layer 3 device receives a data frame, it will dismantle the source data frame and re-encapsulate the new source MAC address and destination MAC address. And because the information in the frame header changes, the final frame check CRC should also follow. Change.

Among the multiple data packets in this data flow, only the first data packet is processed by the Layer 3 engine of Layer 3 switching. The processing method is software. The same as the router, the Layer 3 engine obtains the new Layer 2 After encapsulating the information, the packet is routed.

②Principle of hardware forwarding of three-layer switch

Route once, exchange many times

The routing table will only be searched once, and then a mis entry will be formed. Subsequent packets will be forwarded according to the mis entry.

2. Layer 3 switch implementation

1. Traditional MLS

Route once, switch many times

When using traditional MLS, the switch forwards the first packet in the data flow to the Layer 3 engine, which processes the packet in a software switching manner. After processing the first packet in the data flow, the Layer 3 engine programs the hardware switching organization that routes subsequent packets.

This process is called "once routing, many switching", which means that the switch's Layer 3 engine only needs to process the first packet in the data flow, and all subsequent data is forwarded by the hardware. This achieves line-speed forwarding of three-layer switching.

2. CEF-based MLS

Different from traditional MLS, CEF learns routing information in advance based on the routing table (correspondence between ip address and interface) and directly stores it in the FIB (forwarding information base). CEF generates an adjacency table in advance based on the ARP table (correspondence between IP address and MAC address) and forwards it directly by hardware. Traditional MLS requires software to query the routing table at least once and establish a forwarding entry before forwarding can be done by hardware.
FIB (forwarding information base): Correspondence between IP address and VLAN ID

Adjacency table: the corresponding relationship between adjacent hosts and switch MAC addresses

3. Virtual interface

Layer 3 switches have routing functions, so two vlans can access each other. Each vlan virtual interface is the gateway of the network segment.

4. Summary

①: VLAN is the logical division of the switch: broadcast, security, simplified management

②: Trunk simplifies the network structure: achieving interoperability across switches in the same Vlan

③: Characteristics and principles of three-layer switches: once routing, multiple switching

④: Layer 3 switches realize intercommunication between different Vlans

⑤: Layer 3 switches are mostly used in the core layer: routing function + high-speed forwarding

⑥: The three-layer switch has a routing function that can forward data. The IP address is configured on the virtual interface instead of the physical interface. The physical interface is connected to the configuration Trunk of the switch and the configuration Access of the PC.

Guess you like

Origin blog.csdn.net/qq_57093716/article/details/134989718