Data communication method and system based on redundant network failure detection and switching

CN122845388APending Publication Date: 2026-09-29EAST CHINA INST OF COMPUTING TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611039605.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-14
Publication Date
2026-09-29

AI Technical Summary

Technical Problem

1、现有的双网冗余系统主要基于Linux、VxWorks、FreeRTOS等操作系统,Linux、FreeRTOS操作系统虽开源且免费,但版本复杂,难以提供技术支持;VxWorks操作系统开发软件价格昂贵,且在某些领域涉及到国家信息安全问题而备受诟病

Benefits of technology

本发明提供的基于冗余网络故障检测与切换的数据通信方法及系统,基于国产嵌入式实时操作系统ReWorks环境实现双网冗余驱动,环境和相关软件自主可控,结合link状态和网卡运行情况,进行网卡间数据搬移,显著提升了操作系统的信息安全性和网络通信可靠性。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122845388A_ABST
    Figure CN122845388A_ABST
Patent Text Reader

Abstract

A data communication method and system based on redundant network fault detection and switching. The method comprises: establishing a dual-network redundant driver, initializing a dual-network redundant driver control entity, and binding a switchable physical network card; registering a virtual network card at a network protocol stack layer; monitoring real-time link states and error rates of two physical network cards, and performing dual-network redundant switching and updating virtual network card link states based on the same; according to a received interrupt signal, finding a dual-network redundant driver control entity corresponding to a current physical network card, calling a network protocol stack interface, and receiving data at the network protocol stack layer according to the virtual network card; and finding a data sending interface of the current physical network card bound by the virtual network card, and sending data by calling a corresponding interface by using a network card driver. The application realizes real-time link state and error rate monitoring of a redundant network at a driver layer, dual-network switching, and data sending and receiving after switching.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer technology, and in particular to a data communication method and system based on redundant network fault detection and switching, and also provides an industrial control device. Background Technology

[0002] With the development of network technology, Ethernet is entering the field of industrial control on a large scale and is widely used in industrial process control, communication, aerospace and navigation systems. In these systems, multiple computers and other devices often form a communication network to jointly complete the system control. Such systems have extremely high requirements for network real-time performance, anti-interference and reliability. At the same time, such systems are highly integrated, have complex electromagnetic environments, and require various modules to cooperate with each other. The systems are complex and generally operate under long-term high-pressure conditions. Hardware or software failures at a certain link node are inevitable. The dual network card redundancy design of the equipment has been widely used as an effective method to improve the stability and reliability of network communication.

[0003] The current industry practice is mainly based on the VxWorks operating system for network redundancy switching. It mainly detects communication link anomalies at the application layer, switches between primary and backup machines or primary and backup modules after detecting a link anomaly, and then executes the current task. This process takes too long, and in some specific systems, the time spent on this process can lead to data loss.

[0004] In summary, current dual-NIC redundancy technology still has the following drawbacks: 1. Existing dual-network redundancy systems are mainly based on operating systems such as Linux, VxWorks, and FreeRTOS. Although Linux and FreeRTOS are open source and free, their versions are complex and technical support is difficult to provide. VxWorks operating system software is expensive to develop and has been criticized for involving national information security issues in some areas.

[0005] 2. The switching conditions for redundant network cards only determine the link status of the network card and PHY, lacking monitoring of the real-time link status of the network, the bit error rate of transmitted and received data, and abnormal links in the transmission and reception processing flow. Summary of the Invention

[0006] To address the aforementioned shortcomings in the prior art, this invention provides a data communication method and system based on redundant network fault detection and switching, and also provides an industrial control device.

[0007] According to a first aspect of the present invention, a data communication method based on redundant network fault detection and switching is provided, wherein a network interface card (NIC) driver is established at the network driver layer, and further includes: Establish a dual-network redundancy driver at the network driver layer, initialize the dual-network redundancy driver control entity, and bind a switchable physical network card in the dual-network redundancy driver. Register the virtual network interface card (NIC) corresponding to the dual-network redundancy driver at the network protocol stack layer, and start the virtual NIC connection status monitoring task. Monitor the link status of the two physical network cards, including real-time link status and bit error rate; perform dual-network redundancy switching based on the real-time link status and bit error rate, and update the virtual network card link status; In dual-network redundancy working mode, based on the received interruption signal, the network interruption reception processing flow is entered, the dual-network redundancy driver control entity corresponding to the physical network card that is currently receiving network data is found, the network protocol stack interface is called, and the data reception process is processed in the network protocol stack layer according to the virtual network card. The network protocol stack layer uses the registered virtual network interface card (NIC) to find the currently bound physical NIC, and then uses the NIC driver to call the corresponding data sending interface to process the data sending process through the data sending interface of the current physical NIC.

[0008] Preferably, registering the virtual network interface card corresponding to the dual-network redundancy driver at the network protocol stack layer includes: Read the MAC address of the physical network card and write it into the specified data structure so that the virtual network card has a unique MAC address; Assign a specified IP address to the virtual network interface card so that the virtual network interface card has a unique IP address.

