Clock synchronization method, apparatus, device, and storage medium

CN116962437BActive Publication Date: 2026-09-29CHINA MOBILE INFORMATION TECHNOLOGY CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311093388.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-08-28
Publication Date
2026-09-29
Estimated Expiration
2043-08-28

AI Technical Summary

Benefits of technology

[0041]本申请提供一种时钟同步方法、装置、设备及存储介质,与相关技术中时钟同步需要常态化占用至少一台本地服务器设备(硬件资源耗费多、节点对等性被破坏、中心节点异常故障影响业务正常运行等),导致时钟同步效益低下相比,在本申请中,获取待同步节点列表,并确定待同步节点列表中各待同步节点间的网络延迟数据;根据所述待同步节点列表确定各待同步节点所处网络的网络结构、并根据所述网络延迟数据确定所述所处网络的网络状态以及各个待同步节点间时钟的差异情况;根据所述网络结构、所述网络状态及所述时钟差异情况,确定时钟同步场景;根据所述时钟同步场景选取匹配的时钟同步算法,并根据所述匹配的时钟同步算法对各待同步节点进行时钟同步。可以理解,在本申请中,根据获得的待同步节点列表推断网络结构、根据网络延迟数据推断网络状态以及节点间时钟差异情况,再自动根据网络结构、网络状态及各节点时钟差异情况确定时钟同步场景,再根据时钟同步场景确定时钟同步算法,即可进行各个待同步节点的同步,该过程中,充分考虑了资源、节点对等性以及中心节点异常故障等情况,实现无需配置固定服务器,再节省硬件资源的同时,避免因绑定资源破坏节点对等性,以及避免中心节点异常故障影响业务正常运行,提高了时钟同步的效益。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116962437B_ABST
    Figure CN116962437B_ABST
Patent Text Reader

Abstract

The application discloses a clock synchronization method, device and equipment and a storage medium. The method comprises the following steps: acquiring a list of to-be-synchronized nodes, and determining network delay data among the to-be-synchronized nodes in the list of to-be-synchronized nodes; determining a network structure of a network in which each to-be-synchronized node is located according to the list of to-be-synchronized nodes, and determining a network state of the network and a clock difference among the to-be-synchronized nodes according to the network delay data; determining a clock synchronization scene according to the network structure, the network state and the clock difference; selecting a matched clock synchronization algorithm according to the clock synchronization scene, and performing clock synchronization on each to-be-synchronized node according to the matched clock synchronization algorithm. The application aims to avoid the situation that the abnormal failure of a central node affects the normal operation of a service.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of communication and computer technology, and in particular to a clock synchronization method, apparatus, device and storage medium. Background Technology

[0002] With the development of technologies such as big data, cloud computing, containerization, and microservices, distributed computer clusters have become the most common hardware deployment form for major enterprises. In order to ensure the normal operation of network communication between nodes in the cluster, clock synchronization within the cluster is required; otherwise, unpredictable communication failures and business logic errors will occur.

[0003] In related technologies, clock synchronization is generally achieved based on NTP (Network Time Protocol) servers. This method requires the constant use of at least one local server device for clock synchronization processing. This local server device is the central node, which consumes a lot of hardware resources and disrupts node peer-to-peer relationships. There is also the possibility of abnormal failure of the central node affecting the normal operation of business. In other words, the existing clock synchronization method has the technical problem of low clock synchronization efficiency. Summary of the Invention

[0004] In view of this, embodiments of this application provide a clock synchronization method, apparatus, device, and storage medium, aiming to solve the technical problem of low clock synchronization efficiency in related technologies.

[0005] This application provides a clock synchronization method, the method comprising:

[0006] Obtain the list of nodes to be synchronized and determine the network latency data between each node in the list.

[0007] The network structure of the network in which each node to be synchronized is located is determined based on the list of nodes to be synchronized, and the network status of the network in which the node is located and the clock differences between each node to be synchronized are determined based on the network delay data.

[0008] Based on the network structure, the network status, and the clock difference, determine the clock synchronization scenario;

[0009] A matching clock synchronization algorithm is selected based on the clock synchronization scenario, and clock synchronization is performed on each node to be synchronized according to the matching clock synchronization algorithm.

[0010] In one possible implementation of this application, the network latency data includes the network fluctuation variance between each node to be synchronized and the other nodes to be synchronized;

[0011] The step of determining the clock synchronization scenario based on the network structure, the network state, and the clock difference includes:

[0012] Identify unstable link nodes whose network fluctuation variance exceeds a preset variance threshold;

[0013] Based on the network structure of the network in which the nodes other than the unstable link nodes in the list of nodes to be synchronized are located, the network status of the network in which they are located, and the differences in clocks between the corresponding other nodes, determine the clock synchronization scenario.

[0014] The step of selecting a matching clock synchronization algorithm based on the clock synchronization scenario and synchronizing the clocks of each node to be synchronized according to the matching clock synchronization algorithm includes:

[0015] Select a matching clock synchronization algorithm based on the clock synchronization scenario, and perform clock synchronization on other nodes besides the unstable link node based on the matching clock synchronization algorithm;

[0016] Based on the other nodes besides the unstable link node after clock synchronization, clock synchronization compensation processing is performed on the unstable link node.

[0017] In one possible implementation of this application, the step of performing clock synchronization compensation processing on the unstable link node based on other nodes besides the clock-synchronized unstable link node includes:

[0018] Determine the target node from the other nodes to form a stable link with the unstable link node, wherein the target node is determined by controlling the other nodes to send network delay correction data packets to the unstable link node;

[0019] By controlling the target node to send timestamp data packets to the unstable link node, the unstable link node updates its local clock time based on the timestamp data packets and reports a successful synchronization status.

[0020] In one possible implementation of this application, the step of selecting a matching clock synchronization algorithm based on the clock synchronization scenario includes:

[0021] If the clock synchronization scenario involves a number of nodes to be synchronized that is greater than or equal to a first preset number, and each node to be synchronized is located in a different subnet that is greater than a second preset number, then a hierarchical group synchronization algorithm is selected as the matching clock synchronization algorithm. The hierarchical group synchronization algorithm performs intra-group clock synchronization processing on each node to be synchronized according to its subnet, then performs clock synchronization on the representative node to be synchronized between different groups, and then synchronizes the clocks of other nodes to be synchronized within the group based on the representative node to be synchronized. The representative node to be synchronized is a node selected after the intra-group clock synchronization processing.

[0022] If the clock synchronization scenario involves a number of nodes to be synchronized that is less than the first preset number, a matching clock synchronization algorithm is selected based on whether the corresponding node to be synchronized has already performed synchronization.

