Implementation method and system of a heartbeat mechanism
By initializing the master node and configuring the time-sharing sending time of the heartbeat message and the network access application message time of the slave node, the problem of low message acquisition frequency and untimely node status monitoring of the slave node in the distributed system is solved, and high-frequency heartbeat monitoring and status judgment are realized.
Patent Information
- Application Number
- CN202411582547.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-07
- Publication Date
- 2025-11-25
- Estimated Expiration
- 2044-11-07
AI Technical Summary
Existing technologies in the center-jump mechanism of distributed systems suffer from problems such as low frequency of obtaining messages from nodes, long update time, inability to detect node problems in a timely manner, and inability to monitor the status when a node fails.
The master node initializes the heartbeat message and network access application message sending times of multiple slave nodes in a time-division manner. By sending heartbeat messages and network access application messages in a time-division manner, the slave node status is set using configuration messages, and heartbeat packets are sent when necessary to avoid communication conflicts.
It improves the timeliness and reliability of heartbeat monitoring, avoids communication conflicts, maximizes the heartbeat transmission frequency, and can detect slave node problems in a timely manner.
Smart Images

Figure CN119544569B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of communication technology. More specifically, it relates to a method and system for implementing a heartbeat mechanism. Background Technology
[0002] In recent years, distributed systems have been widely used in various industries. As the scale of distributed systems continues to expand and the functions of each component in the system become more and more complex, the probability of system failures is also increasing, making the monitoring of distributed systems increasingly important.
[0003] Heartbeat technology, independent of business processes, is one of the most commonly used technologies in distributed systems and is widely applied. Originally, heartbeat technology was a mechanism in Ethernet where sending and receiving nodes determine their liveness status. Nodes periodically exchange heartbeat data packets to detect the availability of other nodes. Nodes are connected via switches, which can buffer communication messages. For distributed systems with high real-time requirements, size constraints, and cost limitations, communication architectures with switching nodes like Ethernet are less commonly used. Instead, a direct bus connection between nodes is preferred. Only one node can send messages in one direction on the bus at a time, and business messages and heartbeat messages use the same communication bus. Due to real-time requirements, such distributed systems often rely on a unified synchronization signal for operation. Without proper design of communication timing, communication conflicts can easily occur.
[0004] To address the aforementioned issues, existing technologies often employ a designated message sending mode, where one slave node is assigned to send messages at a fixed time each work cycle. This method is simple and effective, avoiding communication conflicts and allowing all slave node messages to be collected over multiple cycles. However, this method has two drawbacks. First, it may result in a very low message retrieval frequency for slave nodes, especially when there are a large number of slave nodes, leading to a long time to update all slave node messages and making it difficult to detect slave node problems in a timely manner. Second, if a node's control or synchronization signal fails, preventing it from actively sending messages, its status can be monitored, making it impossible to determine the node's condition. Summary of the Invention
[0005] The purpose of this disclosure is to provide a method and system for implementing a heartbeat mechanism to solve at least one of the problems existing in the prior art.
[0006] To achieve the above objectives, the present disclosure adopts the following technical solution:
[0007] The first aspect of this disclosure provides a method for implementing a heartbeat mechanism, the method comprising:
[0008] After powering on the master node and multiple slave nodes, initialization is performed to obtain the time-sharing transmission time and heartbeat period of the heartbeat messages of multiple incoming slave nodes, as well as the transmission time of the network access application messages of multiple outgoing slave nodes.
[0009] The master node sends a start message to the multiple incoming slave nodes and the multiple outgoing slave nodes at the start of the current service cycle, so that the multiple incoming slave nodes and the multiple outgoing slave nodes start working;
[0010] Multiple off-network slave nodes send network access application messages to the master node at their respective corresponding network access application message sending times;
[0011] When the master node receives the first network access application message, it sends a pause message to the multiple network access slave nodes and the multiple network exit slave nodes, and stops receiving the remaining network access application messages.
[0012] After processing the first network access application message using the master node, a configuration message is generated, and the configuration message is sent to the multiple network access slave nodes and the multiple network exit slave nodes;
[0013] The off-network slave node is configured as the on-network slave node corresponding to the first on-network application message according to the configuration message.
[0014] If the master node does not receive the network access application message during the network access application period, all the network access slave nodes will send heartbeat messages to the master node in sequence according to the heartbeat cycle at their respective heartbeat message time-sharing time.
[0015] Optionally, the method also includes
[0016] The master node sends a disconnection command message to the network slave node to be uninstalled, thus setting the network slave node to be uninstalled as a disconnection slave node.
[0017] The master node is used to delete the node messages of the network slave node to be uninstalled, and the time-sharing sending time of the heartbeat message corresponding to the network slave node to be uninstalled is recovered.
[0018] Optionally, after powering on the master node and multiple slave nodes, initialization is performed to obtain the time-division multiplexing transmission times and heartbeat cycles of the heartbeat messages of the multiple network-joining slave nodes, as well as the transmission times of the network-joining application messages of the multiple network-disconnecting slave nodes.
[0019] The master node reads messages recorded by local slave nodes and calculates the time-division multiplexing sending times and heartbeat cycles of the heartbeat messages of the multiple network-connected slave nodes; wherein
[0020] The local slave node record message includes the basic message, heartbeat configuration message, and number of slave nodes of the joining slave node.
[0021] Optionally, the initialization process after powering on the master node and multiple slave nodes to obtain the time-division multiple transmission times and heartbeat cycles of the heartbeat messages of the multiple network-joining slave nodes, and the transmission times of the network-joining application messages of the multiple network-disconnecting slave nodes, also includes...
[0022] The heartbeat configuration message is read from the multiple network access nodes and the node waits to receive the start message.
[0023] The multiple off-network slave nodes randomly generate the network access application message sending time and wait to receive the start message.
[0024] Optionally, the step of using the master node to send a start message to the plurality of incoming network slave nodes and the plurality of outgoing network slave nodes at the start of the current service cycle, so that the plurality of incoming network slave nodes and the plurality of outgoing network slave nodes start working includes...
[0025] The reference time is obtained by synchronizing the multiple network-entry slave nodes and the multiple network-exit slave nodes according to the start message. After the multiple network-exit slave nodes send the network-entry application message to the master node based on the reference time and the corresponding network-entry application message sending time, the multiple network-entry slave nodes send the heartbeat message to the master node based on the reference time and the corresponding heartbeat message time-division sending time and heartbeat period.
[0026] Optionally, the step of using the master node to process the first network access application message to generate a configuration message, and then sending the configuration message to the plurality of network access slave nodes and the plurality of network exit slave nodes includes...
[0027] The identity information in the first network access application message is obtained using the master node;
[0028] The master node generates a configuration message based on the identity message, records it, and sends the configuration message to the multiple network-entry slave nodes and the multiple network-exit slave nodes. The configuration message includes the time-sharing sending time of the heartbeat message, the heartbeat period, and the identity message when the network-exit slave node corresponding to the first network-entry application message is set as the network-entry slave node.
[0029] Optionally, the step of using the off-network slave node to set the off-network slave node corresponding to the first network entry application message as the network entry slave node according to the configuration message includes:
[0030] When the identity message in the configuration message matches the identity message in the first network access application message, the off-network slave node corresponding to the first network access application message is set as a network access slave node according to the configuration message.
[0031] Optionally, the method also includes
[0032] If the master node receives a network access application message during the network access application period, it will send a start message to the multiple network access slave nodes and the remaining network exit slave nodes at the start of the next business cycle.
[0033] The remaining offline slave nodes are used to recalculate the network access application message sending time corresponding to the remaining offline slave nodes based on the start message.
[0034] Optionally, the method also includes
[0035] The remaining offline slave nodes each send an access request message to the master node at their respective access request message sending times;
[0036] When the master node receives the first network access application message, it sends a pause message to multiple network access slave nodes and the remaining network exit slave nodes, and stops receiving the remaining network access application messages.
[0037] The master node processes the first network access application message to generate a configuration message, and then sends the configuration message to multiple network access slave nodes and the remaining network exit slave nodes.
[0038] The off-network slave node is set as the on-network slave node corresponding to the first on-network application message according to the configuration message.
[0039] The second aspect of this disclosure provides a system for implementing a heartbeat mechanism, the system comprising:
[0040] An initialization module is used to initialize the master node and multiple slave nodes after powering them on, and to obtain the time-division sending time and heartbeat period of the heartbeat messages of the multiple network-joining slave nodes, as well as the sending time of the network-joining application messages of the multiple network-offending slave nodes.
[0041] The master node is used to send a start message to the multiple network-in slave nodes and the multiple network-out slave nodes at the start of the current business cycle, so that the multiple network-in slave nodes and the multiple network-out slave nodes can start working.
[0042] Multiple offline slave nodes are used to send network access application messages to the master node at their respective network access application message sending times;
[0043] The master node is also used to send a pause message to the multiple network entry slave nodes and the multiple network exit slave nodes when it receives the first network entry application message, and to stop receiving the remaining network entry application messages.
[0044] The master node is also used to process the first network access application message to generate a configuration message, and send the configuration message to the multiple network access slave nodes and the multiple network exit slave nodes;
[0045] Multiple off-network slave nodes are also configured to set the off-network slave node corresponding to the first network entry application message as a network entry slave node according to the configuration message;
[0046] The master node is also used to send heartbeat messages to the master node in sequence according to the heartbeat cycle at the time of their respective heartbeat message sending time-sharing when it does not receive a network access application message during the network access application period.
[0047] The beneficial effects of this disclosure are as follows:
[0048] The technical solution disclosed herein can solve the problem that the frequency of message acquisition by slave nodes in the communication timing design of time-division multiplexing distributed communication systems is very low, especially when the number of slave nodes is particularly large, the time to complete the message update of all slave nodes will be very long, and it will be impossible to detect slave node problems in a timely manner; it can also solve the problem that when a node's control or synchronization signal fails, it cannot actively send messages due to reasons such as failure, thus losing the status monitoring of the node and being unable to determine the status problem of the node; it can effectively improve the timeliness and reliability of heartbeat monitoring, effectively avoid communication conflicts, and maximize the heartbeat sending frequency, so as to detect slave node problems more promptly. Attached Figure Description
[0049] The specific embodiments of this disclosure will be described in further detail below with reference to the accompanying drawings.
[0050] Figure 1 The swimlane diagram illustrates a method for implementing a heartbeat mechanism according to an embodiment of the present invention.
[0051] Figure 2 This diagram illustrates the time-division sending timing of heartbeat messages in a heartbeat mechanism implementation method provided by an embodiment of the present invention.
[0052] Figure 3 The diagram shows a structural schematic of a heartbeat mechanism implementation system provided by an embodiment of the present invention. Detailed Implementation
[0053] In the description of this invention, it should be noted that the terms "upper," "lower," etc., indicating the orientation or positional relationship are based on the orientation or positional relationship shown in the accompanying drawings, and are only for the convenience of describing the invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of the invention. Unless otherwise expressly specified and limited, the terms "installed," "connected," and "linked" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; they can refer to the internal communication between two elements. For those skilled in the art, the specific meaning of the above terms in this invention can be understood according to the specific circumstances.
[0054] It should also be noted that in the description of this invention, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0055] Existing technologies mostly employ a designated message sending mode, where one slave node is assigned to send messages at a fixed time each work cycle. This method is simple and effective, avoids communication conflicts, and can collect messages from all slave nodes over multiple cycles. However, this method may result in a very low message retrieval frequency for slave nodes, especially when there are a large number of slave nodes, making it time-consuming to update messages for all slave nodes and failing to detect problems in a timely manner. Furthermore, if a node's control or synchronization signal fails, preventing it from actively sending messages, its status can be lost, making it impossible to determine the node's condition.
[0056] In view of this, such as Figure 1As shown, one embodiment of the present invention discloses a method for implementing a heartbeat mechanism. The method includes: initializing a master node and multiple slave nodes after powering them with electricity; obtaining the time-division multiplexing sending times and heartbeat cycles of heartbeat messages from multiple incoming slave nodes, and the sending times of network entry application messages from multiple outgoing slave nodes; using the master node to send a start message to the multiple incoming and outgoing slave nodes at the start time of the current service cycle, so that the multiple incoming and outgoing slave nodes begin working; using the multiple outgoing slave nodes to send network entry application messages to the master node at their respective corresponding network entry application message sending times; when the master node receives the first network entry application... When a message is received, the master node sends a pause message to the multiple network entry slave nodes and the multiple network exit slave nodes, and stops receiving the remaining network entry application messages; the master node processes the first network entry application message to generate a configuration message, and sends the configuration message to the multiple network entry slave nodes and the multiple network exit slave nodes; the network exit slave nodes set the network exit slave node corresponding to the first network entry application message as a network entry slave node according to the configuration message; if the master node does not receive a network entry application message during the network entry application time, all network entry slave nodes send heartbeat messages to the master node sequentially according to the heartbeat cycle at their respective corresponding heartbeat message time-sharing sending times.
[0057] In a specific example Figure 1 This example only uses one new node. If there are other new nodes, after receiving the configuration message from node 14 in step 4 and joining the network, and after starting message sending in step 5, the new node, such as node 15, will send a network joining application message at some point within 20 seconds. Then, steps 3, 4, and 5 are repeated until all nodes are joined. After the last start message is sent, the master node will not receive any more network joining application messages within 20 seconds (i.e., the system's network joining application time). After 20 seconds, each slave node starts sending heartbeat packets because the time-sharing sending time of each slave node is set after 20 seconds. After the start message arrives, each slave node starts timing. Because the master node did not send any pause messages after the last start message (because there were no more network joining application messages), the slave nodes can time to their own time-sharing sending time and then send heartbeat packets. Furthermore, if it is not the first power-on, and all slave nodes have already joined the network, the working process is directly from step 1 to step 6.
[0058] The technical solution disclosed herein can solve the problem that the frequency of message acquisition by slave nodes in the communication timing design of time-division multiplexing distributed communication systems is very low, especially when the number of slave nodes is particularly large, the time to complete the message update of all slave nodes will be very long, and it will be impossible to detect slave node problems in a timely manner; it can also solve the problem that when a node's control or synchronization signal fails, it cannot actively send messages due to reasons such as failure, thus losing the status monitoring of the node and being unable to determine the status problem of the node; it can effectively improve the timeliness and reliability of heartbeat monitoring, effectively avoid communication conflicts, and maximize the heartbeat sending frequency, so as to detect slave node problems more promptly.
[0059] In a specific example, this implementation method can be applied to a time-division multiplexing communication distributed system, where service communication and heartbeat communication use the same communication network. This communication network has no switches, and only one node can send data at a time. In a time-division multiplexing communication distributed system, the service work of nodes is periodic, and the period time can vary or remain constant. The time period during which the service occupies the communication bus within a period is relatively fixed.
[0060] In a specific example, heartbeat message sending adopts a fixed periodicity mode, with the node counting the periods and automatically sending a heartbeat packet when the counting period is completed.
[0061] In a specific example, the period and transmission time are calculated and planned by the master node and configured for the slave nodes. In this embodiment, the period and transmission time are uniformly planned by the master node and configured for the slave nodes to avoid heartbeat packet transmission conflicts among slave nodes and to avoid conflicts with business communication.
[0062] In a specific example, the period algorithm of the slave node is calculated according to the shortest period. The shortest period that the node can send is calculated based on parameters such as service occupation time, heartbeat transmission time and slave node capacity. The node's sending time is allocated to each slave node in turn at the interval of heartbeat transmission time.
[0063] In a specific example, for a time-division multiplexing communication distributed system, the service communication time (T) w ), heartbeat communication time (T) h Parameters such as the business cycle are determined by the distributed system design, and the algorithms for each parameter are as follows.
[0064] Furthermore, the greatest common divisor of the business cycle is:
[0065] G = gcd{p1,p2,p3…p} n}
[0066] In the formula, gcd is the greatest common divisor function; p1, p2, p3…p nThere are n different business cycles.
[0067] It should be noted that G needs to be greater than the business communication time; otherwise, there will be no time left for heartbeat communication.
[0068] Furthermore, the minimum heart rate cycle is:
[0069] P h =ceil(N / floor((GT) w ) / T h ))*G
[0070] In the formula, N represents the capacity of the slave nodes in the time-division multiplexing communication distributed system, i.e., the maximum number of slave nodes supported; floor is the floor function; ceil is the floor function; T w For business communication time; T h This refers to the heartbeat communication time.
[0071] Furthermore, the minimum application period for network access is:
[0072] RT min =P h
[0073] The minimum network access request time is equal to the minimum heartbeat period, meaning the total time for all nodes to send network access requests sequentially is the same as the time to send heartbeat packets. Since the network access request message packets are generated using pseudo-random numbers, to reduce the likelihood of nodes generating the same random number, the actual network access request time is set to RT. min Multiples of this number, so that more sending time is available.
[0074] It should be noted that the slave node generates its own random number and decides when to send the network access application based on the random number. In this case, it is possible that two slave nodes generate the same random number. By increasing the range of random numbers, the probability of generating the same random number is reduced.
[0075] Furthermore, the time-division sending time of the slave node is as follows:
[0076] M h (i)=RT+ceil(i / floor((GT w ) / T h ))*T w +(i-1)*T h
[0077] In the formula, i is the sequence number of the slave node joining the network, starting from 1 and not exceeding the system node capacity N; RT is the network entry application time.
[0078] Furthermore, the timing of the node's network access application message packet transmission is as follows:
[0079] M r =M h (random(1,N1*RT / RT min ))-RT
[0080] In the formula, random represents the number of variables from 1 to N1*RT / RT. min A function of random integers between 1 and 1; N1 is a multiple of 1, and N1 is greater than or equal to 1.
[0081] It should be noted that substituting the random integer into the above formula and then subtracting the excess RT gives the time when the node sends its network access request message packet.
[0082] In a specific example, the time-division multiplexing communication distributed system includes one master node and 14 slave nodes. The master node and slave nodes communicate using an optical power divider network. The optical communication signal emitted by the master node is divided into 14 parts by the optical power divider and sent to the 14 slave nodes. The optical communication signals emitted by the slave nodes can be sent to the master node. If two or more slave nodes emit optical signals at the same time, it will cause signal superposition, and the optical communication module of the master node will not be able to demodulate a valid message.
[0083] In a specific example, the business workflow of this time-division multiplexing communication distributed system is as follows: the master node broadcasts work command messages, the slave nodes receive the command messages, the named slave nodes send back monitoring messages to the master node, and all slave nodes perform tasks such as message processing according to the commands.
[0084] In a specific example, depending on the specific business content, the cycle of the entire process is different, with cycles of 1s, 2s, 5s, 10s and 13s. The master node sends commands according to different cycles, and the cycle order is random.
[0085] In a specific example, the communication time between the master and slave nodes is within 200ms (including the time for the master node to send the heartbeat start message packet), the heartbeat sending time is completed within 100ms, and the network access application time is taken as 10 times the RT. min For example in Figure 2 In the 1-second business cycle, the business communication time is within 200ms, and the time each slave node from node 1 to slave node 8 occupies the communication bus for sending heartbeat packets or request packets is within 100ms; in the 2-second business cycle, the business communication time is within 200ms, and the time each slave node from node 1 to slave node 14 occupies the communication bus for sending heartbeat packets or request packets is within 100ms.
[0086] In a specific example, the heartbeat start packet, due to its synchronization function, needs to be sent at the beginning of the business cycle in order to synchronize the heartbeat with the business.
[0087] In a specific example, each node can calculate the heartbeat configuration parameters based on the system operating parameters. Furthermore, according to the above formula, P can be obtained. h =2s, RT=20s. The time-division sending times of the 14 slave nodes are calculated by the master node and are 20.2s, 20.3s, 20.4s, 20.5s, 20.6s, 20.7s, 20.8s, 20.9s, 21.2s, 21.3s, 21.4s, 21.5s, 21.6s, and 21.7s respectively. After each slave node sends its first heartbeat packet, it sends the next heartbeat packet every 2 seconds. (Refer to...) Figure 2 As shown, time-sharing communication can be achieved without causing communication conflicts.
[0088] In a specific example, the sending time of the network access application message packet is calculated by the slave node. First, a random integer between 1 and 140 is generated, and then the sending time is calculated according to a formula. The sending time is distributed within 0.2s-0.9s of each 1s cycle, avoiding conflicts with business communication time. For example, in... Figure 2 Within a 1-second business cycle, the business communication time is distributed within 200ms, and the transmission time is distributed within 800ms.
[0089] In one possible implementation, the method further includes: using the master node to send a disconnect command message to the joining slave node to be unloaded, setting the joining slave node to be unloaded as a disconnect slave node; using the master node to delete the node message of the joining slave node to be unloaded, and reclaiming the time-division sending time of the heartbeat message corresponding to the joining slave node to be unloaded.
[0090] In a specific example, if a slave node needs to be uninstalled, the master node first sends an off-network command message to reset the slave node to an off-network state. The master node then deletes the node message locally and reclaims the time-sharing time slot.
[0091] In one possible implementation, the initialization after powering on the master node and multiple slave nodes to obtain the time-division multiple transmission times and heartbeat cycles of the heartbeat messages of multiple incoming slave nodes, and the transmission times of the network access application messages of multiple outgoing slave nodes, includes: using the master node to read local slave node record messages and calculate the time-division multiple transmission times and heartbeat cycles of the heartbeat messages of the multiple incoming slave nodes; wherein the local slave node record messages include the basic messages, heartbeat configuration messages, and number of slave nodes of the incoming slave nodes.
[0092] In one possible implementation, the initialization process after powering on the master node and multiple slave nodes to obtain the time-division multiple transmission times and heartbeat cycles of the heartbeat messages of the multiple network-entering slave nodes, as well as the transmission times of the network entry application messages of the multiple network-exiting slave nodes, further includes: using the multiple network-entering slave nodes to read the heartbeat configuration message and waiting to receive the start message; and using the multiple network-exiting slave nodes to randomly generate the transmission times of the network entry application messages and waiting to receive the start message.
[0093] In a specific example, after each node powers on, it begins initialization. The master node reads messages recorded by local slave nodes, including basic messages, heartbeat configuration messages, and the number of slave nodes already in the network. It then calculates the time-sharing transmission times for the slave nodes already in the network and identifies available time-sharing transmission times for allocation. Slave nodes read heartbeat configuration messages. Slave nodes already in the network wait for the start message, while slave nodes not yet in the network randomly generate their network application message transmission times and wait for the start message.
[0094] In one possible implementation, the step of using the master node to send a start message to the plurality of network-entering slave nodes and the plurality of network-exit slave nodes at the start time of the current service cycle, so that the plurality of network-entering slave nodes and the plurality of network-exit slave nodes start working, includes: using the plurality of network-entering slave nodes and the plurality of network-exit slave nodes to perform time synchronization according to the start message to obtain a reference time, so that the plurality of network-exit slave nodes send a network-entering application message to the master node based on the reference time and the corresponding network-entering application message sending time, and then the plurality of network-entering slave nodes send a heartbeat message to the master node based on the reference time and the corresponding heartbeat message time-division sending time and heartbeat period.
[0095] In a specific example, after the master node is initialized, it sends a start message at the beginning of the business cycle and then performs business operations. At this time, all slave nodes start working and synchronize their time based on the start message. Slave nodes that have joined the network send heartbeat packets at time 0 based on the synchronization time, according to their own time-division sending time and heartbeat cycle parameters. Slave nodes that have not joined the network send network application messages according to the time when the network application message was sent.
[0096] In a specific example, a slave node that has not yet joined the network sends its network entry request message before a slave node that has joined the network sends its heartbeat packet.
[0097] In a specific example, the slave nodes have two states: working and paused. In the paused state, no heartbeat packets are sent. After the slave nodes are powered on, they are all in the paused state. After the master node sends the start message control packet, each slave node performs time synchronization according to the start message packet. This synchronization time is used as the base time for the slave node's time-sharing transmission time. After the synchronization is completed, the slave node first delays to the node's time-sharing transmission time, and then starts sending the heartbeat message for the first time. Thereafter, it sends according to the period.
[0098] In one possible implementation, the step of using the master node to process the first network access application message to generate a configuration message and sending the configuration message to the plurality of network access slave nodes and the plurality of network exit slave nodes includes: using the master node to obtain the identity message in the first network access application message; using the master node to generate a configuration message based on the identity message, recording it, and sending the configuration message to the plurality of network access slave nodes and the plurality of network exit slave nodes; wherein, the configuration message includes the time-division sending time of the heartbeat message, the heartbeat period, and the identity message corresponding to setting the network exit slave node corresponding to the first network access application message as a network access slave node.
[0099] In a specific example, the random algorithm ensures that the sending times of each non-joining slave node do not overlap to some extent. As soon as the master node receives a valid joining application message, it sends a pause message and stops receiving other received joining application messages.
[0100] In a specific example, the master node processes the received network access application message, which contains information such as the slave node's identity (ID). The master node assigns parameters such as time-sharing time to the slave node, and together with the slave node ID and heartbeat cycle, forms a configuration message packet, which is sent to the slave node and recorded locally.
[0101] In a specific example, the sending time of the network access application message packet is generated according to a pseudo-random algorithm and then mapped to the heartbeat working time period to avoid conflicts with business communication.
[0102] In one possible implementation, the step of using an off-network slave node to set the off-network slave node corresponding to the first network entry application message as a network entry slave node according to the configuration message includes: when the identity message in the configuration message matches the identity message in the first network entry application message, using the off-network slave node corresponding to the first network entry application message to set the off-network slave node corresponding to the first network entry application message as a network entry slave node according to the configuration message.
[0103] In a specific example, each slave node receives the configuration packet, and only the slave node with the same ID in the configuration packet will use the configuration packet to configure itself. The configuration packet sets the slave node to the network entry status.
[0104] In a specific example, slave nodes have two states: network-joined and network-off. After the master node configures the slave nodes, it sets them to the network-joined state. Only slave nodes in the network-joined state can send heartbeat message packets. Slave nodes that are not network-joined are in the network-off state. Slave nodes in the network-off state only send network-joining request message packets for a limited period after starting operation; this period is called the network-joining request period. After receiving the network-joining request message packet, the master node sends a pause message control packet to set all slave nodes to the paused state, configures the slave nodes that have applied to join the network, and sets their network-joined state. Then, it sends a start packet to set all slave nodes to start operating.
[0105] In a specific example, the time-sharing sending time set by the master node for each slave node is greater than the network access application time, ensuring that the heartbeat sending of the slave node will not conflict with the network access application message packet.
[0106] In a specific example, the network access status and configuration parameters are stored in the slave node, and the master node also has records, which are not lost when power is lost.
[0107] In one possible implementation, the method further includes: during the network access application period, if the master node receives a network access application message, then the master node sends a start message to the plurality of network access slave nodes and the remaining network exit slave nodes at the start time of the next service cycle; and the remaining network exit slave nodes recalculate the network access application message sending time corresponding to the remaining network exit slave nodes based on the start message.
[0108] In a specific example, the master node processes only one unjoined slave node at a time, gradually reducing the number of unjoined slave nodes.
[0109] In a specific example, each time a slave node that has not joined the network receives a synchronization packet, it recalculates the time when it sent the network joining application message. For example, if it does not join the network this time, it will use the new time when it starts sending the message next time, so as to avoid slave nodes with the same random number from constantly clashing.
[0110] In one possible implementation, the method further includes: utilizing the remaining offline slave nodes to send network access application messages to the master node at their respective network access application message sending times; when the master node receives the first network access application message, utilizing the master node to send a pause message to multiple network access slave nodes and the remaining offline slave nodes, and stopping receiving the remaining network access application messages; utilizing the master node to process the first network access application message to generate a configuration message, and sending the configuration message to multiple network access slave nodes and the remaining offline slave nodes; utilizing the offline slave nodes to set the offline slave node corresponding to the first network access application message as a network access slave node according to the configuration message.
[0111] In a specific example, after the configuration is completed, the master node sends a start message at the beginning of the next business cycle. If there are still nodes that have not joined the network, the above steps are repeated until all nodes join the network.
[0112] In a specific example, after the master node sends the start message, all slave nodes synchronize again. If all slave nodes have already joined the network, no slave node will send a network joining request message within the network joining request time (e.g., 20 seconds). At 20.2 seconds, the first slave node starts sending heartbeat packets and continues to send them at 2-second intervals, while other nodes send them sequentially in time-sharing fashion.
[0113] In summary, this embodiment is applied to a time-division multiplexing communication distributed system with a periodic working pattern. By having the master node in the system calculate and plan the heartbeat communication timing, automatically configure the slave nodes, control the slave nodes' network entry and exit, working and pause states, and perform synchronization measures, the slave nodes in this time-division multiplexing communication system can spontaneously and periodically send heartbeat packets. There is no situation where the communication network is occupied simultaneously between the heartbeat communications of slave nodes, or between the heartbeat communications and the business communications of slave nodes, which can avoid communication conflicts and maximize the heartbeat sending frequency, so as to detect slave node problems more promptly.
[0114] Another embodiment of the present invention discloses a system for implementing a heartbeat mechanism, such as... Figure 3As shown, the system includes: an initialization module, used to initialize the master node and multiple slave nodes after powering them on, obtaining the time-division multiplexing heartbeat message transmission times and heartbeat cycles of multiple incoming slave nodes, and the transmission times of incoming network application messages of multiple outgoing slave nodes; a master node, used to send a start message to the multiple incoming and outgoing slave nodes at the start of the current service cycle, so that the multiple incoming and outgoing slave nodes can start working; multiple outgoing slave nodes, used to send incoming network application messages to the master node at their respective incoming network application message transmission times; and the master node, also used to, upon receiving the first incoming network application message, use the master node to send... The master node is further configured to pause messages to the multiple network entry slave nodes and the multiple network exit slave nodes, and stop receiving the remaining network entry application messages; the master node is also configured to process the first network entry application message to generate a configuration message, and send the configuration message to the multiple network entry slave nodes and the multiple network exit slave nodes; the multiple network exit slave nodes are further configured to set the network exit slave node corresponding to the first network entry application message as a network entry slave node according to the configuration message; the master node is also configured to, if no network entry application message is received within the network entry application time, use all network entry slave nodes to send heartbeat messages to the master node in sequence according to the heartbeat cycle at their respective corresponding heartbeat message time-sharing sending times.
[0115] This embodiment addresses the problem of very low message acquisition frequency from slave nodes in the communication timing design of time-division multiplexing distributed communication systems, especially when the number of slave nodes is large, resulting in long message updates for all slave nodes and making it impossible to detect slave node problems in a timely manner. It also solves the problem of a node being unable to actively send messages due to control or synchronization signal failures in the communication timing design of a time-division multiplexing distributed communication system, thus losing status monitoring of that node and making it impossible to determine its status problems. Furthermore, it effectively improves the timeliness and reliability of heartbeat monitoring, effectively avoids communication conflicts, and maximizes the heartbeat sending frequency, enabling more timely detection of slave node problems.
[0116] Obviously, the above embodiments of the present invention are merely examples for clearly illustrating the present invention, and are not intended to limit the implementation of the present invention. For those skilled in the art, other variations or modifications can be made based on the above description. It is impossible to exhaustively list all the implementation methods here. All obvious variations or modifications derived from the technical solutions of the present invention are still within the protection scope of the present invention.
Claims
1. A method for implementing a heartbeat mechanism, characterized in that, The method includes After powering on the master node and multiple slave nodes, initialization is performed to obtain the time-sharing transmission time and heartbeat period of the heartbeat messages of multiple incoming slave nodes, as well as the transmission time of the network access application messages of multiple outgoing slave nodes. The master node sends a start message to the multiple incoming slave nodes and the multiple outgoing slave nodes at the start of the current service cycle, so that the multiple incoming slave nodes and the multiple outgoing slave nodes start working; Multiple off-network slave nodes send network access application messages to the master node at their respective corresponding network access application message sending times; When the master node receives the first network access application message, it sends a pause message to the multiple network access slave nodes and the multiple network exit slave nodes, and stops receiving the remaining network access application messages. After processing the first network access application message using the master node, a configuration message is generated, and the configuration message is sent to the multiple network access slave nodes and the multiple network exit slave nodes; The off-network slave node is configured as the on-network slave node corresponding to the first on-network application message according to the configuration message. If the master node does not receive the network access application message during the network access application period, all the network access slave nodes will send heartbeat messages to the master node in sequence according to the heartbeat cycle at their respective heartbeat message time-sharing time.
2. The method for implementing the heartbeat mechanism according to claim 1, characterized in that, The method also includes The master node sends a disconnection command message to the network slave node to be uninstalled, thus setting the network slave node to be uninstalled as a disconnection slave node. The master node is used to delete the node messages of the network slave node to be uninstalled, and the time-sharing sending time of the heartbeat message corresponding to the network slave node to be uninstalled is recovered.
3. The method for implementing the heartbeat mechanism according to claim 1, characterized in that, After powering on the master node and multiple slave nodes, initialization is performed to obtain the time-division multiplexing transmission times and heartbeat cycles of the heartbeat messages from multiple incoming slave nodes, as well as the transmission times of the network entry application messages from multiple outgoing slave nodes. The master node is used to read messages recorded by local slave nodes and to calculate the time-division sending time and heartbeat cycle of the heartbeat messages of the multiple network-connected slave nodes. in The local slave node record message includes the basic message, heartbeat configuration message, and number of slave nodes of the joining slave node.
4. The method for implementing the heartbeat mechanism according to claim 3, characterized in that, The initialization process after powering on the master node and multiple slave nodes, obtaining the time-division multiplexing heartbeat message transmission times and heartbeat cycles of multiple network-joining slave nodes, and the network-joining application message transmission times of multiple network-offending slave nodes, also includes... The heartbeat configuration message is read from the multiple network access nodes and the node waits to receive the start message. The multiple off-network slave nodes randomly generate the network access application message sending time and wait to receive the start message.
5. The method for implementing the heartbeat mechanism according to claim 1, characterized in that, The step of using the master node to send a start message to the multiple incoming slave nodes and the multiple outgoing slave nodes at the start of the current service cycle, so that the multiple incoming slave nodes and the multiple outgoing slave nodes start working, includes... The reference time is obtained by synchronizing the multiple network-entry slave nodes and the multiple network-exit slave nodes according to the start message. After the multiple network-exit slave nodes send the network-entry application message to the master node based on the reference time and the corresponding network-entry application message sending time, the multiple network-entry slave nodes send the heartbeat message to the master node based on the reference time and the corresponding heartbeat message time-division sending time and heartbeat period.
6. The method for implementing the heartbeat mechanism according to claim 1, characterized in that, The process involves using the master node to process the first network access application message, generating a configuration message, and then sending the configuration message to the plurality of network access slave nodes and the plurality of network exit slave nodes. The identity information in the first network access application message is obtained using the master node; The master node generates a configuration message based on the identity message, records it, and sends the configuration message to the multiple network-entry slave nodes and the multiple network-exit slave nodes. The configuration message includes the time-sharing sending time of the heartbeat message, the heartbeat period, and the identity message when the network-exit slave node corresponding to the first network-entry application message is set as the network-entry slave node.
7. The method for implementing the heartbeat mechanism according to claim 1, characterized in that, The step of using the off-network slave node to set the off-network slave node corresponding to the first network entry application message as the network entry slave node according to the configuration message includes: When the identity message in the configuration message matches the identity message in the first network access application message, the off-network slave node corresponding to the first network access application message is set as a network access slave node according to the configuration message.
8. The method for implementing the heartbeat mechanism according to claim 1, characterized in that, The method also includes If the master node receives the network access application message during the network access application period, it will send a start message to the multiple network access slave nodes and the remaining network exit slave nodes at the start of the next business cycle. The remaining offline slave nodes are used to recalculate the network access application message sending time corresponding to the remaining offline slave nodes based on the start message.
9. The method for implementing the heartbeat mechanism according to claim 8, characterized in that, The method also includes The remaining offline slave nodes each send an access request message to the master node at their respective access request message sending times; When the master node receives the first network access application message, it sends a pause message to multiple network access slave nodes and the remaining network exit slave nodes, and stops receiving the remaining network access application messages. The master node processes the first network access application message to generate a configuration message, and then sends the configuration message to multiple network access slave nodes and the remaining network exit slave nodes. The off-network slave node is set as the on-network slave node corresponding to the first on-network application message according to the configuration message.
10. A system for implementing a heartbeat mechanism, characterized in that, The system includes The initialization module is used to initialize the master node and multiple slave nodes after powering them on, and to obtain the time-sharing transmission time and heartbeat period of the heartbeat messages of multiple slave nodes entering the network, as well as the transmission time of the network entry application messages of multiple slave nodes leaving the network. The master node is used to send a start message to the multiple network-in slave nodes and the multiple network-out slave nodes at the start of the current business cycle, so that the multiple network-in slave nodes and the multiple network-out slave nodes can start working. Multiple offline slave nodes are used to send network access application messages to the master node at their respective network access application message sending times; The master node is also used to send a pause message to the multiple network entry slave nodes and the multiple network exit slave nodes when it receives the first network entry application message, and to stop receiving the remaining network entry application messages. The master node is also used to process the first network access application message to generate a configuration message, and send the configuration message to the multiple network access slave nodes and the multiple network exit slave nodes; Multiple off-network slave nodes are also configured to set the off-network slave node corresponding to the first network entry application message as a network entry slave node according to the configuration message; The master node is also used to send heartbeat messages to the master node in sequence according to the heartbeat cycle at the time of their respective heartbeat message sending time-sharing when it does not receive a network access application message during the network access application period.
Citation Information
Patent Citations
Method, apparatus, device and system for implementing one-way heartbeat mechanism
CN108924195A
Heartbeat interaction method and device
CN118433078A