The principle and difference of the two layer switch, layer three switch and router

Source: Internet
Author: User

Two-tier switch:

The second layer switching technology is more mature, two layer switch is a data link layer device, can identify the MAC address information in the packet, according to the MAC address to forward, and these MAC addresses and corresponding ports recorded in their own internal table of addresses.

Specific as follows:

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

(2) to read the destination MAC address in the header, and find the corresponding port in the Address table;

(3) If the table has a port corresponding to this destination MAC address, the packet is copied directly to this port.

Layer Three switch: Layer three switching technology is the technology that combine routing technology with switching technology. After the first traffic is routed, it will produce a map of the MAC address and IP address, when the same data flow through, will be based on this table directly from the two layer through rather than re-route, thus eliminating the router routing and network delay caused by the increase in packet forwarding efficiency.

Routers: Traditionally, routers work on the third layer of the OSI layer Seven Protocol, whose main task is to receive packets from a network interface, and decide to forward to the next destination address based on the destination address contained therein. Therefore, the router first has to find its destination address in the forwarding routing table, and if the destination address is found, the next MAC address is added before the packet's frame, and the TTL (time to Live) domain of the IP header begins to subtract, and the checksum is recalculated. When the packet is sent to the output port, it needs to wait in order to be transmitted to the output link.

The router can find the routing table in the device according to some kind of routing communication protocol while working. If there is more than one path to a particular node, the basic pre-determined routing criterion is to select the optimal (or most economical) transmission path. Because the various network segments and their interconnected conditions may vary depending on the environment, information about the routing situation is generally updated periodically, as specified by the Routing information protocol used.

The main difference: The two layer switch works at the data link layer, the three layer switch works on the network layer, and the router works at the network layer.

The specific differences are as follows:

The difference between a two-tier switch and a layer three switch:

Layer Three switch uses three layer switching technology

Simply put, three-layer switching technology is: two-layer switching technology + three-layer forwarding technology. It solves the network segment in the LAN, the network segment must rely on the router to manage the situation, to solve the traditional router low speed, complexity caused by the bottleneck problem.

What is three-layer switching

Three-layer switching (also known as multilayer switching technology, or IP switching technology) is proposed in relation to traditional switching concepts. As we all know, the traditional switching technology is made in the second layer of the OSI Network Standard Model, the data link layer, and the three-layer switching technology realizes the high-speed forwarding of the packets in the third layer of the network model. Simply put, three-layer switching technology is: two-layer switching technology + three-layer forwarding technology.

The emergence of three-layer switching technology solves the problem that the network segment must rely on the router to manage the net segment, and solves the bottleneck caused by the traditional router's low speed and complexity.

The principle is: Assume that two use IP protocol site A, b through the third layer of switch to communicate, send site A at the beginning of the sending, the IP address of the B station and compare their own, to determine whether B station and oneself in the same subnet. If the destination station B is in the same subnet as the transmit station A, two-layer forwarding is carried out. If two sites are not in the same subnet, such as Send station A to communicate with the destination station B, send station A to the "Default gateway" ARP (address resolution) packet, and "Default gateway" IP address is actually three layer switch three layer switching module. When send station a broadcasts an ARP request to the IP address of the "default gateway", if the three-tier switch module has known the MAC address of the B station during the previous communication, it will reply to the MAC address of B at Send station A. Otherwise, the three-layer switching module broadcasts an ARP request to the B station according to the routing information, and the B station gets the ARP request to reply to the MAC address of the three-layer switching module, and the three-layer switching module saves this address and replies to the station A, and the MAC address of the B station is sent to the MAC address table of the two- Since then, when a sends packets to B, it is all handed over to the two-layer exchange process, and the information is exchanged at high speed. Since only three layers of processing are required in the routing process, most of the data is forwarded through a two-layer exchange, so the three-layer switch is fast, close to the two-layer switch speed, and much lower than the price of the same router.

The difference between a second layer of switches and routers:

The traditional switch is developed from the bridge and belongs to the second layer of OSI, the data Link layer device. It is based on the MAC address, select routing through the station table, the establishment and maintenance of the station table automatically by the switch. The router belongs to the OSI third layer, the network layer device, which is addressed by IP address and generated through routing table routing protocol. The biggest advantage of the switch is fast, because the switch only needs to recognize the MAC address in the frame, directly according to the MAC address to generate the selection of the forwarding port algorithm is simple, easy to implement the ASIC, so the forwarding speed is very high. But the working mechanism of the switch also brings some problems.

1. Loop: Based on the switch address learning and station table establishment algorithm, the switch is not allowed to exist between the circuit. Once the loop is present, the spanning tree algorithm must be started to block the port that generated the loop. The router's routing protocol does not have this problem, there can be multiple paths between routers to balance the load, improve reliability.

2. Load concentration: There can only be one path between switches, so that information is concentrated on one communication link and cannot be dynamically allocated to balance the load. While the router routing protocol algorithm can avoid this, the OSPF routing protocol algorithm can not only produce multiple routes, but also can choose the best route for different network applications.

