Clock synchronization method, device and system and computer readable storage medium

By using network state prediction equipment and network quality prediction models in the clock synchronization system, dynamically adjusting the transmission frequency of clock synchronization messages, the problem of inconsistency and simple clock synchronization in the existing technology is solved, and high-precision and stable clock synchronization are achieved.

CN119853836APending Publication Date: 2025-04-18TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311348671.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-10-17
Publication Date
2025-04-18

AI Technical Summary

Technical Problem

The prior art fails to provide a general and simple method to achieve clock synchronization, especially in communication scenarios facing high synchronization requirements.

Method used

By introducing network status prediction equipment into the clock synchronization system, the network quality prediction model is used to predict the network quality status within the next period, thereby determining the target transmission frequency and realizing clock synchronization between the terminal device and the synchronization server.

Benefits of technology

This method realizes the universality and simplicity of clock synchronization, and can dynamically adjust the transmission frequency of clock synchronization messages according to network quality, thereby improving synchronization accuracy and stability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119853836A_ABST
    Figure CN119853836A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a clock synchronization method which is applied to a clock synchronization system, the clock synchronization system comprises a network state prediction device, a terminal device and a synchronization server, the terminal device communicates with the network state prediction device and the synchronization server, and the method is executed by the network state prediction device. Comprising the steps that the current clock synchronization state of terminal equipment is determined, if the current clock synchronization state is a time service state, current network data between the terminal equipment and a synchronization server is acquired, the current network data at least comprises network data of the current time period, and then the terminal equipment is synchronized based on the current network data. And predicting a network quality state in the next time period through the network quality prediction model, so as to determine a target sending frequency based on the network quality state, the target sending frequency being a frequency at which the terminal device sends a clock synchronization message to the synchronization server.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of computer technology. Specifically, the present application relates to a clock synchronization method, device, system and computer-readable storage medium. Background Art

[0002] As the basic supporting technology of digital communication network, the development and evolution of clock synchronization technology has always been driven by the development of communication network technology. With the continuous development of new communication services and technologies, the synchronization requirements are getting higher and higher. Basic clock technologies such as clock sources and phase-locked loops have undergone multiple upgrades, and synchronization technologies are constantly being innovated. Time synchronization technology is the focus of current industry attention.

[0003] Clock synchronization technology is very important in any time-sensitive project, for example, it can be used for deterministic communication of critical data in scenarios such as industrial control and vehicle networks. However, a universal and easy-to-use method for clock synchronization has not yet been proposed. Summary of the invention

[0004] The purpose of the embodiment of the present application is to provide a universal and simple method to achieve clock synchronization. In order to achieve the above purpose, the technical solution provided by the embodiment of the present application is as follows:

[0005] In a first aspect, a clock synchronization method is provided, which is applied to a clock synchronization system, wherein the clock synchronization system includes a network status prediction device, a terminal device, and a synchronization server, wherein the terminal device communicates with the network status prediction device and the synchronization server respectively, and the method is performed by the network status prediction device, including:

[0006] Determining a current clock synchronization state of the terminal device;

[0007] If the current clock synchronization state is a timing state, obtaining current network data between the terminal device and the synchronization server, wherein the current network data at least includes network data of a current period;

[0008] Based on the current network data, the network quality status in the next time period is predicted through a network quality prediction model to determine the target sending frequency based on the network quality status. The target sending frequency is the frequency at which the terminal device sends clock synchronization messages to the synchronization server.

[0009] In a possible implementation, if the current clock synchronization state is a punctual state, the duration of the punctual state is determined by the synchronization server according to the network quality state in the next time period;

[0010] If the network quality in the next period is the first quality state, determining the duration of the punctual state to be the first duration;

[0011] If the network quality in the next period is the second quality state, determining the duration of the punctual state to be the second duration;

[0012] The network quality corresponding to the first quality state is higher than the network quality corresponding to the second quality state, and the first duration is shorter than the second duration.

[0013] In a possible implementation manner, determining a target sending frequency of a clock synchronization message according to the network quality status includes:

[0014] If the network quality state is the first quality state, determining the target sending frequency of the clock synchronization message to be the first sending frequency;

[0015] If the network quality state is the second quality state, determining the target sending frequency of the clock synchronization message to be the second sending frequency;

[0016] The network quality corresponding to the first quality state is higher than the network quality corresponding to the second quality state, and the first sending frequency is lower than the second sending frequency.

[0017] In another possible implementation manner, when the current clock synchronization state is a punctual state, the method further includes:

[0018] Determine a network fluctuation state within a next period of time, wherein the network fluctuation state includes a network fluctuation state or a non-network fluctuation state;

[0019] Wherein, in the case of a network fluctuation state, if the network fluctuation level is the first level, the clock synchronization state of the terminal device is changed from the timekeeping state to the timing state, and if the network fluctuation level is the second level, the clock synchronization state of the terminal device is maintained, and the network fluctuation level represents the continuous fluctuation duration of the network, and the continuous fluctuation duration corresponding to the first level is greater than the continuous fluctuation duration corresponding to the second level;

[0020] In the case of non-network fluctuation state, the clock synchronization state of the terminal device is maintained;

[0021] For a terminal device whose current clock synchronization state is a timing state, when the current clock synchronization accuracy is detected to meet the clock accuracy requirement, the clock synchronization state of the terminal device is changed from the timing state to the timekeeping state.

[0022] In another possible implementation, for a terminal device whose current clock synchronization state is a timing state, when the current clock synchronization accuracy is detected to meet the clock accuracy requirement, the clock synchronization state of the terminal device is changed from the timing state to the punctual state;

[0023] Whether the current clock synchronization accuracy meets the clock accuracy requirement is determined in the following manner:

[0024] Obtaining a synchronization accuracy threshold, an uplink delay, and a downlink delay, wherein the uplink delay is a transmission delay of a clock synchronization message, and the downlink delay is a transmission delay of a delay request message, wherein the delay request message is sent by the synchronization server to the terminal device after receiving the clock synchronization message;

[0025] determining a time difference between the uplink delay and the downlink delay;

[0026] If the time difference is not greater than the synchronization accuracy threshold, determining that the current clock synchronization accuracy meets the clock accuracy requirement;

[0027] If the time difference is greater than the synchronization accuracy threshold, it is determined that the current clock synchronization accuracy does not meet the clock accuracy requirement.

[0028] In another possible implementation manner, the clock synchronization between the terminal device and the synchronization server is implemented by the synchronization server based on the clock synchronization message in the following manner:

[0029] For each clock synchronization process in at least one clock synchronization process in the next time period, based on the clock synchronization message of the clock synchronization process, obtaining the initial time offset between the terminal device and the synchronization server in the clock synchronization process;

[0030] Obtain clock synchronization error compensation value;

[0031] Based on the clock synchronization error compensation value, correct the initial time offset corresponding to at least one clock synchronization process in the next time period to obtain a target time offset corresponding to each clock synchronization process;

[0032] Based on the target time offset corresponding to each clock synchronization process, clock synchronization is performed between the terminal device and the synchronization server.

[0033] In another possible implementation manner, the clock synchronization error compensation value is determined in the following manner:

[0034] Acquire historical synchronization data, wherein the historical synchronization data includes synchronization data in at least one historical clock synchronization process between the terminal device and the synchronization server, and the historical synchronization data includes: uplink delay and downlink delay; wherein the uplink delay is the transmission delay of the clock synchronization message, and the downlink delay is the transmission delay of the delay request message, wherein the delay request message is sent by the synchronization server to the terminal device after receiving the clock synchronization message sent by the terminal device;

[0035] Based on the historical synchronization data, the clock synchronization error compensation value is determined.

[0036] In another possible implementation, the historical synchronization data is obtained in the following manner:

[0037] According to the window size of the moving window, the latest historical synchronization data corresponding to the window size before the next time period is obtained, and the window size corresponds to at least one clock synchronization process; the number of at least one clock synchronization process in the next time period corresponds to the moving step size of the moving window.

[0038] In a second aspect, a clock synchronization method is provided, which is applied to a clock synchronization system, wherein the clock synchronization system comprises at least a network status prediction device, a terminal device, and a synchronization server, wherein the terminal device communicates with the network status prediction device and the synchronization server respectively, and the method is executed by the synchronization server, comprising:

[0039] Receiving a clock synchronization message sent by the terminal device;

[0040] Perform clock synchronization based on the clock synchronization message;

[0041] Wherein, the clock synchronization message is sent by the network status prediction device to the synchronization server by controlling the terminal device;

[0042] The clock synchronization message is sent by the network status prediction device to the synchronization server by controlling the terminal device in the following manner:

[0043] Determining a current clock synchronization state of the terminal device;

[0044] If the current clock synchronization state is a timing state, obtaining current network data between the terminal device and the synchronization server, wherein the current network data at least includes network data of a current period;

[0045] Based on the current network data, the network quality status in the next time period is predicted through a network quality prediction model to determine the target sending frequency based on the network quality status. The target sending frequency is the frequency at which the terminal device sends clock synchronization messages to the synchronization server.

[0046] In a possible implementation, if the current clock synchronization state is a punctual state, then the duration of the punctual state is determined according to the network quality state in the next time period;

[0047] If the network quality in the next time period is the first quality state, determining the duration of the punctual state to be the first duration;

[0048] If the network quality in the next time period is the second quality state, determining the duration of the punctual state to be the second duration;

[0049] The network quality corresponding to the first quality state is higher than the network quality corresponding to the second quality state, and the first duration is shorter than the second duration.

[0050] In a possible implementation, for a terminal device whose current clock synchronization state is a timing state, the method further includes:

[0051] Determine the current clock synchronization accuracy;

[0052] When it is detected that the current clock synchronization accuracy reaches the clock accuracy requirement, the clock synchronization state of the terminal device is controlled to be changed from the timing state to the punctual state.

[0053] In another possible implementation, a method of determining whether the current clock synchronization accuracy meets the clock accuracy requirement includes:

[0054] Obtaining a synchronization accuracy threshold, an uplink delay, and a downlink delay, wherein the uplink delay is a transmission delay of a clock synchronization message, and the downlink delay is a transmission delay of a delay request message, wherein the delay request message is sent by the synchronization server to the terminal device after receiving the clock synchronization message;

[0055] determining a time difference between the uplink delay and the downlink delay;

[0056] If the time difference is not greater than the synchronization accuracy threshold, determining that the current clock synchronization accuracy meets the clock accuracy requirement;

[0057] If the time difference is greater than the synchronization accuracy threshold, it is determined that the current clock synchronization accuracy does not meet the clock accuracy requirement.

[0058] In another possible implementation manner, when the current clock synchronization state is a punctual state, the method further includes:

[0059] Receiving network fluctuation state indication information sent by the network state prediction device, wherein the network fluctuation state indication information is used to indicate whether the network fluctuation state in the next time period is a network fluctuation state or a non-network fluctuation state;