[0009] Preferably, the monitoring of the link status of the two physical network cards includes real-time link status and bit error rate; based on the real-time link status and bit error rate, performing dual-network redundancy switching and updating the virtual network card link status includes: The system monitors the real-time link status and bit error rate of the current physical network interface card (NIC). It determines the link status of the currently bound NIC by reading the link status register of the PHY chip, or by checking if the bit error rate of the received data frames within the sliding time window exceeds a bit error rate threshold. If the current NIC is in a normal state, it remains active. If the current NIC is in an abnormal state, the system monitors the link status and bit error rate of the backup NIC to determine its status. If the backup NIC is in a normal state, the system switches to the backup NIC. If the backup NIC is in an abnormal state, the system continues to use the current NIC without switching. If all NICs are in an abnormal state in the current state, a prompt message is output via the serial port. Update the link status of the virtual network interface card (NIC) based on the current link status of the physical NIC and the backup physical NIC. Monitor whether the link status of the virtual network interface card has changed; if there is no change, return to continue monitoring the link status and bit error rate of the current physical network interface card; if there is a change, report the link status of the virtual network interface card to the network protocol stack layer, and move the data corresponding to the address pointed to by the network packet buffer pMblk of the abnormal physical network interface card to the new physical network interface card. Determine whether the data corresponding to the address pointed to by the network packet buffer pMblk of the abnormal physical network card needs to be retransmitted; if it does not need to be retransmitted, return to continue monitoring the link status and bit error rate of the current physical network card; otherwise, retransmit the data corresponding to the address pointed to by the network packet buffer pMblk, and then continue monitoring the link status and bit error rate of the current physical network card. Repeat the monitoring and switching process described above until the termination condition is met.

[0010] Preferably, updating the link status of the virtual network interface card (NIC) based on the link status of the current physical NIC and the backup physical NIC includes: determining whether the corresponding physical NIC is linked up or linked down by reading the link status register of the PHY chip, and then determining whether the link status of the virtual NIC has changed; if the status has not changed, then returning to continue monitoring the link status and bit error rate of the physical NIC and the backup physical NIC; if the status has changed, then reporting the change in the link status of the virtual NIC to the network protocol stack layer, and the network protocol layer updates the link status of the virtual NIC.

[0011] Preferably, the step of moving the data corresponding to the address pointed to by the network packet buffer pMblk of the abnormal physical network card to the new physical network card includes: In the network packet buffer pMblk of the malfunctioning physical network card, the data corresponding to the address pointed to by pMblk is found. After switching to another normal network card, the data corresponding to the address pointed to by the network packet buffer pMblk of the malfunctioning network card is copied to the network packet buffer pMblk of the new physical network card, thereby avoiding network packet loss.

[0012] Preferably, before the data receiving process, the method further includes: Determine if there is data in the receive descriptor; if so, request network data storage resources and modify the receive descriptor configuration to prepare for the next data reception; otherwise, terminate the data reception process directly.

[0013] Preferably, the network card driver registers a corresponding virtual network card with the network protocol stack layer and binds it to an independent physical network card. In single-network working mode, the corresponding physical network card is directly invoked to execute the data receiving and data sending processes; In the dual-network redundancy working mode, the corresponding physical network card is invoked to execute the data receiving and data sending processes in conjunction with the dual-network redundancy driver.

[0014] Preferably, the network card driver further includes: The process includes initializing the corresponding virtual network interface card (NIC), initializing the control entity, initializing the data buffer, and adding the two physical NIC entities corresponding to the virtual NIC to the status monitoring linked list.

[0015] Preferably, the method is implemented based on the real-time embedded development system ReWorks.

[0016] According to a second aspect of the present invention, a data communication system based on redundant network fault detection and switching is provided, comprising: The network driver module is used to establish a dual-network redundancy driver at the network driver layer, initialize the dual-network redundancy driver control entity, bind switchable physical network cards in the dual-network redundancy driver, register the virtual network card corresponding to the dual-network redundancy driver at the network protocol stack layer, and start the virtual network card connection status monitoring task. The network link status monitoring module is used to monitor the link status of two physical network cards, including real-time link status and bit error rate; based on the real-time link status and bit error rate, it performs dual-network redundancy switching and updates the virtual network card link status. The data receiving module is used to initiate a network interruption reception process based on the reception interruption signal, and to determine whether the network is a dual-network redundant network. If so, it uses the dual-network redundancy driver to find the dual-network redundancy driver control entity corresponding to the physical network card currently receiving network data, calls the network protocol stack interface, and performs data reception process processing based on the virtual network card at the network protocol stack layer. If not, it directly calls the corresponding physical network card in the single network to execute the data reception process and receive data through the network card driver. The data transmission module is used when the current network is a dual-network redundant network. The network protocol stack layer uses the registered virtual network card to find the current physical network card bound to the virtual network card, and uses the network card driver to call the corresponding data transmission interface to send data. Otherwise, the network card driver directly calls the corresponding physical network card in the single network to execute the data transmission process and send data.

[0017] According to a third aspect of the present invention, an industrial control device is provided, employing the data communication method based on redundant network fault detection and switching as described above.

