Zero packet loss network implementation and verification method based on Loongson CPU and operating system
By porting the PRP protocol stack to Loongson CPUs and the Loongnix operating system, a PRP network based on Loongson boards and ordinary switches was built, solving the problems of poor reliability of traditional networks and high cost of PRP switches, and realizing a domestic solution with zero packet loss and information security.
Patent Information
- Application Number
- CN202511476373.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-16
- Publication Date
- 2026-01-13
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
In existing technologies, traditional networks have poor reliability and are prone to packet loss, while PRP switches are expensive and use foreign CPUs and operating systems, posing information security risks.
Using Loongson CPUs and the Loongnix operating system, a PRP virtual network device was created under the Loongnix operating system, the PRP protocol stack was ported, and the PRP protocol stack was adapted into the Loongson board. A PRP network hardware environment based on the Loongson board and ordinary switches was built, configured, and verified.
It achieves a zero-packet-loss network, reduces networking costs, has high reliability and zero handover latency, while meeting information security requirements and conforming to the trend of domestic substitution.
Smart Images

Figure CN121334089A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of communication technology, specifically relating to a method for implementing and verifying a zero-packet-loss network based on a Loongson CPU and operating system. Background Technology
[0002] In recent years, information technology has developed rapidly, and global technological competition has become increasingly fierce. As the core of information technology, chips and operating systems have become increasingly strategically important. Developed countries have attempted to curb the development of information technology in developing countries through technological blockades and trade restrictions. Since chips and operating systems are the foundation of information technology, the localization of chips and operating systems is a necessary measure to cope with global technological competition, safeguard national security, promote industrial upgrading, and enhance competitiveness.
[0003] As an emerging industrial network solution, industrial Ethernet is becoming increasingly familiar and accepted. How can we ensure that industrial Ethernet meets the extremely stringent stability and redundancy requirements of the industrial sector? The IEC (International Electrotechnical Commission) has been promoting and improving relevant standards and technologies. Among them, IEC 62439-3:2016, published in 2016, released the PRP (Parallel Redundancy Protocol) for building highly available automated networks for industrial communication networks. Through this redundancy protocol, it is possible to ensure that all transmitted data can communicate normally and securely during the transmission of field communication data when the link changes, without delay or interruption, achieving true zero packet loss.
[0004] The invention patent application with application number CN201620393602.2 discloses a redundant Ethernet interface based on the Linux system, which implements bonding network redundancy processing through the Linux system. However, the switching time of bonding redundancy is greater than 200 milliseconds, which cannot meet the application scenarios with extremely high reliability and real-time requirements.
[0005] The invention patent application with application number CN202210963472.1 discloses a link resource optimization method based on the standard PRP protocol. This invention realizes the optimization of PC-to-PC data transmission and reception based on the PRP protocol, but it does not provide a feasible verification method, and uses a non-domestic processor and operating system, which does not meet the requirements of national information security.
[0006] Currently, zero-packet-loss networks based on PRP switches and foreign processors and operating systems have been promoted and applied to a certain extent. However, PRP switches are expensive and foreign solutions pose information security risks. This invention is based on Loongson CPUs and operating systems as well as ordinary network switches, which not only reduces application costs but also meets the strategic needs of domestic substitution for information systems. Summary of the Invention
[0007] (a) Technical problems to be solved The technical problem to be solved by this invention is how to provide a zero-packet-loss network implementation and verification method based on Loongson CPU and operating system, so as to solve the shortcomings of traditional networks such as poor reliability and easy packet loss, high cost of PRP switches, and information security risks associated with using foreign CPUs and operating systems.
[0008] (II) Technical Solution To address the aforementioned technical problems, this invention proposes a method for implementing and verifying zero-packet-loss networks based on a Loongson CPU and operating system. This method includes the following steps: S1. Steps to set up the cross-compilation environment for the operating system: Install the Ubuntu system and install the Loongnix operating system cross-compilation environment; S2, PRP protocol stack porting and adaptation method: Create a PRP virtual network device under the Loongnix operating system and adapt the PRP protocol stack code to the PRP virtual network device. S3 and PRP network hardware environment setup method: Based on Loongson boards and ordinary switches, build the hardware environment of PRP network. S4 and PRP network configuration and execution method: Burn the compiled operating system onto the Loongson board, connect to and configure the PRP function in the Loongson board through a PC; Verification methods for S5 and PRP networks: Verify the PRP network by pinging a PC using a Loongson board, pinging each other using Loongson boards, and disconnecting the network cable.
[0009] (III) Beneficial Effects This invention proposes a method for implementing and verifying zero-packet-loss networks based on Loongson CPU and operating system. This invention ports the PRP protocol stack to the Loongnix operating system, so the network data sent and received by the board is all PRP data packets, eliminating the need for a dedicated PRP switch for protocol conversion, which can greatly save networking costs. The CPU and operating system used in this invention are domestically produced, thus fully conforming to the current trend of domestic substitution.
[0010] This invention provides a method for implementing and verifying a zero-packet-loss network based on a Loongson CPU and operating system. By adapting the PRP protocol stack into the Loongson board, a zero-packet-loss network can be implemented using a regular switch. Compared to traditional networks, it has significant advantages in high reliability, zero packet loss, and zero handover latency. Furthermore, because the hardware and software use domestically produced CPUs and operating systems, it also offers advantages in information security. Attached Figure Description
[0011] Figure 1 This is a schematic diagram of the method flow of the present invention; Figure 2 This is a schematic diagram of the PRP network hardware environment setup method of the present invention. Detailed Implementation
[0012] To make the objectives, contents, and advantages of the present invention clearer, the specific embodiments of the present invention will be described in further detail below with reference to the accompanying drawings and examples.
[0013] This invention relates to a high-reliability, zero-packet-loss Ethernet communication technology based on Loongson CPU and operating system. It is mainly used in industries with high requirements for information security and extremely high requirements for the stability of transmission and control systems, such as national power systems, aerospace, and military transmission and control systems.
[0014] The technical problem to be solved by this invention is to provide a method for implementing and verifying a zero-packet-loss network based on Loongson CPU and operating system, so as to solve the shortcomings of traditional networks such as poor reliability, easy packet loss, high cost of PRP switches, and information security risks associated with using foreign CPUs and operating systems.
[0015] To achieve the above objectives, this invention provides a method for implementing and verifying a zero-packet-loss network based on a Loongson CPU and operating system, and implements and verifies it based on a Loongson 2K1000 board and the Loongnix operating system, including: S1. Steps to set up a cross-compilation environment for the operating system: Install the Ubuntu system and install a cross-compiler.
[0016] S2. Porting and Adaptation Methods for the PRP Protocol Stack: Create a PRP virtual network device under the Loongnix operating system, and adapt the PRP protocol stack code to the PRP virtual network device. S3 and PRP network hardware environment setup method: Based on Loongson 2K1000 board and ordinary switch, build the hardware environment of PRP network.
[0017] S4 and PRP network configuration and execution method: Burn the compiled operating system onto the board, connect to the board via PC and configure the PRP function in the board; Verification methods for S5 and PRP networks: Verify the PRP network through various methods such as pinging a PC from the board, pinging each other between boards, and disconnecting the network cable.
[0018] This invention ported the PRP protocol stack to the Loongnix operating system, so the network data sent and received by the board is all PRP data packets, eliminating the need for a dedicated PRP switch for protocol conversion, which can greatly save networking costs; the CPU and operating system used in this method are domestically produced, so it is in full line with the current trend of domestic substitution. Example
[0019] Figure 1 This is a flowchart illustrating a zero-packet-loss network implementation and verification method based on a Loongson CPU and operating system, according to the present invention. Figure 1 As shown, the method includes: (1) Steps for setting up the cross-compilation environment of Loongnix operating system. Install Ubuntu 16.04 and install the Loongnix operating system cross-compilation environment.
[0020] In practice, first install Ubuntu 16.04 on a PC, download the Loongson PMON source code, Loongnix operating system source code, and cross-compilation tools from the Loongson official website, and then install flex, bison, xutils-dev, and cross-compilation tools on Ubuntu 16.04. Before compiling, set the environment variable to the path of the installed cross-compilation tools.
[0021] (2) Porting and adaptation method of PRP protocol stack. Create a PRP virtual network device under the Loongnix operating system and adapt the PRP protocol stack code to the PRP virtual network device.
[0022] In practice, the operation set function prp_ops is first selected in the PRP initialization function prp_dev_finalize according to the PRP protocol and registered in the PRP virtual network device. prp_ops is a structure of type struct net_device_ops. When the user layer calls ip link to create a virtual network device, it will eventually enter prp_dev_finalize.
[0023] static const struct net_device_ops prp_ops = { .ndo_open = prp_open, .ndo_close = prp_close, .ndo_start_xmit = prp_handle_frame, .ndo_add_slave = prp_add_slave, .ndo_del_slave = prp_del_slave, }; prp_open / prp_close: Initialize / close the PRP device state machine; prp_add_slave: Binds two physical network cards as PRP redundant interfaces; prp_del_slave: Removes redundant interfaces; prp_handle_frame: When sending, copy the data packet and transmit the same frame simultaneously through both ports. When receiving, filter out duplicate frames.
[0024] Then, in prp_dev_finalize, the prp_add_port function is called. prp_add_port mainly implements the association between physical network devices and virtual network devices, redundant link management, and registration of hook functions. Hook functions are used to listen for and process lifecycle events of network devices. When the port bound to hrs_add_port triggers the NETDEV_DOWN event, the hook function detects the port failure and immediately switches traffic to another port, achieving 0ms interruption recovery.
[0025] (3) Method for building a PRP network hardware environment: Based on the Loongson 2K1000 board and ordinary network switches, build a PRP network hardware environment.
[0026] In practical implementation, first prepare at least two Loongson 2K1000 boards, requiring each board to have dual physical network cards and dual network ports. Prepare two ordinary network switches, two USB-to-serial cables, and several network cables. Connect the dual network ports of the boards to the two switches using network cables. For convenient data observation, prepare one PC. Connect one end of the USB-to-serial cable to the debugging serial port of the 2K1000 board, and the other end to the PC. The PC is also connected to any of the switches via a network cable. Refer to the connection diagram. Figure 2 .
[0027] (4) Configuration and execution methods of PRP networks; In practice, the first step is to flash the compiled operating system onto the Loongson 2K1000 board: compile the Loongnix operating system, compile the PRP protocol stack as a module and generate the kernel module ppr.ko, transfer ppr.ko to the file system directory of the 2K1000 board via TFTP, and then enter the following commands sequentially in the shell of the PC's serial port to configure the network: 1) Load the PRP module insmod prp.ko 2) Configure the MAC addresses of the two physical network cards on the 2K1000 board. ifconfig eth0 hw ether MAC address && ifconfig eth1 hw ether MAC address 3) Create a PRP device and associate it with physical NIC 0 and NIC 1. ip link add name prp0 type hsr slave1 eth0 slave2 eth1 supervisionproto 4) Enable PRP device ifconfig prp0 up 5) Configure the IP address and subnet mask of the PRP device. ifconfig prp0 IP address netmask subnet mask This completes the configuration of one board. The steps are the same for the other boards, except that the MAC address and IP address need to be modified accordingly.
[0028] (5) Verification methods for PRP networks; In practice, first install the Wireshark software on the PC, then perform packet capture tests using the ping command, which mainly includes: 1) Pinging a PC with a 2K1000 board After the 2K1000 board successfully pings the PC, the PC simultaneously replies with a duplicate packet. If the 2K1000 board sends two data packets at the same time, the PC should receive both data packets simultaneously. This can be observed by capturing packets with Wireshark software, which shows that the board sent two packets at the same time.
[0029] Double-clicking the source for different IP addresses will show data ending with a0 5a 88 fb and b0 5a 88 fb, indicating that they are A-frames and B-frames respectively, with 88fb being the end-of-frame marker for the PRP packet.
[0030] Comparing the data at the same time, it can be seen that the data is the same, indicating that the data sent by frames A and B at the same time is the same, achieving the effect of redundancy backup.
[0031] 2) Ping between 2K1000 boards Since both 2K1000 boards send PRP packets at this time, the PRP protocol will actively filter redundant data packets. Therefore, the 2K1000 board will first receive two data packets, and after processing by the PRP protocol, it will finally retain one data packet.
[0032] 3) Network cable disconnection test Unplugging any network cable from one of the boards does not affect normal communication. Packet captures using Wireshark show that no valid data is lost and there is zero handover latency, indicating that the PRP network has been successfully established. Example
[0033] A method for implementing and verifying zero-packet-loss networks based on Loongson CPU and operating system, comprising: (1) Steps for setting up a cross-compilation environment for a domestic operating system. Install Ubuntu 16.04 and install a cross-compiler.
[0034] (2) Porting and adaptation method of PRP protocol stack. Create a PRP virtual network device under the Loongnix operating system and adapt the PRP protocol stack code to the PRP virtual network device.
[0035] (3) Method for building a PRP network hardware environment. The hardware environment for building a PRP network is built based on the Loongson 2K1000 board and ordinary switches.
[0036] (4) PRP network configuration and execution methods.
[0037] (5) Verification method of PRP network.
[0038] Furthermore, in step (2) of the PRP protocol stack porting and adaptation method, a method is adopted to create a PRP virtual network device under the Loongnix operating system and adapt the PRP protocol stack code to the PRP virtual network device, including: In practical implementation, firstly, the operation set function `prp_ops` is selected according to the PRP protocol in `prp_dev_finalize` and registered with the PRP virtual network device. The two physical network cards are bound as PRP redundant interfaces, and frame processing is performed in `prp_handle_frame`. Then, in `prp_dev_finalize`, the `prp_add_port` function is called to implement the association between the physical network device and the virtual network device, redundant link management, and registration of hook functions. The hook functions are used to listen for and process the lifecycle events of the network device. When the port bound to `hrs_add_port` triggers the `NETDEV_DOWN` event, the hook function detects the port failure and immediately switches the traffic to another port, realizing 0ms interrupt recovery and completing the porting and adaptation of the PRP protocol stack to the operating system.
[0039] Furthermore, in step (3) of the method for building the PRP network hardware environment, the hardware environment of the PRP network can be built by connecting to an ordinary network switch via a network cable, without using a PRP switch, based on the Loongson 2K1000 board and an ordinary switch.
[0040] Furthermore, in step (4) of the PRP network configuration and execution method, the compiled Loongnix operating system is burned onto the Loongson 2K1000 board, the PRP is compiled in a module manner, and the prp.ko is transferred to the file system directory of the Loongson 2K1000 board and configured and executed via command line at the shell end of the PC serial port.
[0041] Furthermore, in step (5) of the PRP network verification method, the methods include pinging the Loongson 2K1000 board by PC, pinging each other by 2K1000 boards and using Wireshark to capture packets for analysis, and testing for network cable disconnection.
[0042] This invention ported the PRP protocol stack to the Loongnix operating system, so the network data sent and received by the board is all PRP data packets, eliminating the need for a dedicated PRP switch for protocol conversion, which can greatly save networking costs; the CPU and operating system used in this invention are domestically produced, thus fully conforming to the current trend of domestic substitution.
[0043] This invention provides a method for implementing and verifying a zero-packet-loss network based on a Loongson CPU and operating system. By adapting the PRP protocol stack into the Loongson board, a zero-packet-loss network can be implemented using a regular switch. Compared to traditional networks, it has significant advantages in high reliability, zero packet loss, and zero handover latency. Furthermore, because the hardware and software use domestically produced CPUs and operating systems, it also offers advantages in information security.
[0044] The above description is only a preferred embodiment of the present invention. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the technical principles of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.
Claims
1. A method for implementing and verifying zero-packet-loss networks based on Loongson CPU and operating system, characterized in that, The method includes the following steps: S1. Steps to set up the cross-compilation environment for the operating system: Install the Ubuntu system and install the Loongnix operating system cross-compilation environment; S2, PRP protocol stack porting and adaptation method: Create a PRP virtual network device under the Loongnix operating system and adapt the PRP protocol stack code to the PRP virtual network device. S3 and PRP network hardware environment setup method: Based on Loongson boards and ordinary switches, build the hardware environment of PRP network. S4 and PRP network configuration and execution method: Burn the compiled operating system onto the Loongson board, connect to and configure the PRP function in the Loongson board through a PC; Verification methods for S5 and PRP networks: Verify the PRP network by pinging a PC using a Loongson board, pinging each other using Loongson boards, and disconnecting the network cable.
2. The method for implementing and verifying zero-packet-loss networks based on Loongson CPU and operating system as described in claim 1, characterized in that, S1 includes: first, installing the Ubuntu system on the PC, downloading the Loongson PMON source code, the Loongnix operating system source code and cross-compilation tools, and then installing flex, bison, xutils-dev and cross-compilation tools on the Ubuntu system. Before compiling, set the environment variable to the path of the installed cross-compilation tools.
3. The method for implementing and verifying zero-packet-loss networks based on Loongson CPU and operating system as described in claim 1, characterized in that, S2 includes: selecting the operation set function prp_ops according to the PRP protocol in the PRP initialization function prp_dev_finalize, registering it to the PRP virtual network device, where prp_ops is a structure of type struct net_device_ops, which will eventually enter prp_dev_finalize when the user layer calls ip link to create a virtual network device; binding the two physical network cards as PRP redundant interfaces in prp_dev_finalize, and performing frame processing in prp_handle_frame.
4. The method for implementing and verifying zero-packet-loss networks based on Loongson CPU and operating system as described in claim 3, characterized in that, S2 further includes: calling the prp_add_port function in prp_dev_finalize. prp_add_port implements the association between physical network devices and virtual network devices, redundant link management, and registration of hook functions. The hook functions are used to listen for and process lifecycle events of network devices. When the port bound to hrs_add_port triggers the NETDEV_DOWN event, the hook function detects the port failure and immediately switches traffic to another port, achieving 0ms interruption recovery.
5. The method for implementing and verifying zero-packet-loss networks based on Loongson CPU and operating system as described in claim 1, characterized in that, S3 includes: First, prepare at least two Loongson circuit boards, which are required to have dual physical network cards and dual network ports. Prepare two ordinary network switches, two USB-to-serial cables, and several network cables. Connect the dual network ports of the Loongson circuit boards to the two switches respectively using network cables. To facilitate data observation, prepare a PC. Connect one end of the USB-to-serial cable to the debugging serial port of the Loongson circuit board and the other end to the PC. The PC is also connected to any switch via a network cable.
6. The method for implementing and verifying zero-packet-loss networks based on Loongson CPU and operating system as described in claim 1, characterized in that, The S4 includes: compiling the Loongnix operating system, compiling the PRP protocol stack as a module and generating the kernel module prp.ko, transferring prp.ko to the file system directory of the Loongson board via TFTP, and entering commands in the shell of the PC serial port to configure the network.
7. The method for implementing and verifying a zero-packet-loss network based on a Loongson CPU and operating system as described in claim 6, characterized in that, In step S4, entering commands in the shell terminal of the PC's serial port to configure the network includes: 1) Load the PRP module; 2) Configure the MAC addresses of the two physical network cards on the Loongson board; 3) Create a PRP device and associate it with physical NIC 0 and NIC 1; 4) Enable PRP devices; 5) Configure the IP address and subnet mask of the PRP device.
8. The method for implementing and verifying zero-packet-loss networks based on Loongson CPU and operating system as described in claim 1, characterized in that, The S5 Loongson board pinging PC includes: After the Loongson board successfully pings the PC, the PC simultaneously replies with a duplicate packet. If the Loongson board sends two data packets at the same time, the PC should receive both data packets simultaneously. This can be observed by capturing packets with Wireshark software, showing that the Loongson board sent two packets at the same time. Double-clicking the source information for different IP addresses reveals data ending with a0 5a 88 fb and b0 5a 88 fb, indicating that they are A-frames and B-frames respectively, with 88fb being the end-of-frame marker for the PRP data packet. If the data are the same when compared at the same time, it means that the data sent by frames A and B at the same time are the same, thus achieving the effect of redundancy backup.
9. The method for implementing and verifying a zero-packet-loss network based on a Loongson CPU and operating system as described in claim 1, characterized in that, The S5 process of mutual ping between Loongson boards includes: both Loongson boards send PRP packets. The PRP protocol actively filters redundant data packets. The Loongson board will first receive two data packets, and after processing by the PRP protocol, it will finally retain one data packet.
10. The method for implementing and verifying a zero-packet-loss network based on a Loongson CPU and operating system as described in claim 1, characterized in that, The S5 network cable disconnection test includes: randomly unplugging one network cable from one of the Loongson boards without affecting normal communication. If the packet capture from Wireshark shows that no valid data is lost and there is zero handover delay, it indicates that the PRP network has been successfully built.
Citation Information
Patent Citations
Link resource optimization method based on standard PRP protocol
CN115333992B
Redundant ethernet interface based on linux system
CN205610658U
Parallel redundancy protocol (PRP) network connection method under Windows system
CN107332834A
High-reliability full-redundancy network link system and implementation method
CN112511347A
Linux modular PRP protocol stack system
CN115051778A