Time synchronization method, timed device and computer readable storage medium

By obtaining the failure data of the time server and calculating the comprehensive priority, dynamically selecting the optimal synchronization server, solving the problem of instability in the existing technology, and achieving higher time synchronization stability and accuracy.

CN120454907APending Publication Date: 2025-08-08SICHUAN TAIFU GROUND BEIDOU TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510470064.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-15
Publication Date
2025-08-08

AI Technical Summary

Technical Problem

The existing time synchronization system fails to dynamically consider the actual health status of the time server, resulting in the long-term unstable synchronization server, affecting the stability of time synchronization.

Method used

By obtaining the failure data of each time server, calculating its annual average failure time, time source accuracy and time source stability, dynamically determine the comprehensive priority, and selecting the optimal synchronization server for time synchronization using the comprehensive priority.

Benefits of technology

Improve the stability and accuracy of time synchronization, reduce time errors caused by server failure or network jitter, and ensure that the system continuously obtains high-quality time information.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120454907A_ABST
    Figure CN120454907A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a time synchronization method, timed equipment and a computer readable storage medium, which are used for improving the stability of time synchronization. The method provided by the embodiment of the invention comprises the following steps: acquiring fault data of each path of time server, wherein the fault data comprises fault start time and fault end time; when preset time arrives, calculating the comprehensive priority of each path of time server in real time according to the fault data; determining a synchronization server according to the comprehensive priority; and performing time synchronization by using the synchronization server.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of time synchronization technology, and in particular to a time synchronization method, a time-served device, and a computer-readable storage medium. Background Art

[0002] In fields such as distributed systems, communication networks, and precision industrial control, time synchronization technology is crucial for ensuring the coordinated operation of various devices. Existing time synchronization typically relies on multiple time servers, which distribute standard time to the devices being served via network timing protocols (such as NTP and PTP). To ensure synchronization accuracy, the devices being served must select one of the multiple time servers as a reference time source and regularly update their local clocks. However, current time synchronization mechanisms still suffer from several issues that affect the stability of time synchronization.

[0003] Existing time synchronization systems typically use a fixed or simple round-robin approach to select synchronization servers. For example, some systems pre-set a primary time server with a high priority and only switch to a backup server if it becomes unavailable. The main problem with this approach is that it fails to dynamically consider the actual operating status of time servers, potentially leading to long-term instability in the selected synchronization server. Summary of the Invention

[0004] The embodiments of the present application provide a time synchronization method, a time-served device, and a computer-readable storage medium, which can improve the stability of time synchronization.

[0005] A first aspect of an embodiment of the present application provides a time synchronization method, including:

[0006] Obtain fault data of each time server, the fault data including fault start time and fault end time;

[0007] When the preset time arrives, the comprehensive priority of each time server is calculated in real time based on the fault data;

[0008] Determining a synchronization server according to the comprehensive priority;

[0009] The synchronization server is used to perform time synchronization.

[0010] Optionally, the calculating the comprehensive priority of each time server according to the fault data in real time includes:

[0011] Calculate the annual average failure time of each time server based on the failure data;

[0012] Get the time source accuracy of each time server;

[0013] Obtain the time source stability of each time server;

[0014] The comprehensive priority of each time server is calculated according to the annual average failure time, the time source accuracy and the time source stability.

[0015] Optionally, the calculating the annual average failure time of each time server according to the failure data includes:

[0016] Get the start time of each time server;

[0017] Calculate the total running time and total failure time of each time server according to the failure data and the start running time;

[0018] The annual average failure time of each time server is calculated according to the total operating time and the total failure time.

[0019] Optionally, obtaining the time source accuracy of each time server includes:

[0020] Get the current time of each time server;

[0021] The time source accuracy of each time server is calculated based on the current time and the locally maintained Coordinated Universal Time (UTC).

[0022] Optionally, obtaining the time source stability of each time server includes:

[0023] Calculate the standard deviation of frequency drift of each time server;