[0018] By adopting the above technical solution, the present invention has at least one of the following beneficial effects compared with the prior art: The data communication method and system based on redundant network fault detection and switching provided by this invention implements dual-network redundancy driving based on the domestic embedded real-time operating system ReWorks environment. The environment and related software are independently controllable. By combining link status and network card operation status, data transfer between network cards is performed, which significantly improves the information security of the operating system and the reliability of network communication.

[0019] The data communication method and system based on redundant network fault detection and switching provided by this invention, in setting the switching conditions, in addition to the link status, also collects the status information of key points in the network card sending and receiving processing flow, monitors the faults of the redundant network in the hardware driver layer in real time, ensures the real-time switching of redundant network cards, and guarantees the real-time performance of the switching.

[0020] The data communication method and system based on redundant network fault detection and switching provided by this invention reads data from the faulty network card first when the network card switches, and then retransmits it through the normal network card, ensuring that there are no lost frames when sending data.

[0021] The data communication method and system based on redundant network fault detection and switching provided by this invention performs abnormal processing on the bit error data between bound network cards, ensuring that there is no data packet loss during redundant network card switching. Attached Figure Description

[0022] Other features, objects, and advantages of the present invention will become more apparent from the following detailed description of non-limiting embodiments with reference to the accompanying drawings: Figure 1 This is a working architecture diagram of a data communication method based on redundant network fault detection and switching in a preferred embodiment of the present invention.

[0023] Figure 2 This is a flowchart of the dual-network redundancy driver initialization process in a preferred embodiment of the present invention.

[0024] Figure 3 This is a flowchart of the dual-network redundant network link status monitoring process in a preferred embodiment of the present invention.

[0025] Figure 4 This is a flowchart of data reception in a preferred embodiment of the present invention.

[0026] Figure 5 This is a flowchart of data transmission in a preferred embodiment of the present invention.

[0027] Figure 6 This is a data communication network connection diagram based on redundant network fault detection and switching in a specific application example of the present invention. Detailed Implementation

[0028] The embodiments of the present invention are described in detail below: These embodiments are implemented based on the technical solution of the present invention, and provide detailed implementation methods and specific operation processes. It should be noted that those skilled in the art can make several modifications and improvements without departing from the concept of the present invention, and these all fall within the protection scope of the present invention.

[0029] Existing dual NIC redundancy technology typically suffers from operating system information security issues and only assesses the link status of the NIC and PHY, lacking monitoring of real-time network link status, data transmission and reception error rates, and abnormal links in the sending and receiving processing flow.

[0030] To address the aforementioned issues, one embodiment of the present invention provides a data communication method based on redundant network fault detection and switching. This method is developed using the domestically developed real-time embedded development system ReWorks with independent intellectual property rights, which solves the information security problem of the operating system. By monitoring the real-time link operation status of the network card PHY chip, the real-time performance of data switching is ensured. By detecting the bit error rate of network data transmission and processing untransmitted data, the method ensures that no frames are lost when the task data is transmitted.

[0031] Specifically, such as Figure 1 As shown, the data communication method based on redundant network fault detection and switching provided in this embodiment may include: S0 has a network card driver built in the network driver layer; S1, establish a dual-network redundancy driver in the network driver layer, initialize the dual-network redundancy driver control entity, and bind a switchable physical network card in the dual-network redundancy driver. S2, register the virtual network card corresponding to the dual-network redundancy driver in the network protocol stack layer, and start the virtual network card connection status monitoring task; S3, monitor the link status of the two physical network cards, including real-time link status and bit error rate; perform dual-network redundancy switching based on the real-time link status and bit error rate, and update the virtual network card link status; S4, in dual-network redundancy working mode, according to the received interrupt signal, enters the network interrupt receiving process, finds the dual-network redundancy drive control entity corresponding to the physical network card that is currently receiving network data, calls the network protocol stack interface, and performs data receiving process processing according to the virtual network card in the network protocol stack layer. S5, the network protocol stack layer finds the current physical network card bound to the registered virtual network card, and uses the network card driver to call the corresponding data sending interface to process the data sending process through the data sending interface of the current physical network card.

[0032] In some preferred embodiments, the data communication method provided in this embodiment is developed and implemented based on the real-time embedded development system ReWorks.

[0033] In this embodiment, both the dual-network redundancy driver and the network interface card (NIC) driver are built on the network driver layer. The NIC driver is the regular driver for data communication networks, a fundamental condition for the normal operation of the physical NIC. In single-network communication mode, the NIC driver directly calls the corresponding physical NIC for normal communication. In dual-network redundancy network communication mode, the dual-network redundancy driver can be understood as being at the same level as the NIC driver, below the network protocol stack. It is a driver for network communication enhancement functions that switch network data transmission and reception to another working physical NIC in the event of a failure of one physical NIC, allowing the network to continue operating. The dual-network redundancy driver must be based on the normal operation of the NIC driver.

[0034] In some preferred embodiments, the step S1 above, establishing a dual-network redundant driver at the network driver layer, may further include: S11, Initialization process: Initialize the dual-network redundancy network control entity, complete the registration of the network card corresponding to the dual-network redundancy function in the network protocol stack layer, that is: virtual network card bond0, and start the dual-network link status monitoring task.

