What is the difference between a Layer 3 switch and a Layer 2 switch?

Abstract: A three-layer switch is a switch with partial router functions. The most important purpose of a three-layer switch is to speed up data exchange within a large LAN. The routing function is also used for this purpose. It can do one route and multiple times. . What is the difference between a Layer 3 switch and a Layer 2 switch? In addition, the three-layer switch and router have routing functions. What is the difference between the two?

  [Layer 3 Switch] Difference between Layer 3 Switch and Layer 2 Switch Difference between Layer 3 Switch and Router

The difference between a Layer 2 switch and a Layer 3 switch

  Layer 2 switches are used in small local area networks. Needless to say, in small LANs, broadcast packets have little impact. The fast switching function of Layer 2 switches, multiple access ports and low price provide a perfect solution for small network users.

  The advantages of the Layer 3 switch are that the interface type is rich, the supported Layer 3 functions are powerful, and the routing capability is strong. It is suitable for routing between large networks. Its advantages are selecting the best route, load sharing, link backup, and other networks. The exchange of routing information and the like have functions of the router.

  The most important function of the Layer 3 switch is to speed up the fast forwarding of data within the large LAN. The routing function is also used for this purpose. If the large-scale network is divided into small LANs according to departments, regions, etc., this will lead to a large number of Internet access, and the use of Layer 2 switches alone cannot achieve Internet access; for example, simply using routers, due to the limited number of interfaces and The slow forwarding speed will limit the speed of the network and the network scale. The fast forwarding Layer 3 switch with routing function becomes the first choice.

  Generally speaking, in a network with large data traffic on the internal network and requiring fast forwarding response, such as all three layers of switches to do this work, the three-layer switch will be overburdened, the response speed will be affected, and the routing between the networks will be handed over. It is a good networking strategy to make full use of the advantages of different devices. Of course, the premise is that the customer’s pocket is very drum, otherwise it will be second-best, and the three-layer switch will also be the Internet interconnection.

The difference between a three-layer switch and a router

  1. The main functions are different

  Although Layer 3 switches and routers have routing capabilities, we can’t equate them. Just as many network devices now have multiple traditional network device functions, just as many broadband routers now have routing capabilities. The switch port, hardware firewall function, but can not be equated with the switch or firewall. Because the main function of these routers is the routing function, other functions are just additional functions, and the purpose is to make the device more applicable and more practical. The same is true for the three-layer switch here. It is still a switch product, but it is a switch with some basic routing functions. Its main function is still data exchange. That is to say, it has both data exchange and routing functions, but its main function is data exchange; the router only has the main function of route forwarding.

  2. The main applicable environment is different

  The routing function of a Layer 3 switch is usually simpler because it faces a simple LAN connection. Because of this, the routing function of a Layer 3 switch is usually relatively simple, and the routing path is far less complicated than a router. Its main purpose in LAN is to provide fast data exchange function, to meet the application characteristics of frequent LAN data exchange.

  The router is different. Its design is designed to meet different types of network connections. Although it is also suitable for connection between LANs, its routing function is more reflected in the interconnection between different types of networks, such as LAN. Connections with WANs, connections between networks of different protocols, etc., so routers are mainly used between different types of networks. Its main function is routing and forwarding. Solving the connection of various complex routing path networks is its ultimate goal. Therefore, the routing function of the router is usually very powerful, not only applicable to the LAN of the same protocol, but also suitable for different protocols. Between the LAN and the WAN. Its advantages are the choice of routers with optimal routing, load sharing, link backup, and exchange of routing information with other networks. In order to connect with various types of networks, the interface type of the router is very rich, and the three-layer switch is generally only the same type of LAN interface, which is very simple.

  3. Performance is different

  Technically, routers and Layer 3 switches have significant differences in packet switching operations. Routers typically perform packet switching by a microprocessor-based software routing engine, while Layer 3 switches perform packet switching through hardware. After the Layer 3 switch routes the first data stream, it will generate a mapping table of MAC addresses and IP addresses. When the same data stream passes again, it will pass directly from Layer 2 instead of re-routing according to this table. Therefore, the delay of the network caused by the routing of the router is eliminated, and the efficiency of packet forwarding is improved. At the same time, the route lookup of the Layer 3 switch is for data flow. It utilizes the cache technology and is easy to implement by using ASIC technology. Therefore, it can greatly save costs and achieve fast forwarding. The forwarding of the router adopts the longest matching method, which is complicated to implement, and is usually implemented by using software, and the forwarding efficiency is low.

  For this reason, the performance of the three-layer switch is much better than that of the router in terms of overall performance. It is very suitable for LANs with frequent data exchange. However, although the routing function is very powerful, its packet forwarding efficiency is much lower. The three-layer switch is more suitable for the interconnection of different types of networks where data exchange is not very frequent, such as the interconnection between the local area network and the Internet. If a router, especially a high-end router, is used in a local area network, it is a waste to a considerable extent (in terms of its powerful routing function), and it does not satisfactorily meet the communication performance requirements of the LAN, affecting the subnets. Normal communication.

  In summary, there is still a very large difference between the three-layer switch and the router. In any case, for multi-subnet connections in a local area network, it is better to use a three-layer switch, especially in an environment where data exchange between different subnets is frequent. On the one hand, it can ensure the communication performance requirements between subnets, on the other hand, it saves the investment of purchasing switches. Of course, if the communication between subnets is not very frequent, it is understandable to use routers, and the purpose of subnet security isolation and mutual communication can also be achieved. The specifics should be determined according to actual needs.

