LAN Switching solves the performance limitations of the shared network. Each user can enjoy the dedicated bandwidth, thus alleviating the bandwidth shortage and network bottleneck. This article mainly discusses the basic principle and the exchange mode of the exchange technology, and introduces the concept of multi-layer exchange technology from the exchange mode.
I. Basic principles of Exchange Technology
LAN switching technology is a technology on the Data-Link Layer of the Data Link Layer in the OSI reference model. The so-called "switching" actually refers to forwarding Data frame ). In data communication, all switching devices (switches) perform two basic operations:
Exchange data frames and forward the data frames received from the input media to the corresponding output media;
Maintains the exchange operation and constructs and maintains the exchange address table.
Next, we will discuss the details of these two basic operations.
1. Exchange data frames
The switch forwards data frames based on the MACMedia Access Control Address (physical address) of the data frame. When forwarding data frames, the switch follows the following rules:
If the destination MAC address of the data frame is a broadcast address or multicast address, the ports except the data frame are forwarded to all ports of the switch );
If the destination address of the data frame is a unicast address, but this address is not in the Address Table of the switch, it will also forward all ports except the data frame );
If the destination address of the data frame is in the vswitch address table, it is forwarded to the corresponding port according to the address table;
If the destination address of the data frame is in the same network segment as the source address of the data frame, the data frame will be discarded and the exchange will not happen. Next, let's take 1 as an example to see the specific data frame exchange process.
When host D sends a broadcast frame, the switch receives the data frame with the destination address ffff. ffff. ffff from Port E3 and forwards the data frame to ports E0, E1, E2, and E4.
When host D communicates with host E, the switch receives a data frame whose destination address is 0260.8c01.5555 from Port E3. After finding the address table, it finds that 0260.8c01.5555 is not in the table, therefore, the switch still forwards the data frame to E0, E1, E2, and E4 ports.
When host D communicates with host F, the switch receives a data frame whose destination address is 0260.8c01.6666 from Port E3. After finding the address table, it finds that 0260.8c01.6666 is also located at Port E3, that is, it is in the same network segment as the source address, so the switch does not forward the data frame, but directly discards it.
When host D communicates with host A, the switch receives A data frame with the destination address 0260.8c01.1111 from Port E3. Find the address table and find that 0260.8c01.1111 is on port E0, therefore, the switch forwards the data frame to the E0 port so that host A can receive the data frame.
If host B sends data to host C while host D communicates with host A, the switch also forwards the data frame sent by host B to the E2 port connecting host C. At this time, two links are established between E1 and E2, and between E3 and E0 through the hardware Exchange Circuit in the switch. The data communication between the two links is independent of each other, therefore, the network will not conflict. Therefore, the communication between host D and host A is A dedicated link, and between host C and host B is also A dedicated link. Such a link is established only when both parties need it. Once data transmission is completed, the corresponding link is also removed. This is the main feature of vswitches.
From the above exchange operation, we can see that the data Frame Forwarding is based on the MAC address table in the switch. But how is this address table created and maintained? Next we will introduce this issue.
2. construct and maintain the exchange Address Table
In the switch address table, a table item consists of a host MAC address and the switch port number in which the address is located. The generation of the whole address table adopts the dynamic self-learning method, that is, when the switch receives a data frame, it records the source address and input port of the data frame in the exchange address table. In Cisco switches, the exchange address table is placed in the Content-Addressable storage Content-Addressable Memory, CAM). Therefore, it is also called a CAM table.
Of course, before storing the exchange address table items, the switch should first check whether the source address matches the table items in the address table. Only when the match Table item does not exist can the table items be stored. Each address table item has a time mark to indicate the time period of the table item storage. Each time an address table item is used or searched, the time mark of the table item is updated. If the address table item is still not referenced within a certain period of time, it will be removed from the address table. Therefore, the address exchange table maintains the most effective and accurate address-port information.
Ii. exchange mode
When switching data frames, a switch can select different modes to meet network and user needs. Cisco switches provide three switching modes:
1. Storage and forwarding Mode
The Store-and-forward mode means that the switch can complete the entire data frame and perform the forwarding operation only after the CRC verification is passed. If CRC verification fails, that is, the data frame is incorrect, the switch discards the frame. This mode ensures data frame error-free transmission. Of course, the cost is that the transmission delay increases with the length of the data frame.
2. Fast Forwarding Mode
The Fast-forward (Fast-forward) Mode means that when a switch receives a data frame, it immediately performs the forwarding operation once the destination address is detected. However, because the data frame is not a complete frame during forwarding, the data frame will be directly forwarded without verification or error correction, and the wrong data frame will still be forwarded to the network, this wastes the bandwidth of the network. The advantage of this mode lies in the low latency of data transmission, but the cost is that it cannot perform verification and Error Correction on data frames.
3. Free Segmentation
Free Fragment-free) mode is used when the switch receives a data frame, once it detects that the data frame is not a conflict frlision fragment), the forwarding operation is performed. The conflicted fragment is a data frame fragment damaged by a network conflict. It is characterized by a length less than 64 bytes. Conflicting fragments are not valid data frames and should be discarded. Therefore, the free segmentation mode of the switch is to start forwarding once the received part of the data frame exceeds 64 bytes. The performance of this mode is between the storage forwarding mode and the fast forwarding mode.
Figure 2 shows one of the above three exchange modes. We can see that before the forwarding operation, the length of the data frames received by different switching modes is different, which also determines the corresponding delay. The shorter the length of the received data frame, the lower the switch switching delay, the higher the switching efficiency, but the less error detection.
Iii. Multi-layer exchange technology
Generally, hardware is used to implement LAN switching technology. In the LAN data frame format, the location of the destination MAC address is fixed, and the check and verification of the frame header information is very simple, facilitating the implementation of hardware exchange. Therefore, the traditional LAN exchange refers to Layer 2 exchange, that is, based on the Layer 2 information-the destination MAC address.
In the introduction of the switching mode, we can see that the switch needs to receive data of a certain length before performing the switching operation to perform the corresponding Forwarding Detection. If the length of the detection data is increased appropriately, the layer-2 switching technology can be expanded to layer-3 switching technology, or even layer-4 switching technology.
The layer-3 switching technology is to expand the detection data to the IP Group header and exchange it by detecting the IP addresses. It is actually a hardware-based route. Layer-4 switching is to further check the communication protocol type and port number in the IP grouping header, which can be seen as application-based switching.
Currently, the widely used multi-layer switching technology combines Layer 2, Layer 3, and Layer 4 switching technologies to implement the "one-time routing and multiple-times switching" function.