[0023] In one possible implementation of this application, the step of selecting a matching clock synchronization algorithm based on whether the corresponding node to be synchronized has already performed synchronization when the number of nodes to be synchronized in the clock synchronization scenario is less than the first preset number includes the following:

[0024] If clock synchronization has never been performed between the nodes to be synchronized, and the difference between the clocks of different nodes to be synchronized is greater than the first preset time threshold, then the manually designated authoritative node algorithm is selected as the matching clock synchronization algorithm. The manually designated authoritative node algorithm is to manually set a node to be synchronized as the authoritative node and broadcast it to inform other nodes to be synchronized to update their local clocks with the clock of the authoritative node.

[0025] If clock synchronization has been performed between the nodes to be synchronized, then the self-elected authoritative node algorithm is selected as the matching clock synchronization algorithm. In the self-elected authoritative node algorithm, each node to be synchronized elects an authoritative node, and non-authoritative nodes update their local clocks based on the clock of the authoritative node.

[0026] If clock synchronization has never been performed between the nodes to be synchronized, and the difference between the clocks of different nodes to be synchronized is greater than the second preset time threshold, wherein the second preset time threshold is less than the first preset time threshold, then a preset clustering statistical synchronization algorithm is selected as the matching clock synchronization algorithm. The preset clustering statistical synchronization algorithm performs clustering statistics on the time of each node to be synchronized to obtain the highest frequency time distribution interval, and each node to be synchronized updates its local clock time based on the highest frequency time distribution interval.

[0027] If a new node to be synchronized is detected and added to the list of nodes to be synchronized, a node weighted synchronization algorithm is selected as the matching clock synchronization algorithm. The node weighted synchronization algorithm is based on a preset clustering statistical synchronization algorithm, which performs weighted processing on some nodes to obtain the highest frequency time distribution interval. Each node to be synchronized updates its local clock time based on the highest frequency time distribution interval.

[0028] In one possible implementation of this application, the step of synchronizing the clocks of each node to be synchronized according to the matched clock synchronization algorithm includes:

[0029] The clock is synchronized for each node to be synchronized according to the matching clock synchronization algorithm, and it is determined whether the time difference between each node is less than the preset time error threshold.

[0030] If it is determined that the time difference between each node is less than the preset time error threshold, then clock synchronization is considered complete.

[0031] If it is determined that the time difference between each node is not less than the preset time error threshold, then return to the step of obtaining the list of nodes to be synchronized.

[0032] In one possible implementation of this application, the step of determining the network latency data between each node in the list of nodes to be synchronized includes:

[0033] For a set of nodes to be synchronized in the same network environment, the network delay data between one of the nodes to be synchronized and other nodes to be synchronized in different network environments is selected and determined as the network delay data corresponding to each node to be synchronized in the set of nodes to be synchronized.

[0034] This application also provides a clock synchronization device, the device comprising:

[0035] The acquisition module is used to acquire a list of nodes to be synchronized and determine the network latency data between each node in the list.

[0036] The first determining module is used to determine the network structure of the network where each node to be synchronized is located based on the list of nodes to be synchronized, and to determine the network status of the network and the clock difference between the nodes to be synchronized based on the network delay data.

[0037] The second determining module is used to determine the clock synchronization scenario based on the network structure, the network state, and the clock difference.

[0038] A matching clock synchronization algorithm is selected based on the clock synchronization scenario, and clock synchronization is performed on each node to be synchronized according to the matching clock synchronization algorithm.

[0039] This application also provides a clock synchronization device, which is a physical node device. The clock synchronization device includes: a memory, a processor, and a program of the clock synchronization method stored in the memory and executable on the processor. When the program of the clock synchronization method is executed by the processor, it can implement the steps of the clock synchronization method as described above.

[0040] To achieve the above objectives, a storage medium is also provided, on which a clock synchronization program is stored, which, when executed by a processor, implements the steps of any of the clock synchronization methods described above.

[0041] This application provides a clock synchronization method, apparatus, device, and storage medium. Compared with related technologies where clock synchronization requires the constant use of at least one local server (leading to high hardware resource consumption, disruption of node peer-to-peer relationships, and disruption of normal business operations due to central node malfunctions), resulting in low efficiency, this application obtains a list of nodes to be synchronized and determines the network latency data between each node in the list; determines the network structure of the network where each node is located based on the list of nodes to be synchronized, and determines the network status of the network and the clock differences between the nodes based on the network latency data; determines the clock synchronization scenario based on the network structure, network status, and clock differences; selects a matching clock synchronization algorithm based on the clock synchronization scenario, and performs clock synchronization on each node according to the matching clock synchronization algorithm. It is understood that in this application, the network structure is inferred from the obtained list of nodes to be synchronized, the network status and clock differences between nodes are inferred from the network latency data, and then the clock synchronization scenario is automatically determined based on the network structure, network status and clock differences between nodes. Then, the clock synchronization algorithm is determined based on the clock synchronization scenario, and the synchronization of each node to be synchronized can be performed. In this process, resources, node peer-to-peer, and abnormal failures of the central node are fully considered. This achieves the goal of not needing to configure a fixed server, saving hardware resources, avoiding the destruction of node peer-to-peer due to resource binding, and avoiding the impact of abnormal failures of the central node on the normal operation of business, thus improving the efficiency of clock synchronization. Attached Figure Description

[0042] Figure 1 This is a flowchart illustrating the first embodiment of the clock synchronization method of this application;

[0043] Figure 2 This is a detailed flowchart of step S20 in the first embodiment of the clock synchronization method of this application;

[0044] Figure 3 This is a schematic diagram of the device structure of the hardware operating environment involved in the embodiments of this application;

[0045] Figure 4 This is a schematic diagram illustrating the effect of the clock synchronization method in this application without global illumination. Detailed Implementation

[0046] It should be understood that the specific embodiments described herein are merely illustrative of this application and are not intended to limit this application.

[0047] This application provides a clock synchronization method. In one embodiment of the clock synchronization method, it is applied to a clock synchronization device, as shown below. Figure 1 The method includes:

[0048] Step S10: Obtain the list of nodes to be synchronized and determine the network latency data between each node in the list.

[0049] Step S20: Determine the network structure of the network where each node to be synchronized is located based on the list of nodes to be synchronized, and determine the network status of the network and the clock differences between the nodes to be synchronized based on the network delay data.

[0050] Step S30: Determine the clock synchronization scenario based on the network structure, the network status, and the clock difference.