[0060] If the network is in a fluctuating state, the network fluctuation level is continuously detected;

[0061] If it is the first level, the clock synchronization state of the terminal device is changed from the timekeeping state to the time service state;

[0062] If it is the second level, the clock synchronization state of the terminal device is maintained.

[0063] In another possible implementation, performing clock synchronization on each clock synchronization process in at least one clock synchronization process in a next time period includes:

[0064] For each clock synchronization process in at least one clock synchronization process, based on the clock synchronization message of the clock synchronization process, obtaining an initial time offset between the terminal device and the synchronization server in the clock synchronization process;

[0065] Obtain clock synchronization error compensation value;

[0066] Based on the clock synchronization error compensation value, correct the initial time offset corresponding to at least one clock synchronization process in the next time period to obtain a target time offset corresponding to each clock synchronization process;

[0067] Based on the target time offset corresponding to each clock synchronization process, clock synchronization is performed between the terminal device and the synchronization server.

[0068] In another possible implementation manner, obtaining the clock synchronization error compensation value includes:

[0069] Acquire historical synchronization data, wherein the historical synchronization data includes synchronization data in at least one historical clock synchronization process between the terminal device and the synchronization server, and the historical synchronization data includes: uplink delay and downlink delay; wherein the uplink delay is the transmission delay of the clock synchronization message, and the downlink delay is the transmission delay of the delay request message, wherein the delay request message is sent by the synchronization server to the terminal device after receiving the clock synchronization message sent by the terminal device;

[0070] Based on the historical synchronization data, the clock synchronization error compensation value is determined.

[0071] In another possible implementation, the acquiring of historical synchronization data includes:

[0072] According to the window size of the moving window, the latest historical synchronization data corresponding to the window size before the next time period is obtained, and the window size corresponds to at least one clock synchronization process; the number of at least one clock synchronization process in the next time period corresponds to the moving step size of the moving window.

[0073] In another possible implementation manner, determining the clock synchronization error compensation value based on the historical synchronization data includes:

[0074] The target uplink delay is obtained by integrating the uplink delays corresponding to each historical clock synchronization.

[0075] The target downlink delay is obtained by integrating the downlink delays corresponding to each historical clock synchronization.

[0076] A difference between the target uplink delay and the target downlink delay is determined as the clock synchronization error compensation value.

[0077] In a third aspect, a network status prediction device is provided, which is applied to a clock synchronization system, wherein the clock synchronization system further includes a terminal device and a synchronization server, wherein the terminal device communicates with the network prediction device and the synchronization server respectively, and the network status prediction device includes:

[0078] A synchronization state determination module, used to determine the current clock synchronization state of the terminal device;

[0079] A network data acquisition module, used for acquiring current network data between the terminal device and the synchronization server when the current clock synchronization state is a timing state, wherein the current network data at least includes network data of a current period;

[0080] The quality status prediction module is used to predict the network quality status in the next time period based on the current network data and through a network quality prediction model, so as to determine the target sending frequency based on the network quality status. The target sending frequency is the frequency at which the terminal device sends clock synchronization messages to the synchronization server.

[0081] In a possible implementation manner, when the quality status prediction module determines the target sending frequency of the clock synchronization message according to the network quality status, it is specifically used to:

[0082] If the network quality state is the first quality state, determining the target sending frequency of the clock synchronization message to be the first sending frequency;

[0083] If the network quality state is the second quality state, determining the target sending frequency of the clock synchronization message to be the second sending frequency;

[0084] The network quality corresponding to the first quality state is higher than the network quality corresponding to the second quality state, and the first sending frequency is lower than the second sending frequency.

[0085] In another possible implementation, when the current clock synchronization state is a punctual state, the device further includes: a fluctuation state determination module, wherein:

[0086] The fluctuation state determination module is used to determine the network fluctuation state in the next period of time, wherein the network fluctuation state includes a network fluctuation state or a non-network fluctuation state;

[0087] Wherein, in the case of a network fluctuation state, if the network fluctuation level is the first level, the clock synchronization state of the terminal device is changed from the timekeeping state to the timing state, and if the network fluctuation level is the second level, the clock synchronization state of the terminal device is maintained, and the network fluctuation level represents the continuous fluctuation duration of the network, and the continuous fluctuation duration corresponding to the first level is greater than the continuous fluctuation duration corresponding to the second level;

[0088] In the case of non-network fluctuation state, the clock synchronization state of the terminal device is maintained;

[0089] For a terminal device whose current clock synchronization state is a timing state, when the current clock synchronization accuracy is detected to meet the clock accuracy requirement, the clock synchronization state of the terminal device is changed from the timing state to the timekeeping state.

[0090] In another possible implementation, for a terminal device whose current clock synchronization state is a timing state, when the current clock synchronization accuracy is detected to meet the clock accuracy requirement, the clock synchronization state of the terminal device is changed from the timing state to the punctual state;

[0091] Whether the current clock synchronization accuracy meets the clock accuracy requirement is determined in the following manner:

[0092] Obtaining a synchronization accuracy threshold, an uplink delay, and a downlink delay, wherein the uplink delay is a transmission delay of a clock synchronization message, and the downlink delay is a transmission delay of a delay request message, wherein the delay request message is sent by the synchronization server to the terminal device after receiving the clock synchronization message;

[0093] determining a time difference between the uplink delay and the downlink delay;

[0094] If the time difference is not greater than the synchronization accuracy threshold, determining that the current clock synchronization accuracy meets the clock accuracy requirement;

[0095] If the time difference is greater than the synchronization accuracy threshold, it is determined that the current clock synchronization accuracy does not meet the clock accuracy requirement.

[0096] In another possible implementation manner, the clock synchronization between the terminal device and the synchronization server is implemented by the synchronization server based on the clock synchronization message in the following manner:

[0097] For each clock synchronization process in at least one clock synchronization process in the next time period, based on the clock synchronization message of the clock synchronization process, obtaining the initial time offset between the terminal device and the synchronization server in the clock synchronization process;

[0098] Obtain clock synchronization error compensation value;

[0099] Based on the clock synchronization error compensation value, correct the initial time offset corresponding to at least one clock synchronization process in the next time period to obtain a target time offset corresponding to each clock synchronization process;

[0100] Based on the target time offset corresponding to each clock synchronization process, clock synchronization is performed between the terminal device and the synchronization server.

[0101] In another possible implementation manner, the clock synchronization error compensation value is determined in the following manner:

[0102] Acquire historical synchronization data, wherein the historical synchronization data includes synchronization data in at least one historical clock synchronization process between the terminal device and the synchronization server, and the historical synchronization data includes: uplink delay and downlink delay; wherein the uplink delay is the transmission delay of the clock synchronization message, and the downlink delay is the transmission delay of the delay request message, wherein the delay request message is sent by the synchronization server to the terminal device after receiving the clock synchronization message sent by the terminal device;

[0103] Based on the historical synchronization data, the clock synchronization error compensation value is determined.

[0104] In another possible implementation, the historical synchronization data is obtained in the following manner:

[0105] According to the window size of the moving window, the latest historical synchronization data corresponding to the window size before the next time period is obtained, and the window size corresponds to at least one clock synchronization process; the number of at least one clock synchronization process in the next time period corresponds to the moving step size of the moving window.

[0106] In a fourth aspect, a synchronization server is provided, which is applied to a clock synchronization system, wherein the clock synchronization system comprises at least a network status prediction device and a terminal device, wherein the terminal device communicates with the network status prediction device and the synchronization server respectively, and the synchronization server comprises:

[0107] A first receiving module, used to receive a clock synchronization message sent by the terminal device;

[0108] A clock synchronization module, used for performing clock synchronization based on the clock synchronization message;

[0109] Wherein, the clock synchronization message is sent by the network status prediction device to the synchronization server by controlling the terminal device;

[0110] The clock synchronization message is sent by the network status prediction device to the synchronization server by controlling the terminal device in the following manner:

[0111] Determining a current clock synchronization state of the terminal device;

[0112] If the current clock synchronization state is a timing state, obtaining current network data between the terminal device and the synchronization server, wherein the current network data at least includes network data of a current period;

[0113] Based on the current network data, the network quality status in the next time period is predicted through a network quality prediction model to determine the target sending frequency based on the network quality status. The target sending frequency is the frequency at which the terminal device sends clock synchronization messages to the synchronization server.

[0114] In a possible implementation, for a terminal device whose current clock synchronization state is a timing state, the synchronization server further includes: a synchronization accuracy determination module and a first change module, wherein:

[0115] The synchronization accuracy determination module is used to determine the current clock synchronization accuracy;

[0116] The first changing module is used to control the clock synchronization state of the terminal device to be changed from the timing state to the punctual state when it is detected that the current clock synchronization accuracy reaches the clock accuracy requirement.

[0117] In another possible implementation, when determining whether the current clock synchronization accuracy meets the clock accuracy requirement, the synchronization accuracy determination module is specifically used to:

[0118] Obtaining a synchronization accuracy threshold, an uplink delay, and a downlink delay, wherein the uplink delay is a transmission delay of a clock synchronization message, and the downlink delay is a transmission delay of a delay request message, wherein the delay request message is sent by the synchronization server to the terminal device after receiving the clock synchronization message;

[0119] determining a time difference between the uplink delay and the downlink delay;

[0120] If the time difference is not greater than the synchronization accuracy threshold, determining that the current clock synchronization accuracy meets the clock accuracy requirement;

[0121] If the time difference is greater than the synchronization accuracy threshold, it is determined that the current clock synchronization accuracy does not meet the clock accuracy requirement.

[0122] In another possible implementation, when the current clock synchronization state is a punctual state, the synchronization server further includes: a second receiving module, a continuous detection module, a second changing module, and a state maintaining module, wherein:

[0123] The second receiving module is used to receive the network fluctuation state indication information sent by the network state prediction device, and the network fluctuation state indication information is used to indicate whether the network fluctuation state in the next time period is a network fluctuation state or a non-network fluctuation state;

[0124] The continuous detection module is used to continuously detect the network fluctuation level of the network fluctuation when the network is in a fluctuation state;

[0125] The second changing module is used to change the clock synchronization state of the terminal device from the timekeeping state to the timing state when it is at the first level;

[0126] The state maintaining module is used to maintain the clock synchronization state of the terminal device when it is at the second level.

[0127] In another possible implementation, when performing clock synchronization on each clock synchronization process in at least one clock synchronization process in a next time period, the clock synchronization module is specifically used to:

[0128] For each clock synchronization process in at least one clock synchronization process, based on the clock synchronization message of the clock synchronization process, obtaining an initial time offset between the terminal device and the synchronization server in the clock synchronization process;

[0129] Obtain clock synchronization error compensation value;

[0130] Based on the clock synchronization error compensation value, correct the initial time offset corresponding to at least one clock synchronization process in the next time period to obtain a target time offset corresponding to each clock synchronization process;

