Method and system for realizing heartbeat mechanism

By initializing and configuring the master node and slave node in a distributed system, the problems of low frequency of slave node message acquisition and loss of node status monitoring are solved, and efficient heartbeat monitoring and reliable communication design are realized.

CN119544569AActive Publication Date: 2025-02-28BEIJING INST OF RADIO MEASUREMENT
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202411582547.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-07
Publication Date
2025-02-28
Estimated Expiration
2044-11-07

AI Technical Summary

Technical Problem

In the design of the central hop mechanism of distributed systems, the frequency of slave node messages is low, and slave node problems cannot be discovered in time, and when node control or synchronization signal failure is malfunctioned, the message cannot be actively sent, resulting in loss of status monitoring.

Method used

By initializing the master node and slave node, the time-sharing sending time and heartbeat period of the heartbeat message of the network entry slave node, and the time of sending the network entry application message of the off-grid slave node. The master node sends a start message at the beginning of the business cycle, and the slave node sends an access application message off the grid. After processing, the master node generates a configuration message, sets the slave node to the access status, and sends heartbeat messages in sequence when the application message is not received.

Benefits of technology

It effectively improves the timeliness and reliability of heartbeat monitoring, avoids communication conflicts, increases the heartbeat transmission frequency, and can detect slave node problems more in a timely manner.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119544569A_ABST
    Figure CN119544569A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a heartbeat mechanism implementation method and system. The method comprises the following steps: after supplying power to a master node and a slave node, initializing to obtain a heartbeat message time-sharing sending moment, a heartbeat period and a network access application message sending moment; sending a start message to the slave node at the start moment of the current service cycle by using the master node; sending the network access application message to the master node by using the off-network slave node at the network access application message sending moment; using the master node to send a pause message to the slave node; processing the first network access application message by using the master node, then generating a configuration message, and sending the configuration message to the slave node; using the off-network slave nodes to set the corresponding off-network slave nodes as network access slave nodes according to the configuration message; and in the network access application time, if the master node does not receive the network access application message, sending heartbeat messages to the master node in sequence according to the heartbeat cycle at the corresponding heartbeat message time-sharing sending moments by using all the network access slave nodes.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of communication technology, and more specifically, to a method and system for implementing a heartbeat mechanism. Background Art

[0002] In recent years, distributed systems have been widely used in various industries. The scale of distributed systems has continued to expand, and the functions of each component in the system have become more and more complex, which has increased the probability of system failure. The monitoring of distributed systems has become increasingly important.

[0003] Heartbeat technology, which is independent of business processes, is one of the most commonly used technologies in distributed systems and is widely used in distributed systems. Heartbeat technology was originally a mechanism for judging the survival status between transceiver nodes in Ethernet. Heartbeat packets are periodically exchanged between nodes to detect the availability of other nodes. Switches are used to connect nodes, and communication messages can be cached. For some distributed systems with high real-time, volume and cost requirements, communication architectures with switching nodes such as Ethernet are rarely used. Buses with direct connections between nodes are mostly used. Only one node can send messages in one direction at the same time on the bus, and business messages and heartbeat messages use the same communication bus. Due to the real-time requirements, this distributed system often uses a unified synchronous signal driver to work. If the communication timing is not designed, communication conflicts are likely to occur.

[0004] In order to solve the above problems, the existing technologies mostly adopt the roll-call sending mode, which specifies a slave node to send messages at a fixed time in each working cycle. This method is simple and effective, can avoid communication conflicts, and can collect all the messages from the slave nodes through multiple cycles. However, on the one hand, this method may cause the frequency of obtaining slave node messages to be very low, especially when the number of slave nodes is particularly large, it will take a long time to complete the message update of all slave nodes, and the problems of the slave nodes cannot be discovered in time; on the other hand, when the control or synchronization signal of a node fails, the node cannot actively send messages, thereby losing the status monitoring of the node and being unable to judge the status of the node. Summary of the invention

[0005] The purpose of the present 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] In order to achieve the above objectives, the present invention adopts the following technical solutions:

[0007] The first aspect of the present disclosure provides a method for implementing a heartbeat mechanism, the method comprising:

[0008] After powering on the master node and multiple slave nodes, they are initialized to obtain the time-sharing sending time and heartbeat cycle of multiple network-connected slave nodes, as well as the sending time of network-connected application messages of multiple off-network slave nodes;

[0009] Using the master node to send a start message to the multiple network-entering slave nodes and the multiple network-offline slave nodes at the start time of the current service cycle, so that the multiple network-entering slave nodes and the multiple network-offline slave nodes start working;

[0010] Utilize the plurality of off-network slave nodes to respectively send network access application messages to the master node at the respective corresponding network access application message sending times;