[0024] The time source stability of each time server is determined according to the frequency drift standard deviation.

[0025] Optionally, the calculating the comprehensive priority of each time server according to the annual average failure time, the time source accuracy, and the time source stability includes:

[0026] The comprehensive priority of each time server is calculated based on the comprehensive priority formula, the annual average failure time, the time source accuracy, and the time source stability; the comprehensive priority formula is:

[0027]

[0028] Where CP is the comprehensive priority, AFT is the average annual failure time, A is the time source accuracy, S is the time source stability, and w1, w2, and w3 are constant term coefficients.

[0029] Optionally, after obtaining the fault data of each time server, the method further includes:

[0030] The fault data is persistently stored.

[0031] A second aspect of an embodiment of the present application provides a time-served device, including:

[0032] An acquiring unit, configured to acquire fault data of each time server, wherein the fault data includes a fault start time and a fault end time;

[0033] A calculation unit, configured to calculate the comprehensive priority of each time server in real time based on the fault data when a preset time arrives;

[0034] a determining unit, configured to determine a synchronization server according to the comprehensive priority;

[0035] A synchronization unit is used to perform time synchronization using the synchronization server.

[0036] Optionally, the calculation unit includes:

[0037] A first calculation module is used to calculate the annual average failure time of each time server based on the failure data;

[0038] The first acquisition module is used to obtain the time source accuracy of each time server;

[0039] The second acquisition module is used to obtain the time source stability of each time server;

[0040] The second calculation module is used to calculate the comprehensive priority of each time server according to the annual average failure time, the time source accuracy and the time source stability.

[0041] Optionally, the first calculation module is specifically configured to:

[0042] Get the start time of each time server;

[0043] Calculate the total running time and total failure time of each time server according to the failure data and the start running time;

[0044] The annual average failure time of each time server is calculated according to the total operating time and the total failure time.

[0045] Optionally, the first acquisition module is specifically configured to:

[0046] Get the current time of each time server;

[0047] The time source accuracy of each time server is calculated based on the current time and the locally maintained Coordinated Universal Time (UTC).

[0048] Optionally, the second acquisition module is specifically configured to:

[0049] Calculate the standard deviation of frequency drift of each time server;

[0050] The time source stability of each time server is determined according to the frequency drift standard deviation.

[0051] Optionally, the second calculation module is specifically configured to:

[0052] The comprehensive priority of each time server is calculated based on the comprehensive priority formula, the annual average failure time, the time source accuracy, and the time source stability; the comprehensive priority formula is:

[0053]

[0054] Where CP is the comprehensive priority, AFT is the average annual failure time, A is the time source accuracy, S is the time source stability, and w1, w2, and w3 are constant term coefficients.

[0055] Optionally, the timing device further includes:

[0056] The storage unit is used to persistently store the fault data.

[0057] A third aspect of an embodiment of the present application provides a time-served device, including:

[0058] processor, memory, input and output units, and buses;

[0059] The processor is connected to the memory, the input and output unit, and the bus;

[0060] A program is stored in the memory, and the processor calls the program to execute the method in the first aspect and any possible implementation of the first aspect.

[0061] A fourth aspect of an embodiment of the present application provides a computer-readable storage medium, on which a program is stored. When the program is executed on a computer, the computer executes the method in the first aspect and any possible implementation of the first aspect.

[0062] It can be seen from the above technical solutions that the embodiments of the present application have the following advantages:

[0063] The device receiving the timing service obtains fault data from each time server and calculates a comprehensive priority based on this data in real time. This allows the device to dynamically determine the optimal synchronization server and use it for time synchronization. This process allows the device to avoid selecting servers with chronic faults or poor stability as its time synchronization source, thereby improving the accuracy and reliability of timing, reducing time deviations caused by server anomalies, ensuring that the system can continuously and stably obtain high-quality time information, and improving the stability of time synchronization. BRIEF DESCRIPTION OF THE DRAWINGS

[0064] Figure 1 This is a flow chart of an embodiment of a time synchronization method in an embodiment of the present application;

