Disclosure of Invention
The application provides a dual-redundancy network communication switching method, a device and a system, which adopt a singlechip to periodically inquire the connection state of a PHY port of a non-management network switching chip in a main program, and automatically switch to a backup network connection port when network connection abnormality occurs, so that the system host is not relied on, the reliability of the system is not influenced, and the use cost and the installation space requirement are reduced because a dual-network card or a network management type switch is not used.
In a first aspect, an embodiment of the present application provides a dual redundancy network communication switching method, where the dual redundancy network communication switching method includes the following steps:
periodically inquiring the connection state of the PHY port of the dual-redundancy physical layer interface device of the non-management network exchange chip by utilizing the singlechip, and judging whether the PHY port is physically connected or not;
based on the spanning tree protocol, and according to the connection state of the PHY port, dynamically adjusting the spanning tree state of the PHY port to complete the PHY port switching.
With reference to the first aspect, in one implementation manner, the dynamically adjusting the spanning tree state of the PHY port according to the connection state of the PHY port based on the spanning tree protocol to complete the PHY port switching includes:
Initializing the spanning tree state of the PHY ports, so that the spanning tree state of one PHY port is a forward state, and the spanning tree state of the other PHY port is a block state;
And dynamically adjusting according to the connection state result of the PHY ports periodically queried by the singlechip, setting the PHY ports with physical connection to be in forward state, and setting the other PHY ports to be in block state so as to finish PHY port switching.
With reference to the first aspect, in an implementation manner, the periodically querying, by using the single chip microcomputer, a connection state of a PHY port of the dual-redundancy physical layer interface device of the non-management network switch chip, and determining whether the PHY port has a physical connection includes:
and periodically inquiring the functional register address 0x01H of the PHY chip in the PHY port by using the singlechip to judge whether the PHY port has physical connection.
In a second aspect, an embodiment of the present application provides a dual redundancy network communication switching apparatus, which is characterized in that the dual redundancy network communication switching apparatus includes:
The inquiry module is used for periodically inquiring the connection state of the PHY ports of the dual-redundancy physical layer interface device of the non-management network switching chip based on the singlechip and judging whether the PHY ports are physically connected or not;
And the switching module is based on a spanning tree protocol and dynamically adjusts the spanning tree state of the PHY port according to the connection state of the PHY port so as to finish PHY port switching.
With reference to the second aspect, in one implementation manner, the switching module dynamically adjusts a spanning tree state of the PHY port according to a connection state of the PHY port based on a spanning tree protocol to complete PHY port switching, including:
Initializing the spanning tree state of the PHY ports, so that the spanning tree state of one PHY port is a forward state, and the spanning tree state of the other PHY port is a block state;
And dynamically adjusting according to the connection state result of the PHY ports periodically queried by the singlechip, setting the PHY ports with physical connection to be in forward state, and setting the other PHY ports to be in block state so as to finish PHY port switching.
With reference to the second aspect, in an implementation manner, the query module periodically queries, based on the single chip microcomputer, a connection state of a PHY port of a dual-redundancy physical layer interface device of the non-management network switch chip, and determines whether the PHY port has a physical connection, including:
And periodically inquiring the functional register address 0x01H of the PHY chip in the PHY port based on the singlechip to judge whether the PHY port has physical connection.
In a third aspect, an embodiment of the present application provides a dual-redundancy network communication switching system, where the dual-redundancy network communication switching system includes an embedded real-time operation platform and a switch;
The embedded real-time operation platform comprises a singlechip, and the switch comprises an unmanaged network switching chip;
The singlechip is used for periodically inquiring the connection state of the PHY port of the dual-redundancy physical layer interface device of the non-management network exchange chip and judging whether the PHY port is physically connected or not;
The singlechip is also based on a spanning tree protocol, and dynamically adjusts the spanning tree state of the PHY port according to the connection state of the PHY port so as to complete PHY port switching.
With reference to the third aspect, in one implementation manner, the single chip microcomputer is configured to:
Initializing the spanning tree state of the PHY ports, so that the spanning tree state of one PHY port is a forward state, and the spanning tree state of the other PHY port is a block state;
And dynamically adjusting according to the connection state result of the PHY ports which are periodically queried, setting the PHY ports with physical connection to be in a forward state, and setting the other PHY ports to be in a block state so as to finish PHY port switching.
With reference to the third aspect, in one implementation manner, a PHY chip is disposed in the PHY port, and the single chip microcomputer is configured to query a functional register address 0x01H of the PHY chip to determine whether the PHY port has a physical connection.
With reference to the third aspect, in one implementation manner, the single chip microcomputer and the unmanaged network switching chip are connected through a media independent interface.
The technical scheme provided by the embodiment of the application has the beneficial effects that at least:
The dual-redundancy network communication switching method of the application periodically inquires the connection state of the PHY ports of dual-redundancy physical layer interface equipment of a non-management network switching chip by utilizing a singlechip, judges whether the PHY ports are physically connected or not, dynamically adjusts the spanning tree state of the PHY ports based on a spanning tree protocol according to the connection state of the PHY ports, and completes the PHY port switching. The application adopts the singlechip to periodically inquire the connection state of the PHY port of the non-management network exchange chip in the main program, and when network connection abnormality occurs, the connection state is automatically switched to the backup network connection port, the system host is not depended, the system reliability is not affected, and the use cost and the installation space requirement are reduced because the double network card or the network management type switch is not used.
Detailed Description
In order that those skilled in the art will better understand the present application, a technical solution in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in which it is apparent that the described embodiments are only some embodiments of the present application, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
The terms "comprising" and "having" and any variations thereof in the description and claims of the application and in the foregoing drawings are intended to cover non-exclusive inclusions. For example, a process, method, system, article, or apparatus that comprises a list of steps or elements is not limited to only those listed steps or elements but may include other steps or elements not listed or inherent to such process, method, article, or apparatus. The terms "first," "second," and "third," etc. are used for distinguishing between different objects and not necessarily for describing a sequential or chronological order, and are not limited to the fact that "first," "second," and "third" are not identical.
In describing embodiments of the present application, "exemplary," "such as," or "for example," etc., are used to indicate by way of example, illustration, or description. Any embodiment or design described herein as "exemplary," "such as" or "for example" is not necessarily to be construed as preferred or advantageous over other embodiments or designs. Rather, the use of words such as "exemplary," "such as" or "for example," etc., is intended to present related concepts in a concrete fashion.
In the description of the embodiment of the present application, "/" means or, for example, a/B may mean a or B, and "and/or" in the text is merely an association relationship describing an association object, means that three relationships may exist, for example, a and/or B, three cases where a exists alone, a and B exist together, and B exists alone, and further, in the description of the embodiment of the present application, "a plurality" means two or more.
In some of the processes described in the embodiments of the present application, a plurality of operations or steps occurring in a particular order are included, but it should be understood that the operations or steps may be performed out of the order in which they occur in the embodiments of the present application or in parallel, the sequence numbers of the operations merely serve to distinguish between the various operations, and the sequence numbers themselves do not represent any order of execution. In addition, the processes may include more or fewer operations, and the operations or steps may be performed in sequence or in parallel, and the operations or steps may be combined.
For the purpose of making the objects, technical solutions and advantages of the present application more apparent, the embodiments of the present application will be described in further detail with reference to the accompanying drawings.
In a first aspect, an embodiment of the present application provides a dual redundancy network communication handover method.
In an embodiment, referring to fig. 1, fig. 1 is a flow chart illustrating an embodiment of a dual redundancy network communication handover method according to the present application. As shown in fig. 1, the dual redundancy network communication switching method includes:
S1, periodically inquiring the connection state of a PHY port of dual-redundancy physical layer interface equipment of a non-management network exchange chip by utilizing a singlechip, and judging whether the PHY port is physically connected or not;
s2, based on a spanning tree protocol, dynamically adjusting the spanning tree state of the PHY port according to the connection state of the PHY port so as to complete PHY port switching.
Specifically, the Protocol of the dual redundant network in the present embodiment adopts STP (SPANNING TREE Protocol ). The main idea of STP is that when redundant links are present, only the main link is allowed to be active, and if the main link is disconnected due to a failure, the standby link is opened. STP spanning tree is a protocol for building loop-free network structures. STP can build a spanning tree by selecting a root node, thereby avoiding loops in the network. A spanning tree is a sub-graph that contains all network nodes that connects all nodes by connecting a minimal set of edges while maintaining loop-free. The STP protocol spanning tree has the function of prohibiting unnecessary connection, and the dual redundancy function can realize simultaneous access of two network wires to avoid conflict by utilizing the function of the spanning tree.
In this embodiment, each PHY port of the switch has a PHY chip, and the address 0x01H of the function register (BASIC STATUS REGISTER) of each PHY chip is read to determine whether the PHY terminal has physical connection. Setting the spanning tree state of the non-management network switching chip storage register port as a forward state or a block state. And periodically reading the state of the PHY port in the main cycle of the singlechip program, setting the PHY port with physical connection to be in a forward state, setting the other PHY port to be in a block state, completing network port switching, and realizing a dual-redundancy network function.
Specifically, see fig. 2:
Step 1, initializing spanning tree states of a dual redundant PHY port, namely port1, forward state, port2 and block state;
step 2, reading PHY port connection states of port1 and port2 in a main cycle period of a singlechip program;
step 3, judging whether the PHY port of the port1 or the port2 is in a connection state, if not, returning to the step 2, and if so, executing the step 4;
Step 4, reading the PHY port spanning tree state in the connection state;
Step 5, judging whether the PHY port generation tree state in the connection state is a forward state or not, if so, returning to the step 2, and if not, executing the step 6;
It can be understood that the initialization is default that the PHY port of port1 is in a connection state, if the PHY port of port1 is still in a connection state during periodic reading, the PHY port of port1 is kept as it is, if the PHY port of port1 is not in a connection state, the standby link is opened after the connection state is broken;
and 6, setting the PHY port to be in a forward state, and returning to the step 2.
Thus, the network port switching is completed, and the dual redundancy network function is realized.
It can be understood that the application adopts the non-management network exchange chip to complete the receiving and transmitting of network data, bears the function of dual redundant interfaces, and periodically inquires the PHY network connection state in the main program by the singlechip, and when the network connection is abnormal, the application automatically switches to the backup network connection port, and the switching time is consistent with the sampling period of the system. The test result shows that the switching delay time of the dual-redundancy network is within 20 ms;
in addition, the invention increases the reliability of network transmission, realizes transparent switching on the client, does not affect the system task, and realizes the dual redundancy network function under the condition of not increasing the IP address.
The application has the advantages of simple structure, low cost and easy operation, and can realize the data processing without depending on the system host computer, and has no influence on the system reliability.
In summary, the dual-redundancy network communication switching method of the present application periodically queries the connection state of the PHY port of the dual-redundancy physical layer interface device of the non-management network switching chip by using the singlechip to determine whether the PHY port has physical connection, and dynamically adjusts the spanning tree state of the PHY port based on the spanning tree protocol according to the connection state of the PHY port to complete the PHY port switching. The application adopts the singlechip to periodically inquire the connection state of the PHY port of the non-management network exchange chip in the main program, and when network connection abnormality occurs, the connection state is automatically switched to the backup network connection port, the system host is not depended, the system reliability is not affected, and the use cost and the installation space requirement are reduced because the double network card or the network management type switch is not used.
In a second aspect, the embodiment of the application further provides a dual-redundancy network communication switching device.
In an embodiment, referring to fig. 3, fig. 3 is a schematic functional block diagram of an embodiment of a dual redundancy network communication switching apparatus according to the present application. As shown in fig. 3, the dual redundancy network communication switching apparatus includes a query module and a switching module.
The query module periodically queries the connection state of the PHY ports of the dual-redundancy physical layer interface device of the non-management network switching chip based on the singlechip and judges whether the PHY ports are physically connected or not;
And the switching module is based on a spanning tree protocol and dynamically adjusts the spanning tree state of the PHY port according to the connection state of the PHY port so as to finish PHY port switching.
Further, in an embodiment, the switching module dynamically adjusts the spanning tree state of the PHY port according to the connection state of the PHY port based on the spanning tree protocol to complete the PHY port switching, including:
Initializing the spanning tree state of the PHY ports, so that the spanning tree state of one PHY port is a forward state, and the spanning tree state of the other PHY port is a block state;
And dynamically adjusting according to the connection state result of the PHY ports periodically queried by the singlechip, setting the PHY ports with physical connection to be in forward state, and setting the other PHY ports to be in block state so as to finish PHY port switching.
Further, in an embodiment, the query module periodically queries the connection state of the PHY port of the dual-redundancy physical layer interface device of the non-management network switch chip based on the singlechip, and determines whether the PHY port has physical connection, including:
And periodically inquiring the functional register address 0x01H of the PHY chip in the PHY port based on the singlechip to judge whether the PHY port has physical connection.
In a third aspect, the embodiment of the application further provides a dual-redundancy network communication switching system.
In one embodiment, referring to fig. 4, fig. 4 is a block diagram illustrating an embodiment of a dual redundancy network communication switching system according to the present application. As shown in fig. 4, the dual redundant network communication switching system includes an embedded real-time operation platform and a switch.
The embedded real-time operation platform comprises a singlechip, and the switch comprises a non-management network switching chip;
The singlechip is used for periodically inquiring the connection state of the PHY port of the dual-redundancy physical layer interface device of the non-management network exchange chip and judging whether the PHY port is physically connected or not;
The singlechip is also based on a spanning tree protocol, and dynamically adjusts the spanning tree state of the PHY port according to the connection state of the PHY port so as to complete PHY port switching.
Referring to fig. 5, the following describes a single chip and an unmanaged network switching chip in the present application:
a) Chip introduction
1) The core CPU adopts a 32-bit ARM chip, the model of the singlechip is GD32F407VET6, the main frequency reaches more than 100M, and the network communication is realized by an MII interface;
2) The non-management network switching chip is of a SW8328 type, the SW8328 integrates 8-channel gigabit electric interface PHY, supports 10/100/1000BASE-T and 100BASE-FX functions, and supports 1-channel GMII or 2-channel MII/RGMII interfaces as extensible management interfaces.
B) Power supply
The external power supply interface of the 28VDC is provided, and the external power supply interface is converted into 3.3V power supply to GD32, and is converted into +1.1V, +2.5V and +3.3V power supply to the unmanaged network switching chip SW8328
Rated operating voltage is 28VDC (general DC consumer: 22.0V-30.0V).
Product power consumption: the system power is less than or equal to 4W.
C) Communication system
1) The singlechip and the non-management network exchange chip are interconnected through a media independent interface (MII interface) to support data transmission modes of 10Mbit/s and 100 Mbit/s.
2) The MII signal of the single chip MAC controller and the non-management network exchange chip PHY comprises:
3) ETH_MII_TX_CLK, a clock signal used to transmit data, the present scheme uses 100Mbit/s of data transmission, this clock being 25MHz.
4) ETH_MII_RX_CLK, a clock signal used to receive data, the present scheme uses 100Mbit/s data transmission, this clock being 25MHz.
5) ETH_MII_TX_EN, send enable signal, hold until transmission is completed.
6) ETH_MII_TXD [3:0]: transmit data lines, 4 bits of data per transmission, the data being valid when the MII_TX_EN signal is valid. MII_TXD [0] is the least significant bit of data, and MII_TXD [3] is the most significant bit. When the mii_tx_en signal is inactive, the PHY ignores the transmitted data.
7) The ETH_MII_CRS is controlled by the non-management network switching chip PHY only in a half-duplex mode, and the scheme PHY works in a full-duplex mode and is negligible.
8) The ETH_MII_COL collision detection signal only works in a half-duplex mode and is controlled by the non-management network switching chip PHY, and the scheme PHY works in a full-duplex mode and is therefore negligible.
9) ETH_MII_RXD [3:0]: receive data lines, 4 bits of data each time, the data being valid when the MII_RX_DV signal is valid. MII_RXD [0] is the lowest bit of data, and MII_RXD [3] is the highest bit.
10 Etc_mii_rx_dv, receive data enable signal, controlled by PHY, which is active when PHY is ready for data reception by MAC. This signal must appear in synchronization with the first 4 bits of frame data and remain active until the data transfer is complete. This signal must go inactive before the first clock after the last 4 bits of data are transferred.
11 ETH_MII_RX_ER) receives an error signal, maintains the active state for one or more clock cycles (MII_RX_CLK), indicating that the MAC detected an error during reception.
12 The singlechip MAC controller is communicated with the ETH_MDIO data line and the non-management network exchange chip through the ETH_MDC clock line, and can access any register of the external physical layer interface PHY.
13 Eth_mdc, a clock signal with a maximum frequency of 2.5MHz, the pin is kept in a low state in the idle state. The minimum hold time of the high level and the low level of the signal is 160ns when data is transmitted, and the minimum period of the signal is 400ns;
14 Etc_mdio for data transmission with PHY, and receiving/transmitting data in cooperation with MDC clock line.
After the dual-redundancy network communication switching system in the embodiment is adopted, the specific implementation effect is as follows:
1) The Ethernet A is connected with external equipment;
2) The Ethernet B is connected with external equipment;
3) The Ethernet A and the Ethernet B are simultaneously connected and disconnected with any network cable, and connection is established within 20ms of the other network cable;
4) The Ethernet A or the Ethernet B is connected with only one network cable (such as the Ethernet A), the other network cable (such as the Ethernet B), the Ethernet (such as the Ethernet A) communicated before disconnection, and the Ethernet B can still be connected.
Further, in an embodiment, the single chip microcomputer is configured to:
Initializing the spanning tree state of the PHY ports, so that the spanning tree state of one PHY port is a forward state, and the spanning tree state of the other PHY port is a block state;
And dynamically adjusting according to the connection state result of the PHY ports which are periodically queried, setting the PHY ports with physical connection to be in a forward state, and setting the other PHY ports to be in a block state so as to finish PHY port switching.
Further, in an embodiment, a PHY chip is disposed in the PHY port, and the single chip microcomputer is configured to query a function register address 0x01H of the PHY chip to determine whether the PHY port has physical connection.
Further, in an embodiment, the single chip microcomputer is connected to the unmanaged network switching chip through a media independent interface.
The foregoing description is only of the preferred embodiments of the present application, and is not intended to limit the scope of the application, but rather is intended to cover any equivalents of the structures or equivalent processes disclosed herein or in the alternative, which may be employed directly or indirectly in other related arts.