[0011] When the master node receives the first network access application message, the master node is used to send a pause message to the multiple network access slave nodes and the multiple network access slave nodes, and stops receiving the remaining network access application messages;

[0012] Using the master node to process the first network access application message to generate a configuration message, and sending the configuration message to the multiple network access slave nodes and the multiple network-exit slave nodes;

[0013] Using the off-network slave node to set the off-network slave node corresponding to the first network access application message as the network access slave node according to the configuration message;

[0014] If the master node does not receive the network access application message within the network access application time, all network access slave nodes are used to send heartbeat messages to the master node in sequence according to the heartbeat cycle at their corresponding heartbeat message time-sharing sending times.

[0015] Optionally, the method further comprises

[0016] Using the master node to send an off-network command message to the on-network slave node to be uninstalled, setting the on-network slave node to be uninstalled as an off-network slave node;

[0017] The master node is used to delete the node message of the network-entering slave node to be uninstalled, and the time-sharing sending time of the heartbeat message corresponding to the network-entering slave node to be uninstalled is recovered.

[0018] Optionally, the master node and multiple slave nodes are powered on and initialized to obtain the heartbeat message time-sharing sending time and heartbeat cycle of multiple network-connected slave nodes, and the network access application message sending time of multiple off-network slave nodes.

[0019] The master node is used to read the local slave node record message and calculate the heartbeat message time-sharing sending time and heartbeat cycle of the multiple networked slave nodes; wherein

[0020] The local slave node record message includes the basic message of the networked slave node, the heartbeat configuration message and the number of slave nodes.

[0021] Optionally, the master node and multiple slave nodes are powered on and initialized to obtain the heartbeat message time-sharing sending time and heartbeat cycle of multiple network-connected slave nodes, and the network application message sending time of multiple off-network slave nodes.

[0022] Using the multiple network entry slave nodes to read the heartbeat configuration message and wait for receiving a start message;

[0023] The multiple off-grid slave nodes are used to randomly generate a time for sending a network access application message and wait for receiving a start message.

[0024] Optionally, the using the master node to send a start message to the multiple network-entering slave nodes and the multiple network-offline slave nodes at the start time of the current service cycle so that the multiple network-entering slave nodes and the multiple network-offline slave nodes start working includes:

[0025] The multiple network-entering slave nodes and the multiple network-offline slave nodes are used to perform time synchronization according to the start message to obtain a reference time, so that the multiple network-entering slave nodes send network access application messages to the master node based on the reference time and the corresponding network access application message sending time, so that the multiple network-entering slave nodes send heartbeat messages to the master node based on the reference time and the corresponding heartbeat message time-sharing sending time and heartbeat period.

[0026] Optionally, the using the master node to process the first network access application message to generate a configuration message, and sending the configuration message to the multiple network access slave nodes and the multiple network-exit slave nodes includes:

[0027] Using the master node to obtain the identity information in the first network access application message;

[0028] The master node is used to generate a configuration message according to the identity message, and the configuration message is recorded and sent to the multiple network-entering slave nodes and the multiple off-network slave nodes; wherein the configuration message includes the heartbeat message time-sharing sending time corresponding to setting the off-network slave node corresponding to the first network access application message as the network-entering slave node, the heartbeat cycle and the identity message.

[0029] Optionally, the step of using the off-network slave node to set the off-network slave node corresponding to the first network access application message as the network access 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 an access slave node according to the configuration message using the off-network slave node corresponding to the first network access application message.

[0031] Optionally, the method further comprises

[0032] Within the network access application time, if the master node receives the network access application message, the master node is used to send a start message to the multiple network access slave nodes and the remaining off-network slave nodes at the start time of the next service cycle;

[0033] The remaining off-network slave nodes are used to recalculate the network access application message sending time corresponding to the remaining off-network slave nodes according to the start message.

[0034] Optionally, the method further comprises

[0035] Utilize the remaining off-network slave nodes to respectively send network access application messages to the master node at the respective corresponding network access application message sending times;

[0036] When the master node receives the first network access application message, the master node is used to send a pause message to multiple network access slave nodes and the remaining off-network slave nodes, and stops receiving the remaining network access application messages;

[0037] Using 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 off-network slave nodes;

[0038] The off-network slave node corresponding to the first network access application message is set as an on-network slave node by using the off-network slave node according to the configuration message.

[0039] The second aspect of the present 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 on, and obtain the time-sharing sending time and heartbeat cycle of the multiple network-entering slave nodes, and the sending time of the network access application message of the multiple off-network slave nodes;