3. Broadcast control: The switch can only narrow down the conflict domain, not the broadcast domain. The entire switched network is a large broadcast domain, broadcast messages scattered over the entire switched network. While routers can isolate broadcast domains, broadcast messages cannot continue to be broadcast through the router.

4. subnetting: The switch only recognizes MAC addresses. The MAC address is a physical address and has a flat address structure, so you can't divide subnets by MAC addresses. While the router recognizes the IP address, the IP address is assigned by the network administrator, is the logical address and the IP address has a hierarchy, is divided into network number and host number, can be easily used to divide the subnet, the main function of the router is to connect to different networks.

5. Confidentiality issues: Although the switch can also be based on the source MAC address of the frame, the destination MAC address and other frames to filter the frame, but the router based on the source IP address of the message, Destination IP address, TCP port address and other content to implement filtering, more intuitive and convenient.

6. Media-Related: The switch as a bridge device can also complete the transformation between different link layer and physical layer, but this conversion process is more complex, not suitable for ASIC implementation, it is bound to reduce the switch forwarding speed. As a result, the switch mainly accomplishes the network interconnection of the same or similar physical media and link protocol, and it is not used to interconnect between the physical media and the network of the link layer protocol. Routers are different, it is mainly used for interconnection between different networks, so can connect different physical media, Link layer Protocol and Network Layer protocol network. Although the router occupies the advantage in function, it is expensive and the message forwarding speed is low. In recent years, switches have made many improvements to improve performance, the most prominent of which is virtual networks and three-tier switching.

Dividing subnets can narrow the broadcast domain and reduce the impact of broadcast storms on the network. Routers each interface to connect a subnet, broadcast messages can not be broadcast through the router, the subnets connected to different interfaces of the router belong to different subnets, the subnet range is physically divided by the router. For the switch, each port corresponds to a network segment, because the subnet consists of a number of network segments, through the combination of switch ports, can be logically divided into subnets. Broadcast messages can only be broadcast in the subnet, not spread to other subnets, through the rational division of logical subnets, to achieve the purpose of controlling the broadcast. Because logical subnets are arbitrarily combined by switch ports, there is no physical correlation, so called virtual subnets, or virtual networks. Virtual network technology does not use routers to solve the problem of isolation of broadcast messages, and the virtual network is independent of its physical location, that is, the adjacent network segments can belong to different virtual networks, and the distance between the two segments may belong to different virtual networks, and the distance between the two segments may belong to the same virtual network. The terminals in different virtual networks cannot communicate with each other, which enhances the access control of the data within the network.

The difference between a third layer of switches and routers:

Before the advent of the third-tier switching technology, there was little need to differentiate between routing devices and routers, and they were exactly the same: providing routing functionality was working on the router, however, the third layer of switches was now fully capable of performing most of the functions of traditional routers. As a network interconnect device, the third layer switches have the following characteristics:
1. Forwarding traffic based on a third-tier address;

2. Full Exchange function;

3. Can complete special services, such as message filtering or authentication;

4. Perform or do not perform route processing.

The third layer switches have the following advantages over traditional routers:

1. The transmission bandwidth between subnets can be arbitrarily allocated: traditional routers each interface to a subnet, the rate at which the subnet travels through the router is limited by the bandwidth of the interface. The three-layer switch is different, it can be defined as a virtual network of multiple ports, the virtual network of multiple ports as a virtual network interface, the virtual network information can be composed of a virtual network of the port to the three-layer switch, because the number of ports can be arbitrarily specified, the transmission bandwidth between subnets is not limited.

2. Reasonable allocation of information resources: because of the resource rate in the access subnet and access to the global network resource rate is not different, the subnet set up a separate server is not significant, by setting up the server in the global network not only save costs, but also reasonable allocation of information resources.

3. Cost reduction: The usual network design uses switches to form subnets, and routers to interconnect between subnets. At present, the network design using three layer switch can not only make arbitrary virtual subnetting, but also can communicate between subnets through the switch three layer routing function, thus saving the expensive router.

4. Flexible connection between switches: As switches, they are not allowed to have loops between them, as routers, and can have multiple paths to improve reliability and balance load. Layer three switches block the ports that cause loops with spanning tree algorithm, but when routing is selected, the blocked paths are still chosen as optional routes.

Switches and routers are the contradiction of performance and function, the switch exchange speed is fast, but the control function is weak, the router control performance is strong, but the message forwarding speed is slow. The latest technology to solve this contradiction is the three-layer exchange, both the Switch line speed forwarding message capability, and the router has good control functions.