[0065] Figure 2 A flowchart of an embodiment of calculating the comprehensive priority in an embodiment of the present application;

[0066] Figure 3 This is a flow chart of an embodiment of calculating the average annual failure time in the embodiment of the present application;

[0067] Figure 4 This is a flow chart of an embodiment of obtaining the time source accuracy in the embodiment of the present application;

[0068] Figure 5 A schematic diagram of a flow chart of an embodiment of obtaining the stability of a time source in an embodiment of the present application;

[0069] Figure 6 This is a structural diagram of an embodiment of a timing device in the embodiment of the present application;

[0070] Figure 7 This is a structural diagram of an embodiment of a timing device in the embodiments of the present application. DETAILED DESCRIPTION

[0071] Embodiments of the present application provide a time synchronization method, a timed device, and a computer-readable storage medium for improving the stability of time synchronization.

[0072] The embodiments of the present application will be described below with reference to the accompanying drawings.

[0073] See also Figure 1 In one embodiment of the time synchronization method of the present application, the following steps are included:

[0074] 101. Obtain the fault data of each time server, the fault data including the fault start time and the fault end time;

[0075] The device receiving the timing service obtains the fault data of each time server, which includes the fault start time and fault end time. The device receiving the timing service first identifies the operating status of the time server through network monitoring, log analysis, or server feedback information. When the server experiences an abnormality, the device records the specific time when the fault occurred as the fault start time; when the server returns to normal, it records the fault end time. The device receiving the timing service may actively query the server status through periodic polling, or it may receive fault information based on the server's self-reporting mechanism. For time servers with multiple fault records, the device receiving the timing service will store historical fault information for subsequent analysis of fault trends and calculation of priorities.

[0076] 102. When the preset time arrives, the comprehensive priority of each time server is calculated in real time based on the fault data;

[0077] When the preset time arrives, the device receiving the timing service calculates the comprehensive priority of each time server in real time based on the acquired fault data. During the calculation process, the device receiving the timing service may consider multiple factors, such as the server's historical fault duration, fault frequency, stability in the recent period, network latency, and the server's current availability. For time servers with a long history of faults or a high fault frequency, the device receiving the timing service may lower their priority to reduce the possibility of using unstable servers. At the same time, the device receiving the timing service may give higher weight to faults within the most recent time window to ensure that servers that have been running stably in the recent period are given priority. In addition, if the server's network latency is high, the device receiving the timing service may further adjust its priority to ensure timing accuracy. After comprehensively considering these factors, the device receiving the timing service calculates the comprehensive priority of each time server and ranks them.

[0078] 103. Determine the synchronization server based on the comprehensive priority;

[0079] The time-served device determines the synchronization server based on the calculated comprehensive priority. Normally, a time server with a higher priority will be selected as the synchronization server first, but if multiple time servers have the same priority, the time-served device may adopt additional screening strategies. For example, the time-served device can further refine the selection based on factors such as network latency and time deviation to ensure that the selected server can provide the most accurate time. At the same time, the time-served device may adopt a polling or backup mechanism to automatically switch to the next highest priority server when the main synchronization server is unavailable to ensure the continuity and reliability of time synchronization. Once the synchronization server is determined, the time-served device marks it as the current time source and prepares for time synchronization operations.

[0080] 104. Use the synchronization server to synchronize time.

[0081] The time-served device uses a determined synchronization server for time synchronization. First, the time-served device sends a time synchronization request to the synchronization server. The request may include a timestamp, synchronization mode, and other relevant parameters. After receiving the request, the synchronization server will return the current standard time, and may also include information such as the server's clock accuracy and network delay. After receiving the returned time data, the time-served device will correct it based on its own clock deviation. For example, the time-served device can estimate the time synchronization error by calculating the round-trip time (RTT) and use the clock drift compensation algorithm to make adjustments to reduce the impact of network transmission delay on timing accuracy. After synchronization is completed, the time-served device will continuously monitor the stability of the synchronization server and re-execute the priority calculation at the next preset time to adapt to possible failures or changes in network status to ensure continuous and stable time synchronization.