[0035] S12, Network Link Status Monitoring Process: Monitor the link status of two physical network cards and perform dual-network redundancy switching based on the link status of the physical network cards.

[0036] S13, Data Reception Process: Enter the network interrupt reception handling function. If it is a dual-network redundancy, find the dual-network redundancy network control entity corresponding to the physical network card that is currently receiving network data, and call the network protocol stack process to process the data; if it is a single network, call the corresponding physical network card data reception process.

[0037] S14, Data transmission process: If dual-network redundancy is used, the virtual network card bond0 registered at the protocol layer through the dual-network redundancy driver calls the dual-network redundancy driver data transmission processing flow to transmit data according to the currently active physical network card; otherwise, the network card registered at the protocol layer through the network card driver calls the data transmission processing flow corresponding to the physical network card to transmit data.

[0038] In some preferred embodiments, the step S2 above, registering the virtual network card corresponding to the dual-network redundancy driver at the network protocol stack layer, may further include: S21, Read the MAC address of the physical network card and write it into the specified data structure to realize the unique MAC address function of the virtual network card; S22, assign a specified IP address to the virtual network card to realize the unique IP address function of the virtual network card.

[0039] In some preferred embodiments, such as Figure 3 As shown, S3 above, monitoring the link status of the two physical network cards, including real-time link status and bit error rate; performing dual-network redundancy switching based on the real-time link status and bit error rate, and updating the virtual network card link status, may further include: S31. Monitor the real-time link status and bit error rate of the current physical network card (the currently bound physical network card). Determine the link status (whether it is linked up) of the currently bound physical network card by reading the link status register of the PHY chip, or by determining whether the bit error rate of the data frames received by the network port within the sliding time window is greater than the bit error rate threshold. If the current physical network card is in normal status, maintain the current physical network card. If the current physical network card is in abnormal status, monitor the link status and bit error rate of the backup physical network card to determine the status of the backup physical network card. If the backup physical network card is in normal status, switch to the backup physical network card. If the backup physical network card is in abnormal status, continue to maintain the current physical network card without switching. If all physical network cards are in abnormal status in the current state, it may be due to a network card hardware failure or a disconnected network cable. In this case, output a prompt message through the serial port, i.e., output the message "All current network cards are abnormal, and normal communication cannot be completed", to remind the staff to perform relevant tests or handle the problem.

[0040] S32, update the link status of the virtual network card based on the current link status of the physical network card and the backup physical network card; S33, monitor whether the link status of the virtual network interface card (NIC) has changed. A change refers to a switch between link up and link down states, where the virtual NIC was previously linked up and is currently linked down, or vice versa. If no change occurs, return to continue monitoring the link status and bit error rate of the currently bound physical NIC. If a change occurs, report the link status of the virtual NIC to the network protocol stack layer, and simultaneously move the data corresponding to the address pointed to by the network packet buffer pMblk of the abnormal physical NIC to the new physical NIC. S34, determine whether the data corresponding to the address pointed to by the network packet buffer pMblk of the abnormal physical network card needs to be retransmitted; if it does not need to be retransmitted, return to continue monitoring the link status and bit error rate of the current physical network card; otherwise, retransmit the data corresponding to the address pointed to by the network packet buffer pMblk, and then continue monitoring the link status and bit error rate of the current physical network card. S35, repeat the above monitoring and switching process until the termination condition is met.

[0041] In some preferred embodiments, the bit error rate described in 31 above is calculated in the following manner: Bit error rate = number of erroneous bits / total number of received bits = number of CRC error frames × frame length × 8 / total number of received frames × frame length × 8. A typical testing method involves determining if the bit error rate, calculated over a sliding window (e.g., 5 seconds), is greater than the switching bit error rate threshold for 3-5 consecutive times; in this case, a network switch is performed. In some preferred embodiments, step S32 above, updating the link status of the virtual network card based on the link status of the current physical network card and the backup physical network card, may further include: The system reads the link status register of the PHY chip to determine whether the corresponding physical network interface card (NIC) is linked up or linked down. Then, it checks whether the link status of the virtual NIC has changed. A change means that during the detection of the virtual NIC, it was linked up previously and is currently linked down, or vice versa. If the status has not changed, it returns to monitoring the link status and bit error rate of the physical NIC and the backup physical NIC. If a change has occurred, it reports the virtual NIC's link status change to the network protocol stack, and the network protocol stack updates the virtual NIC's link status.

[0042] In some preferred embodiments, the above-mentioned step S33, whereby the data corresponding to the address pointed to by the network packet buffer pMblk of the abnormal physical network card is moved to the new physical network card, may further include: In the network packet buffer pMblk of the malfunctioning network card, the data corresponding to the address pointed to by pMblk is found. After switching to another normal network card, the data corresponding to the address pointed to by the network packet buffer pMblk of the malfunctioning network card is copied to the network packet buffer pMblk of the new physical network card, thereby avoiding network packet loss.