Difference: two layers, routing, three layers, four layers

Layer 2 switching technology

  The Layer 2 switching technology is relatively mature. The Layer 2 switch is a data link layer device. It can identify the MAC address information in the data packet, forward it according to the MAC address, and record the MAC address and the corresponding port in its own internal. In the address table. The specific workflow is as follows:

  (1) When the switch receives a packet from a port, it first reads the source MAC address in the packet header, so that it knows which port the source MAC address machine is connected to;

  (2) Then read the destination MAC address in the packet header and find the corresponding port in the address table;

  (3) If there is a port corresponding to the destination MAC address in the table, copy the data packet directly to this port;

  (4) If the corresponding port is not found in the table, the data packet is broadcast to all ports. When the destination machine responds to the source machine, the switch can learn which port the destination MAC address corresponds to, and the next time the data is transmitted. It is no longer necessary to broadcast all ports. This process is continuously cycled, and the MAC address information of the entire network can be learned. The Layer 2 switch establishes and maintains its own address table.

Routing technology

  The router works in the third layer of the OSI model – network layer operation, its working mode is similar to that of Layer 2 switching, but the router works in the third layer. This difference determines that routing and switching use different control information when delivering packets. The way of function is different. The working principle is that there is also a table inside the router. This table indicates that if you want to go to a certain place, the next step should be to go there. If you can find the data packet from the routing table, go to the next step and put the link layer. The information is forwarded out; if you don’t know where to go next, discard the packet and return a message to the source address.

  Routing technology is essentially two functions: determining the optimal route and forwarding packets. Various information is written in the routing table, and the routing algorithm calculates the best path to the destination address, and then sends the data packet by a relatively simple direct forwarding mechanism. The next router that accepts the data continues to forward in the same way, and so on, until the packet arrives at the destination router. There are two different ways to maintain routing tables. One is the update of routing information, which advertises part or all of the routing information. The router learns the topology of the whole network by learning routing information from each other. This type of routing protocol is called distance vector routing protocol; The router broadcasts its own link state information and learns the routing information of the entire network by learning each other to calculate the best forwarding path. This type of routing protocol is called a link state routing protocol.

  Since the router needs to do a lot of path calculation work, the working ability of the general processor directly determines the performance of its performance. Of course, this judgment is still for low-end routers, because high-end routers often use distributed processing system architecture.

Layer 3 switching technology

  Equipment using IP A———————— Three-layer switch —————— ——Device B using IP, such as A to send data to B, known destination IP, then A uses the subnet mask to obtain the network address, to determine whether the destination IP is in the same network segment as itself.

  If it is on the same network segment but does not know the MAC address required to forward the data, A sends an ARP request, and B returns its MAC address. A uses this MAC to encapsulate the data packet and sends it to the switch. The switch uses the Layer 2 switching module to search. The MAC address table forwards the packet to the corresponding port.

  If the destination IP address is not displayed on the same network segment, then A needs to communicate with B. If there is no corresponding MAC address entry in the flow cache entry, the first normal data packet is sent to a default gateway. This default gateway Generally, it is set in the operating system and corresponds to the Layer 3 routing module. Therefore, for data that is not the same subnet, the MAC address of the default gateway is first placed in the MAC table; then it is received by the Layer 3 module. This data packet, querying the routing table to determine the route to B, will construct a new frame header, where the MAC address of the default gateway is the source MAC address and the MAC address of the host B is the destination MAC address. Through a certain identification trigger mechanism, the correspondence between the MAC address and the forwarding port of the host A and the B is established, and the inflow cache entry table is recorded, and the data of the subsequent A to B is directly submitted to the layer 2 switching module. This is usually referred to as a route that is forwarded multiple times.

  Layer 2 switches are used in small local area networks. Needless to say, in small LANs, broadcast packets have little impact. The fast switching function of Layer 2 switches, multiple access ports and low price provide a perfect solution for small network users.

  The router has the advantages of rich interface types, powerful Layer 3 support, and strong routing capability. It is suitable for routing between large networks. Its advantages are to choose the best route, load sharing, link backup and routing with other networks. The exchange of information and so on has the function of the router.

  The most important function of the Layer 3 switch is to speed up the fast forwarding of data within the large LAN. The routing function is also used for this purpose. If the large-scale network is divided into small LANs according to departments, regions, etc., this will lead to a large number of Internet access, and the use of Layer 2 switches alone cannot achieve Internet access; for example, simply using routers, due to the limited number of interfaces and The slow forwarding speed will limit the speed of the network and the network scale. The fast forwarding Layer 3 switch with routing function becomes the first choice.

