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.
We can summary that:
Layer 2 switch: based on MAC address
Layer 3 switch: with VLAN function, switching and routing, based on IP.
*Want to order? Check here:
Layer 2 switches: Cisco Switch Catalyst 2960, Cisco Switch Catalyst 1000, Huawei S1700 Series Switches
Layer 3 switches: Cisco Switch Catalyst 9200, Cisco Switch Catalyst 9300, Aruba 3810 Series Switches , Huawei S5700 Series Switches, Juniper EX4300 Series Ethernet Switches
- Layer 3 Switch vs. Router
The router is a three-layer device, but the three-layer switch can work at the third and second layers at the same time.
In fact, there are still big differences between Layer 3 switches and routers:
(1) The main functions are different.
Although both Layer 3 switches and routers have routing functions, they cannot be equated. The router not only has routing functions, but also provides additional functions of switch ports and hardware firewalls. The purpose of the router is to make the device more applicable and more practical.
The same is true for Layer 3 switches. The main function is still data exchange, but it is a switch with some basic routing functions. The three-layer switch has both data exchange and routing and forwarding functions, but its main function is still data exchange; and the router only has the main function of routing and forwarding.
(2) The main applicable environment is different.
The routing function of the three-layer switch is usually relatively simple, because it is mainly facing a simple LAN connection. Features are far less complex than routers. Its main purpose in the local area network is to provide fast data exchange function to meet the application characteristics of frequent data exchange in the local area network.
The router is different. Although it is also suitable for the connection between LANs, its routing function is more reflected in the interconnection between different types of networks, such as the connection between the LAN and the wide area network, and the connection between the networks of different protocols. The advantages of connection, etc. lie in the selection of the best route, load sharing, link backup, and exchange of routing information with other networks. In addition, in order to connect to various types of networks, routers have very rich interface types, while Layer 3 switches generally only have the same type of LAN interface, which is very simple.
(3) The technical realization is different.
There are obvious differences in data packet switching operations between routers and Layer 3 switches.
Routers are generally based on network processors or multi-core routing engines to perform data packet switching.
And the three-layer switch performs data packet switching through hardware. After the Layer 3 switch performs a routing lookup on the first data packet sent to the control plane, it will generate a MAC address and IP address mapping table for the data plane to look up. When the same data flow passes through again, it will use this table. Check the table through instead of sending the control plane again to check the route (ie “one route, multiple exchanges”).
(4) The three-layer switch improves the efficiency of data packet forwarding.
The routing lookup of the three-layer switch is for data flow. It uses cache technology and is easy to implement with ASIC technology. Therefore, it can greatly save costs and achieve fast forwarding.
The router’s forwarding adopts the longest matching method, which is complicated to implement, and is generally implemented by expensive network processors or multi-core processors, and the number of routing tables is huge, and the cost is quite high.
Layer 2 switches are used in small local area networks. In a small local area network, the broadcast packet has little effect. The fast switching function, multiple access ports and low cost of the second-tier switch provide a very complete solution for small network users.
The most important function of the three-layer switch is to speed up the fast forwarding of data within a large local area network. The addition of the routing function also serves this purpose. If the large-scale network is divided into small LANs according to factors such as department, region, etc., this will lead to a large number of inter-network visits, which cannot be realized by simply using a two-layer switch;
For example, simply using a router, due to the limited number of interfaces and slow routing and forwarding speed, will limit the speed and network scale of the network, and the use of a fast forwarding three-layer switch with routing function becomes the first choice.
Network Switch Selector: Cisco, Huawei, Aruba, Dell and More
Switch Setting: How to Build Intercommunication between Two Switches?
Buyer Guide: How to Select Access Layer Switches for Enterprise?
Huawei Switches Vs. Juniper Switches
125 Articles, Datasheets, FAQ, Comparison and More of Cisco Catalyst Switches