[0131] Based on the target time offset corresponding to each clock synchronization process, clock synchronization is performed between the terminal device and the synchronization server.

[0132] In another possible implementation, when acquiring the clock synchronization error compensation value, the clock synchronization module is specifically used to:

[0133] Acquire historical synchronization data, wherein the historical synchronization data includes synchronization data in at least one historical clock synchronization process between the terminal device and the synchronization server, and the historical synchronization data includes: uplink delay and downlink delay; wherein the uplink delay is the transmission delay of the clock synchronization message, and the downlink delay is the transmission delay of the delay request message, wherein the delay request message is sent by the synchronization server to the terminal device after receiving the clock synchronization message sent by the terminal device;

[0134] Based on the historical synchronization data, the clock synchronization error compensation value is determined.

[0135] In another possible implementation, when acquiring historical synchronization data, the clock synchronization module is specifically used to:

[0136] According to the window size of the moving window, the latest historical synchronization data corresponding to the window size before the next time period is obtained, and the window size corresponds to at least one clock synchronization process; the number of at least one clock synchronization process in the next time period corresponds to the moving step size of the moving window.

[0137] In another possible implementation manner, when the clock synchronization module determines the clock synchronization error compensation value based on the historical synchronization data, it is specifically configured to:

[0138] The target uplink delay is obtained by integrating the uplink delays corresponding to each historical clock synchronization.

[0139] The target downlink delay is obtained by integrating the downlink delays corresponding to each historical clock synchronization.

[0140] A difference between the target uplink delay and the target downlink delay is determined as the clock synchronization error compensation value.

[0141] In the fifth aspect, a network status prediction device is provided, which is applied to a clock synchronization system. The clock synchronization system also includes at least a terminal device and a synchronization server. The terminal device communicates with the network prediction device and the synchronization server respectively. The network prediction device includes a memory and a processor. A computer program is stored in the memory. When the processor runs the computer program, it executes the clock synchronization method described in any possible implementation of the first aspect.

[0142] In the sixth aspect, a synchronization server is provided, which is applied to a clock synchronization system, wherein the clock synchronization system also includes at least a network status prediction device and a terminal device, wherein the terminal device communicates with the network prediction device and the synchronization server respectively, and the synchronization server includes a memory and a processor, wherein a computer program is stored in the memory, and the processor executes the clock synchronization method described in any possible implementation of the second aspect when running the computer program.

[0143] In the seventh aspect, an embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the clock synchronization method described in any possible implementation method of the first aspect is implemented.

[0144] In an eighth aspect, an embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the clock synchronization method described in any possible implementation manner of the second aspect is implemented.

[0145] In a ninth aspect, an embodiment of the present application further provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, it implements the clock synchronization method described in any possible implementation manner of the first aspect.

[0146] In the tenth aspect, an embodiment of the present application further provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, it implements the clock synchronization method described in any possible implementation method of the second aspect.

[0147] In an eleventh aspect, an embodiment of the present application further provides a clock synchronization system, the clock synchronization system comprising a network status prediction device, a terminal device and a synchronization server, the terminal device communicates with the network status prediction device and the synchronization server respectively, wherein:

[0148] The network status prediction device is used to predict the network quality status in the next time period according to the current network data acquired between the terminal device and the synchronization server when the clock synchronization state is the timing state, and send the network quality status to the terminal device;

[0149] The terminal device is used to determine a target sending frequency according to the received network quality status, and send a clock synchronization message to the synchronization server based on the target sending frequency;

[0150] The synchronization server is used to obtain an error synchronization compensation value, and calculate an initial clock offset based on a received clock synchronization message, and correct the initial clock offset based on the obtained error synchronization compensation value to obtain a target time offset corresponding to each clock synchronization process, so as to perform clock synchronization between the terminal device and the synchronization server based on the target time offset corresponding to each clock synchronization process.

[0151] The beneficial effects of the technical solution provided by the embodiment of the present application are as follows:

[0152] An embodiment of the present application provides a clock synchronization method, device, system and computer-readable storage medium. In the embodiment of the present application, when the current clock synchronization state of the terminal device is the timing state, the network prediction device obtains the current network data between the terminal device and the synchronization server, and can predict the network quality state in the next time period through a network quality prediction model, so as to determine the target sending frequency according to the network quality state, so that the terminal device sends a clock synchronization message to the synchronization server according to the determined target sending frequency to perform clock synchronization. BRIEF DESCRIPTION OF THE DRAWINGS

[0153] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in describing the embodiments of the present application are briefly introduced below.

[0154] Figure 1 This is a schematic diagram of a time-sensitive network in an embodiment of the present application;

[0155] Figure 2 This is a schematic diagram of the integration of 5G and TSN in an embodiment of the present application;

[0156] Figure 3 A schematic diagram of a clock synchronization system in an embodiment of the present application;

[0157] Figure 4a Schematic diagram of the clock synchronization process using the PTP two-step method in the embodiment of the present application;

[0158] Figure 4b A schematic diagram of clock synchronization in an embodiment of the present application;

[0159] Figure 5 A flow chart showing the relationship between network fluctuation, synchronization accuracy and synchronization status in an embodiment of the present application;

[0160] Figure 6 A schematic diagram of calculating a clock synchronization offset based on a sliding window in an embodiment of the present application;

[0161] Figure 7 This is a flowchart of another clock synchronization method in an embodiment of the present application;

[0162] Figure 8 This is a schematic diagram of the structure of a network status prediction device according to an embodiment of the present application;

[0163] Fig. 9 This is a schematic diagram of the device structure of a synchronization server in an embodiment of the present application;

[0164] Fig.10 This is a schematic diagram of the structure of an electronic device in an embodiment of the present application. DETAILED DESCRIPTION

[0165] The embodiments of the present application are described below in conjunction with the drawings in the present application. It should be understood that the implementation methods described below in conjunction with the drawings are exemplary descriptions for explaining the technical solutions of the embodiments of the present application and do not constitute a limitation on the technical solutions of the embodiments of the present application.

[0166] It will be understood by those skilled in the art that, unless specifically stated, the singular forms "one", "said", and "the" used herein may also include plural forms. It should be further understood that the terms "including" and "comprising" used in the embodiments of the present application refer to that the corresponding features can be implemented as the presented features, information, data, steps, operations, elements and / or components, but do not exclude the implementation as other features, information, data, steps, operations, elements, components and / or combinations thereof supported by the technical field. It should be understood that when we say that an element is "connected" or "coupled" to another element, the one element may be directly connected or coupled to the other element, or it may refer to that the one element and the other element establish a connection relationship through an intermediate element. In addition, the "connection" or "coupling" used herein may include wireless connection or wireless coupling. The term "and / or" used herein indicates at least one of the items defined by the term, for example, "A and / or B" may be implemented as "A", or as "B", or as "A and B". When describing multiple (two or more) items, if the relationship between the multiple items is not clearly defined, the multiple items may refer to one, multiple or all of the multiple items. For example, the description of "parameter A includes A1, A2, A3" can be implemented as parameter A including A1 or A2 or A3, and can also be implemented as parameter A including at least two of the three items A1, A2, A3.

[0167] Before describing the embodiments, the relevant terms of the present application are first explained.

[0168] Bandwidth: The maximum data rate that can pass from one point in the network to another in a unit of time.

[0169] Delay: refers to the time required for a message to travel from one end of the network to the other. Network delay includes four parts: processing delay, queuing delay, sending delay, and propagation delay. In practice, sending delay and propagation delay are the main considerations.

[0170] Jitter: Network jitter refers to the time difference between the maximum delay and the minimum delay. For example, if the maximum delay for accessing a website is 10ms and the minimum delay is 5ms, then the network jitter is 5ms. Jitter can be used to evaluate the stability of the network. The smaller the jitter, the more stable the network.

[0171] Packet loss: refers to the inability of one or more packets of data to reach their destination through the network.

[0172] The inventive concept of the present application is described below.

[0173] Time-Sensitive Networking (TSN) is a network technology defined by IEEE to achieve time synchronization and deterministic communication between nodes. It is mainly used for real-time communication and network control, including TSN centralized user configuration (CUC), centralized network configuration (CNC), TSN bridge, TSN talker station, TSN listener Station, etc. Figure 1 As shown:

[0174] Currently, IEEE has defined a subset of the IEEE 802.1 standard. These specifications together define various aspects of TSN, including clock synchronization, frame reservation, configuration and management, frame shortening, bridges and gateways, interoperability testing, process identification and time slot management.

[0175] -IEEE 802.1AS-2011: TSN Universal Clock Synchronization Protocol

[0176] -IEEE 802.1Qbv-2015:TSN frame reservation protocol

[0177] -IEEE 802.1Qca-2018:TSN configuration and management protocol

[0178] -IEEE 802.1Qcc-2017:TSN switch and end system configuration and management

[0179] -IEEE 802.1Qbu-2016:TSN frame shortening protocol

[0180] -IEEE 802.1Qbg-2012: TSN bridge and gateway standard

[0181] -IEEE 802.1Qci-2019:TSN interoperability test specification

[0182] -IEEE 802.1CB-2017:TSN Process Identification Protocol

[0183] -IEEE 802.1Qch-2020:TSN Timeslot Management Protocol

[0184] Solutions for integrating 5G and TSN Figure 2 As shown, the 5G system constitutes a TSN switch, in which DS-TT and NW-TT are the TSN translators on the terminal side and the network side, respectively. Figure 2 The architecture diagram of the 5G-TSN converged network is shown. The 5G-TSN converged network consists of a business system network composed of a TSN network and a bearer network composed of a 5G transmission network. The TSN network side includes multiple TSN switches (TSN switch 1 and TSN switch 2) and TSN converters (DS-TT, Device-Side TSN Translator, NW-TT, Net-Working TSN Translator), wherein the TSN switch is used to forward business flow message packets to the terminal destination in the TSN network; the TSN converter is used to achieve effective coordination between the 5G network and the TSN business network, so that the terminal-side TSN node can achieve TSN-based synchronous connection with the network-side TSN node through the 5G network.

[0185] The 5G transmission network adopts the existing common structure, including UE (User Equipment), AMF (Access and Mobility Management Function),

[0186] SMF (Session Management function, session management function),

[0187] UDM (Unified Data Management),

[0188] PCF (Policy Control function),

[0189] NEF (Network Exposure Function),

[0190] RAN (Radio Access Network),

[0191] UPF (User plane function) and time-sensitive network application function (TSN AF), etc.

[0192] Furthermore, in the related technologies of clock synchronization, there are the following related problems:

[0193] 1. The time synchronization accuracy between two server nodes will be affected by network fluctuations, especially when the two server nodes are in a large network environment. The accuracy of synchronization achieved through the Network Time Protocol (NTP) will be affected by network fluctuations, causing the system time of the two to drift.