[0041] The master node is used to send a start message to the multiple network-entering slave nodes and the multiple network-offline slave nodes at the start time of the current service cycle, so that the multiple network-entering slave nodes and the multiple network-offline slave nodes start working;

[0042] A plurality of off-network slave nodes, used to respectively send network access application messages to the master node at the respective corresponding network access application message sending times;

[0043] The master node is further configured to, when receiving the first network access application message, send a pause message to the plurality of network access slave nodes and the plurality of network access slave nodes using the master node, and stop receiving the remaining network access application messages;

[0044] The master node is further configured to generate a configuration message after processing the first network access application message, and send the configuration message to the multiple network access slave nodes and the multiple network off-network slave nodes;

[0045] A plurality of off-network slave nodes, further configured to set the off-network slave node corresponding to the first network access application message as a network access slave node according to the configuration message;

[0046] The master node is also used to use all the network access 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 moments if no network access application message is received within the network access application time.

[0047] The beneficial effects of the present disclosure are as follows:

[0048] The technical solution disclosed in the present invention can solve the problem that the frequency of obtaining slave node messages in the communication timing design of a time-division multiplexing communication distributed system is very low, especially when the number of slave nodes is particularly large, it will take a long time to complete the message update of all slave nodes, and the slave nodes cannot be discovered in time; and it can solve the problem that when the control or synchronization signal of a certain node fails in the communication timing design of a time-division multiplexing communication distributed system, the node cannot actively send messages, thereby losing status monitoring of the node and being unable to judge the status of the node; it can effectively improve the timeliness and reliability of heartbeat monitoring, effectively avoid communication conflicts, and at the same time maximize the heartbeat sending frequency, so that slave node problems can be discovered more timely. BRIEF DESCRIPTION OF THE DRAWINGS

[0049] The specific implementation methods of the present disclosure are further described in detail below with reference to the accompanying drawings.

[0050] Figure 1 A swimlane diagram showing a method for implementing a heartbeat mechanism provided by an embodiment of the present invention.

[0051] Figure 2 A schematic diagram of the time division of sending heartbeat messages in a method for implementing a heartbeat mechanism provided by an embodiment of the present invention is shown.

[0052] Figure 3 A structural schematic diagram of a system for implementing a heartbeat mechanism provided by an embodiment of the present invention is shown. DETAILED DESCRIPTION

[0053] In the description of the present invention, it should be noted that the terms "upper", "lower", etc. indicate positions or positional relationships based on the positions or positional relationships shown in the accompanying drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific position, be constructed and operated in a specific position, and therefore cannot be understood as a limitation on the present invention. Unless otherwise clearly specified and limited, the terms "installed", "connected", and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be an indirect connection through an intermediate medium, or it can be a connection between the two elements. For those of ordinary skill in the art, the specific meanings of the above terms in the present invention can be understood according to the specific circumstances.

[0054] It should also be noted that, in the description of the present invention, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprise", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the statement "comprises a ..." does not exclude the presence of other identical elements in the process, method, article or device including the element.

[0055] The existing technology mostly adopts the roll-call sending mode, and each working cycle specifies a slave node to send messages at a fixed time. This method is simple and effective, can avoid communication conflicts, and can collect all the messages of the slave nodes through multiple cycles. However, on the one hand, this method may cause the frequency of obtaining slave node messages to be very low, especially when the number of slave nodes is particularly large, it will take a long time to complete the message update of all slave nodes, and it will be impossible to find the problems of the slave nodes in time; on the other hand, when the control or synchronization signal of a node fails, the node cannot actively send messages, thereby losing the status monitoring of the node and being unable to judge the status of the node.

[0056] In view of this, if Figure 1As shown, an embodiment of the present invention discloses a method for implementing a heartbeat mechanism, the method comprising: initializing a master node and a plurality of slave nodes after powering on, obtaining the heartbeat message time-sharing sending time and heartbeat cycle of a plurality of network-entering slave nodes, and the network-entry application message sending time of a plurality of off-network slave nodes; using the master node to send a start message to the plurality of network-entering slave nodes and the plurality of off-network slave nodes at the start time of the current service cycle, so that the plurality of network-entering slave nodes and the plurality of off-network slave nodes start working; using the plurality of off-network 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 receiving a network access application message, the master node is used to send a pause message to the multiple network access slave nodes and the multiple off-network slave nodes, and stop receiving the remaining network access application messages; the master node is used to process the first network access application message to generate a configuration message, and the configuration message is sent to the multiple network access slave nodes and the multiple off-network slave nodes; 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 by the off-network slave node; within the network access application time, if the master node does not receive the network access application message, all the network access slave nodes are used to send heartbeat messages to the master node in sequence according to the heartbeat cycle at the respective corresponding heartbeat message time-sharing sending times.