[0082] In this embodiment, the time-served device can effectively use fault data to optimize the selection of time servers and improve the accuracy and stability of time synchronization. First, by obtaining fault data, the time-served device can accurately grasp the operating status of each time server and provide a basis for subsequent priority calculation. Secondly, through comprehensive priority calculation, the time-served device can fully consider the server's historical failures, current status, and network conditions to ensure that stable and reliable servers are selected for time synchronization. Subsequently, in the process of determining the synchronization server, the time-served device can further optimize the selection strategy to reduce the time error caused by the instability of the synchronization server. Finally, in the time synchronization stage, the time-served device can combine network delay compensation and clock drift correction technology to improve synchronization accuracy. Overall, this mechanism enables the time-served device to always select a more reliable synchronization server, reduce the time synchronization error caused by server failure or network jitter, and thus improve the accuracy and stability of the overall time synchronization.

[0083] Furthermore, in order to avoid the impact of manual maintenance on statistical data, the system should allow manual invalidation of one or more segments of fault data.

[0084] See also Figure 2 In some embodiments of the present application, when the preset time arrives, step 102 in the above embodiment calculates the comprehensive priority of each time server in real time based on the fault data, which may include the following steps:

[0085] 201. Calculate the annual average failure time of each time server based on the failure data;

[0086] The receiving device calculates the average annual downtime for each time server based on the failure data. First, the receiving device compiles the time server's historical failure records, including the start and end times of the failure, and calculates the duration of each failure. It then adds up all failure durations to calculate the total downtime for the server over the year. Finally, the receiving device divides this total downtime by the time span of the failures or normalizes it to an annual scale to calculate the average annual downtime. This calculation reflects the long-term stability of the time server and provides a reliable basis for subsequent priority calculations.

[0087] 202. Obtain the time source accuracy of each time server;

[0088] The time-served device obtains the time source accuracy of each time server. Time source accuracy generally refers to the deviation between the time provided by the time server and the standard time (such as UTC). The time-served device can measure this deviation by regularly comparing the server time with a high-precision reference time. For example, the time-served device can adopt a high-precision timing protocol (such as PTP) or obtain calibration data from an authoritative time source, and calculate the error distribution of the time server. A lower time deviation indicates that the time source has a higher accuracy, while a larger deviation may lead to an increase in synchronization error. After obtaining the accuracy data, the time-served device may classify or weight it for use in the subsequent calculation of the comprehensive priority.

[0089] 203. Obtain the time source stability of each time server;

[0090] The device receiving timing information obtains the time source stability of each time server. Time source stability typically refers to the clock frequency drift of the time server, that is, the magnitude of the change in its time error over a period of time. The device receiving timing information can assess its stability by sampling the time server's time data multiple times and calculating the time drift rate (such as the Allan variance). If the time server's error changes slightly, it indicates high stability; if the error fluctuates significantly, the server's clock is unstable. Insufficiently stable servers can lead to reduced timing accuracy, making this metric crucial in overall priority calculations.

[0091] 204. Calculate the comprehensive priority of each time server based on the average annual failure time, time source accuracy and time source stability.

[0092] The receiving device calculates the overall priority of each time server based on the average annual failure time, time source accuracy, and time source stability. During this calculation, the receiving device may assign different weights to different indicators based on their importance. For example, the average annual failure time reflects the long-term reliability of the server, time source accuracy directly affects timing accuracy, and time source stability determines the long-term consistency of the timing system. The receiving device may use a weighted average, scoring mechanism, or other optimization algorithm to comprehensively evaluate the priority of each server and ultimately determine a single value as the overall priority of the server. Servers with higher priorities will be preferred in subsequent time synchronization processes to improve overall time synchronization stability.

