• icon
  • add add
    Sitemap
  • icon
  • icon
News

Comparison between layer 3 switch and Router

Published by Harmony December 25,2024

In large LAN, this kind of function is perfect, it is very helpful to master layer 3 switch, but some manufacturers can also directly connect to the Internet to provide router function.

                                                

In the aspect of network structure, it has also developed from the early local area network of shared media to the current switched local area network. Switching LAN technology makes the dedicated bandwidth unique to users, and greatly improves the efficiency of LAN transmission. It can be said that in the technology of network system integration, the first layer interface and layer 2 switching technology directly oriented to users have obtained satisfactory answers. However, as the core of the network, the router technology, which plays the role of inter-network interconnection, has no qualitative breakthrough. In this case, a new routing technology emerges as the times require, which is layer 3 switching technology: it is said that it is a router, because it can operate in the network association. The third layer is a kind of routing understanding device and can play the role of routing decision; it is said to be a switch because it is very fast, almost reaching the speed of layer 2 switching. Layer 2 switches, layer 3 switches and routers, who are superior and who are inferior, and what environment are they suitable for? To answer this question, let's start with how these three technologies work:

 

1. Layer 2 switching technology

 

Layer 2 switch is a data link layer device, which can read the MAC address information in the packet and exchange it according to the MAC address.

 

There is an address table inside the switch, which indicates the correspondence between the MAC address and the switch port. When the switch receives a packet from a port, it first reads the source MAC address in the packet header, which knows which port the machine of the source MAC address is connected to, then reads the destination MAC address in the packet header, and looks for the corresponding port in the address table. If there is a port corresponding to the destination MAC address in the table, the packet is copied directly to the port. If the corresponding port is not found in the table, the packet is broadcast to all ports when the destination machine is to the source machine In response, the switch can learn which port the destination MAC address corresponds to and no longer need to broadcast all ports the next time the data is transmitted.

 

This is how the layer 2 switch establishes and maintains its own address table. Because layer 2 switches generally have a wide switching bus bandwidth, they can exchange data for many ports at the same time. If the layer 2 switch has N ports, the bandwidth of each port is M, and its switch bus bandwidth is more than N × M, then the switch can achieve line speed switching. Layer 2 switches do not restrict broadcast packets and copy them to all ports.

 

A two-layer switch typically contains an ASIC (Application Specific Integrated Circuit) chip that is specifically used to process the packet forwarding, so that the forwarding speed can be very fast.

 

2.Routing technology

 

Routers operate in the network layer, the third layer of the OSI seven-layer network model.

 

There is a routing table inside the router that indicates where the next step should go if you are going somewhere. The router receives a data packet from a certain port. It first removes(unpacks)the packet header of the link layer, reads the destination IP address, and then looks up the routing table. If it can determine where to send the next step, it adds the packet header(packaging)of the link layer to forward the data packet;If the next address cannot be determined, a message is returned to the source address and the packet is dropped. 

 

Routing technology and layer 2 switching look a little similar. In fact, the main difference between routing and switching is that switching occurs in the second layer of the OSI reference model (data link layer), while routing occurs in the third layer. This difference determines that routing and exchange need to use different control information in the process of transmitting data, so the two ways to achieve their respective functions are different.

 

Routing technology is actually composed of two most basic activities, that is, determining the optimal path and transmitting packets. Among them, the transmission of packets is relatively simple and direct, while the determination of routing is more complex. The routing algorithm writes a variety of different information in the routing table, and the router will choose the best path according to the destination to be reached by the packet to send the packet to the next router that can reach the destination. When the next router receives the packet, it also looks at its destination address and continues to send it to the subsequent router using the appropriate path. And so on until the packet reaches its final destination.

 

Routers can communicate with each other and maintain their routing tables by transmitting different types of information. Routing update information is a kind of information, which is usually composed of some or all routing tables. By analyzing the routing update information sent by other routers, the router can master the topology of the whole network. Link state broadcasting is another kind of information transmitted between routers. It can notify other routers of the link state and progress of the sender.

 

3. Three-layer switching technology

 

A device with a third layer switching function is a second layer switch with a third layer routing function, but it is an organic combination of the two, and is not a simple addition of the hardware and software of the router device to the local area network switch.

 

From a hardware point of view, the interface modules of the layer 2 switch exchange data through a high speed backplane / bus (the rate can be as high as tens of Gbit/s). In the layer 3 switch, the layer 3 routing hardware module related to the router is also plugged into the high speed backplane / bus, which enables the routing module to exchange data at a high speed with other modules that need to be routing. Thus, it breaks through the limit of the interface rate of the traditional external router. On the software side, layer 3 switches also have important measures, which define the traditional software-based router software.

 

