Time synchronization optimization method and system based on nearest K neighbor network topology
By clustering and topology reconstruction of wireless sensor networks and selecting appropriate reference and neighboring nodes for time synchronization, the problem of insufficient time synchronization accuracy in wireless sensor networks is solved, energy consumption is reduced, and network connectivity is improved.
Patent Information
- Application Number
- CN202511475129.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-15
- Publication Date
- 2026-02-13
AI Technical Summary
Existing wireless sensor networks suffer from insufficient accuracy in time synchronization, especially when node failures lead to broken time synchronization links and increased communication energy consumption.
A time synchronization optimization method based on the nearest K-neighbor network topology is adopted. The network topology is reconstructed by clustering the network nodes to be synchronized, and time synchronization is performed by using the intra-group communication rules and energy information of the K-neighbors. Reference and neighboring network nodes are selected for synchronization.
It improves the accuracy of network node time synchronization, reduces energy consumption, and enhances network connectivity and redundant connection management.
Smart Images

Figure CN121531445A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of network communication technology, specifically to a time synchronization optimization method and system based on the nearest K neighbor network topology. Background Technology
[0002] In recent years, the Industrial Internet of Things (IIoT) has developed rapidly. Traditional wired sensor networks, due to limitations such as complex wiring and poor scalability, can no longer meet the needs of industrial production for flexible equipment deployment, real-time monitoring, and efficient management. Wireless sensor networks have emerged to address this need. They possess self-organizing characteristics, allowing nodes to automatically discover and connect to the network without complex manual configuration; they offer low power consumption, significantly extending the lifespan of battery-powered equipment and reducing maintenance costs; and they support the access of various types of sensors, flexibly adapting to different industrial application scenarios.
[0003] However, wireless sensor networks face numerous challenges in practical applications, among which ensuring accurate time synchronization between sensor nodes is crucial. The accuracy of time synchronization directly affects the consistency of data acquisition, the timeliness of event monitoring, and the coordination of network communication. The network topology, as the architectural foundation of wireless sensor networks, is closely linked to the effectiveness of time synchronization.
[0004] Existing network topology time synchronization methods typically employ simple structured network topologies (such as chain or tree topologies) and transmit synchronization messages via fixed links to achieve time synchronization between nodes within the network topology. These methods often utilize TPSN (Time Synchronization Protocol) or RBS (Reference Broadcast Synchronization) to achieve time synchronization between nodes within the topology. However, because existing solutions use simple structured network topologies and transmit synchronization messages via fixed links, the failure of a node within the topology leads to the breakdown of the entire time synchronization link. Furthermore, the TPSN and RBS algorithms used in existing technologies rely on global or hierarchical broadcast synchronization messages, requiring nodes to receive a large amount of unnecessary synchronization information (such as RBS reference broadcasts and TPSN hierarchical forwarding). Communication overhead increases exponentially with the number of nodes, resulting in an exponential increase in energy consumption during time synchronization of the entire topology. Consequently, the accuracy of time synchronization between network nodes within the network topology is insufficient. Summary of the Invention
[0005] This application provides a time synchronization optimization method based on the nearest K-neighbor network topology, which can improve the accuracy of time synchronization of network nodes in the set of network nodes to be synchronized.
[0006] A first aspect of this application provides a time synchronization optimization method based on the nearest K-neighbor network topology, the method comprising: Cluster the network nodes to be synchronized in the set of network nodes to be synchronized to obtain S sets of first network nodes; Based on the intra-group communication rules of K neighbors, the original network topology of the first network nodes in the S sets of first network nodes is reconstructed to obtain the first network topology; The time of the first network node in the first network topology is synchronized to obtain the target network topology.
[0007] In this example, by clustering the network nodes to be synchronized in the set of network nodes to be synchronized, S sets of first network nodes are obtained. The original network topology of the first network nodes in the S sets of first network nodes is reconstructed according to the intra-group communication rules of K neighboring nodes to obtain the first network topology. The first network nodes in the first network topology are synchronized in time to obtain the target network topology, which improves the accuracy of time synchronization of the network nodes to be synchronized in the set of network nodes to be synchronized.
[0008] In one possible implementation, a method for clustering the network nodes to be synchronized in a set of network nodes to obtain S first sets of network nodes includes: Based on the coordinate position information of the network nodes to be synchronized in the set of network nodes to be synchronized, the distance between each network node to be synchronized in the set of network nodes to be synchronized is calculated to obtain a first distance set; Based on the first distance in the first distance set, the network nodes to be synchronized in the set of network nodes to be synchronized are clustered to obtain S sets of first network nodes.
[0009] In one possible implementation, a method for reconstructing the original network topology of the first network nodes in a set of S first network nodes according to the intra-group communication rules of K neighboring nodes, to obtain the first network topology, includes: Based on the original network topology of the first network node in the S sets of first network nodes, determine the number of edges corresponding to the connection between the first network node in the S sets of first network nodes and other first network nodes, and obtain the first quantity information; Based on the first quantity information, determine the maximum number of connected nodes allowed for the first network node in the S sets of first network nodes when making network connections, and obtain the first restriction information; Based on the K-nearest neighbor intra-group communication rules, the original network topology of the first network nodes in the S first network node sets is reconstructed according to the first restriction information and the first distance in the first distance set, to obtain the first network topology.
[0010] In one possible implementation, a method for synchronizing the time of a first network node in the first network topology to obtain a target network topology includes: Extract the energy consumption information of each first network node in the first network topology during reception and transmission, calculate the remaining energy information corresponding to each first network node in the first network topology, and obtain the first set of remaining energy information; Based on the first remaining energy information in the first remaining energy information set, the reference network node in each of the S first network node sets is determined to obtain the reference network node set; Based on the reference network nodes in the reference network node set, the neighboring network nodes in each of the S first network node sets are determined, thus obtaining the S neighboring network node sets. The first network topology is synchronized in time based on the reference network nodes in the reference network node set and the neighboring network nodes in the neighboring network node set to obtain the target network topology.
[0011] In one possible implementation, a method for time-synchronizing a first network topology based on reference network nodes in the reference network node set and neighboring network nodes in the neighboring network node set to obtain a target network topology includes: Randomly select a reference network node from the set of reference network nodes to obtain the target reference network node; From the S sets of first network nodes, the set of first network nodes corresponding to the target reference network node is determined, and the set of second network nodes is obtained. Extract the network nodes common to the neighboring network nodes in the second network node set and the S neighboring network node sets to obtain the target neighboring network node set; Based on the local timestamp corresponding to the target reference network node, the second network nodes in the second network node set are synchronized within the group to obtain the third network node set. The target network topology is obtained by globally synchronizing the first network node in the first network topology with the third network node in the third network node set and the target neighbor network nodes in the target neighbor network node set.
[0012] A second aspect of this application provides a time synchronization optimization system based on a nearest K-neighbor network topology, the system comprising: Clustering unit is used to cluster the network nodes to be synchronized in the set of network nodes to be synchronized, and obtain S sets of first network nodes; The reconstruction unit is used to reconstruct the original network topology of the first network nodes in the set of S first network nodes according to the intra-group communication rules of K neighbors, so as to obtain the first network topology. The synchronization unit is used to synchronize the time of the first network nodes in the first network topology to obtain the target network topology.
[0013] In one possible implementation, the clustering unit is specifically used for: Based on the coordinate position information of the network nodes to be synchronized in the set of network nodes to be synchronized, the distance between each network node to be synchronized in the set of network nodes to be synchronized is calculated to obtain a first distance set; Based on the first distance in the first distance set, the network nodes to be synchronized in the set of network nodes to be synchronized are clustered to obtain S sets of first network nodes.
[0014] In one possible implementation, the reconfiguration unit is specifically used for: Based on the original network topology of the first network node in the S sets of first network nodes, determine the number of edges corresponding to the connection between the first network node in the S sets of first network nodes and other first network nodes, and obtain the first quantity information; Based on the first quantity information, determine the maximum number of connected nodes allowed for the first network node in the S sets of first network nodes when making network connections, and obtain the first restriction information; Based on the K-nearest neighbor intra-group communication rules, the original network topology of the first network nodes in the S first network node sets is reconstructed according to the first restriction information and the first distance in the first distance set, to obtain the first network topology.
[0015] In one possible implementation, the synchronization unit is specifically used for: Extract the energy consumption information of each first network node in the first network topology during reception and transmission, calculate the remaining energy information corresponding to each first network node in the first network topology, and obtain the first set of remaining energy information; Based on the first remaining energy information in the first remaining energy information set, the reference network node in each of the S first network node sets is determined to obtain the reference network node set; Based on the reference network nodes in the reference network node set, the neighboring network nodes in each of the S first network node sets are determined, thus obtaining the S neighboring network node sets. The first network topology is synchronized in time based on the reference network nodes in the reference network node set and the neighboring network nodes in the neighboring network node set to obtain the target network topology.
[0016] In one possible implementation, regarding the time synchronization of the first network topology based on the reference network nodes in the reference network node set and the neighboring network nodes in the neighboring network node set to obtain the target network topology, the synchronization unit is specifically used for: Randomly select a reference network node from the set of reference network nodes to obtain the target reference network node; From the S sets of first network nodes, the set of first network nodes corresponding to the target reference network node is determined, and the set of second network nodes is obtained. Extract the network nodes common to the neighboring network nodes in the second network node set and the S neighboring network node sets to obtain the target neighboring network node set; Based on the local timestamp corresponding to the target reference network node, the second network nodes in the second network node set are synchronized within the group to obtain the third network node set. The target network topology is obtained by globally synchronizing the first network node in the first network topology with the third network node in the third network node set and the target neighbor network nodes in the target neighbor network node set.
[0017] A third aspect of this application provides a terminal including a processor, an input device, an output device, and a memory, wherein the processor, input device, output device, and memory are interconnected, wherein the memory is used to store a computer program, the computer program including program instructions, and the processor is configured to invoke the program instructions to execute the step instructions as described in the first aspect of this application.
[0018] A fourth aspect of this application provides a computer-readable storage medium storing a computer program for electronic data interchange, wherein the computer program causes a computer to perform some or all of the steps described in the first aspect of this application.
[0019] A fifth aspect of this application provides a computer program product, wherein the computer program product includes a non-transitory computer-readable storage medium storing a computer program operable to cause a computer to perform some or all of the steps described in the first aspect of this application. The computer program product may be a software installation package. Attached Figure Description
[0020] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0021] Figure 1 This application provides a comparison diagram of the offset drift compensation order for a time synchronization optimization method based on the nearest K-neighbor network topology. Figure 2 This application provides schematic diagrams illustrating the failure of communication topology nodes with different structures for embodiments of the present application; Figure 3 This application provides a comparison chart of energy consumption for a time synchronization optimization method based on nearest K neighbor network topology; Figure 4 This application provides a flowchart illustrating a time synchronization optimization method based on the nearest K-neighbor network topology. Figure 5 This is a schematic diagram of the structure of a terminal provided in an embodiment of this application; Figure 6 This application provides a schematic diagram of the structure of a time synchronization optimization system based on the nearest K-neighbor network topology. Detailed Implementation
[0022] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0023] The terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish different objects, not to describe a specific order. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or apparatus that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to these processes, methods, products, or apparatuses.
[0024] In this application, the reference to "embodiment" means that a specific feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a mutually exclusive, independent, or alternative embodiment. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described in this application can be combined with other embodiments.
[0025] Please see Figure 1 , Figure 1 This application provides a comparison diagram of the offset drift compensation order in a time synchronization optimization method based on the nearest K-neighbor network topology. The left diagram shows that drift compensation is performed first to adjust the clock rate, followed by offset compensation to adjust the phase, ultimately achieving time synchronization. The right diagram shows that after offset compensation, instantaneous synchronization is achieved, but due to drift, a deviation from the reference clock still occurs, requiring further offset compensation after drift compensation. Therefore, this application adopts a method of estimating drift compensation first and then estimating offset compensation.
[0026] To better understand the time synchronization optimization method based on nearest K neighbor network topology provided in this application, a brief introduction to existing network topology time synchronization methods is given below. Please refer to... Figure 2 and Figure 3 , Figure 2 This application provides a schematic diagram of communication topology node failure with different structures as an embodiment. Figure 3 This application provides a comparative diagram of energy consumption for a time synchronization optimization method based on the nearest K-neighbor network topology. Existing solutions employ simple structured network topologies (such as Chain or Tree topologies) and transmit synchronization messages via fixed links to achieve time synchronization between nodes. Methods such as TPSN (Time Synchronization Protocol) and RBS (Reference Broadcast Synchronization) are commonly used for this purpose. However, because existing solutions use simple structured network topologies and transmit synchronization messages via fixed links, the failure of a node in the topology leads to a break in the time synchronization links throughout the entire topology. Furthermore, the TPSN and RBS algorithms used in existing technologies rely on global or hierarchical broadcast synchronization messages, requiring nodes to receive a large amount of unnecessary synchronization information (such as RBS reference broadcasts and TPSN hierarchical forwarding). Communication overhead (energy consumption) increases exponentially with the number of nodes, resulting in an exponential increase in energy consumption during time synchronization of the entire topology. This leads to insufficient accuracy in synchronizing the time of network nodes within the network topology.
[0027] To address the aforementioned technical problems, this application provides a time synchronization optimization method based on the nearest K-neighbor network topology. This method involves clustering the network nodes to be synchronized in the set of network nodes to be synchronized, obtaining S sets of first network nodes; reconstructing the original network topology of the first network nodes in the S sets of first network nodes according to the intra-group communication rules of K-neighbors, obtaining a first network topology; and synchronizing the time of the first network nodes in the first network topology to obtain the target network topology. This improves the accuracy of time synchronization when synchronizing the network nodes to be synchronized in the set of network nodes to be synchronized.
[0028] Please see Figure 4 , Figure 4 This application provides a flowchart illustrating a time synchronization optimization method based on the nearest K-neighbor network topology. Figure 4 As shown, the method includes: 401. Cluster the network nodes to be synchronized in the set of network nodes to be synchronized to obtain S sets of first network nodes.
[0029] Specifically, this can be achieved by extracting the coordinate position information of each network node in the set of network nodes to be synchronized, and calculating the Euclidean distance between any two network nodes in the set of network nodes to be synchronized based on the coordinate position information of each network node in the set of network nodes to be synchronized, thereby obtaining a first distance set; then using the general K-means clustering method to cluster the network nodes in the set of network nodes to be synchronized based on the first distance in the first distance set, dividing the network nodes in the set of network nodes to be synchronized into S subsets, thereby obtaining S first network node sets.
[0030] 402. Based on the intra-group communication rules of K neighboring groups, the original network topology of the first network nodes in the set of S first network nodes is reconstructed to obtain the first network topology.
[0031] Specifically, this can be achieved by obtaining the original network topology of the first network nodes in the S sets of first network nodes to obtain the original network topology; randomly selecting one set of first network nodes from the S sets of first network nodes to obtain the target set of first network nodes; counting the number of target first network nodes in the target set of first network nodes and the number of connections between each target first network node and other target first network nodes to obtain a first quantity information set; determining the maximum number of network nodes allowed for each target first network node in the target set of first network nodes to connect with other target first network nodes based on the first quantity in the first quantity information set to obtain first restriction information; and re-establishing the network connections corresponding to the target first network nodes in the target set of first network nodes based on the first distance in the first distance set and the first restriction information. The network topology is divided such that each target first network node in the target first network node set communicates only with the target first network node within the first restriction information, resulting in a first sub-network topology. This process is repeated from the initial selection of a first network node set from the S first network node sets to the re-division of the network connections corresponding to the target first network nodes in the target first network node set based on the first distance and first restriction information in the first distance set, ensuring that each target first network node in the target first network node set communicates only with the target first network node within the first restriction information, thus obtaining a first sub-network topology. This process is repeated for all first network node sets in the S first network node sets, thereby re-dividing the network connections corresponding to the first network nodes in all first network node sets, ultimately reconstructing the original network topology and obtaining the first network topology.
[0032] 403. Perform time synchronization on the first network node in the first network topology to obtain the target network topology.
[0033] Specifically, the process can be as follows: First network nodes in each of the S sets of first network nodes are identified as network nodes in a sub-network topology, thus dividing the first network topology into S sub-network topologies. Then, the energy consumption information of the first network node in each of the S sub-network topologies when receiving or transmitting signals is calculated, resulting in S sets of first energy consumption information. Based on the first energy consumption information in the S sets of first energy consumption information, the remaining energy intensity of the first network node in each of the S sub-network topologies is calculated, resulting in S sets of first remaining energy information. The number of edges corresponding to each of the S sub-network topologies is counted, resulting in a set of first edge count information. Based on the first edge count information in the first edge count information set and the first energy consumption information in the S sets of first energy consumption information, reference network nodes corresponding to the S sub-network topologies are determined, resulting in S reference network nodes. Finally, the first network nodes in the first network topology are synchronized in time using the S reference network nodes to obtain the target network topology.
[0034] Specifically, the degree matrix corresponding to the target network topology can be constructed using a general degree matrix construction method to obtain the first degree matrix; the adjacency matrix corresponding to the target network topology can be calculated using a general distance-based weighted adjacency matrix calculation method to obtain the first adjacency matrix; the Laplacian matrix corresponding to the target network topology can be calculated based on the first adjacency matrix and the first degree matrix, and the second non-negative eigenvalue in the Laplacian matrix can be extracted to obtain the first eigenvalue; the number of nodes, the number of connections, the number of triangles, and the number of tetrahedrons in the target network topology can be extracted, and the results can be calculated based on the number of nodes, the number of connections, the number of triangles, and the number of tetrahedrons in the target network topology. The Euler characteristic of the target network topology is calculated using a general Euler characteristic calculation method to obtain the first Euler characteristic. It is then determined whether the first Euler characteristic is less than or equal to a preset Euler characteristic threshold, and whether the first eigenvalue is greater than or equal to a preset eigenvalue threshold. If the result is yes, the target network topology is output. If not, the time synchronization of the network nodes in the set of network nodes to be synchronized is repeated according to steps 401-403 until the first Euler characteristic of the target network topology is less than or equal to the preset Euler characteristic threshold, and the first eigenvalue is greater than or equal to the preset eigenvalue threshold. The target network topology is then output.
[0035] In this example, by clustering the network nodes to be synchronized in the set of network nodes to be synchronized, S sets of first network nodes are obtained. The original network topology of the first network nodes in the S sets of first network nodes is reconstructed according to the intra-group communication rules of K neighboring nodes to obtain the first network topology. The first network nodes in the first network topology are synchronized in time to obtain the target network topology, which improves the accuracy of time synchronization of the network nodes to be synchronized in the set of network nodes to be synchronized.
[0036] In one possible implementation, a method for clustering the network nodes to be synchronized in a set of network nodes to obtain S first sets of network nodes includes: A1. Calculate the distance between each network node in the set of network nodes to be synchronized based on the coordinate position information of the network nodes to be synchronized in the set of network nodes to be synchronized, and obtain the first distance set. A2. Cluster the network nodes to be synchronized in the set of network nodes to be synchronized according to the first distance in the first distance set to obtain S sets of first network nodes.
[0037] Specifically, the location information of the network nodes to be synchronized in the set of network nodes to be synchronized can be collected by using a general network node location information collection method to obtain a set of coordinate location information; the Euclidean distance between two sets of network nodes to be synchronized can be calculated based on the coordinate location information in the set of coordinate location information to obtain a first distance set.
[0038] Specifically, the Euclidean distance between two sets of network nodes to be synchronized can be calculated based on the coordinate position information in the coordinate position information set, as shown in the following formula, to obtain the first distance information set: In the formula This represents the first distance information in the first distance information set, namely the Euclidean distance between the i-th and j-th network nodes to be synchronized in the set of network nodes to be synchronized. This represents the x-coordinate of the i-th network node in the set of network nodes to be synchronized; This represents the x-coordinate of the j-th network node in the set of network nodes to be synchronized; This represents the ordinate of the i-th network node in the set of network nodes to be synchronized; This represents the ordinate of the j-th network node in the set of network nodes to be synchronized.
[0039] After obtaining the first distance set, the network nodes to be synchronized in the set of network nodes to be synchronized can be clustered according to the first distance in the first distance set using the general K-means clustering method, resulting in S sets of first network nodes. The first network nodes can be divided into three categories: "reference network nodes," "receiving network nodes," and "adjacent network nodes."
[0040] In one possible implementation, a method for reconstructing the original network topology of the first network nodes in a set of S first network nodes according to the intra-group communication rules of K neighboring nodes, to obtain the first network topology, includes: B1. Determine the number of edges when the first network node in the S sets of first network nodes is connected to other first network nodes based on the original network topology of the first network node in the S sets of first network nodes, and obtain the first quantity information. B2. Based on the first quantity information, determine the maximum number of connected nodes allowed for the first network node in the S sets of first network nodes when making network connections, and obtain the first restriction information; B3. Based on the K-nearest neighbor intra-group communication rules, the original network topology of the first network nodes in the S sets of first network nodes is reconstructed according to the first restriction information and the first distance in the first distance set to obtain the first network topology.
[0041] This can be achieved by extracting the original network topology of the first network nodes in the set of S first network nodes to obtain the original network topology; and by using a common network topology edge counting method to count the number of edges in the original network topology to obtain the first quantity information.
[0042] Since the K-nearest neighbor intra-group communication rule means that each first network node only establishes network communication connections with its K nearest first network nodes, if the value of K is set too small, the connectivity between the first network nodes in the set of S first network nodes will be insufficient, resulting in the accuracy of time synchronization of the first network nodes in the set of S first network nodes being difficult to achieve as expected. If the value of K is set too large, although it may improve the accuracy of time synchronization of the first network nodes in the set of S first network nodes, an excessively large value of S will lead to too many redundant network communication connections in the network topology, increasing the network complexity of the communication network constructed by the first network nodes in the set of S first network nodes, and thus significantly increasing the energy consumption for time synchronization of the first network nodes in the set of S first network nodes. Therefore, it is necessary to determine a suitable value of K to simultaneously satisfy the accuracy of time synchronization of the first network nodes in the set of S first network nodes while reducing the energy consumption.
[0043] After obtaining the first quantity information, the node quantity information can be obtained by counting the number of the first network node in the S sets of first network nodes; the ratio between the number of edges and the number of nodes in the original network topology can be calculated based on the node quantity information and the first quantity information to obtain the first ratio information; and the maximum number of connected nodes allowed for the first network node in the S sets of first network nodes when making network connections can be determined based on the first ratio information to obtain the first restriction information.
[0044] Specifically, the maximum number of allowed network nodes in the S sets of first network nodes can be determined based on the first ratio information using the following formula, thus obtaining the first restriction information: In the formula This indicates the first proportion of information; Indicates the first quantity information; Indicates the number of nodes; Indicates the first limiting information; The degree of the first network node in the first set of network nodes can be understood as the number of edges connected to the first network node in the first set of network nodes. This represents the positive integer corresponding to the first restriction information, rounded down.
[0045] After obtaining the first restriction information, the network communication connection corresponding to each first network node in the original network topology can be modified according to the first distance in the first distance set based on the intra-group communication rule of K-nearest neighbor, so that each first network node only establishes a network communication connection with the S first network nodes closest to itself, thereby completing the reconstruction of the original network topology of the first network nodes in the set of S first network nodes, and obtaining the first network topology.
[0046] In this example, the original network topology of the first network node is reconstructed according to the intra-group communication rules of K-neighbors, so that each first network node only establishes network communication connections with the S nearest first network nodes. This enhances the connectivity between each first network node in the first network node set and reduces redundant connections between each first network node in the first network node set, thereby improving the accuracy of time synchronization of each first network node in the first network node set, and further improving the accuracy of time synchronization of the network nodes to be synchronized in the set of network nodes to be synchronized.
[0047] In one possible implementation, a method for synchronizing the time of a first network node in the first network topology to obtain a target network topology includes: C1. Extract the energy consumption information of each first network node in the first network topology during reception and transmission, calculate the remaining energy information of each first network node in the first network topology, and obtain the first set of remaining energy information. C2. Based on the first remaining energy information in the first remaining energy information set, determine the reference network node in each of the S first network node sets to obtain the reference network node set; C3. Based on the reference network nodes in the reference network node set, determine the neighboring network nodes in each of the S first network node sets to obtain the S neighboring network node sets. C4. Synchronize the first network topology with time based on the reference network nodes in the reference network node set and the neighboring network nodes in the neighboring network node set to obtain the target network topology.
[0048] Specifically, this can be achieved by extracting the energy information corresponding to each first network node in the first network topology in its initial state to obtain initial energy information; determining the data size of the time synchronization data packets sent or received by the first network topology during time synchronization to obtain first data packet information; determining the energy consumption information required for each first network node in the first network topology to complete one transmission of the time synchronization data packet based on the first data packet information to obtain a first energy consumption information set; determining the energy consumption information required for each first network node in the first network topology to complete one reception of the time synchronization data packet based on the first data packet information to obtain a second energy consumption information set; and using a general free space propagation model, calculating the remaining energy information corresponding to each first network node in the first network topology based on the first distance in the first distance set, the first data packet information, the first energy consumption information in the first energy consumption information set, the second energy consumption information in the second energy consumption information set, and the initial energy information to obtain first remaining energy information.
[0049] Specifically, the remaining energy information for each first network node in the first network topology can be calculated using a general free-space propagation model, based on the first distance in the first distance set, the first data packet information, the first energy consumption information in the first energy consumption information set, the second energy consumption information in the second energy consumption information set, and the initial energy information, as shown in the following formula, to obtain the first remaining energy information: In the formula This represents the first energy consumption information in the first energy consumption information set; Indicates the information in the first data packet; The basic energy consumption coefficient of the electronic circuit corresponding to the first network node in the first network topology can be determined by user input or by system default. The energy attenuation coefficient of the free space propagation model can be determined by user input or by system default. Represents the first distance in the first distance set; This represents the second energy consumption information in the second energy consumption information set; This represents the first remaining energy information in the first set of remaining energy information; This indicates the initial energy information.
[0050] Since the reference node is the core of network topology time synchronization, the more neighboring nodes a node has, the wider its communication range and the more energy it can allocate to meet its communication needs. The more energy a node currently has remaining, the stronger its continuous transmission capability. Therefore, the reference node should be selected from the network topology nodes with the most neighboring nodes and the most remaining energy.
[0051] After obtaining the first set of remaining energy information, a third set of quantity information can be obtained by determining the number of neighboring nodes of each first network node in the first network topology. Based on the third quantity information in the third set of quantity information and the first remaining energy information in the first set of remaining energy information, a pair of neighboring node counts minus node remaining energy corresponding to the first network node in S sets of first network nodes is constructed, resulting in S sets of pairs. The pairs in the S sets of pairs can be represented as Node(E,U), where E represents the third quantity information in the third set of quantity information and U represents the first remaining energy information in the first set of remaining energy information. The first network node with the largest number of neighboring nodes and the largest remaining energy is selected from each of the S sets of pairs to obtain a reference set of network nodes.
[0052] After obtaining the reference network node set, the first network nodes in the S first network node sets (excluding the reference network nodes in the reference network node set) can be identified as receiving nodes to obtain S receiving node sets. For each receiving node set, with its corresponding reference network node as the center point, the four receiving nodes farthest from the reference network node are selected in the receiving node set according to four preset selection directions to obtain S target receiving node sets. The target receiving nodes in the S target receiving node sets are identified as neighboring network nodes to obtain S neighboring network node sets.
[0053] After obtaining the S sets of neighboring network nodes, a target reference network node can be obtained by randomly selecting a reference network node from the set of reference network nodes; the first network topology is then synchronized in time based on the target reference network node and the neighboring network nodes in the set of S neighboring network nodes to obtain the target network topology.
[0054] In this example, by accurately determining the first network node with the most neighboring nodes and the most remaining energy based on the remaining energy information of each first network node in the first network topology, a reference network node set is obtained. Time synchronization of each first network node in the first network topology is achieved through two broadcasts, thereby improving the accuracy of time synchronization of network nodes to be synchronized in the set of network nodes to be synchronized.
[0055] In one possible implementation, a method for time-synchronizing a first network topology based on reference network nodes in the reference network node set and neighboring network nodes in the neighboring network node set to obtain a target network topology includes: D1. Randomly select a reference network node from the set of reference network nodes to obtain the target reference network node; D2. Determine the first network node set corresponding to the target reference network node from the S first network node sets to obtain the second network node set; D3. Extract the network nodes that are common to the neighboring network nodes in the second network node set and the S neighboring network node sets to obtain the target neighboring network node set; D4. Based on the local timestamp corresponding to the target reference network node, perform intra-group time synchronization on the second network node in the second network node set to obtain the third network node set. D5. Based on the third network node in the third network node set and the target neighbor network node in the target neighbor network node set, perform global time synchronization on the first network node in the first network topology to obtain the target network topology.
[0056] One method is to obtain the target reference network node by randomly selecting a reference network node from the set of reference network nodes.
[0057] After obtaining the target reference network node, the second network node set can be obtained by extracting the first network node set corresponding to the target reference network node from the S first network node sets.
[0058] After obtaining the second set of network nodes, the target domain network node set can be obtained by extracting the intersection between the second network nodes in the second set of network nodes and the neighboring network nodes in the S sets of neighboring network nodes.
[0059] After obtaining the target neighborhood network node set, the target second network node set can be obtained by extracting the second network node from the second network node set that is only one hop away from the target reference network node; extracting the drift amount of the local hardware clock corresponding to the target reference network node to obtain the first clock drift amount; determining the offset amount of the local hardware clock corresponding to the target reference network node based on the first clock drift amount to obtain the first clock offset amount; determining the clock drift amount compensation information and clock offset amount compensation information corresponding to the target reference network node based on the first clock drift amount and the first clock offset amount to obtain the first clock drift compensation information and the first clock offset compensation information; extracting each node in the second network node set; determining the local timestamp corresponding to the target reference network node based on the first clock drift compensation information, the first time offset compensation information, the first clock drift amount, and the first clock offset amount; and obtaining the first time synchronization information based on the local timestamp, identity information, and cumulative time error value corresponding to the target reference network node.
[0060] The local timestamp corresponding to the target reference network node can be determined using the method shown in the following formula, based on the first clock drift compensation information, the first time offset compensation information, the first clock drift amount, and the first clock offset: In the formula This represents the local timestamp corresponding to the target reference network node under ideal conditions; Indicates the first clock drift amount; This indicates the local timestamp corresponding to the target reference network node; The ideal reference time can be determined by user input or by the system default. This indicates the first clock drift compensation information; Indicates the first clock offset; This indicates the offset compensation information at the first moment; This indicates the total number of broadcasts performed during clock synchronization. This represents the difference in transmission delay for information synchronized at the first moment. This represents the transmission delay when the i-th second network node in the second network node set sends the first-time synchronization information to the j-th second network node. This represents the transmission delay when the j-th second network node in the second network node set sends the first-time synchronization information to the i-th second network node; This represents the sum of the timestamps in the first time synchronization information received and sent by the i-th second network node in the second network node set during the nth round of broadcasting. This represents the timestamp information received by the i-th second network node in the second network node set from the first time synchronization information. This represents the timestamp information in the first time synchronization information sent by the i-th second network node in the second network node set; This represents the sum of the timestamps in the first time synchronization information received and sent by the j-th second network node in the second network node set during the nth round of broadcasting. This represents the timestamp information received by the j-th second network node in the second network node set from the first time synchronization information. This represents the timestamp information in the first time synchronization information sent by the j-th second network node in the second network node set; This represents the uncertainty delay introduced by the diffusion factor when the i-th second network node in the second network node set sends the first-time synchronization information to the j-th second network node; This represents the uncertainty delay introduced by the diffusion factor when the j-th second network node in the second network node set sends the first time synchronization information to the i-th second network node. It can be determined by user input or by system default.
[0061] The target reference network node broadcasts the first-time synchronization information to the target second network nodes in the target second network node set for the first time, and receives the response messages returned by the target second network nodes in the target second network node set after receiving the first-time synchronization information, thus obtaining a response message set. The response messages in the response message set are normalized, and the normalized value corresponding to each response message in the response message set is calculated, thus obtaining a first normalized value set. Based on a preset normalized value threshold, first normalized values higher than the preset normalized value are selected from the first normalized value set, thus obtaining a target normalized value set. The target second network node corresponding to each target normalized value in the target normalized value set is extracted and determined as the master node, thus obtaining a master node set. The receiving network nodes in the second network node set are extracted, thus obtaining a second... The system receives a set of network nodes; identifies the second receiving network nodes (excluding the master nodes in the master node set) as slave nodes, thus obtaining a slave node set; determines the local timestamp corresponding to the target reference network as the time synchronization information for the second broadcast, thus obtaining second time synchronization information; uses the target reference network nodes to broadcast the second time synchronization information to the master nodes in the master node set for the second time, and the master nodes in the master node set synchronize their time according to the received second time synchronization information, thus obtaining a first master node set; the first master node set sends the second time synchronization information to the slave nodes in the slave node set, and the slave nodes in the slave node set synchronize their time according to the received second time synchronization information, thereby completing the intra-group time synchronization of the second network nodes in the second network node set, thus obtaining a third network node set.
[0062] After obtaining the third set of network nodes, the target reference network node in the third set can be used to determine the local reference network node. When the target neighboring network node in the target neighboring network node set receives time synchronization information from a non-local reference network node, the target neighboring network node in the target neighboring network node set will transmit the received time synchronization information from the non-local reference network node to the local reference network node to obtain the third time synchronization information. It is then determined whether the third time synchronization information is the same as the second time synchronization information. If they are the same, the local reference network node generates confirmation information and transmits the generated confirmation information through the target neighboring network node set. The target neighboring network node transmits the data to the non-local reference network node in the reference network node set, thereby achieving global time synchronization of the first network node in the first network topology and obtaining the target network topology. The generated confirmation information can be, for example, "Time synchronization information is consistent, time synchronization is allowed". If they are different, the third time synchronization information is replaced with the second time synchronization information to obtain confirmation information. The confirmation information is then transmitted through the target neighboring network node in the target neighboring network node set to the non-local reference network node in the reference network node set, thereby achieving global time synchronization of the first network node in the first network topology and obtaining the target network topology.
[0063] In this example, by accurately estimating the drift compensation information and offset compensation information of the target reference network node, and accurately calculating the local timestamp of the target reference network node based on the drift compensation information and offset compensation information, the accuracy of the second time synchronization information is improved. Furthermore, by using the neighboring network nodes in the neighboring network node set to achieve time synchronization of non-local reference network nodes, the propagation path of the second time synchronization information is reduced when achieving time synchronization of non-local reference network nodes, thus reducing the risk of loss of the second time synchronization information when achieving time synchronization of non-local reference network nodes, thereby improving the accuracy of time synchronization of network nodes to be synchronized in the set of network nodes to be synchronized.
[0064] For examples consistent with the above embodiments, please refer to... Figure 5 , Figure 5 This is a schematic diagram of the structure of a terminal provided in an embodiment of this application, such as... Figure 5 As shown, the system includes a processor, an input device, an output device, and a memory, which are interconnected. The memory stores a computer program, which includes program instructions. The processor is configured to invoke the program instructions. The program includes instructions for performing the following steps. Cluster the network nodes to be synchronized in the set of network nodes to be synchronized to obtain S sets of first network nodes; Based on the intra-group communication rules of K neighbors, the original network topology of the first network nodes in the S sets of first network nodes is reconstructed to obtain the first network topology; The time of the first network node in the first network topology is synchronized to obtain the target network topology.
[0065] The above mainly describes the solutions of the embodiments of this application from the perspective of the method execution process. It is understood that, in order to achieve the above functions, the terminal includes the corresponding hardware structure and / or software modules for executing each function. Those skilled in the art should readily recognize that, in conjunction with the units and algorithm steps of the various examples described in the embodiments provided herein, this application can be implemented in hardware or a combination of hardware and computer software. Whether a function is executed in hardware or by computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0066] This application embodiment can divide the terminal into functional units according to the above method example. For example, each function can be divided into a separate functional unit, or two or more functions can be integrated into one processing unit. The integrated unit can be implemented in hardware or as a software functional unit. It should be noted that the unit division in this application embodiment is illustrative and only represents one logical functional division. In actual implementation, there may be other division methods.
[0067] For those consistent with the above, please refer to Figure 6 , Figure 6 This application provides a schematic diagram of the structure of a time synchronization optimization system based on the nearest K-neighbor network topology. For example... Figure 5 As shown, the system includes: Clustering unit 601 is used to perform clustering processing on the network nodes to be synchronized in the set of network nodes to be synchronized, to obtain S sets of first network nodes; The reconstruction unit 602 is used to reconstruct the original network topology of the first network nodes in the set of S first network nodes according to the intra-group communication rules of K neighbors, so as to obtain the first network topology. Synchronization unit 603 is used to synchronize the time of the first network node in the first network topology to obtain the target network topology.
[0068] In one possible implementation, the clustering unit 601 is specifically used for: Based on the coordinate position information of the network nodes to be synchronized in the set of network nodes to be synchronized, the distance between each network node to be synchronized in the set of network nodes to be synchronized is calculated to obtain a first distance set; Based on the first distance in the first distance set, the network nodes to be synchronized in the set of network nodes to be synchronized are clustered to obtain S sets of first network nodes.
[0069] In one possible implementation, the reconfiguration unit 602 is specifically used for: Based on the original network topology of the first network node in the S sets of first network nodes, determine the number of edges corresponding to the connection between the first network node in the S sets of first network nodes and other first network nodes, and obtain the first quantity information; Based on the first quantity information, determine the maximum number of connected nodes allowed for the first network node in the S sets of first network nodes when making network connections, and obtain the first restriction information; Based on the K-nearest neighbor intra-group communication rules, the original network topology of the first network nodes in the S first network node sets is reconstructed according to the first restriction information and the first distance in the first distance set, to obtain the first network topology.
[0070] In one possible implementation, the synchronization unit 603 is specifically used for: Extract the energy consumption information of each first network node in the first network topology during reception and transmission, calculate the remaining energy information corresponding to each first network node in the first network topology, and obtain the first set of remaining energy information; Based on the first remaining energy information in the first remaining energy information set, the reference network node in each of the S first network node sets is determined to obtain the reference network node set; Based on the reference network nodes in the reference network node set, the neighboring network nodes in each of the S first network node sets are determined, thus obtaining the S neighboring network node sets. The first network topology is synchronized in time based on the reference network nodes in the reference network node set and the neighboring network nodes in the neighboring network node set to obtain the target network topology.
[0071] In one possible implementation, in obtaining the target network topology by time synchronization of the first network topology based on the reference network nodes in the reference network node set and the neighboring network nodes in the neighboring network node set, the synchronization unit 603 is specifically used for: Randomly select a reference network node from the set of reference network nodes to obtain the target reference network node; From the S sets of first network nodes, the set of first network nodes corresponding to the target reference network node is determined, and the set of second network nodes is obtained. Extract the network nodes common to the neighboring network nodes in the second network node set and the S neighboring network node sets to obtain the target neighboring network node set; Based on the local timestamp corresponding to the target reference network node, the second network nodes in the second network node set are synchronized within the group to obtain the third network node set. The target network topology is obtained by globally synchronizing the first network node in the first network topology with the third network node in the third network node set and the target neighbor network nodes in the target neighbor network node set.
[0072] This application also provides a computer storage medium storing a computer program for electronic data interchange, which causes a computer to perform some or all of the steps of any of the time synchronization optimization methods based on nearest K neighbor network topology as described in the above method embodiments.
[0073] This application also provides a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program that causes a computer to perform some or all of the steps of any of the time synchronization optimization methods based on nearest K neighbor network topology as described in the above method embodiments.
[0074] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this application. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions and modules involved are not necessarily essential to this application.
[0075] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions in other embodiments.
[0076] In the several embodiments provided in this application, it should be understood that the disclosed apparatus can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical or other forms.
[0077] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0078] Furthermore, the functional units in the various embodiments of the application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software program module.
[0079] If the integrated unit is implemented as a software program module and sold or used as an independent product, it can be stored in a computer-readable storage device (CMD). Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a memory and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned memory includes various media capable of storing program code, such as USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical disks.
[0080] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by a program instructing related hardware. The program can be stored in a computer-readable storage device, which may include: a flash drive, a read-only memory, a random access memory, a magnetic disk, or an optical disk, etc.
[0081] The embodiments of this application have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of this application. The description of the above embodiments is only for the purpose of helping to understand the method and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A time synchronization optimization method based on nearest K neighbor network topology, characterized in that, The method includes: Cluster the network nodes to be synchronized in the set of network nodes to be synchronized to obtain S sets of first network nodes; Based on the intra-group communication rules of K neighbors, the original network topology of the first network nodes in the S sets of first network nodes is reconstructed to obtain the first network topology; The time of the first network node in the first network topology is synchronized to obtain the target network topology.
2. The time synchronization optimization method based on nearest K neighbor network topology according to claim 1, characterized in that, The clustering process is performed on the network nodes to be synchronized in the set of network nodes to be synchronized, resulting in S sets of first network nodes, including: Based on the coordinate position information of the network nodes to be synchronized in the set of network nodes to be synchronized, the distance between each network node to be synchronized in the set of network nodes to be synchronized is calculated to obtain a first distance set; Based on the first distance in the first distance set, the network nodes to be synchronized in the set of network nodes to be synchronized are clustered to obtain S sets of first network nodes.
3. The time synchronization optimization method based on nearest K neighbor network topology according to claim 2, characterized in that, The process of reconstructing the original network topology of the first network nodes in the set of S first network nodes according to the intra-group communication rules of K neighbors to obtain the first network topology includes: Based on the original network topology of the first network node in the S sets of first network nodes, determine the number of edges corresponding to the connection between the first network node in the S sets of first network nodes and other first network nodes, and obtain the first quantity information; Based on the first quantity information, determine the maximum number of connected nodes allowed for the first network node in the S sets of first network nodes when making network connections, and obtain the first restriction information; Based on the K-nearest neighbor intra-group communication rules, the original network topology of the first network nodes in the S first network node sets is reconstructed according to the first restriction information and the first distance in the first distance set, to obtain the first network topology.
4. The time synchronization optimization method based on nearest K neighbor network topology according to claim 3, characterized in that, The step of synchronizing the time of the first network node in the first network topology to obtain the target network topology includes: Extract the energy consumption information of each first network node in the first network topology during reception and transmission, calculate the remaining energy information corresponding to each first network node in the first network topology, and obtain the first set of remaining energy information; Based on the first remaining energy information in the first remaining energy information set, the reference network node in each of the S first network node sets is determined to obtain the reference network node set; Based on the reference network nodes in the reference network node set, the neighboring network nodes in each of the S first network node sets are determined, thus obtaining the S neighboring network node sets. The first network topology is synchronized in time based on the reference network nodes in the reference network node set and the neighboring network nodes in the neighboring network node set to obtain the target network topology.
5. The time synchronization optimization method based on nearest K neighbor network topology according to claim 4, characterized in that, The step of synchronizing the first network topology with time based on the reference network nodes in the reference network node set and the neighboring network nodes in the neighboring network node set to obtain the target network topology includes: Randomly select a reference network node from the set of reference network nodes to obtain the target reference network node; From the S sets of first network nodes, the set of first network nodes corresponding to the target reference network node is determined, and the set of second network nodes is obtained. Extract the network nodes common to the neighboring network nodes in the second network node set and the S neighboring network node sets to obtain the target neighboring network node set; Based on the local timestamp corresponding to the target reference network node, the second network nodes in the second network node set are synchronized within the group to obtain the third network node set. The target network topology is obtained by globally synchronizing the first network node in the first network topology with the third network node in the third network node set and the target neighbor network nodes in the target neighbor network node set.
6. A time synchronization optimization system based on nearest K neighbor network topology, characterized in that, The system includes: Clustering unit is used to cluster the network nodes to be synchronized in the set of network nodes to be synchronized, and obtain S sets of first network nodes; The reconstruction unit is used to reconstruct the original network topology of the first network nodes in the set of S first network nodes according to the intra-group communication rules of K neighbors, so as to obtain the first network topology. The synchronization unit is used to synchronize the time of the first network nodes in the first network topology to obtain the target network topology.
7. The time synchronization optimization system based on nearest K neighbor network topology according to claim 6, characterized in that, In the process of clustering the network nodes to be synchronized in the set of network nodes to be synchronized to obtain S sets of first network nodes, the clustering unit is specifically used for: Based on the coordinate position information of the network nodes to be synchronized in the set of network nodes to be synchronized, the distance between each network node to be synchronized in the set of network nodes to be synchronized is calculated to obtain a first distance set; Based on the first distance in the first distance set, the network nodes to be synchronized in the set of network nodes to be synchronized are clustered to obtain S sets of first network nodes.
8. The time synchronization optimization system based on nearest K neighbor network topology according to claim 7, characterized in that, In reconstructing the original network topology of the first network nodes in the set of S first network nodes according to the intra-group communication rules of K neighbors, to obtain the first network topology, the reconstruction unit is specifically used for: Based on the original network topology of the first network node in the S sets of first network nodes, determine the number of edges corresponding to the connection between the first network node in the S sets of first network nodes and other first network nodes, and obtain the first quantity information; Based on the first quantity information, determine the maximum number of connected nodes allowed for the first network node in the S sets of first network nodes when making network connections, and obtain the first restriction information; Based on the K-nearest neighbor intra-group communication rules, the original network topology of the first network nodes in the S first network node sets is reconstructed according to the first restriction information and the first distance in the first distance set, to obtain the first network topology.
9. A terminal, characterized in that, The device includes a processor, an input device, an output device, and a memory, which are interconnected. The memory stores a computer program, which includes program instructions. The processor is configured to invoke the program instructions to execute the time synchronization optimization method based on the nearest K-neighbor network topology as described in any one of claims 1-5.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, the computer program including program instructions that, when executed by a processor, cause the processor to perform the time synchronization optimization method based on the nearest K-neighbor network topology as described in any one of claims 1-5.