[0051] Step S40: Select a matching clock synchronization algorithm according to the clock synchronization scenario, and perform clock synchronization on each node to be synchronized according to the matching clock synchronization algorithm.

[0052] In this embodiment, the basic concepts are explained first:

[0053] Variance: The mean of the squared differences between each sample value and the mean of all sample values;

[0054] Network Time Protocol (NTP).

[0055] The background involved in this embodiment is as follows:

[0056] In related technologies, clock synchronization is achieved based on NTP (Network Time Protocol) servers. In this method, each client device actively initiates an NTP service request to obtain the standard time from the server and correct its local time to keep the time of each device relatively consistent.

[0057] Specifically, clock synchronization based on NTP servers can be divided into local NTP server solutions and Internet NTP server solutions, depending on the server deployment location. Local NTP servers require at least one local server device to be used continuously, and this local server device must be able to communicate with all client devices; while Internet NTP server solutions require client devices to be able to access the public Internet.

[0058] For on-premises NTP server solutions: Thanks to the development of technologies such as cloud computing, containerization, and microservices, enterprise server clusters typically use elastic deployment solutions, adjusting the cluster size as needed (creating or destroying nodes at any time). Using on-premises NTP servers results in the constant occupation of server resources, wasting resources and disrupting the complete peer-to-peer relationship between nodes within the cluster, violating the fundamental principles of containerized deployment and microservice architecture design. Furthermore, to implement NTP server services across clusters, either cross-network access between all client devices and the server needs to be established, or an NTP server needs to be added to each cluster, requiring a synchronization solution for multiple NTP services (high resource consumption, high hardware resource consumption, and disruption of node peer-to-peer relationships).

[0059] Regarding Internet NTP service solutions: In order to minimize Internet security risks, most enterprise internal server cluster devices cannot directly access the public Internet. They generally achieve public Internet access through solutions such as bastion hosts and proxy hosts. However, achieving public Internet access through solutions such as bastion hosts and proxy hosts requires complex permission requests and configurations, and increases potential Internet security risks.

[0060] However, in intranet environments without public network access and without the conditions to set up an NTP server (including situations where synchronization between multiple NTP servers needs to be maintained), clock synchronization is difficult.

[0061] This embodiment aims to: infer the network structure based on the obtained list of nodes to be synchronized, infer the network status and clock differences between nodes based on network latency data, and then automatically determine the clock synchronization scenario based on the network structure, network status and clock differences between nodes, and recommend a clock synchronization algorithm to synchronize each node to be synchronized. In this process, there is no need to configure a fixed server (clock synchronization between nodes to be synchronized), which saves hardware resources and avoids the destruction of node peer-to-peer due to resource binding, and avoids the impact of abnormal failure of the central node on the normal operation of the business.

[0062] In other words, this embodiment proposes a decentralized distributed clock synchronization scheme that eliminates the dependence on a central node or server, avoids the impact of abnormal failures of the central node on the normal operation of the business, and can be applied to internal server clusters of enterprises or to clock synchronization between Internet applications. In this scheme, clock synchronization deployment and configuration are simple, fast, low cost, and the clock synchronization effect is excellent.

[0063] In other words, it is important to emphasize that in this embodiment, there is no need to set a central node; all nodes are completely equal, requiring no additional server space, no access to the public internet, and without disrupting the server's flexible deployment logic. Furthermore, the logic execution scripts and configuration files can be deployed to each node in batches without differentiation, making deployment simple and convenient; the execution logic of each stage can be configured or customized, offering high flexibility.

[0064] In this application, unstable link nodes with network fluctuation variance greater than a preset variance threshold are also removed (low-reliability data is discarded) to reduce disturbance to the overall clock synchronization algorithm and improve the accuracy of clock synchronization.

[0065] This application also provides a compensation synchronization scheme for unstable nodes that failed to complete the first round of time synchronization due to network instability. That is, while discarding low-reliability data and reducing the disturbance to the overall clock synchronization algorithm, the clock synchronization of all nodes to be synchronized is achieved.

[0066] This application integrates multiple clock synchronization algorithms and / or rules, enabling the selection of corresponding synchronization algorithms and / or rules based on different clock synchronization scenarios (different network topologies and network quality conditions, etc.).

[0067] This application can be used as a general clock synchronization solution for enterprise internal server clusters or for clock synchronization between Internet applications. It is simple and quick to deploy and configure, with low cost, and can achieve clock synchronization effect with corresponding accuracy.

[0068] This proposal addresses the problem of a lack of NTP servers (components) or abnormal failures of NTP servers in distributed computer clusters, eliminating the reliance on NTP synchronization software (synchronization is achieved through the clocks of the nodes to be synchronized, without the need to specifically determine an NTP server or access the public Internet).

[0069] The specific steps are as follows:

[0070] Step S10: Obtain the list of nodes to be synchronized and determine the network latency data between each node in the list.

[0071] As an example, first determine the list of nodes to be synchronized (divided into different synchronization scenarios).

[0072] As an example, the list of nodes to be synchronized can include all devices in the same subnet;

[0073] As an example, the list of nodes to be synchronized can include all devices across multiple subnets;

[0074] As an example, the list of nodes to be synchronized can include several specified devices within the same subnet;

[0075] As an example, the list of nodes to be synchronized could include all devices across multiple subnets.

[0076] As an example, when the nodes to be synchronized in the list are all devices in the same subnet, the nodes to be synchronized can be directly marked by the network segment, such as using 192.168.1.0 / 24 to mark the corresponding node to be synchronized;

[0077] As an example, if the list of nodes to be synchronized involves multiple subnets, multiple network segments can be used to mark the nodes to be synchronized, such as using 192.168.1.0 / 24 and 192.168.2.0 / 244 to mark the corresponding nodes to be synchronized;

[0078] As an example, for a specific device, the device IP / hostname information can be listed, or the device IP / hostname information and network segment information can be combined to mark the corresponding node to be synchronized;

[0079] As an example, since the nodes to be synchronized are peers, the list information of the nodes to be synchronized needs to be synchronized to all nodes to be synchronized.

[0080] After determining the list of nodes to be synchronized, determine the network latency data between each node in the list (each device in the cluster does not need to access the public Internet and does not need to deploy a local NTP server regularly).

[0081] As an example, each node records its network latency data with all other nodes.

[0082] As an example, a single record in the network latency data contains information such as the average network latency from this node to all other nodes and the network fluctuation variance.

[0083] As an example, average network latency and network fluctuation variance can be represented in JSON format, such as: {"NodeB":[10,20],"NodeC":[20,10]}.