[0194] 2. The existing time synchronization service implemented through the Precision Time Protocol (PTP) is more restrictive and requires that the servers be strictly in a LAN environment and a small number of switches to be implemented. In addition, it is expensive and is not suitable for large-scale replication of scenarios.

[0195] 3. The existing time synchronization service implemented through NTP has low accuracy and a high probability of clock drift;

[0196] In order to solve the above technical problems, compared with NTP, the number of times messages are sent and received is increased, and the timestamp of the sent message is sent through a new message, making the acquisition of the timestamp more accurate; compared with PTP, the way of obtaining the timestamp is changed by calling the system function, so that time synchronization is decoupled from the hardware, reducing the dependence on the hardware while maintaining a high degree of accuracy. Algorithm compensation is performed at the algorithm level, taking into account the synchronization error caused by the difference in uplink and downlink experiments, and maintaining the synchronization of sending and receiving;

[0197] Furthermore, the timing and punctuality modes of time synchronization are changed to a time synchronization mode based on a predicted network, and an algorithm is designed to predict the network status between the current server nodes in advance. The network parameters involved mainly include jitter, delay, and bandwidth. Decisions on time synchronization are made by detecting the network status in the future. If the network is poor, the synchronization interval is temporarily suspended, the punctuality time is increased in the punctuality mode, and the packet sending interval of the time synchronization service is slowed down in the timing mode to avoid synchronization accuracy drift due to network bursts. In an embodiment of the present application, the timing mode will perform a large-scale clock correction based on the predicted network, striving to quickly achieve the optimal synchronization accuracy; the punctuality mode is a small-scale clock adjustment to minimize the interference caused by fluctuations.

[0198] The clock synchronization method provided in the embodiment of the present application is applied to a clock synchronization system, such as Figure 3 As shown, the clock synchronization system includes a network status prediction device, a terminal device and a synchronization server. The terminal device communicates with the network prediction device and the synchronization server respectively, and the network prediction device communicates with the synchronization server.

[0199] In the embodiment of the present application, the network status prediction device may be a sensor, and the sensor may refer to a roadside sensor, which refers to a sensor installed beside the road and is used to detect the movement status and location information of vehicles, pedestrians, bicycles and other means of transportation to collect traffic flow data and traffic condition information and provide real-time traffic monitoring and management; roadside sensors include magnetic sensors, piezoelectric sensors, microwave radar sensors and other types. The roadside sensors in the embodiment of the present application refer to millimeter wave radars, laser radars, and cameras.

[0200] Furthermore, the network status prediction device can be a QoS prediction server, wherein the synchronization server and the QoS prediction server both have signal processing and data processing units, which can be a CPU / GPU machine with a physical entity or a cloud server; the role of the synchronization server is to serve as a synchronization source or as a time synchronization service to provide time synchronization to the sensor; the role of the QoS prediction server is to predict the network status within the future time scale.

[0201] Further, in the embodiment of the present application, a synchronization protocol based on PTP is adopted to achieve time synchronization at the microsecond level. In the PTP protocol, the synchronization process is divided into a one-step method and a two-step method. The following is the difference between them: in the one-step method, the PTP client (which can be a terminal device in the embodiment of the present application) directly sends a synchronization request to the PTP server (which can be a synchronization server in the embodiment of the present application) and obtains timestamp information in the synchronization response. The PTP client does not need to send a delay request, so the synchronization process is relatively simple. In the two-step method, the PTP client needs to first send a synchronization request to the PTP server and obtain timestamp information in the synchronization response. Then, the PTP client needs to send a delay request to the PTP server again and obtain delay information (timestamp t1) in the delay response. In the two-step method, the PTP client needs to communicate twice, so the synchronization process is relatively complicated. The two-step method can synchronize time more accurately because it can consider the impact of network delay on time synchronization, so the two-step method has higher accuracy. In practical applications, if more accurate time synchronization is required, the two-step method can be selected.

[0202] Figure 4a It is a PTP two-step E2E time synchronization model. Among them:

[0203] t 1 : The timestamp of the Sync message sent by the PTP master clock, which is then sent to the slave clock through the Follow Up message.

[0204] t′ 1 : The time when the PTP master clock sends the Sync message, assuming the timestamp of the slave clock at this time.

[0205] t 2 : Timestamp when the PTP slave clock receives the Sync message.

[0206] t 3 : Timestamp when the PTP slave clock sends the Delay Req message.

[0207] t′ 3 : The time when the PTP slave clock sends the Delay Reg message is assumed to be the timestamp of the master clock.

[0208] t 4 : The timestamp of the PTP master clock receiving the Delay Req message is sent back to the slave clock via the Delay Resp message.

[0209] According to the two-step E2E synchronization model:

[0210] t′ 1 -t 1 =t 2 -(t 1+T ms )

[0211] t 3 -t′ 3 =(t 3 +T sm )-t 4

[0212] offset = t′ 1 -t 1 =t 3 -t′ 3

[0213] delay=T ms =T sm If the path is symmetric, we get:

[0214]

[0215]

[0216] Then the time after correction from the clock is:

[0217] t=t′ 1 -offset

[0218] Further, based on the above embodiment, a clock synchronization method is described in detail through a specific embodiment, which is specifically as follows:

[0219] The embodiment of the present application provides a clock synchronization method, which is executed by a network status prediction device, such as Figure 4b As shown, the method may include:

[0220] Step S401: Determine the current clock synchronization state of the terminal device.

[0221] For the embodiment of the present application, clock synchronization is performed between the terminal device and the synchronization server, and the network status prediction device can obtain the current clock synchronization status of the terminal device to determine whether the terminal device is currently in a timing state or a punctual state.

[0222] Step S402: If the current clock synchronization state is the timing state, the current network data between the terminal device and the synchronization server is obtained.

[0223] For the embodiment of the present application, if the network status prediction device determines that the current clock synchronization state is the timing state, the current network data between the terminal device and the synchronization server is obtained. In the embodiment of the present application, the current network data between the terminal device and the synchronization server can be reported by the synchronization server after each round of authorization.

[0224] The current network data at least includes network data of the current period.

[0225] Step S403: Based on the current network data, the network quality status in the next period is predicted by a network quality prediction model to determine the target sending frequency based on the network quality status.

[0226] The target sending frequency is the frequency at which the terminal device sends clock synchronization messages to the synchronization server.

[0227] For the embodiment of the present application, after obtaining the current network data, the network quality prediction model is used to predict the network quality status in the next time period, that is, to predict the network quality between the terminal device and the synchronization server in the future period, so as to further determine the frequency of the terminal device sending clock synchronization messages to the synchronization server in the next time period according to the network quality status. In the embodiment of the present application, the network quality prediction model is used to predict the network quality status in the next time period, that is, to adopt a machine learning method based on time series prediction. For example, the network quality prediction model can be a recurrent neural network (RNN), a light gradient boosting machine (LGBM), a random forest (RF), and the like.

[0228] Furthermore, after predicting the network quality status in the next time period, the network status prediction server can continue to determine the target sending frequency based on the network quality status, and can also send the network quality status to the terminal device, and the terminal device determines the target sending frequency.

[0229] Specifically, according to the network quality state, determining the target sending frequency of the clock synchronization message includes: if the network quality state is a first quality state, determining the target sending frequency of the clock synchronization message to be a first sending frequency; if the network quality state is a second quality state, determining the target sending frequency of the clock synchronization message to be a second sending frequency. The network quality corresponding to the first quality state is higher than the network quality corresponding to the second quality state, and the first sending frequency is lower than the second sending frequency.

[0230] That is to say, in the embodiment of the present application, after predicting the network quality status in the next time period, the network status prediction device can determine the target sending frequency of the terminal device sending the clock synchronization message according to the network quality status, so that the terminal device sends the clock synchronization message according to the target sending frequency. Specifically, if it is predicted that the network quality in the next time period is good, for example, the network delay is low, the jitter is low, and the available bandwidth is large, then the target sending frequency is determined to be the first sending frequency; if it is predicted that the network quality in the next time period is poor, for example, the network delay is high, the jitter is high, and the available bandwidth is small, then the target sending frequency is determined to be the second sending frequency.

[0231] It should be noted that the first sending frequency may be the frequency at which the terminal device sends clock synchronization messages in the current time period, and the second sending frequency may be a frequency that is increased based on the frequency of the clock synchronization messages sent by the terminal device in the current time period, that is, the second sending frequency is greater than the first sending frequency; further, the first sending frequency may not be the frequency at which the terminal device sends clock messages in the current time period; in an embodiment of the present application, if it is predicted that the network quality in the next time period is better, the relationship between the network quality in the next time period and the network quality in the current time period can be further determined. If the network quality in the next time period is lower than the network quality in the current time period, it is determined that the frequency at which the terminal device sends clock synchronization messages in the next time period (that is, the first sending frequency) is greater than the frequency at which the terminal device sends clock synchronization messages in the current time period. Otherwise, the first sending frequency is not greater than the frequency at which the terminal device sends clock synchronization messages in the current time period.

[0232] In another possible implementation, after the network status prediction device predicts the network quality status in the next time period, it can inform the terminal device of the network quality status, so that the terminal device determines the frequency of sending clock synchronization messages in the next time period based on the network quality status in the next time period; that is, if the network quality in the next time period is poor, the terminal device can reduce the frequency of sending clock messages to the synchronization server, and conversely, the frequency of sending clock messages to the synchronization server may not be reduced. In an embodiment of the present application, when the network status prediction server predicts the network quality status in the next time period, and the network quality status in the next time period is poor, the frequency of sending clock synchronization messages is reduced, that is, the packet sending interval of the clock synchronization service is slowed down to avoid synchronization accuracy drift due to network bursts.

[0233] Furthermore, for a terminal device whose current clock synchronization state is a timing state, when the current clock synchronization accuracy is detected to meet the clock accuracy requirement, the clock synchronization state of the terminal device is changed from the timing state to the punctual state. In the embodiment of the present application, the synchronization accuracy detection can be performed in real time, or the synchronization accuracy detection can be performed at regular intervals. If the current clock synchronization accuracy meets the clock accuracy requirement, the clock synchronization state of the terminal device is changed from the timing state to the punctual state. Otherwise, it remains in the timing state. Figure 5 shown.

[0234] Specifically, the synchronization accuracy can be detected by the synchronization server. In an embodiment of the present application, whether the current clock synchronization accuracy meets the clock accuracy requirement is determined in the following manner: obtaining a synchronization accuracy threshold, an uplink delay, and a downlink delay, wherein the uplink delay is the transmission delay of the clock synchronization message, and the downlink delay is the transmission delay of the delay request message, wherein the delay request message is sent by the synchronization server to the terminal device after receiving the clock synchronization message; determining the time difference between the uplink delay and the downlink delay; if the time difference is not greater than the synchronization accuracy threshold, determining that the current clock synchronization accuracy meets the clock accuracy requirement; if the time difference is greater than the synchronization accuracy threshold, determining that the current clock synchronization accuracy does not meet the clock accuracy requirement.