Four-layer switching technology

  A simple definition of Layer 4 switching is that it is a function that determines whether the transmission is based not only on the MAC address (Layer 2 bridge) or the source/destination IP address (Layer 3 routing), but also on TCP/UDP ( The fourth layer) application port number. The fourth layer of switching functions is like a virtual IP, pointing to a physical server. The services it transmits are subject to a variety of protocols, including HTTP, FTP, NFS, Telnet, or other protocols. These services require a complex load balancing algorithm based on physical servers. In the IP world, the service type is determined by the terminal TCP or UDP port address, and the application interval in the fourth layer exchange is determined by the source and terminal IP addresses, TCP and UDP ports. In the Layer 4 exchange, a virtual IP address (VIP) is set up for each server group used for the search, and each group of servers supports an application. Each application server address stored in the Domain Name Server ( DNS ) is a VIP, not a real server address. When a user applies for an application, a VIP connection request with a target server group (for example, a TCP SYN packet) is sent to the server switch. The server switch selects the best server in the group, replaces the VIP in the terminal address with the IP of the actual server, and transmits the connection request to the server. In this way, all packets in the same interval are mapped by the server switch and transmitted between the user and the same server. Principle of Layer 4 Switching The fourth layer of the OSI model is the transport layer. The transport layer is responsible for end-to-end communication, ie coordinating communication between the network source and the target system. In the IP stack, this is the protocol layer where TCP (a transport protocol) and UDP (user data packet protocol) are located.

  In the fourth layer, the TCP and UDP headers contain port numbers, which uniquely distinguish which application protocols (such as HTTP, FTP, etc.) are included in each packet. The endpoint system uses this information to distinguish the data in the packet, especially the port number that enables a receiving computer system to determine the type of IP packet it receives and hand it over to the appropriate high-level software. The combination of port number and device IP address is often referred to as a “socket.” The port numbers between 1 and 255 are reserved, they are referred to as “well known” ports, that is, in all host TCP/IP stack implementations, these port numbers are the same. In addition to the “well-known” ports, standard UNIX services are allocated in the 256 to 1024 port range, and custom applications typically allocate port numbers above 1024. A recent list of assigned port numbers can be found on RFc1700 “Assigned Numbers”. The additional information provided by the TCP/UDP port number can be utilized by the network switch, which is the basis for Layer 4 switching.

  A switch with Layer 4 functionality can function as a “virtual IP” (VIP) front end connected to the server. Each server and server group that supports single or universal applications are configured with a single VIP address. This VIP address is sent out and registered on the domain name system. When a service request is made, the Layer 4 switch identifies the beginning of a session by determining the start of TCP. It then uses sophisticated algorithms to determine the best server to handle this request. Once this decision is made, the switch associates the session with a specific IP address and replaces the VIP address on the server with the server’s real IP address.

  Each Layer 4 switch maintains a source IP address that matches the selected server and a connection table associated with the source TCP port. The Layer 4 switch then forwards the connection request to this server. All subsequent packets are remapped and forwarded between the client and the server until the switch discovers the session. In the case of Layer 4 switching, the access can be connected to a real server to satisfy user-defined rules, such as having an equal number of accesses per server or allocating transport streams according to the capacity of different servers.

How to choose a third layer switch

  At present, the third layer switch shows a strong growth trend, replacing the router in the local area network, and its huge market potential is attracting a large number of domestic and foreign manufacturers to join the competition. Fortunately, domestic manufacturers have developed their own ASIC chips and network management software in key technologies, thus providing users with a broad space in the choice of brand. At present, major domestic manufacturers include Cisco, 3Com, Annette, Extreme, Fountry, Avaya, Nortel, Entersys, D-Link, SVA, Digital China Network, Huawei, Tongfang Network, Tsinghua Biwei and TCL. In the face of such a colorful brand, it is a problem that users must solve when they choose from.

  For the choice of Layer 3 switches, the network structure and application of different users will be different, so the focus of selecting Layer 3 switches will be different. But for the user, generally pay attention to the following aspects.

