What is a switch?
A switch, meaning "switch," is a network device used for forwarding electrical (or optical) signals. It provides a dedicated electrical signal path for any two network nodes connected to the switch. The most common type of switch is the Ethernet switch . Other common types include telephone voice switches and fiber optic switches.
Switching is a general term for technologies that, according to the information transmission needs of both ends of a communication network, use manual or automated methods to send the information to be transmitted to the appropriate route that meets the requirements. Switches can be divided into wide area network (WAN) switches and local area network (LAN) switches based on their operating location. A WAN switch is a device that performs information exchange functions in a communication system; it operates at the data link layer. A switch has multiple ports, each with bridging capabilities, which can connect a LAN or a high-performance server or workstation. In practice, switches are sometimes referred to as multi-port bridges.
Switch startup process
The typical startup process of a switch includes the operation of loading software and completing the following tasks:
Complete the initialization of the low-level switch CPU. This will initialize the physical memory and CPU registers of the control image, including parameters such as quantity and speed.
Perform a Power-On Self-Test (POST) for the CPU subsystem. It will detect the CPU DRAM and the flash memory device with the live flash file system.
Initialize the flash memory system on the system motherboard.
Load the default operating system software image into memory and start the switch.
This bootloader provider accesses the flash file system before the operating system is loaded. Normally, the bootloader is only used to load, decompress, and log in to the operating system. After the bootloader relinquishes CPU control to the operating system, it becomes inactive until the next system reboot or power-on.
Before assigning information to the switch, ensure that the switch's console interface is connected to a PC or terminal, and that the PC or terminal emulation software is configured to set the connection speed and character format for the switch's console interface. The default connection speed is 9600 b/s, and the default data bit width is 8 bits.
Working principle of a switch
When a switch receives data, it checks the destination MAC address and then forwards the data from the interface where the destination host resides. The switch achieves this by maintaining an internal MAC address table that records the correspondence between all MAC addresses in the network and the switch's ports. When a data frame needs to be forwarded, the switch looks up the destination MAC address in its MAC address table to determine the corresponding port. In other words, it knows which port the device with that MAC address is connected to, and then forwards the data frame from that port.
1. The switch establishes a mapping between the source MAC address in the received data frame and the switch port, and writes it into the MAC address table.
2. The switch compares the destination MAC address in the data frame with the established MAC address table to determine which port to forward the data.
3. If the destination MAC address in the data frame is not in the MAC address table, it is forwarded to all ports. This process is called flooding.
4. Broadcast and multicast frames are forwarded to all ports.
Example: A network is shown in Figure 1.
Table 1 Port/MAC Address Mapping Table
MAC address port
00-10-B5-4B-30-85E0/1
00-10-B5-4B-30-90E0/2
00-10-B5-4B-30-65E0/24
Suppose host pc1 sends a data frame to host pc7. After the data frame is sent to the switch, the switch first looks up the MAC address table and finds that host pc7 is connected to the E0/24 interface, so it forwards the data frame out from the E0/24 interface.
II. The process of constructing a MAC address table
To quickly forward packets, Ethernet switches need to build and maintain MAC address tables. Switches use source MAC address learning to build these tables.
(1) Initial state of the switch
The initial state of the switch is that the MAC address table is empty, as shown in Figure 2.
(2) Learning the source MAC address of the address table
When computer PC1 wants to send a data frame to computer PC6, since the address table is empty at this time, the switch will forward the data frame to all ports except the port E0/1 where PC1 is connected. Before forwarding, the source MAC address of the data frame (00-10-B5-4B-30-85) is checked first, and a record (00-10-B5-4B-30-85, E0/1) is added to the switch's MAC address table to correspond to port E0/1.
(3) Computer PC6 receives data frames
After receiving the data frame, computer PC6 compares the destination MAC address of the data frame with its own MAC address. If it finds that PC1 is looking for the same MAC address, it accepts the data frame, while other computers discard the data frame.
When PC6 replies to PC1, the switch forwards the message directly from port E0/1 and learns that (00-10-B5-4B-30-65) is the port connected to PC6, adding it to the address table, as shown in Figure 3.
The other ports of the switch continuously add new MAC address and port number mappings to the MAC address table using source MAC address learning until the MAC address table is complete.
To ensure that the information in the MAC address table reflects network conditions in real time, each learned record has an aging period. If address information is received within the aging period, the record is refreshed. If no corresponding address information is received, the record is deleted. For example, if computer PC6 stops communicating with the switch, the switch will delete its corresponding record from the MAC address table after the aging period.
You can also manually add static records to the switch's MAC address table. Manually configured static records have no aging time limit. Since there can only be one record for the same MAC address in the MAC address table, once the MAC address and port number mapping is manually configured, the switch will no longer dynamically learn the computer's MAC address.