[0057] In a specific example, Figure 1 Only one example of a new node is given. If there are other new nodes, in step 4, the slave node 14 receives the configuration message to enter the network. After the start message is sent in step 5, the new node, such as node 15, will send a network application message at a certain moment within 20 seconds, and then repeat steps 3, 4 and 5 until all nodes are connected to the network. After the last start message is sent, the master node will not receive the network application message within 20 seconds (i.e., the system's network application time). After 20 seconds, each slave node starts to send a heartbeat packet, because the time-sharing sending moment of each slave node will be set after 20 seconds. After the start message arrives, each slave node starts timing, because after the last start message, the master node does not send a pause message (because there is no network application message), so the slave node can count to its own time-sharing sending moment, and then send a heartbeat packet. Further, if it is not the first time to power on, all slave nodes have already entered the network, and the working process is to go directly to step 6 after step 1.

[0058] The technical solution disclosed in the present invention can solve the problem that the frequency of obtaining slave node messages in the communication timing design of a time-division multiplexing communication distributed system is very low, especially when the number of slave nodes is particularly large, it will take a long time to complete the message update of all slave nodes, and the slave nodes cannot be discovered in time; and it can solve the problem that when the control or synchronization signal of a certain node fails in the communication timing design of a time-division multiplexing communication distributed system, the node cannot actively send messages, thereby losing status monitoring of the node and being unable to judge the status of the node; it can effectively improve the timeliness and reliability of heartbeat monitoring, effectively avoid communication conflicts, and at the same time maximize the heartbeat sending frequency, so that slave node problems can be discovered more timely.

[0059] In a specific example, the implementation method can be applied to a time-division multiplexing communication distributed system, and the business communication and heartbeat communication use the same communication network, the communication network has no switches, and only one node can send data at the same time. The business work of the nodes in the time-division multiplexing communication distributed system is periodic, the cycle time can be variable or unchanged, and the time period that the business occupies the communication bus in a cycle is relatively fixed.

[0060] In a specific example, the heartbeat message is sent in a fixed cycle mode, and the slave node counts the cycle and automatically sends the heartbeat packet when the counting cycle is completed.

[0061] In a specific example, the master node calculates and plans the period and the sending time and configures the slave node. In this embodiment, the master node uniformly plans the period and the sending time and configures the slave node to avoid conflicts in the heartbeat packets of the slave nodes and conflicts with business communications.

[0062] In a specific example, the period algorithm of the slave node is calculated according to the shortest period, and the shortest period that the node can send is calculated based on parameters such as business occupancy time, heartbeat transmission time and slave node capacity; the node sending time is allocated to each slave node in turn with the heartbeat transmission time as the interval.

[0063] In a specific example, for a time division multiplexing communication distributed system, the service communication time (T w ), heartbeat communication time (T h ) and business working cycle and other parameters are determined along with the distributed system design. The algorithms for each parameter are as follows.

[0064] Furthermore, the greatest common divisor of business cycles is:

[0065] G=gcd{p1,p2,p3…p n}

[0066] Where gcd is the greatest common divisor function; p1, p2, p3…p nFor 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 heartbeat period is:

[0069] P h =ceil(N / floor((GT w ) / T h ))*G

[0070] Where N is the capacity of the slave nodes of the time-division multiplexing communication distributed system, that is, the maximum number of slave nodes supported; floor is the rounding function; ceil is the rounding function; T w T is the business communication time; h Heartbeat communication time.

[0071] Furthermore, the minimum application time for network access is:

[0072] RT min =P h

[0073] The minimum network application time is equal to the minimum heartbeat period, that is, the total time for all nodes to send network application in sequence is the same as the time to send heartbeat packets. Since the network application message packet is sent using a pseudo-random number, in order to reduce the situation where the random numbers generated by the slave nodes are the same, the actual network application time is set to RT min multiples of , so that there are more available sending times.

[0074] It should be noted that the slave node generates random numbers by itself and decides when to send a network access application based on the random numbers. In this case, the random numbers generated by two slave nodes may be the same. By increasing the range of random numbers, the probability of generating the same random numbers is reduced.

[0075] Furthermore, the time-sharing sending time of the slave node is:

[0076] M h (i) = RT + ceil (i / floor ((GT w ) / T h ))*T w +(i-1)*T h

[0077] Where i is the serial number of the slave node entering the network, starting from 1 and not exceeding the system node capacity N; RT is the network application time.

[0078] Furthermore, the time at which the network access application message packet of the slave node is sent is:

[0079] M r =M h (random(1,N1*RT / RT min ))-RT

[0080] In the formula, random is generated from 1 to N1*RT / RT min A function of random integers between ; N1 is a multiple, N1 is greater than or equal to 1.

[0081] It should be noted that the random integer is substituted into the above formula and then the redundant RT is subtracted, that is, the time when the network access application message packet of the slave node is sent.

[0082] In a specific example, a time-division multiplexing communication distributed system includes 1 master node and 14 slave nodes. The master node and the slave nodes communicate using an optical power division network. The optical communication signal emitted by the master node is divided into 14 parts by an optical power division device and sent to 14 slave nodes. The optical communication signal emitted by the slave node can be sent to the master node. If two or more slave nodes emit optical signals at the same time, signal superposition will occur, 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 the time-division multiplexing communication distributed system is that the master node broadcasts a work command message, the slave node receives the command message, the named slave node returns a monitoring message to the master node, and all slave nodes perform message processing and other tasks according to the command.

[0084] In a specific example, depending on the specific circumstances of the business content, the cycle of the entire work process is different, including 1s, 2s, 5s, 10s and 13s cycles. The master node sends commands according to different cycles, and the cycle arrangement order is random.

[0085] In a specific example, the service 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 application time is 10 times the RT. min For example, in Figure 2 In the 1s business cycle, the business communication time is within 200ms, and the time for each slave node from node 1 to send a heartbeat packet or an application packet to occupy the communication bus is within 100ms; in the 2s business cycle, the business communication time is within 200ms, and the time for each slave node from node 1 to send a heartbeat packet or an application packet to occupy the communication bus is within 100ms.

[0086] In a specific example, the heartbeat start packet has a synchronization function and needs to be sent at the start of a service cycle to synchronize the heartbeat with the service.

[0087] In a specific example, each node can calculate the heartbeat configuration parameters according to the system operating parameters. Further, according to the above formula, P h =2s, RT=20s. The time-sharing sending times of the 14 slave nodes are calculated by the master node, which 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. After each slave node sends the heartbeat packet for the first time, it sends the next heartbeat packet every 2s. 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 application message packet is calculated by the slave node, which first generates a random integer between 1 and 140, and then calculates the sending time according to the formula. The sending time is distributed in 0.2s-0.9s of each 1s cycle, which will not conflict with the service communication time. Figure 2 In the 1s service cycle, the service communication time is distributed within 200ms and the sending time is distributed within 800ms.

[0089] In a possible implementation, the method also includes: using the master node to send an off-network command message to the network-entering slave node to be uninstalled, setting the network-entering slave node to be uninstalled as an off-network slave node; using the master node to delete the node message of the network-entering slave node to be uninstalled, and recovering the time-sharing sending time of the heartbeat message corresponding to the network-entering slave node to be uninstalled.

[0090] In a specific example, if a slave node is to be uninstalled, the master node first sends an off-network command message to reset the slave node to an off-network state, and the master node deletes the node message locally and reclaims the time-sharing sending moment.

[0091] In a possible implementation, the master node and multiple slave nodes are initialized after powering on, and obtaining the time-sharing sending times and heartbeat cycles of the heartbeat messages of the multiple network-entering slave nodes, as well as the time-sharing sending times of the network-entering application messages of the multiple off-network slave nodes includes: using the master node to read the local slave node record messages and calculate the time-sharing sending times and heartbeat cycles of the heartbeat messages of the multiple network-entering slave nodes; wherein the local slave node record messages include the basic messages of the network-entering slave nodes, the heartbeat configuration messages and the number of slave nodes.

[0092] In a possible implementation, the master node and multiple slave nodes are initialized after powering on, and obtaining the time-sharing sending times and heartbeat cycles of the multiple network-entering slave nodes, as well as the sending times of the network access application messages of the multiple off-network slave nodes also includes: using the multiple network-entering slave nodes to read the heartbeat configuration messages and wait for receiving a start message; using the multiple off-network slave nodes to randomly generate the sending times of the network access application messages and wait for receiving a start message.

[0093] In a specific example, each node starts initialization after power-on. The master node reads the local slave node record message, including the basic message, heartbeat configuration message and number of slave nodes that have been connected to the network, calculates the time-sharing sending time of the slave nodes that have been connected to the network, and finds the time-sharing sending time that can be allocated. The slave node reads the heartbeat configuration message, the slave node that has been connected to the network waits for the start message, and the slave node that has not been connected to the network randomly generates the time to send the network application message and waits for the start message.

[0094] In a possible implementation, the method of using the master node to send a start message to the multiple network-entering slave nodes and the multiple off-network slave nodes at the start time of the current service cycle so that the multiple network-entering slave nodes and the multiple off-network slave nodes start working includes: using the multiple network-entering slave nodes and the multiple off-network slave nodes to perform time synchronization according to the start message to obtain a reference time, so that the multiple off-network slave nodes send a network access application message to the master node based on the reference time and the corresponding network access application message sending time, so that the multiple network-entering slave nodes send a heartbeat message to the master node based on the reference time and the corresponding heartbeat message time-sharing sending time and heartbeat cycle.

[0095] In a specific example, after the master node is initialized, a start message is sent at the start time of the service cycle, and then the service work is carried out. At this time, all slave nodes start working, and time synchronization is performed based on the start message. The slave nodes that have joined the network use the synchronization time as the reference time 0 to send heartbeat packets according to the time-sharing sending time and heartbeat cycle parameters of the node, and the slave nodes that have not joined the network send network application messages according to the network application message sending time.

[0096] In a specific example, the non-networked slave node sends a network access application message earlier than the networked node, that is, the non-networked slave node sends a network access application message before the networked slave node sends a heartbeat packet.

[0097] In a specific example, the slave node has two states: working and paused. No heartbeat packet is sent in the paused state. The slave nodes are in the paused state after power-on. After the master node sends the start message control packet, each slave node performs time synchronization according to the start message packet. The synchronization time is used as the reference time for the slave node's time-sharing sending moment. After the synchronization is completed, the slave node first delays to the node's time-sharing sending moment, and then starts sending the heartbeat message for the first time, and then sends it according to the cycle.

[0098] In a possible implementation, the process 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 multiple network access slave nodes and the multiple off-network 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 and sending the configuration message to the multiple network access slave nodes and the multiple off-network slave nodes; wherein the configuration message includes the heartbeat message time-sharing sending time, heartbeat period and the identity message corresponding to setting the off-network slave node corresponding to the first network access application message as the network access slave node.

[0099] In a specific example, the random algorithm makes the sending times of the non-networked slave nodes not overlap to a certain extent. The master node sends a pause message as soon as it receives a valid network access application message, and no longer receives other received network access application messages.

[0100] In a specific example, the master node processes the received network access application message, which includes information such as the slave node identity (ID). The master node assigns parameters such as time-sharing transmission time to the slave node, and forms a configuration message package together with the slave node ID and heartbeat cycle, which is sent to the slave node and recorded locally.

[0101] In a specific example, the sending time of the network 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 communications.

[0102] In a possible implementation manner, the using of the off-network slave node to set the off-network slave node corresponding to the first network access application message as the network access 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, using the off-network slave node corresponding to the first network access application message to set the off-network slave node corresponding to the first network access application message as the network access slave node according to the configuration message.

[0103] In a specific example, each slave node can receive the configuration package, and only the slave node with the same ID in the configuration package will use the configuration package for configuration, and the configuration package will set the slave node to the network access state.

[0104] In a specific example, the slave node has two states: connected and off-network. After the master node completes the configuration of the slave node, it sets the slave node to the connected state. Only the slave node in the connected state can send heartbeat message packets. The slave node that is not connected to the network is in the off-network state. The slave node in the off-network state only sends the network application message packet within a period of time after starting to work. This period of time is called the network application time. After receiving the network application message packet, the master node sends a pause message control packet to set all slave nodes to the pause state, configure the slave node that applies for network access, and set the network status. Then send the start packet to set all slave nodes to start working.

[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 solidified in the slave node, and the master node also has records, which will not be lost in the event of a power failure.

[0107] In a possible implementation, the method also includes: within the network access application time, if the master node receives a network access application message, using the master node to send a start message to the multiple network access slave nodes and the remaining off-network slave nodes at the start time of the next service cycle; using the remaining off-network slave nodes to recalculate the network access application message sending time corresponding to the remaining off-network slave nodes according to the start message.

[0108] In a specific example, the master node processes only one slave node that is not connected to the network each time, and the number of slave nodes that are not connected to the network is gradually reduced.

[0109] In a specific example, each time a slave node that has not joined the network receives a synchronization packet, it recalculates the time to send the network application message. For example, if it has not joined the network this time, it will use a new time to send the message next time to avoid conflicts between slave nodes with the same random number.

[0110] In a possible implementation, the method also includes: using the remaining off-network slave nodes to respectively send network access application messages to the master node at the respective corresponding network access application message sending times; when the master node receives the first network access application message, using the master node to send a pause message to multiple network access slave nodes and the remaining off-network slave nodes, and stop receiving the remaining network access application messages; using 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 off-network slave nodes; using the off-network slave node to set the off-network 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 service 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, the slave nodes synchronize again. If all slave nodes have joined the network, no slave node sends a network application message within the network application time (e.g., 20 seconds). At 20.2 seconds, the first slave node starts sending heartbeat packets, and starts sending them continuously with a period of 2 seconds, and other nodes send them in turn in time.

[0113] In summary, the present embodiment is applied to a time-division multiplexing communication distributed system with a periodic working regularity. The master node in the system calculates and plans the heartbeat communication timing, automatically configures the slave nodes, controls the network access and off-network, working and pause states of the slave nodes, and synchronizes the slave nodes, so that the slave nodes in the time-division multiplexing communication system can spontaneously and periodically send heartbeat packets. The heartbeat communications of the slave nodes and the heartbeat communications and the business communications of the slave nodes do not occupy the communication network at the same time, which can avoid communication conflicts. At the same time, the heartbeat sending frequency is maximized, and slave node problems can be discovered 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, which is used to initialize the master node and multiple slave nodes after powering on, and obtain the time-sharing sending time and heartbeat cycle of the heartbeat messages of the multiple network-entering slave nodes, and the sending time of the network-entry application messages of the multiple off-network slave nodes; the master node is used to send a start message to the multiple network-entering slave nodes and the multiple off-network slave nodes at the start time of the current service cycle, so that the multiple network-entering slave nodes and the multiple off-network slave nodes start working; the multiple off-network slave nodes are used to send the network-entry application messages to the master node at the respective corresponding sending time of the network-entry application messages; the master node is also used to send the network-entry application messages to the master node by using the master node when receiving the first network-entry application message The master node is further configured to pause sending messages to the multiple network access slave nodes and the multiple off-network slave nodes, and stop receiving the remaining network access application messages; the master node is further configured to generate a configuration message after processing the first network access application message, and send the configuration message to the multiple network access slave nodes and the multiple off-network slave nodes; the multiple off-network slave nodes are further configured to set the off-network slave node corresponding to the first network access application message as a network access slave node according to the configuration message; the master node is further configured to use all the network access 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 moments within the network access application time if no network access application message is received.

[0115] This embodiment can solve the problem that the frequency of obtaining slave node messages in the communication timing design of the time-division multiplexing communication distributed system is very low, especially when the number of slave nodes is particularly large, it will take a long time to complete the message update of all slave nodes, and the slave nodes cannot be discovered in time; and it can solve the problem that when the control or synchronization signal of a node fails in the communication timing design of the time-division multiplexing communication distributed system, the node cannot actively send messages, thereby losing status monitoring of the node and being unable to judge the status of the node; it can effectively improve the timeliness and reliability of heartbeat monitoring, effectively avoid communication conflicts, and at the same time maximize the heartbeat sending frequency, so that slave node problems can be discovered more timely.

[0116] Obviously, the above embodiments of the present invention are merely examples for clearly illustrating the present invention, and are not limitations on the embodiments of the present invention. For those skilled in the art, other different forms of changes or modifications can be made based on the above description. It is impossible to list all the embodiments here. All obvious changes or modifications derived from the technical solution 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, they are initialized to obtain the time-sharing sending time and heartbeat cycle of multiple network-connected slave nodes, as well as the sending time of network-connected application messages of multiple off-network slave nodes; Using the master node to send a start message to the multiple network-entering slave nodes and the multiple network-offline slave nodes at the start time of the current service cycle, so that the multiple network-entering slave nodes and the multiple network-offline slave nodes start working; Utilize the plurality of off-network slave nodes to respectively send network access application messages to the master node at the respective corresponding network access application message sending times; When the master node receives the first network access application message, the master node is used to send a pause message to the multiple network access slave nodes and the multiple network access slave nodes, and stops receiving the remaining network access application messages; Using the master node to process the first network access application message to generate a configuration message, and sending the configuration message to the multiple network access slave nodes and the multiple network-exit slave nodes; Using the off-network slave node to set the off-network slave node corresponding to the first network access application message as the network access slave node according to the configuration message; If the master node does not receive the network access application message within the network access application time, all network access slave nodes are used to send heartbeat messages to the master node in sequence according to the heartbeat cycle at their corresponding heartbeat message time-sharing sending moments.

2. The method for implementing the heartbeat mechanism according to claim 1, characterized in that: The method also includes Using the master node to send an off-network command message to the on-network slave node to be uninstalled, setting the on-network slave node to be uninstalled as an off-network slave node; The master node is used to delete the node message of the network-entering slave node to be uninstalled, and the time-sharing sending time of the heartbeat message corresponding to the network-entering slave node to be uninstalled is recovered.

3. The method for implementing the heartbeat mechanism according to claim 1, characterized in that: The master node and multiple slave nodes are powered on and initialized to obtain the heartbeat message time-sharing sending time and heartbeat cycle of multiple network-connected slave nodes, as well as the network application message sending time of multiple off-network slave nodes. Using the master node to read the local slave node record message and calculate the heartbeat message time-sharing sending time and heartbeat cycle of the multiple networked slave nodes; in The local slave node record message includes the basic message of the networked slave node, the heartbeat configuration message and the number of slave nodes.

4. The method for implementing the heartbeat mechanism according to claim 3, characterized in that: The master node and multiple slave nodes are powered on and initialized to obtain the heartbeat message time-sharing sending time and heartbeat cycle of multiple network-connected slave nodes, as well as the network application message sending time of multiple off-network slave nodes. Using the multiple network entry slave nodes to read the heartbeat configuration message and wait for receiving a start message; The multiple off-grid slave nodes are used to randomly generate a time for sending a network access application message and wait for receiving a start message.

5. The method for implementing the heartbeat mechanism according to claim 1, characterized in that: The using the master node to send a start message to the multiple network-entering slave nodes and the multiple network-offline slave nodes at the start time of the current service cycle, so that the multiple network-entering slave nodes and the multiple network-offline slave nodes start working, comprises The multiple network-entering slave nodes and the multiple network-offline slave nodes are used to perform time synchronization according to the start message to obtain a reference time, so that after the multiple network-entering slave nodes send a network access application message to the master node based on the reference time and the corresponding network access application message sending time, the multiple network-entering slave nodes send a heartbeat message to the master node based on the reference time and the corresponding heartbeat message time-sharing sending time and heartbeat period.

6. The method for implementing the heartbeat mechanism according to claim 1, characterized in that: The using the master node to process the first network access application message to generate a configuration message, and sending the configuration message to the multiple network access slave nodes and the multiple network-exit slave nodes includes Using the master node to obtain the identity information in the first network access application message; The master node is used to generate a configuration message according to the identity message, and the configuration message is recorded and sent to the multiple network-entering slave nodes and the multiple off-network slave nodes; wherein the configuration message includes the heartbeat message time-sharing sending time corresponding to setting the off-network slave node corresponding to the first network access application message as the network-entering slave node, the heartbeat cycle and the identity message.

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 access application message as the network access 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 an access slave node according to the configuration message using the off-network slave node corresponding to the first network access application message.

8. The method for implementing the heartbeat mechanism according to claim 1, characterized in that: The method also includes Within the network access application time, if the master node receives the network access application message, the master node is used to send a start message to the multiple network access slave nodes and the remaining off-network slave nodes at the start time of the next service cycle; The remaining off-network slave nodes are used to recalculate the network access application message sending time corresponding to the remaining off-network slave nodes according to the start message.

9. The method for implementing the heartbeat mechanism according to claim 8, characterized in that: The method also includes Utilize the remaining off-network slave nodes to respectively send network access application messages to the master node at the respective corresponding network access application message sending times; When the master node receives the first network access application message, the master node is used to send a pause message to multiple network access slave nodes and the remaining off-network slave nodes, and stops receiving the remaining network access application messages; Using 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 off-network slave nodes; The off-network slave node corresponding to the first network access application message is set as an on-network slave node by using the off-network slave node according to the configuration message.

10. A heartbeat mechanism implementation system, characterized in that: The system includes An initialization module is used to initialize the master node and multiple slave nodes after powering on, obtain the time-sharing sending time and heartbeat cycle of multiple network-connected slave nodes, and the sending time of network-connected application messages of multiple off-network slave nodes; The master node is used to send a start message to the multiple network-entering slave nodes and the multiple network-offline slave nodes at the start time of the current service cycle, so that the multiple network-entering slave nodes and the multiple network-offline slave nodes start working; A plurality of off-network slave nodes, used to respectively send network access application messages to the master node at the respective corresponding network access application message sending times; The master node is further configured to, when receiving the first network access application message, send a pause message to the plurality of network access slave nodes and the plurality of network access slave nodes using the master node, and stop receiving the remaining network access application messages; The master node is further configured to generate a configuration message after processing the first network access application message, and send the configuration message to the multiple network access slave nodes and the multiple network off-network slave nodes; A plurality of off-network slave nodes, further configured to set the off-network slave node corresponding to the first network access application message as a network access slave node according to the configuration message; The master node is also used to use all the network access 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 moments if no network access application message is received within the network access application time.

Citation Information

Patent Citations

  • Method, apparatus, device and system for implementing one-way heartbeat mechanism

    CN108924195A

  • Heartbeat detection method, device and system, electronic equipment and storage medium

    CN114157591A

  • Heartbeat interaction method and device

    CN118433078A