Home > Article > Software Tutorial > Analysis of the working principle of the switch. Must-see: Simply master the working principle of the switch in 1 minute.
php editor Zimo takes you to master the working principle of the switch in 1 minute! The switch is an important part of the network equipment. By learning its working principle, we can better understand the basic mechanism of network communication. In a network, switches play an important role in connecting different devices and forwarding data. Want to learn more about how a switch works? Don’t miss this article!
With the development of enterprise networks, more and more users need to access the network, and the large number of access ports provided by switches can well meet this demand.
The switch solved the conflict problem of early Ethernet and improved performance and security.
The switch works at the data link layer and forwards data frames based on header information.
Next, we take a small switching network as an example to explain the basic working principle of a switch.
There is a MAC address table in the switch, which stores the mapping relationship between MAC addresses and switch ports. The MAC address table is also called the CAM (Content Addressable Memory) table.
As shown in the figure, there are three types of frame forwarding operations by the switch: Flooding, Forwarding ), discarding (Discarding).
1. Flooding: The switch forwards frames coming from a certain port through all other ports (note that "all other ports" refers to all ports except the port where the frame enters the switch. ).
2. Forwarding: The switch forwards frames coming from a certain port through another port (note that "another port" cannot be the port through which the frame enters the switch).
3. Discard: The switch directly discards the frames coming from a certain port.
The basic working principle of the switch can be briefly described as follows:
1. If a unicast frame enters the switch, the switch will look up the destination MAC address of the frame in the MAC address table. .
1) If the MAC address cannot be found, the switch will perform a flooding operation.
2) If the MAC address is found, compare the port corresponding to the MAC address in the MAC address table to see if it is the port through which the frame enters the switch. If not, the switch performs a forwarding operation. If so, the switch performs a discard operation.
2. If a broadcast frame enters the switch, the switch will not check the MAC address table, but will directly perform a flooding operation.
3. If a multicast frame enters the switch, the processing behavior of the switch is complicated, which will be discussed later.
In addition, the switch also has learning capabilities. When a frame enters the switch, the switch checks the source MAC address of the frame, maps the source MAC address to the port through which the frame enters the switch, and then stores this mapping relationship in the MAC table.
Initial state of the switch
In the initial state, the switch does not know the MAC address of the connected host, so the MAC The address table is empty. As shown in the figure, SWA is in the initial state. Before receiving the data frame sent by host A, there is no entry in the MAC address table.
Learn MAC address
When host A sends data to host C, it will usually first send an ARP request to obtain it. The MAC address of host C. The destination MAC address in this ARP request frame is the broadcast address, and the source MAC address is its own MAC address.
After SWA receives the frame, it will add the mapping relationship between the source MAC address and the receiving port to the MAC address table.
By default, the aging time of MAC address table entries learned by X7 series switches is 300 seconds. If a data frame is received from host A again within the aging time, the aging time of the mapping between host A's MAC address and G0/0/1 stored in SWA will be refreshed.
After that, if the switch receives a data frame with the destination MAC address 00-01-02-03-04-AA, it will be forwarded through the G0/0/1 port.
Forwarding data frames
The destination MAC address of the data frame sent by host A is the broadcast address, so the switch will broadcast the data frame to host B and host C through the G0/0/2 and G0/0/3 ports.
Target host reply
After receiving this data frame, host B and host C will check the ARP data frame. However, host B will not reply to the frame. Host C will process the frame and send an ARP response. The destination MAC address of this reply data frame is the MAC address of host A, and the source MAC address is the MAC address of host C.
When SWA receives a reply data frame, it will add the mapping relationship between the source MAC address of the frame and the interface to the MAC address table. If this mapping relationship already exists in the MAC address table, it will be refreshed. Then SWA queries the MAC address table, finds the corresponding forwarding port based on the frame's destination MAC address, and then forwards the data frame from G0/0/1.
The above is the detailed content of Analysis of the working principle of the switch. Must-see: Simply master the working principle of the switch in 1 minute.. For more information, please follow other related articles on the PHP Chinese website!