This is done by:

 

For packet forwarding:such as IP/IPX packet forwarding, these regular processes are realized at high speed through hardware. 

 

For layer 3 routing software, such as routing information update, routing table maintenance, routing calculation, routing determination and so on, it is realized by optimized and efficient software.

 

Assuming that two machines using the IP protocol communicate through the third layer switch, the machine A, at the beginning of the transmission, knows the destination IP address, but it is not known to send the required MAC address on the local area network. To determine the destination MAC address using Address Resolution (ARP). The machine A compares its own IP address with the destination IP address, extracts the network address from the subnet mask configured in its software to determine whether the destination machine is within the same subnet as itself. if the destination machine B is in the same subnet with the machine A, A broadcasts an ARP request, B returns its MAC address, A obtains the destination machine, After the MAC address of B, the address is cache and the MAC address packet is used to forward the data. The second layer switching module looks up the MAC address table to determine that the packet is sent to the destination port. If the two machines are not in the same subnet, if the sending machine A wants to communicate with the destination machine C, the sending machine A sends the ARP packet to the "default gateway", and the IP address of the "default gateway" is already set in the system software. This IP address actually corresponds to the layer 3 switching module of the layer 3 switch. So when sending machine A broadcasts an ARP request to the IP address of the "default gateway", if layer 3 switches If the module has obtained the MAC address of the destination machine C in the previous communication process, the MAC address of C is returned to the transmitting machine A;Otherwise, the third layer switching module broadcasts an ARP request to the destination machine according to the routing information. After receiving the ARP request, the destination machine C returns its MAC address to the third layer switching module, and the third layer switching module saves the address and responds to the sending machine A. After that, when the packet forwarding between A and C is carried out, it will be encapsulated with the final MAC address of the destination machine, and the data forwarding process is all submitted to the second layer exchange process, and the information can be exchanged at high speed. It's a one-time election.  The road is exchanged many times.

 

Layer 3 switching has the following outstanding characteristics:

 

The organic combination of hardware accelerates the data exchange.

 

The optimized routing software improves the efficiency of the routing process.

 

In addition to the necessary routing decision process, most of the data forwarding process is processed by layer 2 switching.

 

When multiple subnets are connected to each other, they are only logically connected to the third layer switching module, which does not need to increase the port as the traditional external router, which protects the investment of users.

 

4. Comparison of three technologies

 

It can be seen that layer 2 switches are mainly used in small local area networks, and the number of machines is less than 20 or 30. In such a network environment, broadcast packets have little influence. The fast switching function of layer 2 switches, multiple access ports and low prices provide a very perfect solution for small network users. There is no need to introduce routing functionality in this small network to increase the difficulty and cost of management, so there is no need to use routers, and of course, there is no need to use layer 3 switches.

 

The layer 3 switch is designed for IP with simple interface type and strong layer 2 packet processing ability, so it is suitable for large local area network. In order to reduce the harm of broadcast storm, large local area network must be divided into a small local area network, that is, a small network segment, according to functional or regional factors, which will inevitably lead to a large number of exchange visits between different network segments. Using layer 2 switching machine alone can not realize the exchange of access between networks, but only using routers, because of the limited number of ports and slow routing speed, the scale and access speed of the network are limited. therefore, in this environment, layer 2 switching technology and routing technology are used. The layer 3 switch, which is formed by the organic combination of technology, is the most suitable.

 

There are many types of router ports, many layer three protocols and strong routing ability, so it is suitable for interconnection between large networks. Although no fewer layer 3 switches and even layer 2 switches have interconnection ports of heterogeneous networks, there are not many interconnection ports in large networks. The main function of interconnection devices is not to exchange quickly between ports, but to choose the best path and share the load. Link backup and, most importantly, routing information exchange with other networks, all of which are routing functions.

 

In this case, it is naturally impossible to use a layer 2 switch, but whether or not to use a layer 3 switch depends on the case. The main influencing factors are network traffic, response speed requirements and investment budget and so on. The most important purpose of layer 3 switch is to speed up the data exchange in large LAN, and the combined routing function is also served for this purpose, so its routing function is not as strong as that of professional routers of the same grade. In the case of large network traffic, if the three-layer switch does both intra-network switching and inter-network routing, it will certainly greatly increase its burden and affect the response speed. There is a lot of traffic in the network However, under the condition of high response speed, the three-layer switch is required to switch in the network, and the router is specially responsible for the routing between the networks, which can give full play to the advantages of different devices and is a good cooperation. Of course, if limited by the investment budget, it is also a good choice for layer 3 switches to interconnect between networks.