[0235] Specifically, in the PTP two-step method, the upstream delay is t 2 -t 1 , the downlink delay is t 4 -t 3 , the time difference between the uplink delay and the downlink delay is: t 2 -t 1 -t 4 +t 3 The synchronization accuracy threshold can be determined according to the network type of the current network, or can be preset. For example, the synchronization accuracy threshold can be 8ms, that is, when t 2 -t 1 -t 4 +t 3 ≤8ms, it is determined that the current clock synchronization accuracy meets the clock accuracy requirement. If t 2 -t 1 -t 4 +t 3 >8ms, it is determined that the current clock synchronization accuracy does not meet the clock accuracy requirement.

[0236] Furthermore, in the case that the current clock synchronization state is a punctual state, the method may further include: determining a network fluctuation state in a next time period.

[0237] Among them, the network fluctuation state includes a network fluctuation state or a non-network fluctuation state. In the embodiment of the present application, when the current clock synchronization state is a punctual state, the network state prediction device determines the network fluctuation state in the next time period. In the embodiment of the present application, the network state prediction device can use the same network quality prediction model as above to predict the network state in the next time period, or it can use another trained network fluctuation prediction model to predict the network fluctuation state in the next time period, which is not limited in the embodiment of the present application.

[0238] Specifically, in the case of network fluctuation, if the network fluctuation level is the first level, the clock synchronization state of the terminal device is changed from the punctual state to the timing state, and if the network fluctuation level is the second level, the clock synchronization state of the terminal device is maintained. The network fluctuation level represents the duration of continuous fluctuation of the network. The duration of continuous fluctuation corresponding to the first level is greater than the duration of continuous fluctuation corresponding to the second level. In the case of non-network fluctuation, the clock synchronization state of the terminal device is maintained. In the embodiment of the present application, Figure 5 As shown, if the current clock synchronization state is in the punctual state, network fluctuation detection is performed. If it is in the network fluctuation state, the network fluctuation level is further determined. If the network fluctuation level is the first level (that is, in a continuous fluctuation state), the clock synchronization state of the terminal device is changed from the punctual state to the timing state, and the time synchronization process is restarted. After each round of timing, the parameters of the current network are re-reported and updated based on the current clock adjustment result. If the network fluctuation level is the second level (that is, in a short-term fluctuation state), if it is a short-term fluctuation, the impact on the accuracy is not large at this time, then the clock synchronization state of the terminal device is maintained, that is, it is still in the punctual state. Further, if it is predicted that the next time period will be a non-network fluctuation state, the clock synchronization state of the terminal device is also maintained as the punctual state.

[0239] Furthermore, whether the network fluctuation level is the first level or the second level can be determined by the synchronization server, and can be determined by a counter. In the embodiment of the present application, the synchronization server can detect that the network is in a fluctuation state for a preset number of consecutive times, that is, t 2 -t 1 -t 4 +t 3 ≤8ms (synchronization accuracy threshold), the network fluctuation level is the first level, that is, it is in a continuous fluctuation state; if the network fluctuation level is the second level, it is in a short-term fluctuation state.

[0240] Furthermore, if the network fluctuation level is the first level (i.e., in a state of continuous fluctuation), the clock synchronization state of the terminal device is changed from the timekeeping state to the timing state. In the timing state, the clock synchronization between the terminal device and the synchronization server can be implemented by the synchronization server in the manner described in the above embodiment; however, in the Internet, the upload and download speeds are not equal, which is usually caused by the physical characteristics of the network connection or the limitations of the network equipment. In order to eliminate the error caused by the asymmetric link to the time synchronization, an algorithm using a sliding window is designed in the embodiment of the present application to compensate for the synchronization error.

[0241] The sliding window algorithm uses a fixed-size window to slide on the historical synchronization data and calculates the average value within the window as the error compensation value. The key to the algorithm is to determine the appropriate window size and how to calculate it. The window size should be selected based on the actual network conditions and synchronization requirements. A smaller window can capture network fluctuations faster, but may be affected by noise. A larger window can reduce the impact of noise, but the response speed to network fluctuations is slower. The appropriate window size can be determined through experiments or based on actual application scenarios.

[0242] If the path delay is calculated according to the PTP time synchronization standard and the error compensation calculation is performed immediately, the error compensation curve will have a large jitter amplitude. Therefore, in the embodiment of the present application, before starting the dynamic time synchronization algorithm, the path asymmetry difference is first measured, and the sliding window compensation is performed, and then the dynamic time synchronization algorithm is started for time synchronization and correction.

[0243] That is to say, in the embodiment of the present application, the clock synchronization between the terminal device and the synchronization server is implemented by the synchronization server based on the clock synchronization message in the following manner (step Sa (not shown in the figure), step Sb (not shown in the figure), step Sc (not shown in the figure), and step Sd (not shown in the figure)):

[0244] Step Sa: for each clock synchronization process in at least one clock synchronization process in the next time period, based on the clock synchronization message of the clock synchronization process, obtain the initial time offset between the terminal device and the synchronization server in the clock synchronization process.

[0245] Specifically, in the embodiment of the present application, at least one clock synchronization can be performed between the terminal device and the synchronization server in each time period, and for each clock synchronization process in at least one clock synchronization process in the next time period, the initial time offset between the terminal device and the synchronization server in the clock synchronization process is obtained. In the embodiment of the present application, the initial time offset between the terminal device and the synchronization server in the clock synchronization process is also the time offset calculated by the PTP algorithm, for example, Among them, offset is the initial time offset.

[0246] Step Sb, obtaining a clock synchronization error compensation value.

[0247] Specifically, the clock synchronization error compensation value is determined in the following manner. In an embodiment of the present application, the clock synchronization error compensation value is calculated by a synchronization server. Specifically, in an embodiment of the present application, the calculation method of the clock synchronization error compensation value may include: obtaining historical synchronization data, and determining the clock synchronization error compensation value based on the historical synchronization data.

[0248] The historical synchronization data includes synchronization data from at least one historical clock synchronization process between the terminal device and the synchronization server, and the historical synchronization data includes: uplink delay and downlink delay; wherein the uplink delay is the transmission delay of the clock synchronization message, and the downlink delay is the transmission delay of the delay request message, wherein the delay request message is sent by the synchronization server to the terminal device after receiving the clock synchronization message sent by the terminal device. In an embodiment of the present application, the historical synchronization data can be each uplink delay and downlink delay obtained in the historical clock synchronization process, and then each uplink delay and downlink delay are merged to obtain the target uplink delay and downlink delay, and then determine the clock synchronization error compensation value. The method shown in the following embodiment can also be used to obtain the clock synchronization error compensation value.

[0249] Furthermore, historical synchronization data can also be obtained by the synchronization server in the following manner: according to the window size of the moving window, the latest historical synchronization data corresponding to the window size before the next time period is obtained, and the window size corresponds to at least one clock synchronization process; the number of at least one clock synchronization process in the next time period corresponds to the moving step size of the moving window.

[0250] The first step is to set the parameters of the sliding window. The setting of the sliding window size needs to consider the frequency characteristics of the synchronization message and the response time of the algorithm. For example, the size of the sliding window is set to 50 and the step size is set to 20 times. Considering the randomness of the path delay of the synchronization message, the average value in the window adopts the arithmetic mean, followed by the asymmetric difference calculation. Perform a statistical analysis of the path delay in the sliding window, remove the maximum and minimum values, and calculate the average value. Perform multiple iterations, filter out unreasonable path delay values, and finally obtain the optimal average value and error average value of the round-trip path.

[0251] Step Sc: Based on the clock synchronization error compensation value, correct the initial time offset corresponding to at least one clock synchronization process in the next time period to obtain the target time offset corresponding to each clock synchronization process.

[0252] Step Sd: Based on the target time offset corresponding to each clock synchronization process, clock synchronization is performed between the terminal device and the synchronization server.

[0253] Specifically, after obtaining the target time offset corresponding to each clock synchronization process, time compensation is performed on the moment when the terminal device sends the Sync message based on the target time offset to perform clock synchronization.

[0254] In the following embodiments, a method of obtaining a clock synchronization error compensation value through a sliding window strategy is introduced with a specific example.

[0255] Figure 6 The specific details of the sliding window strategy in 100 time synchronizations are shown as follows:

[0256] (1) From the 1st to the 50th synchronization:

[0257] In the first 50 synchronizations, window 1 is initialized and the average uplink delay T in window 1 is calculated according to the following formula: ms and the average downstream delay T sm , as shown in the following formula:

[0258]

[0259]

[0260] Among them, T 1i The timestamp that represents the time when the terminal device sends the Sync message, which is then sent to the synchronization server through the Follow Up message. 2i Indicates the timestamp of the synchronization server receiving the Sync message and the timestamp of the PTP slave clock sending the Delay Req message during the i-th clock synchronization process. 3i It is the timestamp of the i-th PTP slave clock sending the Delay Req message; T 4i The timestamp representing the time when the terminal device receives the Delay Req message is sent back to the synchronization server via the Delay Resp message.

[0261] Furthermore, the following equation is then used to calculate diff (i.e., the uplink and downlink asymmetry of 50 synchronizations in window 1):

[0262] diff = T ms -T sm , where T ms is the average upstream delay in window 1, T sm is the average downlink delay in window 1;

[0263] (2) 50th to 70th synchronization:

[0264] After calculating the average path delay of window 1, the time deviation calculation algorithm is entered. Then, sliding statistics are continuously performed to filter out unreasonable path delay values ​​and update the path delay average. Finally, error compensation is calculated. In the next 20 synchronizations, diff is used to compensate for the time offset. The offset after compensation is calculated by the following formula:

[0265]

[0266] Among them, offset1 is the offset after compensation.

[0267] (3) 70th to 90th synchronization:

[0268] When the 70th synchronization ends, the sliding step of window 1 reaches 20. Therefore, we update window 1 to window 2. Window 2 contains historical data from the 20th to the 70th synchronization. Similar to before, calculate the diff of window 2 first. Then use the diff of window 2 to compensate for the time offset until before the 90th synchronization.

[0269] (4) From the 90th to the 100th synchronization:

[0270] At the beginning of the 90th synchronization, window 2 is updated to window 3. The diff is calculated using the same process, and then the offset is compensated using the diff of window 3. Repeating this process, the offset can always be compensated.

[0271] Furthermore, the clock synchronization is performed in the above manner. Compared with NTP, the number of times messages are sent and received is increased, and the timestamp of the sent message is sent through a new message, making the acquisition of the timestamp more accurate. Compared with PTP, the method of obtaining the timestamp is changed by calling the system function, so that the time synchronization is decoupled from the hardware, reducing the dependence on the hardware while maintaining a high degree of accuracy. Algorithm compensation is performed at the algorithm level, taking into account the synchronization error caused by the difference in uplink and downlink experiments, and maintaining the synchronization of sending and receiving.

