Sensor network time synchronization method based on local bidirectional correction and related equipment
By dividing levels in the sensor network and electing reference nodes, using local two-way correction methods to reduce the communication range and synchronous hop count, the problem of large network overhead in traditional methods is solved, and efficient and robust time synchronization is achieved.
Patent Information
- Application Number
- CN202510496449.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-21
- Publication Date
- 2025-08-01
AI Technical Summary
The traditional sensor network time synchronization method relies on two-way communication, resulting in a large network overhead.
The time synchronization method of local two-way correction is adopted to divide the sensor network into multiple levels, and the time correction is performed by managing nodes to elect reference nodes and using bidirectional communication between reference nodes and non-reference nodes to reduce the communication range and synchronous hop count.
While achieving overall time synchronization of sensor networks, it reduces network overhead, improves the robustness and accuracy of time synchronization, and adapts to changes in network communication quality.
Smart Images

Figure CN120417007A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of sensor networks, and particularly to a sensor network time synchronization method and related devices based on local bidirectional correction. Background Art
[0002] The hybrid sensor topology network architecture of the distribution network is an intelligent network structure that combines wired and wireless sensing technologies, multi-protocol communication, and hierarchical data processing, aiming to achieve efficient monitoring, fault diagnosis, and intelligent control of the operation status of the distribution network. As the sensing layer, the sensor network is mainly used to collect the operation data of the distribution network (voltage, current, temperature, harmonics, equipment status, etc.) to the communication layer in real time. The communication layer realizes efficient and reliable data transmission from the sensing layer to the data layer. Finally, the data layer performs data aggregation, storage, analysis, and decision support, etc. The application layer drives the intelligent operation and maintenance of the distribution network based on the data analysis results.
[0003] Sensor network time synchronization is a key technology to ensure that all nodes in the network have a consistent time reference, which is particularly important in scenarios that require high-precision collaborative work (such as industrial control, environmental monitoring, and smart grid).
[0004] The traditional time synchronization method is based on the time-stamp protocol (TSP). By exchanging time stamps between nodes in both directions, the clock offset and propagation delay are calculated, and then the time is corrected and synchronized. However, this method relies on two-way communication and has a large network overhead.
[0005] In view of this, a sensor network time synchronization method and related devices based on local bidirectional correction are needed. Summary of the Invention
[0006] Aiming at the problem of large network overhead in two-way message time synchronization in the prior art, the present invention provides a sensor network time synchronization method and related devices based on local bidirectional correction, which can reduce the network overhead of two-way message time synchronization. The specific technical solutions are as follows:
[0007] In a first aspect, an embodiment of the present application provides a sensor network time synchronization method based on local bidirectional correction, which is applied to a sensor network. The sensor network includes a management node and ordinary nodes. The method includes:
[0008] The management node obtains the network topology of the sensor network; the management node divides the sensor network into N layers based on the network topology, where N is a positive integer greater than 1; the management node elects a reference node corresponding to each layer based on the energy, communication quality, and geographical location of the ordinary nodes in each layer; the reference node uses a two-way time synchronization correction mechanism to correct its own time through two-way communication between the reference nodes of adjacent layers; the non-reference nodes in the ordinary nodes use the two-way time synchronization correction mechanism to correct their own time through two-way communication between the reference nodes and non-reference nodes in the same layer.
[0009] Preferably, after the non-reference nodes in the ordinary nodes use the two-way time synchronization correction mechanism to correct their own time through two-way communication between the reference nodes and non-reference nodes in the same layer, it includes: the non-reference node obtains the time deviation between the reference node in the same layer and the non-reference node itself; the non-reference node calculates the clock drift rate based on the time deviation; the non-reference node adjusts its own local clock based on the clock drift rate.
[0010] Preferably, the management node elects a reference node corresponding to each layer based on the energy, communication quality, and geographical location of the ordinary nodes in each layer, including: the management node calculates the election score corresponding to the node by weighted calculation based on the energy, the communication quality, and the distance between the geographical location and the center of the corresponding layer; the management node elects the reference node based on the election score.
[0011] Preferably, the reference nodes of adjacent layers include an upper-layer reference node and a lower-layer reference node; the reference node uses a two-way time synchronization correction mechanism to correct its own time through two-way communication between the reference nodes of adjacent layers, including: the upper-layer reference node sends a first time synchronization message to the lower-layer reference node; the lower-layer reference node performs two-way timestamp exchange with the upper-layer reference node based on the first time synchronization message; the lower-layer reference node adjusts its own local clock based on the exchanged two-way timestamps.
[0012] Preferably, the non-reference nodes in the ordinary nodes adopt the bidirectional time synchronization correction mechanism, and perform time correction on the non-reference nodes themselves through bidirectional communication between the reference nodes and the non-reference nodes in the same layer, including: the reference node broadcasts a second time synchronization message to the non-reference nodes in the same layer; the non-reference node sends a synchronization request message to the corresponding reference node based on the second time synchronization message, and the synchronization request message includes the first time when the synchronization request message is sent; the reference node replies with a response message to the corresponding non-reference node based on the synchronization request message, and the response message includes the second time when the synchronization request message is received and the third time when the response message is sent; the non-reference node adjusts the local clock of the non-reference node itself based on the first time, the second time, the third time, and the fourth time when the response message is received.
[0013] Preferably, after electing the reference nodes in the corresponding layer, the method further includes: the management node periodically calculates the election scores of the reference nodes; in the case where the reference node fails or the election score is lower than a preset threshold, the management node re-elects the reference node.
[0014] Preferably, the management node divides the sensor network into N layers based on the network topology, including: the management node divides the sensor network into N concentric circular layers based on the network topology.
[0015] In a second aspect, an embodiment of the present application provides a sensor network, which is applied to the method described in the first aspect. The system includes a management node and ordinary nodes;
[0016] The management node is used to obtain the network topology of the sensor network;
[0017] The management node is further used to divide the sensor network into N layers based on the network topology, where N is a positive integer greater than 1;
[0018] The management node is further used to elect the reference nodes corresponding to each layer based on the energy, communication quality, and geographical location of the ordinary nodes in each layer;
[0019] The reference node is used to adopt the bidirectional time synchronization correction mechanism and perform time correction on the reference node itself through bidirectional communication between the reference nodes in adjacent layers;
[0020] The non-reference nodes in the ordinary nodes are used to adopt the bidirectional time synchronization correction mechanism and perform time correction on the non-reference nodes themselves through bidirectional communication between the reference nodes and the non-reference nodes in the same layer.
[0021] In a third aspect, an embodiment of the present application provides a computing device, including: a memory for storing a program; and a processor for loading the program to execute the method described in the first aspect.
[0022] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, which includes a stored program. When the program runs, it controls the device where the computer-readable storage medium is located to execute the method described in the first aspect.
[0023] Compared with the prior art, the beneficial effects of the present invention are as follows: reducing the communication range through local bidirectional correction and reducing the synchronization hop count through hierarchical division of the topological structure, thereby reducing the network overhead while achieving the overall time synchronization of the sensor network; by dynamically electing a reference node, it can adapt to changes in network communication quality, improving the robustness of the time synchronization method while ensuring the accuracy of time synchronization. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] In order to more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the following will briefly introduce the drawings required for the description of the specific embodiments or the prior art. In all the drawings, similar elements or parts are generally identified by similar reference numerals. In the drawings, the elements or parts are not necessarily drawn to scale.
[0025] Figure 1 It is a schematic flowchart of a time synchronization method for a sensor network based on local bidirectional correction provided by an embodiment of the present application;
[0026] Figure 2 It is a schematic diagram of the network topology of a sensor network provided by an embodiment of the present application;
[0027] Figure 3 It is a schematic diagram of the structure of a sensor network provided by an embodiment of the present application;
[0028] Figure 4 It is a schematic diagram of the structure of a computing device provided by an embodiment of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0029] The following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the drawings in the embodiments of the present invention. Obviously, the described embodiments are some, but not all, of the embodiments of the present invention. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.
[0030] It should be understood that when used in this specification and the appended claims, the terms "comprising" and "including" indicate the presence of the described features, wholes, steps, operations, elements, and / or components, but do not preclude the presence or addition of one or more other features, wholes, steps, operations, elements, components, and / or their combinations.
[0031] It should also be understood that the terms used in the specification of the present invention are merely for the purpose of describing specific embodiments and are not intended to limit the present invention. As used in the specification of the present invention and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an", and "the" are intended to include the plural forms.
[0032] It should be further understood that the term "and / or" used in the specification of the present invention and the appended claims refers to any combination and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0033] To solve the problem of large network overhead in the traditional two-way message time synchronization method, the present invention provides a sensor network time synchronization method and related devices based on local two-way correction, which can reduce the network overhead of two-way message time synchronization.
[0034] Please refer to Figure 1 , Figure 1 which is a schematic flow diagram of a sensor network time synchronization method based on local two-way correction provided by an embodiment of this application. This method is applied to a sensor network, and the sensor network includes a management node and ordinary nodes; as Figure 1 shown, the method includes:
[0035] Step 101, the management node obtains the network topology of the sensor network.
[0036] A sensor network is a wireless network formed by a large number of sensor nodes with wireless communication and computing capabilities deployed in the working area through self-organization. Its purpose is to collaboratively sense, collect, and process information about the sensed objects in the network coverage area and send it to the observer. When the sensor network is applied to the power field, the sensor network is used to collect real-time operation data of the distribution network to the communication layer, and the communication layer realizes efficient and reliable data transmission from the sensing layer to the data layer. Finally, the data layer performs data aggregation, storage, analysis, and decision support, etc., and the application layer drives the intelligent operation and maintenance of the distribution network based on the data analysis results.
[0037] Among them, the sensor network includes a management node for data processing and analysis, and ordinary nodes for collecting power grid operation data.
[0038] Specifically, the management node can be a server, a personal computer, a smart terminal, or other computing devices with data processing capabilities; the ordinary node is the basic component unit in the sensor network and is usually composed of parts such as a sensor module, a processor module, a wireless communication module, and a power module.
[0039] The sensor network topology refers to the distribution of each node in the sensor network and the connection relationship between them. It can be understood that the sensor network can be any one of a star topology, a mesh topology, a tree topology, or a cluster topology; based on different topology types, there can be one or more management nodes in the sensor network, and the connection relationship between the management node and the ordinary nodes will also change accordingly.
[0040] Among them, the management node can obtain the real-time connection status of each node in the sensor network and generate the network topology of the sensor network based on the connection status, node attributes, and parameters of the node; it can also obtain the network topology from a storage device pre-storing the network topology through wired or wireless communication methods.
[0041] Step 102: The management node divides the sensor network into N layers based on the network topology.
[0042] Among them, N is a positive integer greater than 1.
[0043] Among them, the management node can divide the sensor network area into N layers according to the geographical location information of each ordinary node in the network topology, and each layer covers a certain geographical range.
[0044] Preferably, the management node divides the sensor network into N concentric circular layers or N polygon circular layers based on the geographical location information of each ordinary node in the network topology.
[0045] Among them, the closer the geographical location of an ordinary node is to the center of the circle, the higher the layer it belongs to.
[0046] Step 103: The management node elects a reference node corresponding to each layer from the ordinary nodes based on the energy, communication quality, and geographical location of the ordinary nodes in each layer.
[0047] Among them, the energy of a node refers to the remaining energy of the node. In the communication field, the remaining energy of a node refers to the available power remaining in a node device (such as a sensor node) in a communication system such as a wireless sensor network.
[0048] The remaining energy is an important indicator to measure the ability of a node to continue working. It directly affects the survival time of the node, as well as the performance and lifespan of the entire network. When the remaining energy of a node is low, it may lead to a reduction in its communication range, a decrease in data transmission frequency, and even the inability to work properly due to energy exhaustion, thereby affecting the integrity and reliability of data collection and transmission in the entire network.
[0049] Among them, the management node can complete the election of the reference node based on the following steps.
[0050] 1) Receive the remaining energy measured by each node in each layer regularly and use it as one of the election parameters; nodes with higher energy have higher weights in the election.
[0051] 2) Receive the communication quality (such as signal strength, packet loss rate, etc.) measured by each node in each layer with its neighbor nodes and use it as one of the election parameters; nodes with higher communication quality have higher weights in the election.
[0052] 3) Obtain the geographical location information of each node and calculate the distance between each node and its corresponding layer center; nodes closer to the layer center have higher weights in the election. Among them, the layer center is the center of the geometric figure obtained by fitting the geographical locations of the nodes in this layer.
[0053] 4) Based on the preset corresponding weight coefficients of energy, communication quality, and distance from the layer center, calculate the election score of each node by weighted calculation; among the nodes in the same layer, the node with the highest score is selected as the reference node.
[0054] Preferably, the management node periodically calculates the election score of the reference node; in the case where the reference node fails or the election score is lower than the preset threshold, the management node can re-elect the reference node.
[0055] Specifically, the management node can regularly evaluate the energy and clock stability of the reference node; if the reference node fails or its performance deteriorates, a re-election is initiated to select a new reference node.
[0056] It can be understood that this election process can also be initiated by neighboring nodes. When a non-reference node discovers that the reference node has failed during communication with the reference node, the non-reference node can initiate a new election to the management node or all non-reference nodes in the same layer.
[0057] The new reference node inherits the time information of the upper-layer reference node and continues the synchronization process.
[0058] The above method for electing the reference node comprehensively considers multiple factors including geographical location information, improving the reliability of the reference node and the overall performance of the network.
[0059] It is understandable that the management node can also adopt other methods to select reference nodes based on the three types of information; for example, sort the energy, communication quality and distance from the center of the hierarchy of each node in the same level; and then select the node with the smallest combined ranking ordinal number among the three nodes in the same level as the reference node.
[0060] Step 104: The reference node adopts a two-way time synchronization correction mechanism to perform time correction on the reference node itself through two-way communication between reference nodes at adjacent levels.
[0061] The top-level reference node can first synchronize time with a common node with a high-precision clock source; alternatively, the top-level reference node can be the common node with a high-precision clock source. Specifically, the node with a high-precision clock source can be a common node including a GPS receiver or a high-precision quartz clock.
[0062] In this way, the time accuracy of the top-level reference node is high and it can serve as the starting point and reference standard for time synchronization of the entire sensor network.
[0063] Then, time synchronization is performed between layers, starting from the upper reference node and then layer by layer downward; after all reference nodes in the sensor network are synchronized, time synchronization is performed within the same layer to achieve time synchronization of the entire sensor network.
[0064] Preferably, the reference nodes of the adjacent layer include an upper reference node and a lower reference node; the upper reference node broadcasts a first time synchronization message to the lower reference node; the lower reference node performs a two-way timestamp exchange with the upper reference node based on the first time synchronization message; the lower reference node adjusts its own local clock based on the exchanged two-way timestamp.
[0065] The specific implementation process of time synchronization through bidirectional communication based on the bidirectional time synchronization correction mechanism is described in step 105 below and will not be repeated here.
[0066] Step 105: The non-reference nodes among the common nodes adopt a two-way time synchronization correction mechanism to perform time correction on the non-reference nodes themselves through two-way communication between the reference nodes and the non-reference nodes in the same layer.
[0067] Among them, after the reference node is elected, the other nodes in a layer except the reference node are non-reference nodes.
[0068] After the reference node completes time synchronization with the upper-layer reference node, the latest accurate time can be synchronized to the non-reference nodes at the same level.
[0069] Preferably, the reference node broadcasts a second time synchronization message to non-reference nodes in the same layer; the non-reference node sends a synchronization request message to the corresponding reference node based on the second time synchronization message, and the synchronization response message includes the first time when the synchronization request message is sent; the reference node replies with a response message to the corresponding non-reference node based on the synchronization request message, and the response message includes the second time when the synchronization request message is received and the third time when the response message is sent; the non-reference node adjusts its own local clock based on the first time, the second time, the third time, and the fourth time when the response message is received.
[0070] The message exchange process for bidirectional communication between a non-reference node and a reference node is as follows:
[0071] 1) Synchronization request phase:
[0072] After receiving the second time synchronization message, the non-reference node sends a synchronization request message (including T1) to the reference node at the first time T1; the reference node receives the synchronization request message at the second time T2.
[0073] 2) Synchronization response phase:
[0074] The reference node sends a response message (including T2 and T3) to the non-reference node at the third time T3; the non-reference node receives the response message at the fourth time T4.
[0075] It can be assumed that the clock deviation of the non-reference node relative to the reference node's clock is Δ (i.e., non-reference node time = reference node time + Δ); the propagation delay (one-way) is D; the two-way path is symmetric (i.e., the request and response path delays are the same).
[0076] 3) Calculate the clock deviation Δ
[0077] ① The propagation time of the synchronization request message from the non-reference node to the reference node is: T2 = T1 + Δ + D;
[0078] ② The propagation time of the response message from the reference node to the non-reference node: T4 = T3 - Δ + D;
[0079] Solve the simultaneous equations for Δ and D:
[0080]
[0081] Then, the non-reference node can adjust its local clock according to the calculated clock deviation Δ to align with the reference node's clock.
[0082] 4) Direct offset correction:
[0083] If Δ > 0, it indicates that the clock of this non-reference node is faster than the reference clock by Δ, and the local clock needs to be decelerated.
[0084] If Δ < 0, it indicates that the clock of this non-reference node is slower than the reference clock by |Δ|, and the local clock needs to be accelerated.
[0085] The adjustment formula is: T adjusted = T local - Δ,
[0086] where, T adjusted represents the adjusted clock, and T local represents the local clock.
[0087] If long-term suppression of clock drift is required, the non-reference node can calculate the clock frequency deviation (such as how many microseconds faster / slower per second), and then fit a linear regression model through multiple measurements of Δ to dynamically adjust the local clock frequency.
[0088] Preferably, the non-reference node can obtain the time deviation between the reference node at the same level and itself, then calculate the clock drift rate corresponding to this non-reference node based on this time deviation, and then adjust the local clock of this non-reference node based on this clock drift rate.
[0089] Preferably, the non-reference node can set a reasonable clock drift correction period according to the network environment and clock stability.
[0090] By dynamically correcting clock drift, the accuracy and robustness of time synchronization in the sensor network can be effectively improved to adapt to the dynamic changes of the network.
[0091] In the embodiments of the present application, the communication range is reduced through local two-way correction, and the synchronization hop count is reduced through hierarchical division of the topological structure, thereby reducing the network overhead while achieving the overall time synchronization of the sensor network: through dynamic election of the reference node and clock drift correction, the change of network communication quality can be adapted, and the robustness of the time synchronization method can be improved while ensuring the accuracy of time synchronization.
[0092] The following gives an example to illustrate the implementation process of this method.
[0093] Please refer to Figure 2 , Figure 2 which is a topological diagram of a sensor network provided by the embodiments of the present application; as Figure 2 shown, within a square area of 100m × 100m, 100 nodes are randomly distributed, and the wireless communication radius of each node is 20m.
[0094] First, consider the way of expanding from the center outwards, and divide these 100 nodes into 5 levels, and the coverage range of each level is as follows (assuming that the levels are divided by concentric circles):
[0095] Layer 1: Central area (0m-20m), reference node R1 (indicated by ★).
[0096] Layer 2: 20m-40m ring area, reference node R2.
[0097] Layer 3: 40m-60m ring area, reference node R3.
[0098] Layer 4: 60m-80m ring area, reference node R4.
[0099] Layer 5: 80m-100m ring area, reference node R5.
[0100] The central position (or the node with the highest energy) of each level is selected as the reference node:
[0101] R1: Located at the center of coordinates (50m,50m).
[0102] R2~R5: distributed at the center of their respective levels (such as distributed along the diagonal).
[0103] If a reference node (such as R3) fails, the nodes in its layer will re-elect a new reference node. The new reference node inherits the time information of the upper layer reference node and continues the synchronization process.
[0104] During intra-layer communication, each standard node (·) synchronizes with its corresponding reference node (★) through bidirectional message exchange. During inter-layer communication, a higher-layer reference node (e.g., R1) synchronizes with lower-layer reference nodes (R2-R5) via multi-hop communication. Layers synchronize with each other through reference nodes (e.g., R1 → R2 → R3 → R4 → R5). Reference nodes at each layer first synchronize with the upper-layer reference node before broadcasting this information to nodes in their own layer.
[0105] The timestamps for a two-way message exchange are: T1 = 1000 μs, T2 = 1012 μs (reference node time), T3 = 1020 μs (reference node time), T4 = 1035 μs. The calculated clock deviation Δ = 13.5 μs, the calculated propagation delay D = 1.5 μs, all subsequent local times need to subtract Δ: T adjusted =T local -13.5μs.
[0106] The following simulation experiment compares the time synchronization methods based on the flooding time synchronization protocol (FTSP) and IEEE 1588PTP.
[0107] 1. Experimental environment
[0108] Simulation platform: OMNeT++ or NS-3.
[0109] Number of nodes: 100 nodes.
[0110] Communication range: 20m.
[0111] Clock drift rate: ±10ppm (typical value).
[0112] 2. Performance metrics
[0113] Synchronization accuracy: The average value and standard deviation of the time deviation between nodes.
[0114] Communication overhead: The number of messages sent during the synchronization process.
[0115] Energy consumption: The energy consumption of nodes during the synchronization process.
[0116] Robustness: The synchronization recovery time after the failure of the reference node.
[0117] 3. Experimental results
[0118] The experimental results are shown in the following table.
[0119]
[0120] 4. Analysis of experimental data
[0121] As can be seen from the results in Table 2, this method achieves high synchronization accuracy through local two-way correction and clock drift compensation. This method significantly reduces the communication overhead through a hierarchical structure and local two-way correction. This method reduces the energy consumption through dynamic reference node election and lightweight implementation. This method improves the robustness through dynamic reference node election and failure handling.
[0122] Through a hierarchical structure, local two-way correction, and dynamic reference node election, this method achieves high-precision, low-overhead, and strong-robustness time synchronization. The experimental data shows that the method in this embodiment is superior to existing methods (such as FTSP and IEEE 1588PTP) in terms of synchronization accuracy, communication overhead, energy consumption, and robustness.
[0123] The method part provided by the embodiments of this application has been described above. The system part provided by the embodiments of this application will be described below.
[0124] Please refer to Figure 3 , Figure 3 which is a schematic structural diagram of a sensor network provided by the embodiments of this application. As Figure 3 shown, the sensor network 20 includes a management node 21 and ordinary nodes 22;
[0125] The management node 21 is used to obtain the network topology of the sensor network 20;
[0126] The management node 21 is further used to divide the sensor network 20 into N levels based on the network topology, where N is a positive integer greater than 1;
[0127] The management node 21 is further used to elect a reference node 221 in each level based on the energy, communication quality, and geographical location of the ordinary nodes 22 in each level;
[0128] The reference node 221 is used to adopt a two-way time synchronization correction mechanism to correct its own time through two-way communication between adjacent reference nodes 221 in the same level;
[0129] The non-reference node 222 in the ordinary node 22 is used to adopt the two-way time synchronization correction mechanism to correct its own time through two-way communication between the reference node 221 and the non-reference node 222 in the same level.
[0130] Preferably, the non-reference node 222 is further used to obtain the time deviation between the reference node in the same level and itself; calculate the clock drift rate corresponding to the non-reference node based on the time deviation; and adjust the local clock of the non-reference node 222 based on the clock drift rate.
[0131] Preferably, the management node 21 is specifically used to calculate the election score corresponding to the node by weighted calculation based on the energy, the communication quality, and the distance from the geographical location to the center of the corresponding level; and the management node elects the reference node based on the election score.
[0132] Preferably, the adjacent reference nodes 221 in the same level include an upper-layer reference node and a lower-layer reference node; the upper-layer reference node broadcasts a first time synchronization message to the lower-layer reference node; the lower-layer reference node performs two-way timestamp exchange with the upper-layer reference node based on the first time synchronization message; and the lower-layer reference node adjusts its own local clock based on the exchanged two-way timestamps.
[0133] Preferably, the reference node 221 broadcasts a second time synchronization message to non-reference nodes 222 at the same level; the non-reference nodes 222 send synchronization request messages to the corresponding reference node 221 based on the second time synchronization message, and the synchronization request messages include the first time when the synchronization request messages are sent; the reference node 221 replies with response messages to the corresponding non-reference nodes 222 based on the synchronization request messages, and the response messages include the second time when the synchronization request messages are received and the third time when the response messages are sent; the non-reference nodes 222 adjust their own local clocks based on the first time, the second time, the third time, and the fourth time when the response messages are received.
[0134] Preferably, the management node 21 is further configured to periodically calculate the election scores of the reference nodes 221; in the case where a reference node fails or the election score is lower than a preset threshold, the management node 21 re-elects the reference node 221.
[0135] Preferably, the management node 21 is specifically configured to divide the sensor network into N concentric rings based on the network topology.
[0136] The sensor network provided by the embodiments of the present application can be understood by referring to the corresponding content in the foregoing method embodiment section, and will not be repeated here.
[0137] As Figure 4 shown, Figure 4 FIG. is a possible logical structure diagram of a computing device provided by an embodiment of the present application. The computing device 400 includes: a processor 401, a communication interface 402, a memory 403, and a bus 404. The processor 401, the communication interface 402, and the memory 403 are interconnected through the bus 404. In the embodiments of the present application, the processor 401 is used to control and manage the actions of the computing device 400. For example, the processor 401 is used to execute Figure 1 the steps in the embodiments and / or other processes for the technologies described herein. The communication interface 402 is used to support the computing device 400 to communicate. The memory 403 is used to store the program code and data of the computing device 400.
[0138] Among them, the processor 401 can be a central processing unit, a general-purpose processor, a digital signal processor, an application-specific integrated circuit, a field-programmable gate array or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. It can implement or execute various exemplary logic blocks, modules, and circuits described in connection with the disclosure of this application. The processor can also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a digital signal processor and a microprocessor, and so on. The bus 404 can be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 4 only a thick line is shown in Figure 4 , but it does not mean that there is only one bus or one type of bus.
[0139] In another embodiment of the present application, a computer-readable storage medium is also provided. The computer-readable storage medium includes instructions that, when run on a computer, cause the computer to execute the above Figure 1 method described in the embodiment.
[0140] Those of ordinary skill in the art can realize that the units of each example described in connection with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. To clearly illustrate the interchangeability of hardware and software, the components of each example have been generally described according to their functions in the above description. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. A professional technician can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the present invention.
[0141] Those skilled in the art can clearly understand that for the convenience and brevity of description, the specific working processes of the systems, devices, and units described above can refer to the corresponding processes in the foregoing method embodiments and will not be elaborated herein.
[0142] In several embodiments provided by the embodiments of the present application, it should be understood that the disclosed systems, devices, and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of the units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed couplings or direct couplings or communication connections to each other can be through some interfaces. The indirect couplings or communication connections of the devices or units can be in electrical, mechanical, or other forms.
[0143] The units described as separate components may or may not be physically separated. The components displayed as units may or may not be physical units, that is, they can be located in one place, or they can be distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0144] In addition, each functional unit in various embodiments of the present invention can be integrated in a processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit. The above-mentioned integrated units can be implemented in the form of hardware or in the form of software functional units.
[0145] If the above functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of the present invention. The foregoing storage medium includes: USB flash drives, read-only memories (ROMs), random access memories (RAMs), mobile hard disks, magnetic disks, or optical discs and other various media that can store program codes.
[0146] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements on some or all of the technical features; and these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the various embodiments of the present invention, and they should all be covered by the scope of the claims and the description of the present invention.
Claims
1. A time synchronization method for sensor networks based on local bidirectional correction, characterized in that Applied to a sensor network, the sensor network including a management node and ordinary nodes; the method includes: The management node obtains the network topology of the sensor network; The management node divides the sensor network into N levels based on the network topology, where N is a positive integer greater than 1; The management node elects a reference node corresponding to each level based on the energy, communication quality, and geographical location of the ordinary nodes in each level; The reference node adopts a two-way time synchronization correction mechanism to correct its own time through two-way communication between the reference nodes of adjacent levels; The non-reference nodes among the ordinary nodes adopt the two-way time synchronization correction mechanism to correct their own time through two-way communication between the reference nodes and non-reference nodes in the same level; 2. The method according to claim 1, wherein After the non-reference nodes among the ordinary nodes adopt the two-way time synchronization correction mechanism to correct their own time through two-way communication between the reference nodes and non-reference nodes in the same level, it includes: The non-reference node obtains the time deviation between the reference node in the same level and the non-reference node itself; The non-reference node calculates the clock drift rate based on the time deviation; The non-reference node adjusts its own local clock based on the clock drift rate; 3. The method according to claim 1, characterized in that, The management node elects a reference node corresponding to each level based on the energy, communication quality, and geographical location of the ordinary nodes in each level, including: The management node calculates the election score corresponding to the node by weighted calculation based on the energy, the communication quality, and the distance between the geographical location and the center of the corresponding level; The management node elects the reference node based on the election score; 4. The method according to claim 1, wherein The reference nodes of adjacent levels include an upper-layer reference node and a lower-layer reference node; the reference node adopts a two-way time synchronization correction mechanism to correct its own time through two-way communication between the reference nodes of adjacent levels, including: The upper-layer reference node sends a first time synchronization message to the lower-layer reference node; The lower-layer reference node performs two-way timestamp exchange with the upper-layer reference node based on the first time synchronization message; The lower-layer reference node adjusts its own local clock based on the exchanged two-way timestamps; 5. The method according to claim 1, characterized in that, The non-reference nodes among the ordinary nodes adopt the two-way time synchronization correction mechanism to correct their own time through two-way communication between the reference nodes and non-reference nodes in the same level, including: The reference node broadcasts a second time synchronization message to the non-reference nodes in the same level; The non-reference node sends a synchronization request message to the corresponding reference node based on the second time synchronization message, and the synchronization request message includes the first time when the synchronization request message is sent; The reference node replies a response message to the corresponding non-reference node based on the synchronization request message, and the response message includes a second time when the synchronization request message is received and a third time when the response message is sent; The non-reference node adjusts its own local clock based on the first time, the second time, the third time, and a fourth time when the response message is received.
6. The method according to claim 3, wherein After electing the reference node in the corresponding layer, the method further includes: The management node periodically calculates the election score of the reference node; When the reference node fails or the election score is lower than a preset threshold, the management node re-elects the reference node.
7. The method according to claim 1, wherein The management node divides the sensor network into N layers based on the network topology, including: The management node divides the sensor network into N concentric circular layers based on the network topology.
8. A sensor network, characterized in that, Applied to the method according to any one of claims 1-7, the sensor network includes a management node and ordinary nodes; The management node is configured to obtain the network topology of the sensor network; The management node is further configured to divide the sensor network into N layers based on the network topology, where N is a positive integer greater than 1; The management node is further configured to elect a reference node corresponding to each layer based on the energy, communication quality, and geographical location of the ordinary nodes in each layer; The reference node is configured to adopt a two-way time synchronization correction mechanism to correct its own time through two-way communication between the reference nodes of adjacent layers; The non-reference node among the ordinary nodes is configured to adopt the two-way time synchronization correction mechanism to correct its own time through two-way communication between the reference node and the non-reference node in the same layer.
9. A computing device, characterized in that, including: A memory for storing programs; A processor for loading the program to execute the method according to any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored program, wherein when the program runs, it controls the device where the computer-readable storage medium is located to execute the method according to any one of claims 1-7.