[0084] As an example, {"NodeB":[10,20] indicates that the average network latency and network fluctuation variance from this node to NodeB are 10 and 20 respectively, and "NodeC":[20,10]} indicates that the average network latency and network fluctuation variance from this node to NodeC are 20 and 10 respectively.

[0085] As an example, network latency data is obtained by having nodes send network packets with timestamped data to each other.

[0086] As an example, to avoid the impact of network stability, different nodes need to send data packets multiple times (e.g., 8 times based on experience). This means that multiple single network latency data need to be recorded, and the average network latency data and network fluctuation variance data need to be calculated to obtain the corresponding average network latency and network fluctuation variance.

[0087] As an example, assuming there are N nodes to be synchronized, then R = 2 * N * (N-1) network delay data entries need to be recorded.

[0088] As an example, the step of determining the network latency data between each node in the list of nodes to be synchronized includes:

[0089] For a set of nodes to be synchronized in the same network environment, the network delay data between one of the nodes to be synchronized and other nodes to be synchronized in different network environments is selected and determined as the network delay data corresponding to each node to be synchronized in the set of nodes to be synchronized.

[0090] If a large number of nodes need to be synchronized, this step can be simplified to reduce the impact of data packet communication on the network. Specifically, the configuration can be tailored to the network environment of each node. For example, devices on the same rack have identical network environments and configurations. Only one node needs to send data packets to obtain network latency data, and other nodes can copy this network latency data. Correspondingly, the same method can be used for devices within the same subnet.

[0091] As an example, after determining the network latency data between each node in the list of nodes to be synchronized, a network latency data table of the nodes to be synchronized can be generated (to form a network latency correction data list).

[0092] Step S20: Determine the network structure of the network where each node to be synchronized is located based on the list of nodes to be synchronized, and determine the network status of the network and the clock differences between the nodes to be synchronized based on the network delay data.

[0093] As an example, the network structure of the network in which each node to be synchronized is located is determined based on the list of nodes to be synchronized. Specifically, the network structure can be determined based on the topology of the networks in which different nodes to be synchronized are located in the list of nodes to be synchronized.

[0094] As an example, the network status of the network, such as network quality status, is also determined based on the network latency data.

[0095] For example, when node A sends timestamp data to node B, node B receives the data and queries the network delay record "NodeA":[10,20]. It compares the network fluctuation variance with a preset variance threshold. If the network fluctuation variance is greater than the preset variance threshold, it indicates that the network state between node A and node B is unstable. Otherwise, it determines that the network quality state is stable. In this embodiment, the network delay record of the node to be synchronized with unstable network quality state is marked and discarded. The corresponding node to be synchronized will not participate in the subsequent time synchronization process between nodes.

[0096] As an example, the clock differences between the nodes to be synchronized are also determined based on the network latency data;

[0097] As an example, after the network delay data table of the nodes to be synchronized is established, clock data can be transmitted between nodes in the following manner. If the network fluctuation variance is not greater than the preset variance threshold, the current time of node A is recorded according to the formula TATimeNow = TATimeSend + Tdelay, and a time data list of each node (clock difference situation) is formed. Here, TATimeNow represents the current time of A, TATimeSend represents the time recorded in the timestamp data sent by A to B, and Tdelay represents the network delay record data of A queried by B.

[0098] Step S30: Determine the clock synchronization scenario based on the network structure, the network status, and the clock difference.

[0099] In this embodiment, a clock synchronization scenario is determined based on the network structure, the network state, and the clock difference.

[0100] Among them, clock synchronization scenarios include scenarios that require hierarchical grouping and scenarios that do not require hierarchical grouping;

[0101] The scenarios that do not require hierarchical grouping include time synchronization scenarios within / between clusters (including scenarios involving the removal of unstable link node data due to unstable network conditions), etc.

[0102] Step S40: Select a matching clock synchronization algorithm according to the clock synchronization scenario, and perform clock synchronization on each node to be synchronized according to the matching clock synchronization algorithm.

[0103] After determining the clock synchronization scenario, a matching clock synchronization algorithm is selected based on the clock synchronization scenario, and clock synchronization is performed on each node to be synchronized according to the matching clock synchronization algorithm.

[0104] As an example, clock synchronization is achieved based on a self-coordination algorithm among the cluster nodes, without needing to access the public internet or deploy a local NTP server regularly. This avoids resource waste, unequal status among nodes, and security risks.

[0105] The step of selecting a matching clock synchronization algorithm based on the clock synchronization scenario includes:

[0106] Step S41: If the clock synchronization scenario is that the number of nodes to be synchronized is greater than or equal to the first preset number, and each node to be synchronized is located in a different subnet greater than the second preset number, then the hierarchical group synchronization algorithm is selected as the matching clock synchronization algorithm.

[0107] As an example, if the number of synchronization nodes is greater than 20 (the first preset number, which can be customized, with a default of 20), and each node is located in 3 or more subnets (the second preset number, which can be customized, with a default of 3), then the hierarchical grouping synchronization algorithm is executed. The synchronization algorithms within and between groups after hierarchical grouping are executed in the same way as when the hierarchical grouping algorithm is not executed.

[0108] Specifically, the hierarchical grouping synchronization algorithm performs intra-group clock synchronization processing on each node to be synchronized according to its subnet, then performs clock synchronization on representative nodes to be synchronized between different groups, and then synchronizes the clocks of other nodes to be synchronized within the group based on the representative node to be synchronized. The representative node to be synchronized is a node selected after the intra-group clock synchronization processing.

[0109] In other words, firstly, each group selects a synchronization algorithm to synchronize the local time within the group; then, a node is selected as a representative node to participate in secondary clock synchronization (inter-group clock synchronization) and update the local time of the representative node; finally, the time of other nodes in the group is synchronized based on the representative node. This hierarchical group synchronization algorithm is suitable for scenarios with a large number of synchronization nodes. Hierarchical grouping can significantly reduce the amount and complexity of synchronization communication. The synchronization method of first within the group, then between groups, and then within the group can minimize the impact of a single time-abnormal node and reduce the overall time error after synchronization. In addition, the selection and execution logic of the intra-group synchronization algorithm and the inter-group synchronization algorithm are similar to the algorithm selection and execution logic in the case where hierarchical group synchronization is not performed.

[0110] In this embodiment, it should be noted that the hierarchical group synchronization algorithm can reduce the impact of data packet communication on the network.

[0111] Step S42: If the clock synchronization scenario is that the number of nodes to be synchronized is less than the first preset number, select a matching clock synchronization algorithm based on whether the corresponding nodes to be synchronized have performed synchronization.

