The difference between Layer 2 and Layer 3 switches
Layer 2 switching technology
The development of the two-layer switching technology is relatively mature. The two-layer switch is a data link layer device, which can identify the MAC address information in the data packet, forward it according to the MAC address, and record these MAC addresses and corresponding ports in its own internal one Address table. The specific workflow is as follows:
(1) When the switch receives a data packet from a certain port, it first reads the source MAC address in the packet header, so that it knows which port the machine with the source MAC address is connected to;
(2) Read the destination MAC address in the header, and look up 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 will be broadcast to all ports. When the destination machine responds to the source machine, the switch can learn which port a destination MAC address corresponds to, and it will be used when the data is transmitted next time. It is no longer necessary to broadcast to all ports. This process is repeated continuously, and the MAC address information of the entire network can be learned. This is how the Layer 2 switch establishes and maintains its own address table.
The following three points can be inferred from the working principle of the Layer 2 switch:
(1) Since the switch exchanges data on most ports at the same time, it requires a wide switching bus bandwidth. If the layer 2 switch has N ports, the bandwidth of each port is M, and the switch bus bandwidth exceeds N×M. Then this switch can realize wire-speed switching;
(2) Learn the MAC address of the machine connected to the port, write it into the address table, and the size of the address table (generally two representations: one is BEFFER RAM, the other is the value of the MAC table entry), the size of the address table affects the access capacity of the switch ；
(3) Another is that Layer 2 switches generally contain ASIC (Application Specific Integrated Circuit) chips specially used to process data packet forwarding, so the forwarding speed can be very fast. As each manufacturer uses different ASICs, it directly affects product performance.
The above three points are also the main technical parameters for judging the performance of Layer 2 and Layer 3 switches. Please pay attention to comparison when considering equipment selection.
Routing technology routers work in the third layer of the OSI model---network layer operation. Its working mode is similar to that of layer two switching, but routers work in the third layer. This difference determines that routing and switching use different controls when transmitting packets. Information, the way to realize the 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, you should go there in the next step. If you can find the data packet in the routing table, go there and put the link layer The information is added and forwarded; if you cannot know where to go next, discard the packet, and then return a message to the source address.
In essence, routing technology has only two functions: determining optimal routing and forwarding data packets. Various information is written in the routing table, the routing algorithm calculates the best path to the destination address, and then the data packet is sent by a relatively simple and direct forwarding mechanism. The next router that receives the data continues forwarding in the same way, and so on, until the data packet reaches the destination router.
There are also two different ways to maintain the routing table. One is the update of routing information, which publishes part or all of the routing information. Routers learn the routing information from each other to master the topology of the entire network. This type of routing protocol is called distance vector routing protocol; the other is It is the router that broadcasts its own link state information, learns the routing information of the entire network through mutual learning, and then calculates a good forwarding path. This type of routing protocol is called a link state routing protocol. Because routers need to do a lot of path calculation work, the working capacity of general processors directly determines the pros and cons of its performance.
Of course, this judgment is still for low-end routers, because high-end routers often use distributed processing system design. Three-layer switching technology In recent years, the propaganda of three-layer technology can make ears, and everyone is calling for three-layer technology. Some people say that this is a very new technology. Others say, three-layer switching, not routers and There is nothing new about the stacking of Layer 2 switches. Is this really the case? Let's first take a look at the working process of the three-layer switch through a simple network.
The networking is relatively simple. Use IP equipment A------------------------Layer 3 switch-------------- ---------- Device B using IP For example, A wants to send data to B, and the destination IP is known, 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 you are in the same network segment, but don’t know the MAC address needed to forward the data, A sends an ARP request, 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, and find MAC address table, forward the data packet to the corresponding port.
If the destination IP address is not in 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 will be sent to a default gateway, this default gateway Generally, it has been set in the operating system, corresponding to the third layer routing module, so it can be seen that for data that is not in the same subnet, first put the MAC address of the default gateway in the MAC table; then the third layer module receives this For data packets, query the routing table to determine the route to B. A new frame header will be constructed, with the MAC address of the default gateway as the source MAC address and the MAC address of host B as the destination MAC address. Through a certain recognition trigger mechanism, the correspondence relationship between the MAC addresses and forwarding ports of host A and B is established, and recorded into the flow cache entry table. The subsequent data from A to B is directly handed over to the layer 2 switching module for completion. This is usually referred to as one route and multiple forwarding. The above is a simple summary of the working process of the three-tier switch, you can see the characteristics of the three-tier switch:
1. High-speed data forwarding is realized by hardware combination.
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, it is also high-speed forwarding by the second layer module. Most of the routing software is processed and efficient optimization software, not simply copying the software in the router. Conclusion Layer 2 switches are used for small local area networks. Needless to say, in a small local area network, broadcast packets have little effect. The fast switching function, multiple access ports and low cost of the two-layer switch provide a very complete solution for small network users.
The advantages of routers are their rich interface types, powerful support for Layer 3 functions, and powerful routing capabilities. They are suitable for routing between large-scale networks. Its advantages lie in choosing the best route, load sharing, link backup, and routing information with other networks. The switch, etc. routers have functions.
The important function of the three-layer switch is to speed up the fast forwarding of data within a large local area network, and the addition of the routing function also serves this purpose. If a large-scale network is divided into small LANs according to factors such as departments, regions, etc., this will lead to a large number of inter-network visits, which cannot be achieved by simply using a two-layer switch; such as the simple use of routers, due to the limited number of interfaces and The routing and forwarding speed is slow, which will limit the speed and network scale of the network. The use of a fast forwarding three-layer switch with routing function will become. If a large-scale network is divided into small LANs according to factors such as departments, regions, etc., this will lead to a large number of inter-network visits, which cannot be achieved by simply using a two-layer switch; such as the simple use of routers, due to the limited number of interfaces and The routing and forwarding speed is slow, which will limit the speed and network scale of the network. The use of a fast forwarding three-layer switch with routing function will become.
Generally speaking, in a network with large intranet data traffic that requires fast forwarding and response, if all the three-layer switches do this work, the three-layer switches will be overloaded, the response speed will be affected, and the routing between the networks will be overloaded. It is a good networking strategy to let the routers take full advantage of the advantages of different devices. Of course, the premise is that the customer's pockets are very strong, otherwise, the second step is to let the three-layer switch also serve as the Internet interconnection.
- 86-18938645642（Manager Wu）
- Address: unit C, 8 / F, building a, anlibang science and Technology Park, Xitian first industrial zone, Gongming street, Guangming New District, Shenzhen
- Shaanxi Xi'an Office
Contact person: Manager Zhang 02988283137 15389041752