[0043] In some preferred embodiments, S4 above may further include, before the data receiving process, the following: Determine if there is data in the receive descriptor; if so, request network data storage resources and modify the receive descriptor configuration to prepare for the next data reception; otherwise, terminate the data reception process directly.

[0044] In some preferred embodiments, the above-mentioned S5, which uses the network card driver to call the corresponding data sending interface to process the data sending process, may further include: S51, Data Reception Process: Network data reception, enters the network interrupt reception handling function. If it is a dual-network redundancy, finds the dual-network redundancy network control entity corresponding to the physical network card that is currently receiving network data, and calls the network protocol stack process to process the data; if it is a single network, calls the corresponding physical network card data reception process.

[0045] S52, Data transmission process: If dual-network redundancy is used, the virtual network card bond0 registered at the protocol layer through the dual-network redundancy driver calls the dual-network redundancy driver data transmission processing flow, and calls the corresponding network card driver data transmission function according to the currently active physical network card to transmit data; otherwise, the network card registered at the protocol layer through the network card driver calls the data transmission processing flow corresponding to the physical network card to transmit data.

[0046] In some preferred embodiments, in S0 above, the network card driver registers the corresponding virtual network card with the network protocol stack layer and simultaneously binds it to an independent physical network card; such as... Figure 1 As shown, the network card driver (i.e., the physical network card driver) and the dual-network redundancy driver in the network card driver layer register the corresponding virtual network cards with the network protocol stack layer. That is, the network protocol stack layer will have network cards corresponding to different types of drivers in the network driver layer. Among them, the dual-network redundancy driver registers the virtual network card bond0 with the network protocol stack layer, and the physical network card driver registers the network card gmac0 corresponding to physical network card 0 and the network card gmac1 corresponding to physical network card 1 with the network card protocol stack layer. Figure 1 The physical network interface card (NIC) can include physical NIC 0 and physical NIC 1, which will not be elaborated further.

[0047] In single-network working mode, the corresponding physical network card is directly invoked to execute the data receiving and data sending processes; In the dual-network redundancy working mode, the corresponding physical network card is invoked to execute the data receiving and data sending processes in conjunction with the dual-network redundancy driver.

[0048] In some preferred embodiments, the above-mentioned S0 may further include initializing the network card driver as follows: The process includes initializing the corresponding virtual network interface card (NIC), initializing the control entity, initializing the data buffer, and adding the two physical NIC entities corresponding to the virtual NIC to the status monitoring linked list.

[0049] In this preferred embodiment, since dual-network redundancy driving is required, at least two actual physical network card control entities need to be monitored. Reading the PHY register status of a physical network card requires information related to the base address of the corresponding register of the control entity of the corresponding physical network card in order to read the corresponding network card's PHY status register. The "etc." process here refers to the process of adding the corresponding two physical network card entities of the virtual network card to the monitoring linked list, and this operation is only performed once during initialization.

[0050] This embodiment provides a data communication method based on redundant network fault detection and switching. It utilizes the domestically developed, proprietary real-time embedded development system ReWorks to monitor the real-time link status and operation of network interface cards (NICs), and performs data transfer between NICs to achieve primary / backup switching of dual-redundant NICs. The dual-network redundancy driver is implemented at the network driver layer, based on one of the two physical NICs for network communication. Actual network data is transmitted through the currently active physical NIC; if redundancy switching occurs, communication switches to the backup NIC. Simultaneously, the network driver layer is also compatible with single-network (non-dual-network redundancy) functionality, where the two physical NICs function as independent NICs. The dual-network redundancy driver and NIC driver are placed at the network driver layer, implementing the dual-network redundancy driver function and the physical NIC driver function respectively. The dual-network redundancy driver mainly includes initialization, network link status monitoring, data reception, and data transmission; the NIC driver mainly includes initialization, data reception, and data transmission.

[0051] The data communication method based on redundant network fault detection and switching provided in this embodiment implements the following dual-network redundancy driving process. (1) Initialization process: Initialize the dual-network redundant network control entity, and complete the registration of the virtual network card bond0 corresponding to the dual-network redundancy function in the network protocol stack layer, and start the dual-network link status monitoring task, such as Figure 2 As shown. (2) Network link status monitoring process: Monitor the link status of the two physical network cards, and perform dual-network redundancy switching according to the link status of the physical network cards, such as Figure 3 As shown, Figure 3In the middle, the descriptor state is used to indicate whether the hardware descriptor state of the current data received or sent by the abnormal network card is normal after the virtual network card state changes from link up to link down, or from link down to link up. After the change, check whether the hardware descriptor state of the current data received or sent by the abnormal network card is normal, and whether the state of the corresponding network packet buffer pMblk of the received or sent data is normal. If it is normal and the data needs to be retransmitted, then retransmit the data; if the state is abnormal, or the data does not need to be retransmitted, then continue monitoring. (3) Data receiving process: Enter the network interruption receiving process. If it is a dual network redundancy, find the dual network redundancy network control entity corresponding to the physical network card that currently receives network data, and call the network protocol stack process to process the data; if it is a single network, call the corresponding physical network card data receiving process, such as Figure 4 As shown. (4) Data transmission process: If it is dual-network redundancy, the virtual network card bond0 registered in the protocol layer by the dual-network redundancy driver calls the dual-network redundancy driver data transmission processing flow to send data according to the currently active physical network card; otherwise, the network card registered in the protocol layer by the network card driver calls the data transmission processing flow corresponding to the physical network card to send data, such as Figure 5 As shown.