[0272] The present application embodiment provides another clock synchronization method, which is executed by a synchronization server, such as Figure 7 As shown, the method may include:

[0273] Step S701: Receive a clock synchronization message sent by a terminal device.

[0274] Step S702: Perform clock synchronization based on the clock synchronization message.

[0275] Among them, the clock synchronization message is sent by the network status prediction device to the synchronization server by controlling the terminal device; in the embodiment of the present application, the manner in which the synchronization server performs clock synchronization based on the clock synchronization message is specifically described in the above embodiment and will not be repeated here.

[0276] The network status prediction device controls the terminal device to send the clock synchronization message to the synchronization server in the following ways:

[0277] Determine the current clock synchronization status of the terminal device;

[0278] If the current clock synchronization state is the timing state, the current network data between the terminal device and the synchronization server is obtained, and the current network data at least includes the network data of the current period;

[0279] Based on the current network data, the network quality status in the next period is predicted through the network quality prediction model to determine the target sending frequency based on the network quality status. The target sending frequency is the frequency at which the terminal device sends clock synchronization messages to the synchronization server.

[0280] Specifically, in an embodiment of the present application, the network status prediction device predicts the network quality status in the next time period to control the terminal device to send a synchronization message to the synchronization server. Please refer to the above embodiment for details and will not be repeated here.

[0281] Another possible implementation of the embodiment of the present application, for a terminal device whose current clock synchronization state is a timing state, the method further includes: determining the current clock synchronization accuracy; when it is detected that the current clock synchronization accuracy reaches the clock accuracy requirement, controlling the clock synchronization state of the terminal device to be changed from the timing state to the punctual state. In the embodiment of the present application, each time the clock synchronization is performed between the synchronization server and the terminal device, the current clock synchronization accuracy can be determined, and the current clock synchronization accuracy can also be determined when the preset time is reached, which is not limited in the embodiment of the present application. In the embodiment of the present application, the specific implementation method is detailed in the above embodiment, which will not be repeated here.

[0282] Specifically, the method for determining whether the current clock synchronization accuracy meets the clock accuracy requirements may include: obtaining the synchronization accuracy threshold, the uplink delay, and the downlink delay to determine the time difference between the uplink delay and the downlink delay; if the time difference is not greater than the synchronization accuracy threshold, it is determined that the current clock synchronization accuracy meets the clock accuracy requirements; if the time difference is greater than the synchronization accuracy threshold, it is determined that the current clock synchronization accuracy does not meet the clock accuracy requirements.

[0283] The uplink delay is the transmission delay of the clock synchronization message, and the downlink delay is the transmission delay of the delay request message, wherein the delay request message is sent by the synchronization server to the terminal device after receiving the clock synchronization message;

[0284] Furthermore, when the current clock synchronization state is a punctual state, the method may also include: receiving network fluctuation state indication information sent by a network state prediction device, the network fluctuation state indication information is used to indicate whether the network fluctuation state in the next time period is a network fluctuation state or a non-network fluctuation state; if it is a network fluctuation state, continuously detecting the network fluctuation level of the network fluctuation; if it is the first level, changing the clock synchronization state of the terminal device from the punctual state to the timing state; if it is the second level, maintaining the clock synchronization state of the terminal device.

[0285] It should be noted that the method for determining the clock synchronization state of the terminal device based on the network fluctuation state is detailed in the above embodiment and will not be repeated here.

[0286] Another possible implementation method of the embodiment of the present application is to perform clock synchronization for each clock synchronization process in at least one clock synchronization process in the next time period, which may specifically include: for each clock synchronization process in at least one clock synchronization process, based on the clock synchronization message of the clock synchronization process, obtaining the initial time offset between the terminal device and the synchronization server in the clock synchronization process; obtaining the clock synchronization error compensation value; based on the clock synchronization error compensation value, correcting the initial time offset corresponding to at least one clock synchronization process in the next time period to obtain the target time offset corresponding to each clock synchronization process; based on the target time offset corresponding to each clock synchronization process, performing clock synchronization between the terminal device and the synchronization server.

[0287] Specifically, obtaining the clock synchronization error compensation value may include: obtaining historical synchronization data, and determining the clock synchronization error compensation value based on the historical synchronization data.

[0288] Among them, the historical synchronization data includes synchronization data of at least one historical clock synchronization process between the terminal device and the synchronization server, and the historical synchronization data includes: uplink delay and downlink delay; among them, the uplink delay is the transmission delay of the clock synchronization message, and the downlink delay is the transmission delay of the delay request message, wherein the delay request message is sent by the synchronization server to the terminal device after receiving the clock synchronization message sent by the terminal device.

[0289] Specifically, obtaining historical synchronization data can include: according to the window size of the moving window, obtaining the latest historical synchronization data corresponding to the window size before the next time period, the window size corresponds to at least one clock synchronization process; the number of at least one clock synchronization process in the next time period corresponds to the moving step size of the moving window.

[0290] Specifically, based on historical synchronization data, the clock synchronization error compensation value is determined, which may include: integrating the uplink delays corresponding to each historical clock synchronization to obtain a target uplink delay; integrating the downlink delays corresponding to each historical clock synchronization to obtain a target downlink delay; determining the difference between the target uplink delay and the target downlink delay as the clock synchronization error compensation value.

[0291] The following introduces the clock synchronization method in the embodiment of the present application through specific examples, and takes the vehicle network scenario as an example for introduction, which is applied to the vehicle network clock synchronization system, in which sensors, synchronization servers, and QoS prediction servers can be used, wherein the sensors communicate with the synchronization server and the QoS prediction server respectively; specifically, the QoS prediction server obtains the current network data between the current sensor and the synchronization server, and then predicts the network quality status between the sensor and the synchronization server in the next time period through a machine learning method based on time series, and can send the network quality status of the next time period to the sensor. In the timing state, if the network quality state is poor, that is, the network delay is high, the jitter is high, and the available bandwidth is small, the sensor increases the frequency of sending Sync messages, and in the punctual state, increases the punctual time of the punctual state;

[0292] In the timing state, the sensor and the synchronization server perform clock synchronization. During the clock synchronization process, if the synchronization server detects the current clock synchronization accuracy, if the current clock synchronization accuracy meets the clock synchronization accuracy requirement, the synchronization server controls the change from the timing state to the timekeeping state. If the current clock synchronization accuracy does not meet the clock synchronization accuracy requirement, the timing state is still maintained to perform clock synchronization.

[0293] Specifically, during the clock synchronization process between the sensor and the synchronization server, the clock synchronization error compensation value based on which the clock synchronization is based in the next period can be determined based on the preset sliding window. For example, the size of the sliding window is 50 and the step size of the sliding window is 20.

[0294] like Figure 6 As shown, based on the size of the sliding window, the clock synchronization data corresponding to the 1-50th clock synchronization (the clock synchronization data corresponding to window 1) is first determined as the historical synchronization data, and the historical synchronization data includes the uplink delay and downlink delay corresponding to the 50 clock synchronization processes, and then the average uplink delay T is calculated based on the uplink delay and downlink delay corresponding to the 50 clock synchronization processes. ms and the average downstream delay T sm , and then according to diff = T ms -T sm, and then slide to window 2 with a sliding step of 20, so as to compensate the time of each clock synchronization process of 51-70 times in window 2 according to the diff calculated in window 1, that is, Among them, t 1 ,t 2 ,t 3 and t 4 It is the timestamp corresponding to each clock synchronization process in the 51-70 clock synchronization processes. The specific meaning represented is as shown above and will not be repeated. Further, according to the above method, the corresponding diff is calculated through the 50 clock synchronization data in window 2, and the window is moved to obtain window 3, so as to compensate the 71-90 clock synchronization processes in window 3 based on the diff corresponding to window 2, as shown above. Further, the corresponding diff is calculated for 40-90 times in window 3 to perform time compensation for the 91-100 clock synchronization processes. The specific process is as shown above and will not be repeated.

[0295] Based on the same principle as the clock synchronization method provided in the embodiment of the present application, the embodiment of the present application also provides a network status prediction device, such as Figure 8 As shown, the network status prediction device 80 includes:

[0296] A synchronization state determination module 81, used to determine the current clock synchronization state of the terminal device;

[0297] The network data acquisition module 82 is used to acquire the current network data between the terminal device and the synchronization server when the current clock synchronization state is the timing state, and the current network data at least includes the network data of the current period;

[0298] The quality status prediction module 83 is used to predict the network quality status in the next time period based on the current network data and through the network quality prediction model, so as to determine the target sending frequency based on the network quality status. The target sending frequency is the frequency at which the terminal device sends clock synchronization messages to the synchronization server.

[0299] In a possible implementation of the embodiment of the present application, when the quality status prediction module 83 determines the target sending frequency of the clock synchronization message according to the network quality status, it is specifically used to:

[0300] If the network quality state is the first quality state, determining the target sending frequency of the clock synchronization message to be the first sending frequency;

[0301] If the network quality state is the second quality state, determining the target sending frequency of the clock synchronization message to be the second sending frequency;

[0302] The network quality corresponding to the first quality state is higher than the network quality corresponding to the second quality state, and the first sending frequency is lower than the second sending frequency.

[0303] In another possible implementation of the embodiment of the present application, when the current clock synchronization state is a punctual state, the device 80 further includes: a fluctuation state determination module, wherein:

[0304] A fluctuation state determination module, used to determine the network fluctuation state in the next period of time, where the network fluctuation state includes a network fluctuation state or a non-network fluctuation state;

[0305] Among them, in the case of network fluctuation state, if the network fluctuation level is the first level, the clock synchronization state of the terminal device is changed from the timekeeping state to the timing state, and if the network fluctuation level is the second level, the clock synchronization state of the terminal device is maintained. The network fluctuation level represents the continuous fluctuation duration of the network. The continuous fluctuation duration corresponding to the first level is greater than the continuous fluctuation duration corresponding to the second level.

[0306] In the case of non-network fluctuation, the clock synchronization state of the terminal device is maintained;

[0307] For a terminal device whose current clock synchronization state is a timing state, when the current clock synchronization accuracy is detected to meet the clock accuracy requirement, the clock synchronization state of the terminal device is changed from the timing state to the timekeeping state.

[0308] In another possible implementation of the embodiment of the present application, for a terminal device whose current clock synchronization state is a timing state, when the current clock synchronization accuracy is detected to meet the clock accuracy requirement, the clock synchronization state of the terminal device is changed from the timing state to the punctual state;

[0309] Whether the current clock synchronization accuracy meets the clock accuracy requirement is determined in the following ways:

[0310] Obtain synchronization accuracy threshold, uplink delay and downlink delay, where uplink delay is the transmission delay of clock synchronization message, and downlink delay is the transmission delay of delay request message, where delay request message is sent by synchronization server to terminal device after receiving clock synchronization message;