1. Throughput when fully configured focus when As with any electronic product, the third layer switch selection, first to analyze the performance of a variety of products, but the face of such exchange capacity (Gbps), backplane bandwidth (Gbps), processing capacity ( Mpps), throughput (Mpps) and many other technical indicators, you better still grasp the “full throughput when configured” indicator, because other technical indicators users generally do not have the ability to measure, only the throughput is user-useable Indicators for direct measurement and verification of test instruments such as Smart Bits and IXIA.

2. Distributed than centralized switch technology different brands of switches used are different, it can be divided into two types of centralized and distributed. Traditional bus switch fabric modules are centralized, and modern switch fabric modules are distributed. Due to the increasing amount of audio, video and data information running in the enterprise intranet, the requirements for the processing power of the switch are becoming higher and higher. In order to achieve high-speed non-blocking switching under high port density conditions, distributed The third layer switch is a wise choice. Because the bus switch module can not avoid conflicts in the Ethernet environment, the matrix just avoids the conflict when the port is exchanged.

3. Delay and Delay Jitter concern corporate intranet almost all high-speed LAN, one of its aims is to audio and video transmission of high-capacity multimedia data, which are very sensitive to high-capacity multimedia data packets and data due to a longer delay Packet loss causes jitter in the information transmission. Some traditional centralized switches have a latency of up to 2ms, while some modern distributed switches have a latency of only about 10ms, which is a hundred times different. The reasons for the excessive delay usually include the switching structure of the blocking design and the excessive use of buffering. Therefore, attention to the delay actually requires attention to the module structure of the product.

4. Stable performance Layer 3 switches are used for backbone and aggregation layer, if the performance is unstable, it will spread to most of the host network system, or even the entire network system. Therefore, only the stable Layer 3 switch is the guarantee for continuous, reliable, secure and normal operation of the network system. Of course, performance stability seems to be abstract, and it seems that historical testing is needed to be convincing. In fact, because the performance of the equipment is actually achieved through a number of basic technical indicators and market reputation. So, you can determine by metrics such as throughput, latency, frame loss rate, address table depth, line-side blocking, and many-to-one functions, as well as market application surveys.

5. Safe and reliable as the third layer switch core network equipment, nature is an important target for hackers, which requires third layer switch must be included in the scope of network security protection. Of course, the term “safe and reliable” as used here should include the software and hardware of the Layer 3 switch. Therefore, from the perspective of “security”, it is necessary to equip a Layer 3 switch with excellent performance and no security firewall function. From the point of view of “reliability”, it is impossible to guarantee that it will not fail due to any objective product, and it is a problem to be concerned if it can be quickly switched to a good device in the event of a failure. In addition, redundancy should be considered in hardware. Whether important components such as power supply, management module and port support redundancy, this is especially important for users with high security and reliability requirements such as telecommunications and finance. There is also a way to dissipate heat, such as whether the cooling fan is set up properly. Finally, for broadband operators, the authentication function is also an important aspect of the investigation. In the past, the switch was used by enterprises. When it was connected to the network, it was directly connected, and no authentication was required. Broadband operators need to confirm whether the user is on record. When a user accesses the Internet, a window appears. Enter the user name and password to pass the authentication. Therefore, the broadband carrier’s Layer 3 switch should also support some special protocols such as 802.1x to achieve authentication.

6. Full-featured products not only meet existing needs, but also to meet the demand in the next period of time, giving the user a value-added space. For example, when the company’s employees increase, you can plug in the module to expand without having to eliminate the original equipment. There are also some features, such as multicast, QoS, port trunking, 802.1d spanning tree (Spanning Tree) and whether to support routing protocols such as RIP and OSPF, which are very important for Layer 3 switches. Taking multicast as an example, in a VOD application, if a group of users simultaneously orders a program, the multicast protocol can ensure that the switch performs data processing smoothly on high-density video stream on demand, and vice versa if the switch does not support the multicast protocol. , the bandwidth used is quite large. For example, the QoS function can be divided into different levels according to different needs of users, which enables the broadband operator to charge the port according to the port, thereby providing different services for different users. In addition, access list features. If VLANs are assigned at the access layer, there is no communication between different VLAN users, because this is based on the second layer of VLAN. If you want to communicate, you must pass the third layer. For example, the financial department and the marketing department of the enterprise generally do not communicate. If a user needs to access, the network administrator can perform a simple command line setting through the third layer switch to enable normal communication between the VLANs. This is the access list function. It is a function of porting from a router to a Layer 3 switch, enabling one-way or two-way communication between different VLANs. If an external IP address is found to always send unwanted packets to its own network, it can be set in the access list to prevent it from sending packets.

  In addition, it is also the focus of research on service, product usability and cost performance.

Leave a Comment