[0052] Based on the same inventive concept, another embodiment of the present invention provides a data communication system based on redundant network fault detection and switching.

[0053] Specifically, the data communication system based on redundant network fault detection and switching provided in this embodiment may include: The network driver module is used to establish a dual-network redundancy driver at the network driver layer, initialize the dual-network redundancy driver control entity, bind switchable physical network cards in the dual-network redundancy driver, register the virtual network card corresponding to the dual-network redundancy driver at the network protocol stack layer, and start the virtual network card connection status monitoring task. The network link status monitoring module is used to monitor the link status of two physical network cards, including real-time link status and bit error rate; based on the real-time link status and bit error rate, it performs dual-network redundancy switching and updates the virtual network card link status. The data receiving module is used to initiate a network interruption reception process based on the reception interruption signal, and to determine whether the network is a dual-network redundant network. If so, it uses the dual-network redundancy driver to find the dual-network redundancy driver control entity corresponding to the physical network card currently receiving network data, calls the network protocol stack interface, and performs data reception process processing based on the virtual network card at the network protocol stack layer. If not, it directly calls the corresponding physical network card in the single network to execute the data reception process and receive data through the network card driver. The data transmission module is used when the current network is a dual-network redundant network. The network protocol stack layer uses the registered virtual network card to find the current physical network card bound to the virtual network card, and uses the network card driver to call the corresponding data transmission interface to send data. Otherwise, the network card driver directly calls the corresponding physical network card in the single network to execute the data transmission process and send data.

[0054] The working process of the system provided in this embodiment will be further described in detail below with reference to preferred embodiments.

[0055] The dual-network redundancy initialization module's workflow is as follows: Figure 2 As shown, the initialization of dual-network redundancy is mainly to complete the preliminary work of dual-network redundancy, which further includes: initializing the dual-network redundancy network control entity unit; completing the network card registration unit corresponding to the dual-network redundancy function in the network protocol stack layer, that is: registering the virtual network card bond0; and starting the dual-network link status monitoring task unit.

[0056] This module implements the single MAC address function of the virtual network card bond0 by reading the MAC address of the default bound physical network card 1 and writing it into a specific data structure. It also implements the single IP address function of the virtual network card bond0 by registering the virtual network card with the protocol layer and assigning it a specified IP address through a dual-network redundancy driver.

[0057] The network link status monitoring module's workflow is as follows: Figure 3 As shown, this implements network link status monitoring for dual-network redundant network interface cards. Further includes: The link status monitoring unit is used to monitor the link status between two physical network interface cards (NICs), including real-time link status and bit error rate. The network interface card (NIC) status monitoring unit is used to determine the NIC status based on the link status. If the current physical network card is in normal condition, then keep the current network card.

[0058] Otherwise, it indicates that the current network card is malfunctioning; in this case: Monitor the link status of the backup network card. If the link status of the backup network card is normal, switch to the backup network card. If the backup network card link status is abnormal, the currently used physical network card will remain in use and will not be switched.

[0059] The virtual network interface card (NIC) status update unit is used to update the link status of the virtual NIC (bond0) based on the current link status of physical NIC 1 and physical NIC 2.

[0060] The status change monitoring unit is used to monitor whether the status of the virtual network interface card (bond0) link changes; If the virtual network interface (bond0) link status remains unchanged, continue monitoring the current physical network interface status and bit error rate.

[0061] If the virtual network interface (bond0) link state changes, the protocol stack will report the virtual network interface (bond0) link state change; at the same time, the pMblk start pointer of the abnormal network interface will be calculated.

[0062] Determine whether the pMblk start pointer data of the abnormal network interface card (NIC) needs to be retransmitted. If retransmission is not required, continue monitoring the current physical NIC status and bit error rate. Otherwise, retransmit the network data of the pMblk pointer, and continue monitoring the current physical NIC status and bit error rate.

[0063] This module performs dual-network redundancy switching based on the physical network interface card (NIC) link status and bit error rate. It also reports and updates the connection status of the virtual NIC (bond0) in the protocol stack based on changes in the NIC's connection status. Simultaneously, this monitoring process can monitor the NIC's own status and network communication reliability, and determine whether to perform NIC switching based on the monitoring results.

[0064] The data receiving module's workflow is as follows: Figure 4 As shown, the method for implementing data reception using a dual-network redundant network card further includes: When a receive interrupt is generated, the network interrupt receive handler is entered. If it is a dual-network redundancy, the dual-network redundancy driver finds the dual-network redundancy network control entity corresponding to the physical network card that is currently receiving network data, and calls the network protocol stack process to process the data. If it is a single network, the network card driver calls the corresponding physical network card data receive process.