[0311] Determine the time difference between the upstream delay and the downstream delay;

[0312] If the time difference is not greater than the synchronization accuracy threshold, it is determined that the current clock synchronization accuracy meets the clock accuracy requirement;

[0313] If the time difference is greater than the synchronization accuracy threshold, it is determined that the current clock synchronization accuracy does not meet the clock accuracy requirement.

[0314] In another possible implementation of the embodiment of the present application, the clock synchronization between the terminal device and the synchronization server is implemented by the synchronization server based on the clock synchronization message in the following manner:

[0315] For each clock synchronization process in at least one clock synchronization process in the next time period, based on the clock synchronization message of the clock synchronization process, obtain the initial time offset between the terminal device and the synchronization server in the clock synchronization process;

[0316] Obtain clock synchronization error compensation value;

[0317] Based on the clock synchronization error compensation value, correct the initial time offset corresponding to at least one clock synchronization process in the next period to obtain the target time offset corresponding to each clock synchronization process;

[0318] Based on the target time offset corresponding to each clock synchronization process, clock synchronization is performed between the terminal device and the synchronization server.

[0319] In another possible implementation of the embodiment of the present application, the clock synchronization error compensation value is determined by:

[0320] Obtaining historical synchronization data, wherein the historical synchronization data includes synchronization data in at least one historical clock synchronization process between the terminal device and the synchronization server, and the historical synchronization data includes: uplink delay and downlink delay; wherein the uplink delay is the transmission delay of the clock synchronization message, and the downlink delay is the transmission delay of the delay request message, wherein the delay request message is sent by the synchronization server to the terminal device after receiving the clock synchronization message sent by the terminal device;

[0321] Based on historical synchronization data, a clock synchronization error compensation value is determined.

[0322] In another possible implementation of the embodiment of the present application, the historical synchronization data is obtained by the following method:

[0323] According to the window size of the moving window, the latest historical synchronization data corresponding to the window size before the next time period is obtained, and the window size corresponds to at least one clock synchronization process; the number of at least one clock synchronization process in the next time period corresponds to the moving step of the moving window.

[0324] The network status prediction device of the embodiment of the present application can execute the method provided by the synchronization server of the embodiment of the present application, and the implementation principle is similar. The actions performed by each module in the network status prediction device of each embodiment of the present application correspond to the steps in the method of each embodiment of the present application. For the detailed functional description of each module of the device, please refer to the description in the corresponding method shown in the previous text, which will not be repeated here.

[0325] The present application embodiment provides another synchronization server, such as Fig. 9 As shown, the synchronization server 90 includes:

[0326] A first receiving module 91, configured to receive a clock synchronization message sent by a terminal device;

[0327] A clock synchronization module 92, configured to perform clock synchronization based on a clock synchronization message;

[0328] Among them, the clock synchronization message is sent by the network status prediction device to the synchronization server by controlling the terminal device;

[0329] The network status prediction device controls the terminal device to send the clock synchronization message to the synchronization server in the following ways:

[0330] Determine the current clock synchronization status of the terminal device;

[0331] If the current clock synchronization state is the timing state, the current network data between the terminal device and the synchronization server is obtained, and the current network data at least includes the network data of the current period;

[0332] Based on the current network data, the network quality status in the next period is predicted through the network quality prediction model to determine the target sending frequency based on the network quality status. The target sending frequency is the frequency at which the terminal device sends clock synchronization messages to the synchronization server.

[0333] In another possible implementation of the embodiment of the present application, for a terminal device whose current clock synchronization state is a timing state, the synchronization server 90 further includes: a synchronization accuracy determination module and a first change module, wherein:

[0334] A synchronization accuracy determination module, used to determine the current clock synchronization accuracy;

[0335] The first changing module is used to control the clock synchronization state of the terminal device to be changed from the timing state to the timekeeping state when it is detected that the current clock synchronization accuracy reaches the clock accuracy requirement.

[0336] In another possible implementation of the embodiment of the present application, when determining whether the current clock synchronization accuracy meets the clock accuracy requirement, the synchronization accuracy determination module is specifically used to:

[0337] Obtain synchronization accuracy threshold, uplink delay and downlink delay, where uplink delay is the transmission delay of clock synchronization message, and downlink delay is the transmission delay of delay request message, where delay request message is sent by synchronization server to terminal device after receiving clock synchronization message;

[0338] Determine the time difference between the upstream delay and the downstream delay;

[0339] If the time difference is not greater than the synchronization accuracy threshold, it is determined that the current clock synchronization accuracy meets the clock accuracy requirement;

[0340] If the time difference is greater than the synchronization accuracy threshold, it is determined that the current clock synchronization accuracy does not meet the clock accuracy requirement.

[0341] In another possible implementation of the embodiment of the present application, when the current clock synchronization state is a punctual state, the synchronization server 90 further includes: a second receiving module, a continuous detection module, a second changing module and a state maintaining module, wherein:

[0342] A second receiving module is used to receive network fluctuation status indication information sent by the network status prediction device, where the network fluctuation status indication information is used to indicate whether the network fluctuation status in the next time period is a network fluctuation status or a non-network fluctuation status;

[0343] A continuous detection module, used for continuously detecting the network fluctuation level of the network fluctuation when the network is in a fluctuation state;

[0344] The second changing module is used to change the clock synchronization state of the terminal device from the timekeeping state to the timing state when it is the first level;

[0345] The state maintaining module is used to maintain the clock synchronization state of the terminal device when it is at the second level.

[0346] In another possible implementation of the embodiment of the present application, when the clock synchronization module 92 performs clock synchronization on each clock synchronization process in at least one clock synchronization process in the next time period, it is specifically used to:

[0347] For each clock synchronization process in at least one clock synchronization process, based on the clock synchronization message of the clock synchronization process, obtaining an initial time offset between the terminal device and the synchronization server in the clock synchronization process;

[0348] Obtain clock synchronization error compensation value;

[0349] Based on the clock synchronization error compensation value, correct the initial time offset corresponding to at least one clock synchronization process in the next period to obtain the target time offset corresponding to each clock synchronization process;

[0350] Based on the target time offset corresponding to each clock synchronization process, clock synchronization is performed between the terminal device and the synchronization server.

[0351] In another possible implementation of the embodiment of the present application, when acquiring the clock synchronization error compensation value, the clock synchronization module 92 is specifically used to:

[0352] Obtaining historical synchronization data, wherein the historical synchronization data includes synchronization data in at least one historical clock synchronization process between the terminal device and the synchronization server, and the historical synchronization data includes: uplink delay and downlink delay; wherein the uplink delay is the transmission delay of the clock synchronization message, and the downlink delay is the transmission delay of the delay request message, wherein the delay request message is sent by the synchronization server to the terminal device after receiving the clock synchronization message sent by the terminal device;

[0353] Based on historical synchronization data, a clock synchronization error compensation value is determined.

[0354] In another possible implementation of the embodiment of the present application, when acquiring historical synchronization data, the clock synchronization module 92 is specifically used to:

[0355] According to the window size of the moving window, the latest historical synchronization data corresponding to the window size before the next time period is obtained, and the window size corresponds to at least one clock synchronization process; the number of at least one clock synchronization process in the next time period corresponds to the moving step of the moving window.

[0356] In another possible implementation of the embodiment of the present application, when the clock synchronization module 92 determines the clock synchronization error compensation value based on the historical synchronization data, it is specifically used to:

[0357] The target uplink delay is obtained by integrating the uplink delays corresponding to each historical clock synchronization.

[0358] The target downlink delay is obtained by integrating the downlink delays corresponding to each historical clock synchronization.

[0359] A difference between a target uplink delay and a target downlink delay is determined as a clock synchronization error compensation value.

[0360] The synchronization server of the embodiment of the present application can execute the method provided by the synchronization server of the embodiment of the present application, and the implementation principle is similar. The actions performed by each module in the synchronization server of each embodiment of the present application correspond to the steps in the method of each embodiment of the present application. For the detailed functional description of each module of the device, please refer to the description in the corresponding method shown in the previous text, which will not be repeated here.

[0361] Fig.10 A schematic diagram of the structure of an electronic device applicable to the embodiment of the present application is shown. Fig.10 As shown, the electronic device can be a network status prediction device or a synchronization server. The electronic device can be used to implement the method provided in any embodiment of the present application. For example, the network status prediction device can be used to implement the method executed by the network status prediction device in the embodiment of the present application, and the synchronization server can be used to implement the method executed by the synchronization server in the embodiment of the present application.

[0362] like Fig.10 As shown in FIG. 1 , the electronic device 2000 may mainly include at least one processor 2001 ( Fig.10 2002, a communication module 2003 and an input / output interface 2004, etc. Optionally, the components can be connected and communicated through a bus 2005. It should be noted that: Fig.10 The structure of the electronic device 2000 shown in the figure is merely illustrative and does not constitute a limitation on the electronic device to which the method provided in the embodiment of the present application is applicable.

[0363] Among them, the memory 2002 can be used to store operating systems and applications, etc. The application may include a computer program that implements the method shown in the embodiment of the present application when called by the processor 2001, and may also include a program for implementing other functions or services. The memory 2002 may be a ROM (Read Only Memory) or other types of static storage devices that can store static information and instructions, a RAM (Random Access Memory) or other types of dynamic storage devices that can store information and computer programs, or an EEPROM (Electrically Erasable Programmable Read Only Memory), a CD-ROM (Compact Disc Read Only Memory) or other optical disk storage, optical disk storage (including compressed optical disk, laser disk, optical disk, digital versatile disk, Blu-ray disk, etc.), a magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto.

[0364] The processor 2001 is connected to the memory 2002 via the bus 2005, and implements the corresponding functions by calling the application program stored in the memory 2002. Among them, the processor 2001 can be a CPU (Central Processing Unit), a general processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array) or other programmable logic devices, transistor logic devices, hardware components or any combination thereof, which can implement or execute various exemplary logic blocks, modules and circuits described in conjunction with the disclosure of this application. The processor 2001 can also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, etc.

[0365] The electronic device 2000 can be connected to the network through the communication module 2003 (which may include but is not limited to components such as a network interface) to communicate with other devices (such as a user terminal or a server, etc.) through the network to achieve data interaction, such as sending data to other devices or receiving data from other devices. Among them, the communication module 2003 may include a wired network interface and / or a wireless network interface, etc., that is, the communication module may include at least one of a wired communication module or a wireless communication module.

[0366] The electronic device 2000 can be connected to the required input / output devices, such as a keyboard, a display device, etc., through the input / output interface 2004. The electronic device 2000 itself can have a display device, and can also be connected to other display devices through the interface 2004. Optionally, a storage device, such as a hard disk, can also be connected through the interface 2004, so that data in the electronic device 2000 can be stored in the storage device, or data in the storage device can be read, and data in the storage device can also be stored in the memory 2002. It can be understood that the input / output interface 2004 can be a wired interface or a wireless interface. Depending on the actual application scenario, the device connected to the input / output interface 2004 can be a component of the electronic device 2000, or it can be an external device connected to the electronic device 2000 when needed.