[0112] If the clock synchronization scenario involves a number of nodes to be synchronized that is less than the first preset number, a matching clock synchronization algorithm is selected based on whether the corresponding node to be synchronized has already performed synchronization. The matching clock synchronization algorithms include node weighted synchronization algorithm, manually designated authoritative node algorithm, self-elected authoritative node algorithm, clustering statistical synchronization algorithm, etc.

[0113] As an example, the step of selecting a matching clock synchronization algorithm based on whether the corresponding node to be synchronized has already performed synchronization when the number of nodes to be synchronized in the clock synchronization scenario is less than the first preset number includes any one of the following:

[0114] Step S421: If clock synchronization has never been performed between the nodes to be synchronized, and the difference between the clocks of different nodes to be synchronized is greater than the first preset time threshold, then the manually designated authoritative node algorithm is selected as the matching clock synchronization algorithm. The manually designated authoritative node algorithm is to manually set a node to be synchronized as the authoritative node and broadcast to inform other nodes to be synchronized to update their local clocks with the clock of the authoritative node.

[0115] As an example, the manual designation of authoritative nodes algorithm involves manually setting the local time of a single node based on internet time and broadcasting it to all other nodes to revise their local time according to that node's time. This manual designation of authoritative nodes algorithm is suitable for scenarios where there are large time differences between nodes or where most node times differ significantly from the real time (greater than a first preset time threshold) and where the network environment is relatively complex.

[0116] Step S422: If clock synchronization has been performed between the nodes to be synchronized, then the self-elected authoritative node algorithm is selected as the matching clock synchronization algorithm. In the self-elected authoritative node algorithm, the authoritative node is elected by each node to be synchronized, and the non-authoritative node updates its local clock time based on the clock of the authoritative node.

[0117] As an example, the self-elected authoritative node algorithm elects an authoritative node from each node to be synchronized, and non-authoritative nodes update their local clocks based on the clock of the authoritative node. That is, each node participating in the synchronization elects a temporary authoritative node using the self-elected algorithm, and non-authoritative nodes update their local data based on the data of the temporary authoritative node.

[0118] As an example, the self-elected authoritative node algorithm can be customized. For instance, the bully algorithm can be used among multiple nodes within the same rack. The self-elected authoritative node algorithm is suitable for scenarios where timed time corrections are performed on clusters that have already completed clock synchronization.

[0119] Step S423: If clock synchronization has never been performed between the nodes to be synchronized, and the difference between the clocks of different nodes to be synchronized is greater than the second preset time threshold, wherein the second preset time threshold is less than the first preset time threshold, then a preset clustering statistical synchronization algorithm is selected as the matching clock synchronization algorithm. The preset clustering statistical synchronization algorithm performs clustering statistics on the time of each node to be synchronized to obtain the highest frequency time distribution interval. Each node to be synchronized updates its local clock time based on the highest frequency time distribution interval.

[0120] As an example, for scenarios where the time differences between nodes are large (greater than a second preset time threshold, where the second preset time threshold is less than a first preset time threshold) and the network environment is complex, a preset clustering statistical synchronization algorithm is selected as the matching clock synchronization algorithm. In this algorithm, after each node obtains its node time data list, it performs clustering statistics on the delay data to obtain the highest frequency distribution interval. For example, using 3 seconds as the distribution interval unit, [TA-1s-TA+1s] is obtained as the highest frequency distribution interval, and TA is used as the reference clock to synchronize the local time.

[0121] Step S424: If a new node to be synchronized is detected and added to the list of nodes to be synchronized, a node weighted synchronization algorithm is selected as the matching clock synchronization algorithm. The node weighted synchronization algorithm is based on a preset clustering statistical synchronization algorithm, which performs weighted processing on some nodes to obtain the highest frequency time distribution interval. Each node to be synchronized updates its local clock time based on the highest frequency time distribution interval.

[0122] As an example, the node-weighted synchronization algorithm, as a matching clock synchronization algorithm, is suitable for scenarios where the time differences between nodes are large and the network environment is very complex. The node-weighted synchronization algorithm is based on the clustering statistical synchronization algorithm. When calculating the highest frequency distribution interval, some nodes are weighted. For example, devices in the same rack are assigned a weight of 5, devices in the same subnet are assigned a weight of 2, and devices in different subnets are assigned a weight of 1. Thus, the highest frequency time distribution interval is obtained, and each node to be synchronized updates its local clock time based on this highest frequency time distribution interval.

[0123] This application provides a clock synchronization method, apparatus, device, and storage medium. Compared with related technologies where clock synchronization requires the constant use of at least one local server (leading to high hardware resource consumption, disruption of node peer-to-peer relationships, and disruption of normal business operations due to central node malfunctions), resulting in low efficiency, this application obtains a list of nodes to be synchronized and determines the network latency data between each node in the list; determines the network structure of the network where each node is located based on the list of nodes to be synchronized, and determines the network status of the network and the clock differences between the nodes based on the network latency data; determines the clock synchronization scenario based on the network structure, network status, and clock differences; selects a matching clock synchronization algorithm based on the clock synchronization scenario, and performs clock synchronization on each node according to the matching clock synchronization algorithm. It is understood that in this application, the network structure is inferred from the obtained list of nodes to be synchronized, the network status and clock differences between nodes are inferred from the network latency data, and the clock synchronization scenario is automatically determined based on the network structure, network status and clock differences between nodes. Then, the clock synchronization algorithm is determined based on the clock synchronization scenario, and the synchronization of each node to be synchronized can be performed. In this process, resources, node peer-to-peer, and abnormal failures of the central node are fully considered. This achieves the goal of not needing to configure a fixed server, saving hardware resources, avoiding the destruction of node peer-to-peer due to resource binding, and avoiding the impact of abnormal failures of the central node on the normal operation of business, thus improving the efficiency and effectiveness of clock synchronization.

[0124] Furthermore, based on the first embodiment of this application, another embodiment of this application is provided, in which the network latency data includes the network fluctuation variance between each node to be synchronized and the other nodes to be synchronized;

[0125] The step of determining the clock synchronization scenario based on the network structure, the network state, and the clock difference includes:

[0126] Step S31: Identify unstable link nodes whose network fluctuation variance is greater than a preset variance threshold;

[0127] In this embodiment, nodes whose network fluctuation variance is greater than a preset variance threshold are considered as unstable link nodes. Specifically, for example, node A sends timestamp data to node B. After receiving the data, node B queries the network delay record "NodeA":[10,20] and compares the network fluctuation variance with the preset variance threshold. If the network fluctuation variance is greater than the preset variance threshold, it indicates that the network state between node A and node B is unstable.

