Time synchronization method and device based on node cooperation, equipment and storage medium
By using a node collaboration mechanism to quickly elect a new clock source in a wireless ad hoc network, the problem of time synchronization difficulties caused by source clock node failure is solved, enabling rapid recovery of network operation and full network clock synchronization, while reducing message overhead.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- NANJING ZHONGKEXUNDA INFORMATION TECHNOLOGY CO LTD
- Filing Date
- 2024-11-12
- Publication Date
- 2026-07-14
AI Technical Summary
In wireless ad hoc networks, when the source clock node fails, existing technologies struggle to quickly restore network operation, leading to difficulties in time synchronization recovery, a large number of packets, and high overhead.
Through a node collaboration mechanism, a new clock source node is elected. One of the multiple next-hop nodes of each node is used as a message forwarding node to make voting requests and responses, quickly determine the new clock source, reduce forwarding by neighboring nodes, and avoid signaling storms.
It enables rapid recovery of the decentralized network, reduces message overhead, ensures network-wide clock synchronization, and improves system stability and availability.
Smart Images

Figure CN119676729B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of wireless ad hoc networks, and in particular to a time synchronization method, apparatus, device, and storage medium based on node cooperation. Background Technology
[0002] Wireless ad hoc networks are mobile communication networks composed of several mobile nodes that do not rely on fixed infrastructure. They are characterized by being decentralized, self-organizing, dynamically changing network topology, and highly resistant to destruction, and have broad application prospects in both military and civilian fields.
[0003] Time synchronization is crucial for wireless ad hoc networks, ensuring normal data transmission and serving as a key technology. When the source clock node fails, data is often flooded through all neighbors, resulting in a large number of packets, high overhead, and difficulty in quickly restoring the network to its decentralized state. Summary of the Invention
[0004] This application aims to propose a time synchronization method, apparatus, device, and storage medium based on node collaboration, which can quickly complete the joint decision-making of all network nodes to generate a new time synchronization source, and help to quickly restore the network's operating status.
[0005] The time synchronization method based on node collaboration according to the first aspect of this application includes:
[0006] If no time synchronization signal is received from the clock source node within a preset time synchronization period, the election cycle count is updated, and a voting request message is generated based on the election cycle count and the local address.
[0007] The voting request message is sent through a message forwarding node; wherein, the message forwarding node corresponding to each node is one of the multiple next-hop nodes of the node;
[0008] Within a preset voting response period, the node receives voting response messages from other nodes and determines the number of votes obtained within the preset voting response period; wherein, each node that receives the voting request message generates a voting response message based on the voting request message and sends it through the corresponding message forwarding node;
[0009] The election status is determined based on the number of votes cast.
[0010] If the election status indicates that the election was successful, the time synchronization operation is completed.
[0011] According to some embodiments of this application, the message forwarding node corresponding to each node is the next-hop node with the largest number of neighbors among the multiple next-hop nodes corresponding to the node.
[0012] According to some embodiments of this application, the target address in the voting response message is consistent with the local address in the corresponding voting request message;
[0013] The step of receiving voting response messages from other nodes within a preset voting response period and determining the number of votes obtained within the preset voting response period includes:
[0014] Within the preset voting response period, determine the consistency between the local address and the target address in the voting response message;
[0015] If the local address matches the target address in the voting response message, update the vote count;
[0016] When the preset voting response period ends, the number of votes cast during the preset voting response period is obtained.
[0017] According to some embodiments of this application, within the preset voting response period, the consistency between the local address and the target address in the voting response message is determined, and then the process further includes:
[0018] If the local address is inconsistent with the target address in the voting response message, and the node corresponding to the local address is a message forwarding node, then the voting response message is forwarded.
[0019] According to some embodiments of this application, each node that receives the voting request message generates a voting response message based on the voting request message, including:
[0020] Obtain the election cycle number from the voting request message;
[0021] If the voting request message is the first voting request message received after the election cycle number is updated, the voting response message is generated.
[0022] According to some embodiments of this application, determining the election status based on the number of votes cast includes:
[0023] If the number of votes is greater than or equal to a first threshold, the election status indicates that the election was successful;
[0024] If the number of votes is less than the first threshold, the election status indicates that the election has failed.
[0025] According to some embodiments of this application, the step of performing time synchronization operation when the election status indicates that the election was successful includes:
[0026] If the election status indicates that the election was successful, the system switches to the clock source node status.
[0027] Broadcast the local clock information to other nodes across the network.
[0028] According to a second aspect embodiment of the present application, a node-based time synchronization apparatus includes:
[0029] The generation unit is used to update the election cycle number and generate a voting request message based on the election cycle number and the local address if no time synchronization signal is received from the clock source node within a preset time synchronization cycle.
[0030] A sending unit is used to send the voting request message through a message forwarding node; wherein, the message forwarding node corresponding to each node is one of the multiple next-hop nodes of the node;
[0031] The receiving unit is configured to receive voting response messages sent by other nodes within a preset voting response period, and determine the number of votes obtained within the preset voting response period; wherein each node that receives the voting request message generates a voting response message based on the voting request message, and sends it through the corresponding message forwarding node;
[0032] A determining unit is used to determine the election status based on the number of votes cast;
[0033] The synchronization unit is used to perform time synchronization operations when the election status indicates that the election was successful.
[0034] An electronic device according to a third aspect of this application includes a processor and a memory, the memory storing a program or instructions executable on the processor, the program or instructions, when executed by the processor, implementing the steps of the node-cooperative time synchronization method as described in any of the first aspect embodiments above.
[0035] A computer-readable storage medium according to a fourth aspect embodiment of the present application stores computer-executable instructions for performing the node-cooperative time synchronization method as described in the first aspect embodiment above.
[0036] In this embodiment, when the source clock node fails, other nodes in the network compete to generate a new source clock node. For messages that need to be communicated to the entire network, each node selects only one of its neighboring nodes as a message forwarding node for forwarding and propagation. Other neighboring nodes only receive the messages and do not forward them, thus completing the message propagation across the entire network. This effectively avoids the signaling storm caused by forwarding messages from all neighboring nodes, which leads to excessive overhead from flooding and forwarding messages. The rapid joint decision-making by all nodes in the network to generate a new time synchronization source helps to quickly restore the operation of the decentralized network, minimizes the impact on task execution, and achieves network-wide clock synchronization in the shortest possible time.
[0037] Other features and advantages of this application will be set forth in the following description, and will be apparent in part from the description, or may be learned by practicing this application. Attached Figure Description
[0038] The above and / or additional aspects and advantages of this application will become apparent and readily understood from the description of the embodiments taken in conjunction with the following drawings, in which:
[0039] Figure 1 This is a flowchart illustrating an embodiment of the node-collaboration-based time synchronization method of this application;
[0040] Figure 2 This is a schematic diagram of an embodiment of the node-cooperative time synchronization device of this application;
[0041] Figure 3 This is a schematic diagram of the hardware structure of an embodiment of the electronic device of this application. Detailed Implementation
[0042] The embodiments of this application are described in detail below. Examples of these embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain this application, and should not be construed as limiting this application.
[0043] In the description of this application, the use of terms such as "first," "second," etc., is for the purpose of distinguishing technical features only and should not be construed as indicating or implying relative importance or implicitly indicating the number of technical features indicated or the order of the technical features indicated.
[0044] In the description of this application, it should be understood that the orientation descriptions, such as up, down, etc., are based on the orientation or positional relationship shown in the accompanying drawings, and are only for the convenience of describing this application 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 this application.
[0045] In the description of this application, it should be noted that, unless otherwise explicitly defined, terms such as "setup," "installation," and "connection" should be interpreted broadly, and those skilled in the art can reasonably determine the specific meaning of the above terms in this application in conjunction with the specific content of the technical solution.
[0046] The technical solution of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the embodiments described below are some embodiments of this application, not all embodiments.
[0047] Figure 1 A flowchart illustrating the node-collaboration-based time synchronization method provided in this application. Figure 2 This is a schematic diagram of an embodiment of the node-cooperative time synchronization device of this application; Figure 3 This is a schematic diagram of the hardware structure of an embodiment of the electronic device of this application.
[0048] See below. Figure 1 The embodiments of this application will be further described below.
[0049] This application proposes a node-cooperation-based time synchronization method, which is applied to any node in a network to be synchronized. The node-cooperation-based time synchronization method includes the following steps:
[0050] Step 101: If no time synchronization signal is received from the clock source node within a preset time synchronization period, update the election cycle count and generate a voting request message based on the election cycle count and the local address.
[0051] Step 102: Send the voting request message through the message forwarding node; where the message forwarding node corresponding to each node is one of the node's multiple next-hop nodes;
[0052] Step 103: Within the preset voting response period, receive voting response messages sent by other nodes and determine the number of votes obtained within the preset voting response period; wherein, each node that receives a voting request message generates a voting response message based on the voting request message and sends it through the corresponding message forwarding node;
[0053] Step 104: Determine the election status based on the number of votes cast;
[0054] Step 105: If the election status indicates that the election was successful, complete the time synchronization operation.
[0055] In this embodiment, when the source clock node fails, other nodes in the network compete to generate a new source clock node. For messages that need to be communicated to the entire network, each node selects only one of its neighboring nodes as a message forwarding node for forwarding and propagation. Other neighboring nodes only receive the messages and do not forward them, thus completing the message propagation across the entire network. This effectively avoids the signaling storm caused by forwarding messages from all neighboring nodes, which leads to excessive overhead from flooding and forwarding messages. The rapid joint decision-making by all nodes in the network to generate a new time synchronization source helps to quickly restore the operation of the decentralized network, minimizes the impact on task execution, and achieves network-wide clock synchronization in the shortest possible time.
[0056] The network to be synchronized mentioned above can be a wireless ad hoc network, specifically, a decentralized wireless ad hoc network.
[0057] In step 101 above, if no time synchronization signal is received from the clock source node within a preset time synchronization period, the election cycle count is updated, and a voting request message is generated based on the election cycle count and the local address.
[0058] The aforementioned preset time synchronization period can be preset based on the past cycles of receiving time synchronization signals from the clock source node. Under normal circumstances, the node will receive a time synchronization signal from the clock source node within each preset time synchronization period and perform time synchronization based on this signal. However, if the clock source node fails, the node will not receive a time synchronization signal from the clock source node within the preset time synchronization period. In this case, a new clock source node needs to be re-elected for time synchronization in the event of a failure.
[0059] The aforementioned preset time synchronization period can be timed using a time measurement tool, specifically a timer.
[0060] For example, after receiving the synchronization clock information from the clock source node, each node starts a timer with a timeout period of a preset time synchronization cycle. When a node does not receive a time synchronization signal from the clock source node within the timeout period, it determines that the clock source node has failed and then participates in the election.
[0061] The above-mentioned election cycle count can be recorded as the number of times a node participates in an election. Each time a node starts a new election process, the election cycle count will be updated. Specifically, the election cycle count can be incremented by one. Thus, a higher election cycle count value means that it occurred at a later point in time, which is the latest round of election caused by the most recent failure.
[0062] The aforementioned voting request message can be a request sent by this node to other nodes across the network to elect itself during the election process. The voting request message includes the number of election cycles and the local address of this node.
[0063] In step 102 above, the voting request message is sent through the message forwarding node; wherein, the message forwarding node corresponding to each node is one of the multiple next-hop nodes of the node.
[0064] The message forwarding node corresponding to each of the above nodes is one of the multiple next-hop nodes of the node. It can be one of the multiple neighbor nodes of each node as its corresponding message forwarding node. It is used to forward and propagate relevant information during the election process after the clock source signal transmission failure. Other neighbor nodes only receive and do not forward, thus completing the message propagation of the entire network. This can effectively avoid the signaling storm caused by all neighbor nodes forwarding, and avoid the problem of too many flooded forwarding messages and high overhead.
[0065] In step 103 above, within a preset voting response period, voting response messages sent by other nodes are received, and the number of votes obtained within the preset voting response period is determined; wherein, each node that receives a voting request message generates a voting response message based on the voting request message, and sends it through the corresponding message forwarding node.
[0066] The aforementioned voting response message can be sent to other nodes that have received the voting request message from this node. Each other node may receive voting request messages from multiple nodes, but will only choose to vote for one node and send a response voting response message. The specific selection process will be based on the content contained in the multiple voting request messages according to a certain priority rule. Specifically, it can be based on the information of the number of election cycles contained in the voting request message.
[0067] The aforementioned preset voting response period can be a preset time period during which voting is acceptable, and the voting response messages received within this period can be counted as votes.
[0068] In step 104 above, the election status is determined based on the number of votes cast.
[0069] The aforementioned election status can include situations indicating election success and situations indicating election failure. The election status can be determined based on the number of votes, which can be interpreted as an election success if the number of votes reaches a certain threshold, and an election failure if the number of votes does not reach this threshold.
[0070] In step 105 above, if the election status indicates that the election was successful, the time synchronization operation is completed.
[0071] The above time synchronization operation can be performed based on the successfully elected nodes.
[0072] If the election status is "election failed", return to the previous step 101, in the case that no time synchronization signal is received from the clock source node after the preset time for time synchronization, update the number of election cycles, and generate a voting request message based on the number of election cycles.
[0073] In some implementations, the message forwarding node corresponding to each node is the next-hop node with the largest number of neighbors among the multiple next-hop nodes of the corresponding node.
[0074] In this implementation, the next-hop node with the largest number of neighbors is selected as the message forwarding node. The node selects neighboring nodes that can connect to more nodes from its own neighbors to spread relevant information about the election process. This can quickly spread voting request messages and voting response messages throughout the network, shorten the re-election time, and achieve network-wide clock synchronization in the shortest possible time.
[0075] For example, the time synchronization information of node m is in its single-hop neighbor node n i Broadcast within {n1, n2, n3…}, where i is the number of neighboring nodes of node m, and node m records the single-hop node n. i The number of neighbors is count[i], and the single-hop node with the largest number of neighbor nodes is selected. p As the forwarder and propagator of the broadcast message of node m, it is as follows:
[0076] n p =max{count[1],count[2],count[3],…,count[i]},p∈{1,…,n}.
[0077] In some implementations, message forwarding nodes can be determined through the following steps:
[0078] Broadcast the local address to multiple one-hop nodes;
[0079] Receive the addresses of multiple one-hop nodes and generate a list of one-hop nodes, where the list of one-hop nodes records each one-hop node and its corresponding address;
[0080] Broadcast a list of one-hop node addresses to multiple one-hop nodes;
[0081] Receive a list of one-hop node addresses from multiple one-hop nodes and generate a list of two-hop nodes. The list of two-hop nodes records each two-hop node connected through each one-hop node and its corresponding address.
[0082] Based on the list of two-hop nodes, the first-hop node with the largest number of connections is determined to be the message forwarding node.
[0083] The aforementioned one-hop node is the next-hop node or neighbor node.
[0084] For example, a node periodically broadcasts its one-hop node information to its neighbors. Simultaneously, the node records its neighbor list S1, which includes each neighbor node and its corresponding address. Then, based on the neighbor node information carried by each neighbor, the node generates a local list of two-hop nodes accessible via that neighbor, thus forming its own two-hop neighbor list S2, which contains the addresses of the two-hop neighbors. It's important to note that when members of the local two-hop neighbor list are added or deleted, the two-hop neighbor connection counts of each member in the one-hop neighbor list must be iterated through.
[0085] For example, if node r's neighbor is node s, and node s belongs to list S1, let count[s] = the number of nodes in the two-hop list that reach node r through node s. Similarly, after traversing all the neighbors in the one-hop neighbor list S1 of node r, we obtain the count values of n one-hop nodes. The neighbor node with the largest count value is selected as n. p This selects the neighbor n with the largest number of connections among the r neighboring nodes of this node. p via n p To complete the forwarding of election requests.
[0086] In some implementations, the target address in the voting response message is the same as the local address in the corresponding voting request message;
[0087] Within a preset voting response period, it receives voting response messages from other nodes and determines the number of votes received within the preset voting response period, including:
[0088] Within a preset voting response period, determine the consistency between the local address and the target address in the voting response message;
[0089] If the local address matches the target address in the voting response message, update the vote count;
[0090] If the preset voting response period ends, the number of votes cast within the preset voting response period is obtained.
[0091] In this implementation, since the node may receive votes cast for itself or for other nodes, it needs to forward and propagate these votes. Therefore, it is necessary to judge the content of the received voting response message. Specifically, by checking whether the local address of the node is consistent with the target address in the voting response message, the vote count is updated only when the addresses are consistent. Specifically, the vote count can be incremented by one, thus achieving accurate confirmation of the vote count.
[0092] The voting request message contains the local address of this node. When other nodes that receive this voting request message decide to vote for this node, the target address in their voting response message must be set to this local address in order to send the voting response message to this node. Therefore, if the target address in the received voting response message is inconsistent with the local address, it can be determined that the voting response message is not for itself.
[0093] In some implementations, receiving voting response messages from other nodes within a preset voting response period and determining the number of votes obtained within the preset voting response period also includes: the node casting a vote for itself, i.e., adding one to the original number of votes.
[0094] In some implementations, within a preset voting response period, the consistency between the local address and the target address in the voting response message is determined, and then the process further includes:
[0095] If the local address is inconsistent with the target address in the voting response message, and the node corresponding to the local address is a message forwarding node, then forward the voting response message.
[0096] In this implementation, since the node may receive votes for itself or for other nodes, it needs to forward and propagate these votes. Therefore, it is necessary to judge the content of the received voting response message. Specifically, by checking whether the local address of the node matches the target address in the voting response message, if the addresses do not match, it can be determined that the voting response message is not for itself, the vote count is not updated, and the voting response message still needs to be forwarded. However, since only message forwarding nodes are used to forward and propagate relevant information during the election voting process, and other neighboring nodes only receive but do not forward, it is necessary to determine whether the node is a message forwarding node. Only when the node is a message forwarding node should the voting response message be forwarded, which helps to reduce message overhead.
[0097] In some implementations, each node that receives a voting request message generates a voting response message based on the voting request message, including:
[0098] Retrieve the election cycle number from the vote request message;
[0099] If the voting request message is the first voting request message received after the election cycle number is updated, a voting response message is generated.
[0100] The above-mentioned election cycle count can be recorded as the number of times a node participates in an election. Each time a node starts a new election process, the election cycle count will be updated. Specifically, the election cycle count can be incremented by one. Thus, a higher election cycle count value means that it occurred at a later point in time, which is the latest round of election caused by the most recent failure.
[0101] In this embodiment, other nodes that vote select the node corresponding to the first voting request message received after the election cycle number is updated. That is, the earliest voting request message received after the most recent failure is the optimal choice for voting, which can better select a new clock source node.
[0102] In some implementations, the election status is determined based on the number of votes cast, including:
[0103] If the number of votes is greater than or equal to the first threshold, the election status indicates that the election was successful;
[0104] If the number of votes is less than a first threshold, the election status indicates that the election has failed.
[0105] The first threshold mentioned above can be half the total number of nodes in the network. That is, if more than half of the nodes vote, the election is considered successful, and if less than half of the nodes vote, the election is considered unsuccessful.
[0106] In some implementations, when the election status indicates a successful election, the time synchronization operation is performed, including:
[0107] If the election status indicates a successful election, switch to the clock source node status;
[0108] Broadcast the local clock information to other nodes across the network.
[0109] In this implementation, if the node is successfully elected, it becomes the new clock source node, and other nodes in the network can synchronize their time through this node.
[0110] In some implementations, in a decentralized wireless ad hoc network, the clock source node broadcasts its message, i.e., local clock information, through its neighboring nodes. After receiving the message, the neighboring nodes compare it with the clock information in their own context and synchronize with the clock source node. Other nodes receive the clock information from their previous hop node and synchronize accordingly, thus flooding the entire network to achieve time synchronization without a central node.
[0111] In some implementations, nodes in this scheme can be in one of three states: candidate node, alternate node, and clock source node. The state of each node will change under different circumstances. The three states are as follows:
[0112] Candidate Node: A node initially functions as a candidate node, receiving instructions from the clock source node. If it does not receive a time synchronization signal from the clock source node within a preset time synchronization period, its state will switch to that of a substitute node. In some cases, a node may also switch to a substitute node state if it does not receive an election request from a substitute node within a certain period.
[0113] Candidate Node: If a node's state is to switch to candidate node, a new election will begin. In this state, the node's election count will be updated, and it will broadcast a request for votes from other nodes to the entire network, i.e., send a vote request message; if it receives more than the required number of votes within a preset voting response period, the node's state will switch from candidate node to clock source node.
[0114] Clock Source Node: If a node successfully becomes the clock source node, it will act as the new clock source node for the entire network and send time synchronization signals to all nodes in the candidate node state to ensure that other nodes are synchronized with its own state. If a node in the candidate node state does not receive a time synchronization signal within the preset time synchronization period, the node will conduct a new election and switch to the alternate node state.
[0115] In some implementations, based on the above state transitions, the specific steps for re-electing a synchronized clock source node in the event of a fault are as follows:
[0116] A node can transition from a candidate node to a substitute node state by starting a timer T_E after receiving synchronization clock information from the clock source node via single-hop broadcast or forward propagation. The timeout period is a preset time synchronization period TM1. If a node does not receive a synchronization signal from the clock source node within the preset time synchronization period TM1, it will switch to a substitute node state. At this time, the node will automatically increment the current election cycle count, switch its own state to the substitute state, cast its own vote, send a vote request to other nodes to nominate itself, and start a timer T_R to wait for the vote response. The timeout period is a preset vote response period TM2.
[0117] When other nodes receive a voting request, they decide whether to cast a vote for that node based on the election cycle number carried in the received voting request message and the number of election votes recorded locally. Specifically, if a voting request message is received from another node, the following judgment is made: if the election cycle number has been updated and a new round of election voting requests has been received for the first time, then that node is elected as the new clock source node for the next round, and a voting response message is sent; similarly, to quickly submit the voting result to the candidate nodes, the node's neighbor node n is selected. pForward and disseminate voting response messages; if the election cycle number is updated and a new round of election voting requests is not received for the first time, do not perform voting operations on the candidate node; if a voting response message is received and the destination node is not itself, then broadcast and forward it within the neighborhood if it is a message forwarding node.
[0118] During the waiting period for voting results, a candidate node awaits vote responses from other nodes in the network. Upon receiving a vote response message supporting it, its counter increments by 1. The counting process ends when timer T_R times out. Specifically, if the number of votes exceeds half the total number of nodes in the network within the preset voting response period TM2, the election is considered successful, and the candidate node's identity is changed to that of a clock source node. It then broadcasts its identity as a clock source node across the network, informing other nodes to synchronize their time with the new clock source node. If the number of votes is less than half the total number of nodes in the network, the election is considered unsuccessful, the candidate node's identity is changed to that of a candidate node, and the election response timer T_R is deleted.
[0119] When a candidate node receives a time synchronization message from the clock source node, it synchronizes its own time.
[0120] Thus, a new synchronization source node was elected in the event of a failure of the original clock source node, ensuring that the overall network execution tasks are not affected, enhancing the stability of the entire system, and improving the system's availability and fault tolerance.
[0121] The node-based time synchronization method provided in this application can be executed by a node-based time synchronization device 200. This application uses the execution of the node-based time synchronization method by the node-based time synchronization device 200 as an example to illustrate the node-based time synchronization device 200 provided in this application.
[0122] Please see Figure 2 This is a schematic diagram of a time synchronization device 200 based on node collaboration provided in an embodiment of this application. Figure 2 As shown, the node-collaboration-based time synchronization device 200 includes:
[0123] The generation unit 201 is used to update the election cycle number and generate a voting request message based on the election cycle number and the local address if no time synchronization signal is received from the clock source node within a preset time synchronization cycle.
[0124] The sending unit 202 is used to send the voting request message through the message forwarding node; wherein, the message forwarding node corresponding to each node is one of the multiple next-hop nodes of the node;
[0125] The receiving unit 203 is used to receive voting response messages sent by other nodes within a preset voting response period, and to determine the number of votes obtained within the preset voting response period; wherein, each node that receives a voting request message generates a voting response message based on the voting request message, and sends it through the corresponding message forwarding node;
[0126] The determining unit 204 is used to determine the election status based on the number of votes cast;
[0127] Synchronization unit 205 is used to complete time synchronization operation when the election status indicates that the election was successful.
[0128] In some implementations, the message forwarding node corresponding to each node is the next-hop node with the largest number of neighbors among the multiple next-hop nodes of the corresponding node.
[0129] In some implementations, the target address in the voting response message is the same as the local address in the corresponding voting request message;
[0130] The receiving unit 203 can be used for:
[0131] Within a preset voting response period, determine the consistency between the local address and the target address in the voting response message;
[0132] If the local address matches the target address in the voting response message, update the vote count;
[0133] If the preset voting response period ends, the number of votes cast within the preset voting response period is obtained.
[0134] In some embodiments, the receiving unit 203 may also be used for:
[0135] If the local address is inconsistent with the target address in the voting response message, and the node corresponding to the local address is a message forwarding node, then forward the voting response message.
[0136] In some embodiments, the receiving unit 203 may be used for:
[0137] Retrieve the election cycle number from the vote request message;
[0138] If the voting request message is the first voting request message received after the election cycle number is updated, a voting response message is generated.
[0139] In some implementations, the determining unit 204 may be used for:
[0140] If the number of votes is greater than or equal to the first threshold, the election status indicates that the election was successful;
[0141] If the number of votes is less than a first threshold, the election status indicates that the election has failed.
[0142] In some implementations, the synchronization unit 205 can be used for:
[0143] If the election status indicates a successful election, switch to the clock source node status;
[0144] Broadcast the local clock information to other nodes across the network.
[0145] Since the node-based time synchronization device 200 adopts all the technical solutions of the node-based time synchronization method of the above embodiments, it has at least all the beneficial effects brought about by the technical solutions of the above embodiments, and will not be described again here.
[0146] Figure 3 This is a schematic diagram of the hardware structure of the electronic device provided in the embodiments of this application.
[0147] This electronic device may include a processor 301 and a memory 302 storing computer program instructions.
[0148] Specifically, the processor 301 may include a central processing unit (CPU), an application-specific integrated circuit (ASIC), or one or more integrated circuits that can be configured to implement the embodiments of this application.
[0149] Memory 302 may include mass storage for data or instructions. For example, and not limitingly, memory 302 may include a hard disk drive (HDD), floppy disk drive, flash memory, optical disk, magneto-optical disk, magnetic tape, or Universal Serial Bus (USB) drive, or a combination of two or more of these. Where appropriate, memory 302 may include removable or non-removable (or fixed) media. Where appropriate, memory 302 may be internal or external to the integrated gateway disaster recovery device. In a particular embodiment, memory 302 is non-volatile solid-state memory.
[0150] In some embodiments, memory 302 may include read-only memory (ROM), random access memory (RAM), disk storage media device, optical storage media device, flash memory device, electrical, optical, or other physical / tangible memory storage device. Thus, generally, memory includes one or more tangible (non-transitory) computer-readable storage media (e.g., memory devices) encoded with software including computer-executable instructions, and when the software is executed (e.g., by one or more processors), it is operable to perform the operations described with reference to the method according to one aspect of this disclosure.
[0151] The processor 301 reads and executes computer program instructions stored in the memory 302 to implement any of the node-cooperative time synchronization methods described in the above embodiments.
[0152] In one example, the electronic device may also include a communication interface 303 and a bus 310. For example, Figure 3 As shown, the processor 301, memory 302, and communication interface 303 are connected through bus 310 and complete communication with each other.
[0153] The communication interface 303 is mainly used to realize communication between various modules, devices, units and / or equipment in the embodiments of this application.
[0154] Bus 310 includes hardware, software, or both, that couples components of an online data traffic metering device together. For example, and not limitingly, the bus may include an Accelerated Graphics Port (AGP) or other graphics bus, an Enhanced Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), HyperTransport (HT) interconnect, an Industry Standard Architecture (ISA) bus, an Infinite Bandwidth Interconnect, a Low Pin Count (LPC) bus, a memory bus, a Microchannel Architecture (MCA) bus, a Peripheral Component Interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a Serial Advanced Technology Attachment (SATA) bus, a Video Electronics Standards Association Local (VLB) bus, or other suitable buses, or combinations of two or more of these. Where appropriate, bus 310 may include one or more buses. Although specific buses are described and illustrated in embodiments of this application, any suitable bus or interconnect is contemplated herein.
[0155] The electronic device can execute the node-cooperative time synchronization method in the embodiments of this application, thereby achieving a combination of Figure 1 and Figure 2 The method and apparatus for time synchronization based on node collaboration are described.
[0156] Furthermore, in conjunction with the node-collaboration-based time synchronization method in the above embodiments, this application embodiment can provide a computer storage medium for implementation. This computer storage medium stores computer program instructions; when these computer program instructions are executed by a processor, they implement any of the node-collaboration-based time synchronization methods in the above embodiments.
[0157] It should be clarified that this application is not limited to the specific configurations and processes described above and shown in the figures. For the sake of brevity, detailed descriptions of known methods are omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of this application is not limited to the specific steps described and shown. Those skilled in the art can make various changes, modifications, and additions, or change the order of steps, after understanding the spirit of this application.
[0158] The functional blocks shown in the above-described structural diagram can be implemented as hardware, software, firmware, or a combination thereof. When implemented in hardware, they can be electronic circuits, application-specific integrated circuits (ASICs), appropriate firmware, plug-ins, function cards, etc. When implemented in software, the elements of this application are programs or code segments used to perform the required tasks. Programs or code segments can be stored on a machine-readable medium or transmitted over a transmission medium or communication link via data signals carried on a carrier wave. "Machine-readable medium" can include any medium capable of storing or transmitting information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, ROM, flash memory, erasable ROM (EROM), floppy disks, CD-ROMs, optical disks, hard disks, fiber optic media, radio frequency (RF) links, etc. Code segments can be downloaded via computer networks such as the Internet, intranets, etc.
[0159] It should also be noted that the exemplary embodiments mentioned in this application describe methods or systems based on a series of steps or apparatus. However, this application is not limited to the order of the above steps; that is, the steps can be performed in the order mentioned in the embodiments, or in a different order, or several steps can be performed simultaneously.
[0160] The aspects of this disclosure have been described above with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this disclosure. It should be understood that each block in the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing apparatus to produce a machine such that these instructions, executable via the processor of the computer or other programmable data processing apparatus, enable the implementation of the functions / actions specified in one or more blocks of the flowchart illustrations and / or block diagrams. Such a processor can be, but is not limited to, a general-purpose processor, a special-purpose processor, a special application processor, or a field-programmable logic circuit. It is also understood that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can also be implemented by special-purpose hardware performing the specified functions or actions, or can be implemented by a combination of special-purpose hardware and computer instructions.
[0161] The above description is merely a specific implementation of this application. Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, modules, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here. It should be understood that the protection scope of this application is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in this application, and these modifications or substitutions should all be covered within the protection scope of this application.
Claims
1. A time synchronization method based on node collaboration, characterized in that, Applied to any node in the network to be synchronized, including: If no time synchronization signal is received from the clock source node within a preset time synchronization period, the election cycle count is updated, and a voting request message is generated based on the election cycle count and the local address. The voting request message is sent through a message forwarding node; wherein, the message forwarding node corresponding to each node is one of the multiple next-hop nodes of the node; Within a preset voting response period, the node receives voting response messages from other nodes and determines the number of votes received within the preset voting response period; wherein, each node that receives the voting request message generates the voting response message based on the voting request message and sends it through the corresponding message forwarding node; The election status is determined based on the number of votes cast. If the election status indicates that the election was successful, the time synchronization operation is completed.
2. The time synchronization method based on node collaboration according to claim 1, characterized in that, The message forwarding node corresponding to each node is the next-hop node with the largest number of neighbors among the plurality of next-hop nodes corresponding to the node.
3. The time synchronization method based on node collaboration according to claim 1, characterized in that, The target address in the voting response message is the same as the local address in the corresponding voting request message; The step of receiving voting response messages from other nodes within a preset voting response period and determining the number of votes obtained within the preset voting response period includes: Within the preset voting response period, determine the consistency between the local address and the target address in the voting response message; If the local address matches the target address in the voting response message, update the vote count; When the preset voting response period ends, the number of votes cast during the preset voting response period is obtained.
4. The time synchronization method based on node collaboration according to claim 3, characterized in that, After determining the consistency between the local address and the target address in the voting response message within the preset voting response period, the method further includes: If the local address is inconsistent with the target address in the voting response message, and the node corresponding to the local address is a message forwarding node, then the voting response message is forwarded.
5. The time synchronization method based on node collaboration according to claim 1, characterized in that, Each node that receives the voting request message generates the voting response message based on the voting request message, including: Obtain the election cycle number from the voting request message; If the voting request message is the first voting request message received after the election cycle number is updated, the voting response message is generated.
6. The time synchronization method based on node collaboration according to claim 1, characterized in that, Determining the election status based on the number of votes includes: If the number of votes is greater than or equal to a first threshold, the election status indicates that the election was successful; If the number of votes is less than the first threshold, the election status indicates that the election has failed.
7. The time synchronization method based on node collaboration according to claim 1 or 6, characterized in that, When the election status indicates that the election was successful, the time synchronization operation is performed, including: If the election status indicates that the election was successful, the system switches to the clock source node status. Broadcast the local clock information to other nodes across the network.
8. A time synchronization device based on node collaboration, characterized in that, include: The generation unit is used to update the election cycle number and generate a voting request message based on the election cycle number and the local address if no time synchronization signal is received from the clock source node within a preset time synchronization cycle. A sending unit is used to send the voting request message through a message forwarding node; wherein the message forwarding node corresponding to each node is one of the multiple next-hop nodes of the node; The receiving unit is configured to receive voting response messages sent by other nodes within a preset voting response period, and determine the number of votes obtained within the preset voting response period; wherein, each node that receives the voting request message generates the voting response message based on the voting request message, and sends it through the corresponding message forwarding node; A determining unit is used to determine the election status based on the number of votes cast; The synchronization unit is used to perform time synchronization operations when the election status indicates that the election was successful.
9. An electronic device, characterized in that, It includes a processor and a memory, the memory storing a program or instructions that can run on the processor, the program or instructions being executed by the processor to implement the steps of the node-cooperative time synchronization method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions for causing a computer to perform the node-based time synchronization method as described in any one of claims 1 to 7.