[0093] In this embodiment, the device receiving the timing service can comprehensively evaluate the reliability, accuracy, and stability of the time server, thereby calculating a more reasonable overall priority. By combining the average annual failure time, the device can identify servers with long-term reliable operation; by obtaining the time source accuracy, the device can filter out servers with higher timing accuracy; and by analyzing the time source stability, the device can avoid selecting servers with large clock drift. Ultimately, during the overall priority calculation phase, the device can make the optimal choice based on multiple key indicators, ensuring that the time synchronization process is always based on the most stable time server, thereby improving the stability of time synchronization.

[0094] See also Figure 3 In some embodiments of the present application, step 201 in the above embodiment of calculating the annual average failure time of each time server based on the failure data may include the following steps:

[0095] 301. Obtain the start time of each time server;

[0096] The device receiving the timing service obtains the start time of each time server. This typically refers to the time server's official commissioning. The device can obtain this data by querying the server's initial configuration log, device registration information, or operational records in the management system. If the server undergoes a reset or hardware replacement during operation, the device may need to update the start time based on the latest initialization time to ensure accurate calculations. This data provides the basis for subsequent calculations of the server's total operational time.

[0097] 302. Calculate the total running time and total failure time of each time server based on the failure data and the start running time;

[0098] The time-served device calculates the total running time and total failure time of each time server based on the fault data and the start time of operation. First, the time-served device calculates the total running time, which is the time span from the start time of the server to the current time, excluding non-working time (such as planned maintenance or outage period). Then, the time-served device organizes all fault records of the server and calculates the cumulative duration of all faults to obtain the total failure time. During this calculation process, the time-served device needs to ensure data integrity to avoid missing short-term fault records. At the same time, it may be necessary to filter abnormal data to improve the calculation accuracy. The calculation results of total running time and total failure time will be used as input for the next step of calculating the average annual failure time.

[0099] 303. Calculate the annual average failure time of each time server based on the total operating time and the total failure time.

[0100] The receiving device calculates the average annual downtime for each time server based on the total uptime and total downtime. The receiving device first normalizes the total downtime to an annual scale, converting the server's total uptime into its annual average downtime. For example, for servers that have been operating for less than a year, the receiving device might use a scaling method to estimate the average annual downtime. For servers that have been operating for more than a year, the receiving device can directly calculate the annual average. The resulting average annual downtime is used to measure the server's long-term stability and provide data support for subsequent comprehensive priority calculations.

[0101] In this embodiment, the device receiving the timing service accurately calculates the average annual downtime for each time server. By obtaining the start time, the device can determine the actual operating time of the time server. By calculating the total operating time and total downtime, the device can quantify the overall reliability of the server. Finally, by normalizing the average annual downtime, the device can provide a standardized stability indicator, providing a more reliable basis for subsequent time server priority calculation and selection, thereby improving the stability of time synchronization.

[0102] See also Figure 4 In some embodiments of the present application, step 202 in the above embodiment, obtaining the time source accuracy of each time server, may include the following steps:

[0103] 401. Get the current time of each time server;

[0104] The device receiving the time service obtains the current time from each time server. It requests the current time from each time server using a network timing protocol (such as NTP or PTP) and records the time information returned by the server. To reduce the impact of network latency on time acquisition, the device may make multiple requests and calculate the average, or use timestamp comparison to improve the accuracy of the time data. The obtained current time will serve as the basis for subsequent calculations of the time source accuracy.

[0105] 402. Calculate the time source accuracy of each time server based on the current time and the locally maintained Coordinated Universal Time (UTC).

[0106] The timed device calculates the time source accuracy of each time server based on the current time and the locally maintained Coordinated Universal Time (UTC). The timed device maintains a high-precision UTC time reference, which can be obtained through a satellite timing system (such as GPS), an authoritative time server, or a local high-precision atomic clock calibration. The timed device then compares the current time of each time server with the UTC reference and calculates the time deviation, usually in milliseconds or nanoseconds. In order to improve the reliability of the calculation, the timed device may perform statistical analysis on the deviation data, such as calculating the average error, maximum error, and standard deviation, to comprehensively evaluate the time source accuracy of the time server.