[0367] The bus 2005 for connecting the components may include a path to transmit information between the above components. The bus 2005 may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc. According to different functions, the bus 2005 may be divided into an address bus, a data bus, a control bus, etc.

[0368] Optionally, for the solution provided in the embodiments of the present application, the memory 2002 can be used to store a computer program for executing the solution of the present application, and run by the processor 2001. When the processor 2001 runs the computer program, the actions of the method or device provided in the embodiments of the present application are implemented.

[0369] Based on the same principle as the method provided in the embodiment of the present application, the embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the corresponding content of the aforementioned method embodiment can be implemented.

[0370] An embodiment of the present application also provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the corresponding content of the aforementioned method embodiment can be implemented.

[0371] It should be noted that the terms "first", "second", "third", "fourth", "1", "2", etc. (if any) in the specification and claims of this application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the numbers used in this way can be interchangeable where appropriate, so that the embodiments of the application described herein can be implemented in an order other than that shown or described in the drawings.

[0372] It should be understood that, although each operation step is indicated by arrows in the flowchart of the embodiment of the present application, the implementation order of these steps is not limited to the order indicated by the arrows. Unless clearly stated herein, in some implementation scenarios of the embodiment of the present application, the implementation steps in each flowchart can be performed in other orders according to demand. In addition, some or all of the steps in each flowchart may include multiple sub-steps or multiple stages based on actual implementation scenarios. Some or all of these sub-steps or stages may be executed at the same time, and each sub-step or stage in these sub-steps or stages may also be executed at different times respectively. In different scenarios of execution time, the execution order of these sub-steps or stages may be flexibly configured according to demand, and the embodiment of the present application does not limit this.

[0373] The above is only an optional implementation method for some implementation scenarios of the present application. It should be pointed out that for ordinary technicians in this technical field, without departing from the technical concept of the solution of the present application, other similar implementation methods based on the technical ideas of the present application are also within the protection scope of the embodiments of the present application.

Claims

1. A clock synchronization method, characterized in that: Applied to a clock synchronization system, the clock synchronization system includes a network status prediction device, a terminal device and a synchronization server, the terminal device communicates with the network status prediction device and the synchronization server respectively, and the method is executed by the network status prediction device, including: Determining a current clock synchronization state of the terminal device; If the current clock synchronization state is a timing state, obtaining current network data between the terminal device and the synchronization server, wherein the current network data at least includes network data of a current period; Based on the current network data, the network quality status in the next time period is predicted through a network quality prediction model to determine the target sending frequency based on the network quality status. The target sending frequency is the frequency at which the terminal device sends clock synchronization messages to the synchronization server.

2. The method according to claim 1, characterized in that Determining a target sending frequency of a clock synchronization message according to the network quality status includes: If the network quality state is the first quality state, determining the target sending frequency of the clock synchronization message to be the first sending frequency; If the network quality state is the second quality state, determining the target sending frequency of the clock synchronization message to be the second sending frequency; The network quality corresponding to the first quality state is higher than the network quality corresponding to the second quality state, and the first sending frequency is lower than the second sending frequency.

3. The method according to claim 1, characterized in that: If the current clock synchronization state is a punctual state, the duration of the punctual state is determined by the synchronization server according to the network quality state in the next time period; If the network quality in the next period is the first quality state, determining the duration of the punctual state to be the first duration; If the network quality in the next period is the second quality state, determining the duration of the punctual state to be the second duration; The network quality corresponding to the first quality state is higher than the network quality corresponding to the second quality state, and the first duration is shorter than the second duration.

4. The method according to claim 1, characterized in that: In the case where the current clock synchronization state is a punctual state, the method further includes: Determine a network fluctuation state within a next period of time, wherein the network fluctuation state includes a network fluctuation state or a non-network fluctuation state; Wherein, in the case of a network fluctuation state, if the network fluctuation level is the first level, the clock synchronization state of the terminal device is changed from the timekeeping state to the timing state, and if the network fluctuation level is the second level, the clock synchronization state of the terminal device is maintained, and the network fluctuation level represents the continuous fluctuation duration of the network, and the continuous fluctuation duration corresponding to the first level is greater than the continuous fluctuation duration corresponding to the second level; In the case of non-network fluctuation state, the clock synchronization state of the terminal device is maintained; For a terminal device whose current clock synchronization state is a timing state, when the current clock synchronization accuracy is detected to meet the clock accuracy requirement, the clock synchronization state of the terminal device is changed from the timing state to the timekeeping state.

5. The method according to any one of claims 1 to 4, characterized in that: For a terminal device whose current clock synchronization state is a timing state, when the current clock synchronization accuracy is detected to meet the clock accuracy requirement, the clock synchronization state of the terminal device is changed from the timing state to the punctual state; Whether the current clock synchronization accuracy meets the clock accuracy requirement is determined in the following manner: Obtaining a synchronization accuracy threshold, an uplink delay, and a downlink delay, wherein the uplink delay is a transmission delay of a clock synchronization message, and the downlink delay is a transmission delay of a delay request message, wherein the delay request message is sent by the synchronization server to the terminal device after receiving the clock synchronization message; determining a time difference between the uplink delay and the downlink delay; If the time difference is not greater than the synchronization accuracy threshold, determining that the current clock synchronization accuracy meets the clock accuracy requirement; If the time difference is greater than the synchronization accuracy threshold, it is determined that the current clock synchronization accuracy does not meet the clock accuracy requirement.

6. A clock synchronization method, characterized in that: Applied to a clock synchronization system, the clock synchronization system at least includes a network status prediction device, a terminal device and a synchronization server, the terminal device communicates with the network status prediction device and the synchronization server respectively, and the method is executed by the synchronization server, including: Receiving a clock synchronization message sent by the terminal device; Perform clock synchronization based on the clock synchronization message; Wherein, the clock synchronization message is sent by the network status prediction device to the synchronization server by controlling the terminal device; The clock synchronization message is sent by the network status prediction device to the synchronization server by controlling the terminal device in the following manner: Determining a current clock synchronization state of the terminal device; If the current clock synchronization state is a timing state, obtaining current network data between the terminal device and the synchronization server, wherein the current network data at least includes network data of a current period; Based on the current network data, the network quality status in the next time period is predicted through a network quality prediction model to determine the target sending frequency based on the network quality status. The target sending frequency is the frequency at which the terminal device sends clock synchronization messages to the synchronization server.

7. The method according to claim 6, characterized in that For a terminal device whose current clock synchronization state is a timing state, the method further includes: Determine the current clock synchronization accuracy; When it is detected that the current clock synchronization accuracy reaches the clock accuracy requirement, the clock synchronization state of the terminal device is controlled to be changed from the timing state to the punctual state.

8. The method according to claim 7, characterized in that Methods for determining whether the current clock synchronization accuracy meets the clock accuracy requirements include: Obtaining a synchronization accuracy threshold, an uplink delay, and a downlink delay, wherein the uplink delay is a transmission delay of a clock synchronization message, and the downlink delay is a transmission delay of a delay request message, wherein the delay request message is sent by the synchronization server to the terminal device after receiving the clock synchronization message; determining a time difference between the uplink delay and the downlink delay; If the time difference is not greater than the synchronization accuracy threshold, determining that the current clock synchronization accuracy meets the clock accuracy requirement; If the time difference is greater than the synchronization accuracy threshold, it is determined that the current clock synchronization accuracy does not meet the clock accuracy requirement.

9. The method according to claim 6, characterized in that Performing clock synchronization for each clock synchronization process in at least one clock synchronization process in the next time period includes: For each clock synchronization process in at least one clock synchronization process, based on the clock synchronization message of the clock synchronization process, obtaining an initial time offset between the terminal device and the synchronization server in the clock synchronization process; Obtain clock synchronization error compensation value; Based on the clock synchronization error compensation value, correct the initial time offset corresponding to at least one clock synchronization process in the next time period to obtain a target time offset corresponding to each clock synchronization process; Based on the target time offset corresponding to each clock synchronization process, clock synchronization is performed between the terminal device and the synchronization server.

10. The method according to claim 9, characterized in that The obtaining of the clock synchronization error compensation value comprises: Acquire historical synchronization data, wherein the historical synchronization data includes synchronization data in at least one historical clock synchronization process between the terminal device and the synchronization server, and the historical synchronization data includes: uplink delay and downlink delay; wherein the uplink delay is the transmission delay of the clock synchronization message, and the downlink delay is the transmission delay of the delay request message, wherein the delay request message is sent by the synchronization server to the terminal device after receiving the clock synchronization message sent by the terminal device; Based on the historical synchronization data, the clock synchronization error compensation value is determined.

11. The method according to claim 10, characterized in that The obtaining of historical synchronization data includes: According to the window size of the moving window, the latest historical synchronization data corresponding to the window size before the next time period is obtained, and the window size corresponds to at least one clock synchronization process; the number of at least one clock synchronization process in the next time period corresponds to the moving step size of the moving window.

12. A network status prediction device, characterized in that: Applied to a clock synchronization system, the clock synchronization system also includes at least a terminal device and a synchronization server, the terminal device communicates with the network prediction device and the synchronization server respectively, the network prediction device includes a memory and a processor, the memory stores a computer program, and the processor executes the clock synchronization method described in any one of claims 1 to 5 when running the computer program.

13. A synchronization server, characterized in that: Applied to a clock synchronization system, the clock synchronization system also includes at least a network status prediction device and a terminal device, the terminal device communicates with the network prediction device and the synchronization server respectively, the synchronization server includes a memory and a processor, the memory stores a computer program, and the processor executes the clock synchronization method described in any one of claims 6 to 11 when running the computer program.

14. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by a processor, the clock synchronization method described in any one of claims 1 to 5 or any one of claims 6 to 11 is implemented.

15. A clock synchronization system, characterized in that: The clock synchronization system includes a network status prediction device, a terminal device and a synchronization server, wherein the terminal device communicates with the network status prediction device and the synchronization server respectively, wherein: The network status prediction device is used to predict the network quality status in the next time period according to the current network data acquired between the terminal device and the synchronization server when the clock synchronization state is the timing state, and send the network quality status to the terminal device; The terminal device is used to determine a target sending frequency according to the received network quality status, and send a clock synchronization message to the synchronization server based on the target sending frequency; The synchronization server is used to obtain an error synchronization compensation value, and calculate an initial clock offset based on a received clock synchronization message, and correct the initial clock offset based on the obtained error synchronization compensation value to obtain a target time offset corresponding to each clock synchronization process, so as to perform clock synchronization between the terminal device and the synchronization server based on the target time offset corresponding to each clock synchronization process.