Design and Implementation of a Microcontroller-Controlled Network Switch
2026-04-06 04:48:58··#1
Abstract: This paper introduces the development process of a microcontroller-based intelligent Ethernet switch, including hardware circuitry, microcontroller software, and PC management program. Users can configure and manage the network switch through the PC management program or PC terminal. Keywords: Microcontroller, Ethernet switch, AL101 Introduction With the improvement of computer performance and the surge in communication volume, traditional LANs have increasingly exceeded their own capacity. Switched Ethernet technology has emerged to greatly improve the performance of LANs. Network switches can significantly increase bandwidth and establish geographically dispersed networks. Each port of a LAN switch can transmit information in parallel, securely, and in real time. Moreover, it is stable, flexible in structure, easy to install, and easy to manage, well meeting the needs of enterprise networks and broadband access for telecom operators. 1 Hardware Design of the Network Switch With the increasing demand for security and high bandwidth in network applications, network switches are becoming increasingly widely used. This switch uses the ROX bus of the AL101 chip to connect three 8-port switching chips, forming a 24-port switch, meeting the user's need for multiple switching ports. 1.1 Circuit Performance Requirements The high-speed PCB circuit board of the switch has high requirements for EMC and ESD. It uses 75MHz and 50MHz high-speed clocks, requiring crystal oscillator accuracy of less than 50PPM. Simultaneously, the clock needs to be distributed to different chips via a clock distribution circuit, with a phase difference of less than 2ns between the distributed clocks. The switch has 24 10/100M auto-sensing ports, each capable of line-speed switching. Ports can be configured with 10/100M speed, full/half-duplex, flow control, static MAC address, mirroring, VLAN, etc., according to user needs. 1.2 Switch Block Diagram This switch uses a store-and-forward switching technology and mainly consists of five parts: interface unit, switching unit, management unit, indicator unit, and power interface unit. Its block diagram is shown in Figure 1. After receiving Ethernet frame data packets, the RJ45 interface sends them to the PHY (physical interface chip) after transformer isolation and impedance matching. This chip performs the conversion from analog signals to digital signals on the RMII interface and obtains information such as link status, collisions, message length exceeding limits, and speed. Data enters the switching chip (composed of three chips forming a loop via the ROX bus, enabling data exchange between the three chips). The switching chip obtains the destination and source addresses of the data and performs error checking on the Ethernet frame. The switching chip stores the source address in its own MAC address table and then matches the destination address with the address in the MAC address table to determine the appropriate port for data forwarding. If the destination port is in the same switching chip, the data is retrieved from the SGRAM and forwarded to the corresponding port; if the destination port is not in the same switching chip, the data is transmitted to the corresponding switching chip via the ROX bus and then forwarded; if no corresponding destination address is found in the MAC address table, the frame is forwarded to all ports belonging to the same VLAN other than the source port, or to a specific uplink port (depending on the switching chip register settings). The indicator lights are provided by the PHY, allowing observation of the operating speed, connectivity, and data transmission/reception status of each port. During each power-on or reset, the switching chip first reads the contents of the external EEPROM to initialize and configure its registers. The contents of the switching chip registers can be read and written via the PC's management program or PC's terminal emulator to control or read the switch's operating configuration. 2. Software Design of the Network Switch The software of the entire network switch system includes the microcontroller's control software, EEPROM configuration data, and the PC's management program. The microcontroller's control software mainly handles register reading and writing and communication with the PC. Through this management unit, the switch can be configured into various operating modes to meet the needs of different users. The switching chip connects to the EEPROM (24C02) via the I2C bus to store configuration data. When the device powers on or resets, it reads this data from the EEPROM for system initialization. The PC's management program allows users to easily configure the system by connecting the PC's serial port to the system device and using the PC's management program interface. 2.1 Microcontroller Control Software Design The management unit consists of a microcontroller and a serial port, and the PC is used to configure the EEPROM or the switching chip's registers. The microcontroller primarily handles register reading and writing and communication with the PC. The serial port serves as a connection to the PC, and a level conversion chip connects the microcontroller and the serial port to convert signals between them. Through the management unit, the switch can be configured in various operating modes to meet the needs of different users, such as: 10/100M speed settings, full/half-duplex settings, flow control, static MAC address settings, mirroring settings, broadcast storm control, VLAN settings, etc. The microcontroller's software flow is shown in Figure 2. The modules are described below: main—main program; init_uart—serial port initialization; delay—system delay; helpMenu—help menu; systemCheck—check system device ID; whict>:—command prompt (whict is an abbreviation for Wuhan Institute of Chemical Technology); D—view the entire system configuration data; E—edit the system configuration data; F—configure and manage various functions of the switch; R—read the system configuration data; W—the system saves the current configuration data to EEPROM; L—configure the system static MAC address; M—change the system password; I—system software reset; S—the system downloads the default configuration to EEPROM. 2.2 PC Management Program Design The PC management program is programmed in VB language and has an easy-to-understand software interface. Users can easily configure the network switch. The PC management program is shown in Figure 3, and the switch management software interface is shown in Figure 4. 3. Performance Testing of Network Switch The switch was subjected to a 12-hour performance test at room temperature (25℃) using a Smartbits2000 instrument. Four parameters were measured: throughput, latency, packet loss rate, and back-to-back connection. The test results are shown in Table 1.