We know that both of layer 3 switch and router provide function of routing. So, can we use layer 3 switch to replace router? Let’s discuss.
Working principle of Switch
When the switch receives data, it checks its destination MAC address, and then forwards the data from the interface where the destination host is located. The switch can realize this function because there is a MAC address table inside the switch. The MAC address table records the corresponding information of all MAC addresses in the network and each port of the switch. When a certain data frame needs to be forwarded, the switch searches the MAC address table according to the destination MAC address of the data frame to obtain the port corresponding to the address, that is, to know which port of the switch the device with the MAC address is connected to, and then the switch Forward the data frame from this port.
(1) The switch establishes the mapping between the address and the switch port according to the source MAC address in the received data frame, and writes it into the MAC address table.
(2) The switch compares the destination MAC address in the data frame with the established MAC address table to determine which port to forward.
(3) If the destination MAC address in the data frame is not in the MAC address table, it will be forwarded to all ports. This process is called flooding.
(4) Broadcast frames and multicast frames are forwarded to all ports.
Layer 3 Switch vs. Layer 2 Switch
The third layer of switching works in the third layer of the OSI seven-layer network model, the network layer, which uses the header information of the IP packet in the third layer protocol to mark subsequent data service flows, and the subsequent service flows with the same mark The message is exchanged to the second data link layer, thereby opening up a path between the source IP address and the destination IP address.
This path passes through the second link layer. With this path, the three-layer switch does not need to unpack the received data packet to determine the route every time, but directly forward the data packet and exchange the data flow.
It can be seen that the characteristics of the three-layer exchange:
(1) High-speed data forwarding is realized by the combination of hardware.
(2) This is not a simple superposition of Layer 2 switches and routers. Layer 3 routing modules are directly superimposed on the high-speed backplane bus of Layer 2 switching, breaking through the interface rate limit of traditional routers, and the rate can reach dozens of Gbit/s. Counting the backplane bandwidth, these are two important parameters for the performance of the Layer 3 switch.
(3) The concise routing software simplifies the routing process.
(4) Most of the data forwarding, except for the necessary routing selection, is handled by the routing software, and it is forwarded by the second-layer module at a high speed. Most of the routing software is processed and optimized software, not simply copying the software in the router.