[0128] Step S32: Determine the clock synchronization scenario based on the network structure of the network in which other nodes besides the unstable link nodes in the list of nodes to be synchronized are located, the network status of the network in which they are located, and the clock differences between the corresponding other nodes.

[0129] The step of selecting a matching clock synchronization algorithm based on the clock synchronization scenario and synchronizing the clocks of each node to be synchronized according to the matching clock synchronization algorithm includes:

[0130] Step S43: Select a matching clock synchronization algorithm according to the clock synchronization scenario, and perform clock synchronization on other nodes outside the unstable link node according to the matching clock synchronization algorithm;

[0131] In this embodiment, clock synchronization is performed on other nodes besides the unstable link node according to the matching clock synchronization algorithm. That is, the data of the unstable link node cannot be used as valid data to participate in the subsequent clock synchronization algorithm. Therefore, the data of the unstable link is discarded as low-reliability data to avoid the disturbance caused by network fluctuations to the convergence of the synchronization algorithm.

[0132] Step S44: Based on the other nodes besides the unstable link node after clock synchronization, perform clock synchronization compensation processing on the unstable link node.

[0133] As an example, the latency data between each (to be synchronized) node and other nodes includes the average network latency and network fluctuation variance. Nodes with large network fluctuation variance are identified as unstable nodes. After all stable nodes have completed time synchronization, time synchronization compensation is performed on the unstable nodes based on the nodes that have completed time synchronization.

[0134] The step of performing clock synchronization compensation processing on the unstable link node by other nodes besides the unstable link node after clock synchronization includes:

[0135] Step S441: Determine the target node that forms a stable link with the unstable link node from the other nodes, wherein the target node is determined by controlling the other nodes to send network delay correction data packets to the unstable link node;

[0136] Step S442: By controlling the target node to send a timestamp data packet to the unstable link node, the unstable link node updates its local clock time based on the timestamp data packet and reports a successful synchronization status.

[0137] As an example, this embodiment illustrates an implementable compensation scheme. Specifically, for unstable link nodes that have not yet completed time synchronization due to link instability, this scheme will issue a wake-up call after the stable link node completes synchronization. At the same time, each node that has completed time synchronization will periodically send network delay correction data packets and timestamp data packets to the unstable link node. The unstable link node regards all synchronized nodes as authoritative nodes. If a target node that forms a stable link with the unstable link node is determined from the other nodes (if an other node sends data packets to the unstable link node multiple times, and the network fluctuation variance for each time is within a preset variance threshold, then the link between the other node and the unstable link node is determined to be stable, and the other node is the target node), the local clock time is updated based on the timestamp data packet of the target node, and a synchronization success status is reported, ending the time synchronization attempts of other nodes.

[0138] As an example, if synchronization fails to complete after a certain period of time (this parameter can be customized, the default is 24 hours), an alarm will be triggered indicating that the node has failed to synchronize, reminding the user to manually set the time.

[0139] This application also provides a compensation synchronization scheme for unstable nodes that failed to complete the first round of time synchronization due to network instability. That is, while discarding low-reliability data and reducing the disturbance to the overall clock synchronization algorithm, the clock synchronization of all nodes to be synchronized is achieved.

[0140] Furthermore, based on the above embodiments of this application, another embodiment of this application is provided. In this embodiment, the step of synchronizing the clocks of each node to be synchronized according to the matched clock synchronization algorithm includes:

[0141] Step S45: Perform clock synchronization on each node to be synchronized according to the matching clock synchronization algorithm, and determine whether the time difference between each node is less than the preset time error threshold.

[0142] Step S46: If it is determined that the time difference between each node is less than the preset time error threshold, then clock synchronization is determined to be complete.

[0143] Step S47: If it is determined that the time difference between each node is not less than the preset time error threshold, then return to the step of obtaining the list of nodes to be synchronized.

[0144] Specifically, such as Figure 4As shown, after one round of clock synchronization algorithm execution is completed, a clock synchronization termination determination needs to be performed. Before the determination, a preset time error threshold needs to be set, that is, the maximum acceptable time error between nodes. If the time difference between all nodes is less than the time error threshold, the determination ends and clock synchronization is completed; otherwise, the clock synchronization algorithm is re-executed, and the determination is repeated after each re-execution until the determination ends.

[0145] In this embodiment, clock synchronization is considered complete if the time difference between all nodes is less than a preset time error threshold. If the time difference between all nodes is not less than the preset time error threshold, the process returns to obtaining the list of nodes to be synchronized. This embodiment avoids unlimited clock synchronization to prevent resource waste.

[0146] Reference Figure 3 , Figure 3 This is a schematic diagram of the device structure of the hardware operating environment involved in the embodiments of this application.

[0147] like Figure 3 As shown, the clock synchronization device may include: a processor 1001, a memory 1005, and a communication bus 1002. The communication bus 1002 is used to realize the connection and communication between the processor 1001 and the memory 1005.

[0148] Optionally, the clock synchronization device may also include a user interface, a network interface, a camera, RF (Radio Frequency) circuitry, sensors, a WiFi module, etc. The user interface may include a display screen, an input submodule such as a keyboard, and optionally, a standard wired or wireless interface. The network interface may include a standard wired or wireless interface (such as a Wi-Fi interface).

[0149] Those skilled in the art will understand that Figure 3 The clock synchronization device structure shown does not constitute a limitation on the clock synchronization device, and may include more or fewer components than shown, or combine certain components, or have different component arrangements.

[0150] like Figure 3 As shown, the memory 1005, serving as a storage medium, may include an operating system, a network communication module, and a clock synchronization program. The operating system is a program that manages and controls the hardware and software resources of the clock synchronization device, supporting the operation of the clock synchronization program and other software and / or programs. The network communication module is used to enable communication between the cameras within the memory 1005, as well as communication with other hardware and software within the device.

[0151] exist Figure 3In the clock synchronization device shown, the processor 1001 is used to execute the clock synchronization program stored in the memory 1005 to implement the steps of the clock synchronization method described above.

[0152] The specific implementation of the clock synchronization device in this application is basically the same as the various embodiments of the clock synchronization method described above, and will not be repeated here.

[0153] This application also provides a clock synchronization device, the device comprising:

[0154] The acquisition module is used to acquire a list of nodes to be synchronized and determine the network latency data between each node in the list.

[0155] The first determining module is used to determine the network structure of the network where each node to be synchronized is located based on the list of nodes to be synchronized, and to determine the network status of the network and the clock difference between the nodes to be synchronized based on the network delay data.

[0156] The second determining module is used to determine the clock synchronization scenario based on the network structure, the network state, and the clock difference.

