Traditional Culture Encyclopedia - Travel guide - L2 switch

L2 switch

L2 switches are Layer 2 switches; L3 routers are Layer 3 routers; L means Layer;

Layer 2 switching technology is relatively mature, and Layer 2 switches are data links. The road layer device can identify the MAC address information in the data packet, forward it based on the MAC address, and record these MAC addresses and corresponding ports in an internal 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 that the machine with the source MAC address is connected. On which port;

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

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

(4) If the corresponding port cannot be found in the table, broadcast the data packet 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 there is no need to broadcast to all ports the next time it transmits data.

By continuously cycling this process, 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 layer 2 switches:

(1) Since the switch switches data on most ports at the same time, this requires a very 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 the switch can achieve line-speed switching;

(2) Learn port connections The MAC address of the machine is written into the address table. The size of the address table (generally expressed in two ways: one is BEFFER RAM and the other is the MAC table entry value). The size of the address table affects the access capacity of the switch;

< p>(3) Another thing 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. Since 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 this point when considering equipment selection.

Routing technology

Routers work at the third layer of the OSI model --- network layer operation. Its working mode is similar to layer 2 switching, but the router works at the third layer. This The difference determines that routing and switching use different control information when transmitting packets, and implement functions in different ways. The working principle is that there is a table inside the router. What this table indicates is if you want to go to a certain place, where should you go next. If you can find the data packet from the routing table, where should you go next? The information is added and forwarded; if it is not known where to go next, the packet is discarded and a message is returned to the source address.

Routing technology essentially has only two functions: determining the optimal route and forwarding data packets. Various information is written into 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 to forward in the same way, and so on, until the data packet reaches the destination router.

There are two different ways to maintain routing tables. One is to update routing information, publishing 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 a distance vector routing protocol; the other is Routers broadcast their own link status information, learn the routing information of the entire network through mutual learning, and then 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 its performance. Of course, this judgment still applies to mid- to low-end routers, because high-end routers often adopt distributed processing system architecture designs.

(3) Three-layer switching technology

The publicity of three-layer technology in recent years has made your ears tingle, and people are shouting about three-layer technology everywhere. Some people say that this is a very As for new technologies, some people say that Layer 3 switching is just a stack of routers and Layer 2 switches, and there is nothing new about it. Is this really the case? Let's first look at the working process of a layer 3 switch through a simple network.

The networking is relatively simple

Equipment using IP A---------------------Layer 3 switch ------------------------Device B using IP

For example, if A wants to send data to B and the destination IP is known, then A uses the subnet mask to obtain the network address and determines whether the destination IP is in the same network segment as itself.

If they are on the same network segment but do not know the MAC address required 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, and the switch Enable the Layer 2 switching module, search the MAC address table, and forward the data packet to the corresponding port.

If the destination IP address is not in the same network segment, then A wants 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 missing address. Provincial gateway. This default gateway is generally set in the operating system and corresponds to the third layer routing module. Therefore, it can be seen that for data that is not the same subnet, the MAC address of the default gateway is first placed in the MAC table; then When the layer 3 module receives this data packet, it queries the routing table to determine the route to B, and constructs a new frame header 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 identification triggering mechanism, the corresponding relationship between the MAC addresses and forwarding ports of hosts A and B is established

and the incoming cache entry table is recorded. In the future, the data from A to B will be directly handed over to The layer 2 switching module is completed. This is commonly referred to as routing once and forwarding multiple times.

The above is a simple summary of the working process of the three-layer switch. We can see the characteristics of the three-layer switching:

High-speed forwarding of data is achieved by combining hardware.

This is not a simple superposition of layer 2 switches and routers. The layer 3 routing module is 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 several Ten Gbit/s. Counting backplane bandwidth, these are two important parameters for Layer 3 switch performance.

Simple routing software simplifies the routing process.

Most of the data forwarding, except for the necessary route selection, which is handled by the routing software, is forwarded at high speed by the second-layer module. Most of the routing software is processed and efficient optimization software, and it is not a simple copy of the router. software in.

Conclusion

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, multiple access ports and low price of layer 2 switches provide a complete solution for small network users.

The advantage of the router is that it has rich interface types, supports powerful three-layer functions, and has powerful routing capabilities. It is suitable for routing between large networks. Its advantage lies in selecting the best route, load sharing, and link Backup and exchange of routing information with other networks are the functions of a router.

The most important function of a Layer 3 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 a large network is divided into small LANs according to departments, regions, etc., this will lead to a large number of Internet visits. Simply using a Layer 2 switch cannot achieve Internet visits; if you simply use a router, due to the limited number of interfaces and The slow forwarding speed of routing will limit the speed and scale of the network, so the use of fast forwarding Layer 3 switches with routing functions becomes the first choice.

Generally speaking, in a network with large intranet data traffic and fast forwarding and response requirements, if all Layer 3 switches are used to do this work, the Layer 3 switches will be overburdened and the response speed will be affected. It is a good networking strategy to leave the routing between networks to the router and give full play to the advantages of different devices. Of course, the premise is that the customer's pockets are deep, otherwise they should settle for the second best and let the three-layer switch also Also serves as Internet interconnection.