[0107] In this embodiment, the device receiving the timing service can accurately assess the time source accuracy of each time server. By obtaining the current time of the time server, the device can collect timing data in real time. By comparing it with Coordinated Universal Time (UTC), the device can quantify the time deviation and thus determine the accuracy of the server's time source. Time servers with higher accuracy can provide a more reliable timing benchmark. Therefore, this calculation result provides an important basis for the subsequent time server priority calculation, helping to improve the stability of time synchronization.

[0108] See also Figure 5 In some embodiments of the present application, step 203 in the above embodiment, obtaining the time source stability of each time server, may include the following steps:

[0109] 501. Calculate the frequency drift standard deviation of each time server;

[0110] The receiving device calculates the standard deviation of frequency drift for each time server. Frequency drift refers to the degree to which the time server's clock frequency deviates from the ideal frequency, which leads to the accumulation of time errors. The receiving device periodically collects timing data from the time server and calculates the rate of change of time deviation within adjacent time intervals to obtain clock frequency drift data. The receiving device then counts the frequency drift values over a period of time and calculates their standard deviation to measure the clock stability of the time server. A small standard deviation indicates that the server's frequency drift is relatively stable, while a large standard deviation indicates that the server's clock frequency fluctuates significantly, which may lead to increased synchronization errors.

[0111] 502. Determine the time source stability of each time server according to the frequency drift standard deviation.

[0112] The time-served device determines the time source stability of each time server based on the frequency drift standard deviation. Generally speaking, the smaller the frequency drift standard deviation, the higher the stability of the time source. Therefore, the time-served device can set certain thresholds or grading standards to divide the stability of time servers into different levels. For example, the time-served device can set a low standard deviation threshold. Servers below this threshold are considered to be highly stable servers, while servers with larger standard deviations are considered to be less stable servers. In addition, the time-served device may combine other factors (such as historical frequency drift trends) to conduct a more detailed stability assessment to ensure the reliability of the calculation results.

[0113] In this embodiment, the device receiving the timing service can accurately assess the stability of the time server's time source. By calculating the standard deviation of frequency drift, the device can quantify the stability of the time server's clock. This standard deviation-based stability assessment allows the device to select more stable time servers, thereby reducing the accumulation of timing errors. Ultimately, this assessment result is used to prioritize time servers, ensuring that the device consistently selects the most stable time source, thereby improving the stability of time synchronization.

[0114] In some embodiments of the present application, step 204 in the above embodiment, which calculates the comprehensive priority of each time server based on the average annual failure time, time source accuracy, and time source stability, may include the following steps:

[0115] The comprehensive priority of each time server is calculated based on the comprehensive priority formula, average annual failure time, time source accuracy, and time source stability. The comprehensive priority formula is:

[0116]

[0117] Where CP is the comprehensive priority, AFT is the average annual failure time, A is the time source accuracy, S is the time source stability, and w1, w2, and w3 are constant term coefficients.

[0118] The receiving device calculates the comprehensive priority of each time server based on the comprehensive priority formula, the average annual failure time, the time source accuracy, and the time source stability. First, the receiving device obtains the average annual failure time (AFT), the time source accuracy (A), and the time source stability (S) of each time server from the previous calculation results. Then, the receiving device calculates the comprehensive priority of each time server based on the preset comprehensive priority formula:

[0119]

[0120] The parameters of each server are substituted into the calculation, where w1, w2, and w3 are constant coefficients, representing the weight of the impact of different indicators on the overall priority. Since a larger annual average failure time (AFT) indicates lower server reliability, its reciprocal is used as an influencing factor to ensure that servers with shorter failure times have higher priority. Similarly, a greater time source accuracy (A) indicates a larger time error, so its reciprocal is used to ensure that servers with high accuracy receive higher priority; a greater time source stability (S) indicates greater clock frequency fluctuations, so servers with higher stability are given an advantage in the priority calculation. Finally, the device being synchronized calculates the CP value of each time server and ranks the overall priority of all servers, prioritizing servers with higher CP values for time synchronization.