[0157] A matching clock synchronization algorithm is selected based on the clock synchronization scenario, and clock synchronization is performed on each node to be synchronized according to the matching clock synchronization algorithm.

[0158] In one possible implementation of this application, the network latency data includes the network fluctuation variance between each node to be synchronized and the other nodes to be synchronized;

[0159] The clock synchronization device is used to achieve:

[0160] Identify unstable link nodes whose network fluctuation variance exceeds a preset variance threshold;

[0161] Based on the network structure of the network in which the nodes other than the unstable link nodes in the list of nodes to be synchronized are located, the network status of the network in which they are located, and the differences in clocks between the corresponding other nodes, determine the clock synchronization scenario.

[0162] The step of selecting a matching clock synchronization algorithm based on the clock synchronization scenario and synchronizing the clocks of each node to be synchronized according to the matching clock synchronization algorithm includes:

[0163] Select a matching clock synchronization algorithm based on the clock synchronization scenario, and perform clock synchronization on other nodes besides the unstable link node based on the matching clock synchronization algorithm;

[0164] Based on the other nodes besides the unstable link node after clock synchronization, clock synchronization compensation processing is performed on the unstable link node.

[0165] In one possible implementation of this application, the clock synchronization device is used to achieve:

[0166] Determine the target node from the other nodes to form a stable link with the unstable link node, wherein the target node is determined by controlling the other nodes to send network delay correction data packets to the unstable link node;

[0167] By controlling the target node to send timestamp data packets to the unstable link node, the unstable link node updates its local clock time based on the timestamp data packets and reports a successful synchronization status.

[0168] In one possible implementation of this application, the clock synchronization device is used to achieve:

[0169] If the clock synchronization scenario involves a number of nodes to be synchronized that is greater than or equal to a first preset number, and each node to be synchronized is located in a different subnet that is greater than a second preset number, then a hierarchical group synchronization algorithm is selected as the matching clock synchronization algorithm. The hierarchical group synchronization algorithm performs intra-group clock synchronization processing on each node to be synchronized according to its subnet, then performs clock synchronization on the representative node to be synchronized between different groups, and then synchronizes the clocks of other nodes to be synchronized within the group based on the representative node to be synchronized. The representative node to be synchronized is a node selected after the intra-group clock synchronization processing.

[0170] If the clock synchronization scenario involves a number of nodes to be synchronized that is less than the first preset number, a matching clock synchronization algorithm is selected based on whether the corresponding node to be synchronized has already performed synchronization.

[0171] In one possible implementation of this application, the clock synchronization device is used to achieve one of the following:

[0172] If clock synchronization has never been performed between the nodes to be synchronized, and the difference between the clocks of different nodes to be synchronized is greater than the first preset time threshold, then the manually designated authoritative node algorithm is selected as the matching clock synchronization algorithm. The manually designated authoritative node algorithm is to manually set a node to be synchronized as the authoritative node and broadcast it to inform other nodes to be synchronized to update their local clocks with the clock of the authoritative node.

[0173] If clock synchronization has been performed between the nodes to be synchronized, then the self-elected authoritative node algorithm is selected as the matching clock synchronization algorithm. In the self-elected authoritative node algorithm, each node to be synchronized elects an authoritative node, and non-authoritative nodes update their local clocks based on the clock of the authoritative node.

[0174] If clock synchronization has never been performed between the nodes to be synchronized, and the difference between the clocks of different nodes to be synchronized is greater than the second preset time threshold, wherein the second preset time threshold is less than the first preset time threshold, then a preset clustering statistical synchronization algorithm is selected as the matching clock synchronization algorithm. The preset clustering statistical synchronization algorithm performs clustering statistics on the time of each node to be synchronized to obtain the highest frequency time distribution interval, and each node to be synchronized updates its local clock time based on the highest frequency time distribution interval.

[0175] If a new node to be synchronized is detected and added to the list of nodes to be synchronized, a node weighted synchronization algorithm is selected as the matching clock synchronization algorithm. The node weighted synchronization algorithm is based on a preset clustering statistical synchronization algorithm, which performs weighted processing on some nodes to obtain the highest frequency time distribution interval. Each node to be synchronized updates its local clock time based on the highest frequency time distribution interval.

[0176] In one possible implementation of this application, the clock synchronization device is used to achieve:

[0177] The clock is synchronized for each node to be synchronized according to the matching clock synchronization algorithm, and it is determined whether the time difference between each node is less than the preset time error threshold.

[0178] If it is determined that the time difference between each node is less than the preset time error threshold, then clock synchronization is considered complete.

[0179] If it is determined that the time difference between each node is not less than the preset time error threshold, then return to the step of obtaining the list of nodes to be synchronized.

[0180] In one possible implementation of this application, the step of determining the network latency data between each node in the list of nodes to be synchronized includes:

[0181] For a set of nodes to be synchronized in the same network environment, the network delay data between one of the nodes to be synchronized and other nodes to be synchronized in different network environments is selected and determined as the network delay data corresponding to each node to be synchronized in the set of nodes to be synchronized.

[0182] The specific implementation of the clock synchronization device in this application is basically the same as the embodiments of the clock synchronization method described above, and will not be repeated here.

[0183] This application provides a storage medium that stores one or more programs, which can be executed by one or more processors to implement the steps of the clock synchronization method described in any of the above claims.

[0184] The specific implementation of the storage medium in this application is basically the same as the various embodiments of the clock synchronization method described above, and will not be repeated here.

[0185] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the clock synchronization method described above.

[0186] The specific implementation of the computer program product in this application is basically the same as the various embodiments of the clock synchronization method described above, and will not be repeated here.

[0187] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.

[0188] The sequence numbers of the above embodiments of the present invention are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.

[0189] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of a software plus hardware platform, or by hardware, but in many cases the former is a better implementation. Based on this understanding, the technical solution of the present invention, or the part that contributes to the related technology, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM) and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in the various embodiments of the present invention.

[0190] The above are merely preferred embodiments of the present invention and do not limit the scope of the patent. Any equivalent structural or procedural transformations made based on the description and drawings of the present invention, or direct or indirect applications in other related technical fields, are similarly included within the scope of patent protection of the present invention.

Claims