[0065] The data sending module's workflow is as follows: Figure 5 As shown, the method for implementing data reception using a dual-network redundant network card further includes: The protocol layer calls the dual-network redundancy driver's data sending interface through the registered virtual network card bond0. The dual-network redundancy driver calls the data sending interface of the physical network card that is currently active to send data; otherwise, it directly calls the corresponding physical network card in the single network to execute the data sending process and send data through the network card driver.

[0066] It should be noted that the steps in the method provided by the present invention can be implemented using the corresponding components in the system. Those skilled in the art can refer to the technical solution of the system to implement the steps of the method, and can also refer to the technical solution of the method to implement the composition of the system. That is, the embodiments in the system and the embodiments in the method can be understood as preferred examples of each other, which will not be elaborated here.

[0067] Based on the same inventive concept, other embodiments of the present invention provide an industrial control device that employs the data communication method based on redundant network fault detection and switching of any of the above embodiments of the present invention.

[0068] The data communication method and system provided in the above embodiments of the present invention employ dual-network redundancy driving. In the network system, a network node with dual-network redundancy function uses two network interface cards (NICs). The network system is connected via a connector or switch. When the NIC or communication line connection of the node fails, communication is abnormal, and / or communication is unreliable, the node can actively switch to the backup NIC for network communication. Although the node with dual-network redundancy function has two NICs and two channels, it still exhibits the characteristics of a single NIC from the perspective of the application. Specifically, the two NICs use one physical address and one IP address for network communication.

[0069] Figure 6 This is a connection configuration for a dual-network redundancy network in a specific application example. In this network system, the function of a node with dual-network redundancy is as follows: one network card acts as the active network card during normal operation, serving as the current data communication network card; the other network card completes initialization and acts as a backup network card. When the network card in normal communication fails or the system requires it, the network automatically switches to the backup network card in real time to continue network communication. That is, the backup network card becomes the active network card, serving as the data communication network card, while the active network card becomes the backup network card. Figure 6 In this system, the dual-network redundancy drive function simulates a network cable failure by plugging and unplugging one of the two network cables of node 1 or node n, switching the network communication of node 1 or node n to the other network of node 1 or node n.

[0070] Theoretically, dual-network redundancy technology can be implemented at various layers of the TCP / IP reference model, and the lower the layer, the faster the detection and switching speed and the better the effect. However, implementing dual-network redundancy technology at the application layer results in long switching times, which cannot guarantee network reliability and real-time performance. Therefore, the technical solution of this invention adopts dual-network redundancy driving at the network driver layer to further shorten the switching latency and ensure communication reliability.

[0071] The data communication method and system based on redundant network fault detection and switching provided in the above embodiments of the present invention are developed using the domestically developed real-time embedded development system ReWorks with independent intellectual property rights, which solves the information security problem of the operating system; it monitors the real-time link operation status of the network card PHY chip to ensure the real-time performance of data switching, and detects the bit error rate of network data transmission. At the same time, it processes the untransmitted data to ensure that there are no lost frames in the task data transmission.

[0072] Any matters not covered in the above embodiments of the present invention are well-known in the art.

[0073] The specific embodiments of the present invention have been described above. It should be understood that the present invention is not limited to the specific embodiments described above, and those skilled in the art can make various modifications or variations within the scope of the claims, which do not affect the essence of the present invention.

Claims

1. A data communication method based on redundant network fault detection and switching, wherein a network interface card (NIC) driver is established at the network driver layer, characterized in that, Also includes: Establish a dual-network redundancy driver at the network driver layer, initialize the dual-network redundancy driver control entity, and bind a switchable physical network card in the dual-network redundancy driver. Register the virtual network interface card (NIC) corresponding to the dual-network redundancy driver at the network protocol stack layer, and start the virtual NIC connection status monitoring task. Monitor the link status of the two physical network cards, including real-time link status and bit error rate; Based on the real-time link status and bit error rate, perform dual-network redundancy switching and update the virtual network card link status; In dual-network redundancy working mode, based on the received interruption signal, the network interruption reception processing flow is entered, the dual-network redundancy driver control entity corresponding to the physical network card that is currently receiving network data is found, the network protocol stack interface is called, and the data reception process is processed in the network protocol stack layer according to the virtual network card. The network protocol stack layer uses the registered virtual network interface card (NIC) to find the currently bound physical NIC, and then uses the NIC driver to call the corresponding data sending interface to process the data sending process through the data sending interface of the current physical NIC.

2. The data communication method based on redundant network fault detection and switching according to claim 1, characterized in that, Registering the virtual network interface card corresponding to the dual-network redundancy driver at the network protocol stack layer includes: Read the MAC address of the physical network card and write it into the specified data structure so that the virtual network card has a unique MAC address; Assign a specific IP address to the virtual network interface card so that the virtual network interface card has a unique IP address; and / or Before the data receiving process begins, it also includes: Determine if there is data in the receive descriptor; if so, request network data storage resources and modify the receive descriptor configuration to prepare for the next data reception; otherwise, terminate the data reception process directly.