[0121] In this embodiment, the device receiving time services can scientifically and rationally evaluate the overall priority of each time server. By introducing three key indicators: average annual downtime, time source accuracy, and time source stability, and using a reciprocal calculation to ensure that servers with high reliability, high accuracy, and high stability receive higher priority, the device receiving time services can more accurately select the optimal time server as the synchronization source, thereby improving the stability of time synchronization.

[0122] In some embodiments of the present application, after the time-served device obtains the fault data of each time server, it can also persistently store the fault data. By obtaining and persistently storing the fault data, the time-served device can ensure the integrity of the fault history information, providing reliable data support for subsequent calculation of the average annual failure time, analysis of server stability, and optimization of time synchronization strategies. This approach not only improves the system's fault tolerance, but also ensures that the failure status of the time server is tracked over the long term, thereby providing data support for improving the stability of time synchronization.

[0123] See also Figure 6 In the embodiment of the present application, an embodiment of the timing device includes:

[0124] An acquiring unit 601 is configured to acquire fault data of each time server, the fault data including the fault start time and the fault end time;

[0125] The calculation unit 602 is used to calculate the comprehensive priority of each time server in real time based on the fault data when the preset time arrives;

[0126] A determination unit 603 is configured to determine a synchronization server according to the comprehensive priority;

[0127] The synchronization unit 604 is configured to perform time synchronization using a synchronization server.

[0128] In this embodiment, the device being timed can effectively utilize fault data to optimize the selection of time servers and improve the accuracy and stability of time synchronization. First, by acquiring fault data through the acquisition unit 601, the operating conditions of each time server can be accurately grasped, providing a basis for subsequent priority calculations. Secondly, through the comprehensive priority calculation by the calculation unit 602, the historical faults, current status and network conditions of the server can be fully considered to ensure that a stable and reliable server is selected for time synchronization. Subsequently, in the process of determining the synchronization server by the determination unit 603, the selection strategy can be further optimized to reduce the time error caused by the instability of the synchronization server. Finally, in the time synchronization stage, the synchronization unit 604 can combine network delay compensation and clock drift correction technology to improve synchronization accuracy. Overall, this mechanism enables the device being timed to always select a more reliable synchronization server, reduce the time synchronization error caused by server failure or network jitter, and thus improve the accuracy and stability of the overall time synchronization.

[0129] Optionally, the computing unit includes:

[0130] The first calculation module is used to calculate the annual average failure time of each time server based on the failure data;

[0131] The first acquisition module is used to obtain the time source accuracy of each time server;

[0132] The second acquisition module is used to obtain the time source stability of each time server;

[0133] The second calculation module is used to calculate the comprehensive priority of each time server according to the annual average failure time, the time source accuracy and the time source stability.

[0134] Optionally, the first calculation module is specifically configured to:

[0135] Get the start time of each time server;

[0136] Calculate the total running time and total failure time of each time server based on the failure data and the start running time;

[0137] Calculate the annual average failure time of each time server based on the total operating time and total failure time.

[0138] Optionally, the first acquisition module is specifically configured to:

[0139] Get the current time of each time server;

[0140] The time source accuracy of each time server is calculated based on the current time and the locally maintained Coordinated Universal Time (UTC).

[0141] Optionally, the second acquisition module is specifically configured to:

[0142] Calculate the standard deviation of frequency drift of each time server;

[0143] The time source stability of each time server is determined based on the frequency drift standard deviation.

[0144] Optionally, the second calculation module is specifically configured to:

[0145] The comprehensive priority of each time server is calculated based on the comprehensive priority formula, average annual failure time, time source accuracy, and time source stability. The comprehensive priority formula is:

[0146]

[0147] Where Cp is the comprehensive priority, AFT is the average annual failure time, A is the time source accuracy, S is the time source stability, and w1, w2, and w3 are constant term coefficients.