1. A clock synchronization method, characterized in that, The method includes: Obtain the list of nodes to be synchronized and determine the network latency data between each node in the list. The network structure of the network in which each node to be synchronized is located is determined based on the list of nodes to be synchronized, and the network status of the network in which the node is located and the clock differences between each node to be synchronized are determined based on the network delay data. Based on the network structure, the network status, and the clock difference, determine the clock synchronization scenario; Select a matching clock synchronization algorithm based on the clock synchronization scenario, and perform clock synchronization on each node to be synchronized according to the matching clock synchronization algorithm. The network latency data includes the network fluctuation variance between each node to be synchronized and the other nodes to be synchronized. The step of determining the clock synchronization scenario based on the network structure, the network state, and the clock difference includes: Identify unstable link nodes whose network fluctuation variance exceeds a preset variance threshold; Based on the network structure of the network in which the nodes other than the unstable link nodes in the list of nodes to be synchronized are located, the network status of the network in which they are located, and the differences in clocks between the corresponding other nodes, the clock synchronization scenario is determined.

2. The clock synchronization method as described in claim 1, characterized in that, The step of selecting a matching clock synchronization algorithm based on the clock synchronization scenario and synchronizing the clocks of each node to be synchronized according to the matching clock synchronization algorithm includes: Select a matching clock synchronization algorithm based on the clock synchronization scenario, and perform clock synchronization on other nodes besides the unstable link node based on the matching clock synchronization algorithm; Based on the other nodes besides the unstable link node after clock synchronization, clock synchronization compensation processing is performed on the unstable link node.

3. The clock synchronization method as described in claim 2, characterized in that, The step of performing clock synchronization compensation processing on the unstable link node by other nodes besides the unstable link node after clock synchronization includes: Determine the target node from the other nodes to form a stable link with the unstable link node, wherein the target node is determined by controlling the other nodes to send network delay correction data packets to the unstable link node; By controlling the target node to send timestamp data packets to the unstable link node, the unstable link node updates its local clock time based on the timestamp data packets and reports a successful synchronization status.

4. The clock synchronization method as described in claim 1, characterized in that, The step of selecting a matching clock synchronization algorithm based on the clock synchronization scenario includes: If the clock synchronization scenario involves a number of nodes to be synchronized that is greater than or equal to a first preset number, and each node to be synchronized is located in a different subnet that is greater than a second preset number, then the hierarchical group synchronization algorithm is selected as the matching clock synchronization algorithm. If the clock synchronization scenario involves a number of nodes to be synchronized that is less than the first preset number, a matching clock synchronization algorithm is selected based on whether the corresponding node to be synchronized has already performed synchronization.

5. The clock synchronization method as described in claim 4, characterized in that, The step of selecting a matching clock synchronization algorithm based on whether the corresponding node to be synchronized has already performed synchronization when the number of nodes to be synchronized in the clock synchronization scenario is less than the first preset number includes any one of the following: If clock synchronization has never been performed between the nodes to be synchronized, and the difference between the clocks of different nodes to be synchronized is greater than the first preset time threshold, then the manually designated authoritative node algorithm is selected as the matching clock synchronization algorithm. The manually designated authoritative node algorithm is to manually set a node to be synchronized as the authoritative node and broadcast it to inform other nodes to be synchronized to update their local clocks with the clock of the authoritative node. If clock synchronization has been performed between the nodes to be synchronized, then the self-elected authoritative node algorithm is selected as the matching clock synchronization algorithm. In the self-elected authoritative node algorithm, each node to be synchronized elects an authoritative node, and non-authoritative nodes update their local clocks based on the clock of the authoritative node. If clock synchronization has never been performed between the nodes to be synchronized, and the difference between the clocks of different nodes to be synchronized is greater than the second preset time threshold, wherein the second preset time threshold is less than the first preset time threshold, then a preset clustering statistical synchronization algorithm is selected as the matching clock synchronization algorithm. The preset clustering statistical synchronization algorithm performs clustering statistics on the time of each node to be synchronized to obtain the highest frequency time distribution interval, and each node to be synchronized updates its local clock time based on the highest frequency time distribution interval. If a new node to be synchronized is detected and added to the list of nodes to be synchronized, a node weighted synchronization algorithm is selected as the matching clock synchronization algorithm. The node weighted synchronization algorithm is based on a preset clustering statistical synchronization algorithm, which performs weighted processing on some nodes to obtain the highest frequency time distribution interval. Each node to be synchronized updates its local clock time based on the highest frequency time distribution interval.

6. The clock synchronization method as described in claim 1, characterized in that, The step of synchronizing the clocks of each node to be synchronized according to the matched clock synchronization algorithm includes: The clock is synchronized for each node to be synchronized according to the matching clock synchronization algorithm, and it is determined whether the time difference between each node is less than the preset time error threshold. If it is determined that the time difference between each node is less than the preset time error threshold, then clock synchronization is considered complete. If it is determined that the time difference between each node is not less than the preset time error threshold, then return to the step of obtaining the list of nodes to be synchronized.

7. The clock synchronization method as described in claim 1, characterized in that, The step of determining the network latency data between each node in the list of nodes to be synchronized includes: For a set of nodes to be synchronized in the same network environment, the network delay data between one of the nodes to be synchronized and other nodes to be synchronized in different network environments is selected and determined as the network delay data corresponding to each node to be synchronized in the set of nodes to be synchronized.

8. A clock synchronization device, characterized in that, The device includes: The acquisition module is used to acquire a list of nodes to be synchronized and determine the network latency data between each node in the list. The first determining module is used to determine the network structure of the network where each node to be synchronized is located based on the list of nodes to be synchronized, and to determine the network status of the network and the clock difference between each node to be synchronized based on the network delay data. The second determining module is used to determine the clock synchronization scenario based on the network structure, the network state, and the clock difference. Select a matching clock synchronization algorithm based on the clock synchronization scenario, and perform clock synchronization on each node to be synchronized according to the matching clock synchronization algorithm. The network latency data includes the network fluctuation variance between each node to be synchronized and the other nodes to be synchronized. The second determining module is used to implement: Identify unstable link nodes whose network fluctuation variance exceeds a preset variance threshold; Based on the network structure of the network in which the nodes other than the unstable link nodes in the list of nodes to be synchronized are located, the network status of the network in which they are located, and the differences in clocks between the corresponding other nodes, the clock synchronization scenario is determined.

9. A clock synchronization device, characterized in that, The method includes a memory, a processor, and a clock synchronization program stored in the memory and executable on the processor, wherein the processor, when executing the clock synchronization program, implements the steps of the clock synchronization method according to any one of claims 1 to 7.

10. A storage medium, characterized in that, The storage medium stores a clock synchronization program, which, when executed by a processor, implements the steps of the clock synchronization method as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Distributed time synchronization method for hierarchical clustering wireless self-organized network

    CN102665268A

  • Clock synchronization method and device and electronic equipment

    CN111490844A