The main difference between the three-layer switch and the router the difference between the three layer switch and the router is not clear, the most fundamental is that the three layer switch also has "routing" function, and the routing function of the traditional router is generally consistent. However, there is a significant difference between the three-layer switch and the router, as described below.
1. The main function is different although the three layer switches and routers have the routing function, but we can not equate them, just as many network devices now have a variety of traditional network equipment functions, as many broadband routers now have not only routing capabilities, but also provides the switch port, hardware firewall function, But you can't equate it with a switch or a firewall. Because the main function of these routers is also the routing function, the other functions are only its additional functions, the purpose is to make the device suitable for a wider range, make it more practical. The three-layer switch here is also the same, it is still the switch product, but it is a few basic routing functions of the switch, its main function is still data exchange. In other words, it has two functions of data exchange and routing, but its main function is data exchange, and routers only have the main function of routing and forwarding.
2. The main application environment is different. The routing function of a three-layer switch is usually simpler because it is primarily a simple LAN connection. Because of this, the routing capabilities of layer three switches are usually simpler, and routing paths are far less complex than routers. It is used in the main use of LAN or to provide fast data exchange function, to meet the frequent application characteristics of local area network data exchange. While routers are different, it is designed to meet different types of network connection, although also applicable to the connection between the LAN, but its routing function more reflected in the interconnection between different types of networks, such as the connection between the LAN and the WAN, the connection between different protocols, etc. So routers are primarily used between different types of networks. Its main function is routing and forwarding, to solve the various complex routing path network connection is its ultimate goal, so the router's routing function is usually very powerful, not only for the same protocol LAN, more suitable for different protocols of LAN and WAN. It has the advantage of choosing the best routing, load sharing, link backup and other network routing information exchange and so on routers have the function.
3. Performance is different technically speaking, routers and three-layer switches have significant differences in packet switching operations. Routers typically perform packet exchanges by a microprocessor-based software routing engine, while layer three switches perform packet exchange through hardware. Layer three switch after routing the first data stream, it will produce a MAC address and IP address mapping table, when the same data flow through again, will be based on this table directly from the two layer through rather than re-route, thus eliminating the router to make Routing and network delay, improve the efficiency of packet forwarding. At the same time, the three-layer switch routing lookup is for the data flow, it uses the caching technology, it is easy to use ASIC technology to achieve, therefore, can greatly reduce costs and achieve rapid forwarding. And the router's forwarding takes the longest matching way, realizes the complexity, usually uses the software to realize, the forwarding efficiency is low. Because of this, the performance of the three-layer switch is much better than the router in terms of overall performance, which is very suitable for local area networks where data exchange is frequent; While routers are very powerful, the packet forwarding efficiency is much lower than the three-layer switch, which is more suitable for the interconnection of different types of networks where data exchange is not very frequent. such as the interconnection of LAN and Internet. If the router, especially the high-end routers for the local area network, is a considerable amount of waste (in terms of its powerful routing function), but also can not well meet the requirements of LAN communication performance, affecting the normal communication between subnets.
In summary, there is a very substantial difference between the three-layer switch and the router. In any case, multi-subnet connections in a local area network, preferably a three-layer switch, especially in different sub-network data exchange frequently environment. On the one hand, it can ensure the communication performance between subnets, on the other hand, the investment of switch is omitted. Of course, if the communication between the subnets is not very frequent, the use of routers is understandable, but also to achieve sub-network security isolation of mutual communication purposes. Specifically, according to the actual needs of the three-layer switch to determine the most important purpose is to speed up the large LAN internal data exchange, the routing function is also for this purpose, can do a route, multiple forwarding. The process of the regularity of packet forwarding is realized by hardware, and the functions such as routing information updating, routing table maintenance, routing calculation and routing determination are implemented by software.
For security and management convenience, mainly to reduce the harm of broadcast storm, the large LAN must be a function or geographical factors into a small local area network, which makes VLAN technology in the network to obtain a large number of applications, and different VLAN communication between the router to complete the forwarding, With the continuous increase of inter-network visits. The simple use of routers to achieve inter-network access, not only because the number of ports is limited, and the routing speed is slow. This limits the size and access speed of the network. Based on this scenario, the three-layer switch is applied. Layer Three switch is designed for IP, the interface type is simple, has a strong two-layer packet processing capacity, is very suitable for large LAN data Routing and exchange, it can work in the third layer of the Protocol to replace or partially complete the function of traditional routers, but also with almost the second layer of exchange speed, and the price is relatively cheap.
The most important purpose of the three-layer switch is to speed up the data exchange inside the large LAN, the routing function is also around this purpose, so its routing function does not have the same grade professional router. After all, there are many deficiencies in security, protocol support and so on, and can not completely replace the work of routers.
The typical usage in practice is the interconnection of each subnet in the same LAN and the routing between VLANs in the LAN, instead of routing with a three-layer switch. And only the LAN and the public network between the interconnection to achieve cross-regional network access, only through professional routers.
On the surface, the third layer switch is the second layer exchanger and router integration, however this combination is not a simple physical combination, but the logical combination of each to take the director. The important manifestation is that when the first data stream of a source of information is exchanged in the third layer, the routing system produces a mapping table of MAC address and IP address, and stores the table, and when the subsequent traffic of the same information source enters the switching environment again, the switch will be based on the address mapping table generated and saved for the first time. Direct from the second layer from the source address to the destination address, no longer through the third routing system processing, thereby eliminating the network delay of routing choice.

Principles and differences between layer two switches, layer three switches, and routers

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.