[0148] Optionally, the timing device also includes:

[0149] The storage unit is used to store fault data persistently.

[0150] In this implementation, the functions of each unit and module are the same as those mentioned above. Figures 1 to 5 The steps in the illustrated embodiment correspond to each other and will not be repeated here.

[0151] See also Figure 7 Another embodiment of the timing device in the embodiment of the present application includes:

[0152] Processor 701, memory 702, input and output unit 703 and bus 704;

[0153] The processor 701 is connected to the memory 702, the input and output unit 703 and the bus 704;

[0154] The memory 702 stores a program, and the processor 701 calls the program to execute Figures 1 to 5 Steps in the illustrated embodiment.

[0155] In this embodiment, the function of the processor 701 is the same as that of the aforementioned Figures 1 to 5 The steps in the illustrated embodiment correspond to each other and will not be repeated here.

[0156] The embodiment of the present application further provides a computer-readable storage medium having a program stored thereon, which, when executed on a computer, causes the computer to execute the aforementioned Figures 1 to 5 A method in any possible embodiment.

[0157] Those skilled in the art will clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0158] In the several embodiments provided in this application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of the units is merely a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.

[0159] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.

[0160] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.

[0161] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, read-only memory), random access memory (RAM, random access memory), disk or optical disk, and other media that can store program code.

Claims

1. A time synchronization method, applied to a time-served device, characterized in that: include: Obtain fault data of each time server, the fault data including fault start time and fault end time; When the preset time arrives, the comprehensive priority of each time server is calculated in real time based on the fault data; Determining a synchronization server according to the comprehensive priority; The synchronization server is used to perform time synchronization.

2. The method according to claim 1, characterized in that The real-time calculation of the comprehensive priority of each time server according to the fault data includes: Calculate the annual average failure time of each time server based on the failure data; Get the time source accuracy of each time server; Obtain the time source stability of each time server; The comprehensive priority of each time server is calculated according to the annual average failure time, the time source accuracy and the time source stability.

3. The method according to claim 2, characterized in that The calculating the annual average failure time of each time server according to the failure data includes: Get the start time of each time server; Calculate the total running time and total failure time of each time server according to the failure data and the start running time; The annual average failure time of each time server is calculated according to the total operating time and the total failure time.

4. The method according to claim 2, characterized in that Obtaining the time source accuracy of each time server includes: Get the current time of each time server; The time source accuracy of each time server is calculated based on the current time and the locally maintained Coordinated Universal Time (UTC).

5. The method according to claim 2, characterized in that The step of obtaining the time source stability of each time server includes: Calculate the standard deviation of frequency drift of each time server; The time source stability of each time server is determined according to the frequency drift standard deviation.

6. The method according to claim 2, characterized in that The calculating of the comprehensive priority of each time server according to the annual average failure time, the time source accuracy, and the time source stability includes: The comprehensive priority of each time server is calculated based on the comprehensive priority formula, the annual average failure time, the time source accuracy, and the time source stability; the comprehensive priority formula is: Where CP is the comprehensive priority, AFT is the average annual failure time, A is the time source accuracy, S is the time source stability, and w1, w2, and w3 are constant term coefficients.

7. The method according to any one of claims 1 to 6, characterized in that After obtaining the fault data of each time server, the method further includes: The fault data is persistently stored.

8. A time-served device, characterized in that: include: An acquiring unit, configured to acquire fault data of each time server, wherein the fault data includes a fault start time and a fault end time; A calculation unit, configured to calculate the comprehensive priority of each time server in real time based on the fault data when a preset time arrives; a determining unit, configured to determine a synchronization server according to the comprehensive priority; A synchronization unit is used to perform time synchronization using the synchronization server.

9. A time-served device, characterized in that: include: processor, memory, input and output units, and buses; The processor is connected to the memory, the input and output unit, and the bus; A program is stored in the memory, and the processor calls the program to execute the method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a program, and when the program is executed on a computer, the computer is caused to execute the method according to any one of claims 1 to 7.