3. The data communication method based on redundant network fault detection and switching according to claim 1, characterized in that, The monitoring of the link status of the two physical network cards includes real-time link status and bit error rate; Based on the real-time link status and bit error rate, perform dual-network redundancy switching and update the virtual network card link status, including: The system monitors the real-time link status and bit error rate of the current physical network interface card (NIC). It determines the link status of the currently bound NIC by reading the link status register of the PHY chip, or by checking if the bit error rate of the received data frames within the sliding time window exceeds a bit error rate threshold. If the current NIC is in a normal state, it remains active. If the current NIC is in an abnormal state, the system monitors the link status and bit error rate of the backup NIC to determine its status. If the backup NIC is in a normal state, the system switches to it. If the backup NIC is in an abnormal state, the system continues to use the current NIC without switching. If all NICs are in an abnormal state in the current state, a prompt message is output via the serial port. Update the link status of the virtual network interface card (NIC) based on the current link status of the physical NIC and the backup physical NIC. Monitor whether the link status of the virtual network interface card has changed; if there is no change, return to continue monitoring the link status and bit error rate of the current physical network interface card; if there is a change, report the link status of the virtual network interface card to the network protocol stack layer, and move the data corresponding to the address pointed to by the network packet buffer pMblk of the abnormal physical network interface card to the new physical network interface card. Determine whether the data corresponding to the address pointed to by the network packet buffer pMblk of the abnormal physical network card needs to be retransmitted; if it does not need to be retransmitted, return to continue monitoring the link status and bit error rate of the current physical network card; otherwise, retransmit the data corresponding to the address pointed to by the network packet buffer pMblk, and then continue monitoring the link status and bit error rate of the current physical network card. Repeat the monitoring and switching process described above until the termination condition is met.

4. The data communication method based on redundant network fault detection and switching according to claim 3, characterized in that, The step of updating the link status of the virtual network interface card (NIC) based on the link status of the current physical NIC and the backup physical NIC includes: determining whether the corresponding physical NIC is linked up or linked down by reading the link status register of the PHY chip, and then determining whether the link status of the virtual NIC has changed; if the status has not changed, then returning to continue monitoring the link status and bit error rate of the physical NIC and the backup physical NIC; if the status has changed, then reporting the change in the link status of the virtual NIC to the network protocol stack layer, and the network protocol layer updates the link status of the virtual NIC.

5. The data communication method based on redundant network fault detection and switching according to claim 3, characterized in that, The step of moving the data corresponding to the address pointed to by the network packet buffer pMblk of the abnormal physical network card to the new physical network card includes: In the network packet buffer pMblk of the malfunctioning physical network card, the data corresponding to the address pointed to by pMblk is found. After switching to another normal network card, the data corresponding to the address pointed to by the network packet buffer pMblk of the malfunctioning network card is copied to the network packet buffer pMblk of the new physical network card, thereby avoiding network packet loss.

6. The data communication method based on redundant network fault detection and switching according to claim 1, characterized in that, The network card driver registers the corresponding virtual network card with the network protocol stack layer and binds it to an independent physical network card. In single-network working mode, the corresponding physical network card is directly invoked to execute the data receiving and data sending processes; In the dual-network redundancy working mode, the corresponding physical network card is invoked to execute the data receiving and data sending processes in conjunction with the dual-network redundancy driver.

7. The data communication method based on redundant network fault detection and switching according to claim 6, characterized in that, The network card driver also includes: The process includes initializing the corresponding virtual network interface card (NIC), initializing the control entity, initializing the data buffer, and adding the two physical NIC entities corresponding to the virtual NIC to the status monitoring linked list.

8. The data communication method based on redundant network fault detection and switching according to any one of claims 1-7, characterized in that, The data communication method is implemented based on the real-time embedded development system ReWorks.

9. A data communication system based on redundant network fault detection and switching, characterized in that, include: The network driver module is used to establish a dual-network redundancy driver at the network driver layer, initialize the dual-network redundancy driver control entity, and bind a switchable physical network card in the dual-network redundancy driver. Register the virtual network interface card corresponding to the dual-network redundancy driver at the network protocol stack layer, and start the virtual network interface card connection status monitoring task. The network link status monitoring module is used to monitor the link status of two physical network cards, including real-time link status and bit error rate; based on the real-time link status and bit error rate, it performs dual-network redundancy switching and updates the virtual network card link status. The data receiving module is used to initiate a network interruption reception process based on the reception interruption signal, and to determine whether the network is a dual-network redundant network. If so, it uses the dual-network redundancy driver to find the dual-network redundancy driver control entity corresponding to the physical network card currently receiving network data, calls the network protocol stack interface, and performs data reception process processing based on the virtual network card at the network protocol stack layer. If not, it directly calls the corresponding physical network card in the single network to execute the data reception process and receive data through the network card driver. The data transmission module is used when the current network is a dual-network redundant network. The network protocol stack layer uses the registered virtual network card to find the current physical network card bound to the virtual network card, and uses the network card driver to call the corresponding data transmission interface to send data. Otherwise, the network card driver directly calls the corresponding physical network card in the single network to execute the data transmission process and send data.

10. An industrial control device, characterized in that, The data communication method based on redundant network fault detection and switching as described in any one of claims 1-8 is adopted.