Clock synchronization method, device, equipment and readable storage medium
By reading and replacing the 1588 network card driver and compensation value file of the operating system, dynamically adjusting the clock synchronization compensation value, solving the problem of poor clock synchronization accuracy in the existing technology, achieving higher clock synchronization accuracy and business scenario adaptability .
Patent Information
- Application Number
- CN202210845146.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-18
- Publication Date
- 2025-02-14
- Estimated Expiration
- 2042-07-18
AI Technical Summary
In the existing 1588 clock synchronization function, the clock synchronization compensation value is strongly bound to the test scenario, resulting in poor clock synchronization accuracy when the actual business scenario does not match the test scenario.
By starting the operating system, reading the 1588 network card driver and compensation value file, replacing the operating system's network card driver, obtaining the actual system load, and determining the appropriate clock synchronization compensation value based on the compensation value file for clock synchronization.
It realizes dynamic adjustment of clock synchronization compensation value according to actual system load, thereby improving clock synchronization accuracy and adapting to different business scenarios.
Smart Images

Figure CN115296766B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of communication technology, and in particular to a clock synchronization method, device, equipment and readable storage medium. Background Art
[0002] The clock synchronization compensation value used by the existing 1588 clock synchronization function is strongly bound to the test scenario, that is, the clock synchronization compensation value is solidified through testing. If the subsequent actual business scenario does not match the test scenario, the current clock synchronization compensation value will be inapplicable, resulting in poor clock synchronization accuracy. Summary of the invention
[0003] In order to solve the above technical problems, the present invention provides a clock synchronization method, device, equipment and readable storage medium.
[0004] In a first aspect, the present invention provides a clock synchronization method, the clock synchronization method comprising:
[0005] Start the operating system, read the 1588 network card driver and the compensation value file corresponding to the operating system, the compensation value file records the clock synchronization compensation values corresponding to different system loads;
[0006] Replacing the network card driver of the operating system with the 1588 network card driver;
[0007] The actual system load is obtained, and an actual clock synchronization compensation value corresponding to the actual system load is determined according to the compensation value file, and clock synchronization is performed using the actual clock synchronization compensation value.
[0008] Optionally, after the step of obtaining the actual system load and determining the clock synchronization compensation value corresponding to the actual system load according to the compensation value file, so that the 1588 service performs clock synchronization based on the clock synchronization compensation value, the step further includes:
[0009] When the system load change rate is greater than the preset change rate, a new clock synchronization compensation value corresponding to the new system load is determined according to the compensation value file, and clock synchronization is performed with the new clock synchronization compensation value.
[0010] Optionally, after the step of replacing the network card driver of the operating system with the 1588 network card driver, the method further includes:
[0011] Perform clock synchronization with the default clock synchronization offset value;
[0012] Detecting whether a synchronization accuracy error of clock synchronization performed with a default clock synchronization compensation value is less than or equal to a preset threshold;
[0013] The step of obtaining the actual system load, determining the actual clock synchronization compensation value corresponding to the actual system load according to the compensation value file, and performing clock synchronization with the actual clock synchronization compensation value comprises:
[0014] If it is greater than a preset threshold, the actual system load is obtained, and an actual clock synchronization compensation value corresponding to the actual system load is determined according to the compensation value file, and the clock synchronization step is performed using the actual clock synchronization compensation value.
[0015] Optionally, the step of determining the actual clock synchronization compensation value corresponding to the actual system load according to the compensation value file includes:
[0016] Determine a target system load that matches the actual system load and a plurality of clock synchronization compensation values corresponding to the target system load from the compensation value file;
[0017] Selecting a clock synchronization compensation value that has not been selected from a plurality of clock synchronization compensation values corresponding to the target system load;
[0018] Detecting whether a synchronization accuracy error of clock synchronization performed with the selected clock synchronization compensation value is less than or equal to a preset threshold;
[0019] If it is less than or equal to the preset threshold, the selected clock synchronization compensation value is used as the actual clock synchronization compensation value;
[0020] If it is greater than a preset threshold, the process returns to the step of selecting a clock synchronization compensation value that has not been selected from a plurality of clock synchronization compensation values corresponding to the target system load.
[0021] Optionally, the step of detecting whether a synchronization accuracy error of clock synchronization performed using the selected clock synchronization compensation value is less than or equal to a preset threshold value includes:
[0022] Run the clock synchronization program and perform clock synchronization with the selected clock synchronization compensation value;
[0023] Get the log file output by the clock synchronization program;
[0024] Analyze the log file to obtain a synchronization accuracy error of clock synchronization using the selected clock synchronization compensation value;
[0025] Detect whether the synchronization accuracy error is less than or equal to a preset threshold.
[0026] Optionally, before the step of starting the operating system and reading the 1588 network card driver and the compensation value file corresponding to the operating system, the step further includes:
[0027] After the operating system starts, read the 1588 network card driver source code;
[0028] Compile the 1588 network card driver source code to obtain the 1588 network card driver, and replace the network card driver of the operating system with the 1588 network card driver;
[0029] Selecting a system load that has not been selected from the load record table, where the load record table records multiple system loads;
[0030] Set the system load of the operating system to the selected system load;
[0031] Selecting a clock synchronization compensation value that has not been selected from the compensation value record table, wherein the compensation value record table records a plurality of clock synchronization compensation values;
[0032] Detecting whether a synchronization accuracy error of clock synchronization performed with the selected clock synchronization compensation value is less than or equal to a preset threshold;
[0033] If it is less than or equal to the preset threshold, the selected system load, the selected clock synchronization compensation value and the operating system model are stored as a set of associated data, and the step of selecting a clock synchronization compensation value that has not been selected from the compensation value record table is returned;
[0034] If it is greater than the preset threshold, returning to the step of selecting a clock synchronization compensation value that has not been selected from the compensation value record table;
[0035] When the multiple clock synchronization compensation values recorded in the compensation value record table have all been selected, the multiple clock synchronization compensation values recorded in the compensation value record table are set to an unselected state, and the process returns to the step of selecting a system load that has not been selected from the load record table;
[0036] When the multiple system loads recorded in the load record table are all selected, the 1588 network card driver is stored, and a compensation value file corresponding to the operating system is generated and stored based on all the stored group association data.
[0037] In a second aspect, the present invention further provides a clock synchronization device, the clock synchronization device comprising:
[0038] A reading module is used to start the operating system, read the 1588 network card driver and the compensation value file corresponding to the operating system, and the compensation value file records the clock synchronization compensation values corresponding to different system loads;
[0039] A replacement module, used to replace the network card driver of the operating system with the 1588 network card driver;
[0040] The determination module is used to obtain the actual system load, and determine the actual clock synchronization compensation value corresponding to the actual system load according to the compensation value file, and perform clock synchronization with the actual clock synchronization compensation value.
[0041] Optionally, the determination module is further configured to:
[0042] When the system load change rate is greater than the preset change rate, a new clock synchronization compensation value corresponding to the new system load is determined according to the compensation value file, and clock synchronization is performed with the new clock synchronization compensation value.
[0043] In a third aspect, the present invention also provides a clock synchronization device, comprising a processor, a memory, and a clock synchronization program stored in the memory and executable by the processor, wherein when the clock synchronization program is executed by the processor, the steps of the clock synchronization method as described above are implemented.
[0044] In a fourth aspect, the present invention further provides a readable storage medium, on which a clock synchronization program is stored, wherein when the clock synchronization program is executed by a processor, the steps of the clock synchronization method as described above are implemented.
[0045] In the present invention, the operating system is started, the 1588 network card driver and the compensation value file corresponding to the operating system are read, and the compensation value file records the clock synchronization compensation values corresponding to different system loads; the network card driver of the operating system is replaced with the 1588 network card driver; the actual system load is obtained, and the actual clock synchronization compensation value corresponding to the actual system load is determined according to the compensation value file, and the clock synchronization is performed with the actual clock synchronization compensation value. Through the present invention, the corresponding clock synchronization compensation value can be selected according to the actual system load for clock synchronization, thereby improving the accuracy of clock synchronization. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] Figure 1 A schematic diagram of the hardware structure of a clock synchronization device involved in an embodiment of the present invention;
[0047] Figure 2 A schematic diagram of a flow chart of an embodiment of a clock synchronization method of the present invention;
[0048] Figure 3 A schematic diagram of a flow chart of another embodiment of a clock synchronization method of the present invention;
[0049] Figure 4 A detailed flow chart of determining an actual clock synchronization compensation value corresponding to an actual system load according to a compensation value file;
[0050] Figure 5 Schematic diagram of functional modules of an embodiment of a clock synchronization device of the present invention.
[0051] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0052] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.
[0053] In a first aspect, an embodiment of the present invention provides a clock synchronization device.
[0054] Reference Figure 1 , Figure 1 The hardware structure diagram of the clock synchronization device involved in the embodiment of the present invention. In the embodiment of the present invention, the clock synchronization device may include a processor 1001 (e.g., a central processing unit, CPU), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. Among them, the communication bus 1002 is used to realize the connection and communication between these components; the user interface 1003 may include a display screen (Display), an input unit such as a keyboard (Keyboard); the network interface 1004 may optionally include a standard wired interface, a wireless interface (such as wireless fidelity WIreless-FIdelity, WI-FI interface); the memory 1005 may be a high-speed random access memory (random access memory, RAM), or a stable memory (non-volatile memory), such as a disk storage, and the memory 1005 may optionally be a storage device independent of the aforementioned processor 1001. Those skilled in the art will understand that Figure 1 The hardware structure shown in the figure does not constitute a limitation of the present invention, and may include more or less components than those shown in the figure, or combine certain components, or arrange the components differently.
[0055] Continue to refer to Figure 1 , Figure 1 The memory 1005 as a computer storage medium may include an operating system, a network communication module, a user interface module and a clock synchronization program. The processor 1001 may call the clock synchronization program stored in the memory 1005 and execute the clock synchronization method provided in the embodiment of the present invention.
[0056] In a second aspect, an embodiment of the present invention provides a clock synchronization method.
[0057] In one embodiment, referring to Figure 2 , Figure 2 FIG. 1 is a flow chart of an embodiment of a clock synchronization method of the present invention. Figure 2 As shown, the clock synchronization method includes:
[0058] Step S10, starting the operating system, reading the 1588 network card driver and the compensation value file corresponding to the operating system, wherein the compensation value file records clock synchronization compensation values corresponding to different system loads;
[0059] In this embodiment, the execution subject (e.g., server) of the clock synchronization method starts the operating system, which can be selected by the user based on actual needs. After the operating system is started, the 1588 network card driver and the compensation value file corresponding to the operating system are automatically read from the memory, wherein the compensation value file records the clock synchronization compensation values corresponding to different system loads.
[0060] Further, in one embodiment, referring to Figure 3 , Figure 3 FIG. 2 is a flow chart of another embodiment of the clock synchronization method of the present invention. Figure 3 As shown, before step S10, it also includes:
[0061] After the operating system starts, read the 1588 network card driver source code;
[0062] Compile the 1588 network card driver source code to obtain the 1588 network card driver, and replace the network card driver of the operating system with the 1588 network card driver;
[0063] Selecting a system load that has not been selected from the load record table, where the load record table records multiple system loads;
[0064] Set the system load of the operating system to the selected system load;
[0065] Selecting a clock synchronization compensation value that has not been selected from the compensation value record table, wherein the compensation value record table records a plurality of clock synchronization compensation values;
[0066] Detecting whether a synchronization accuracy error of clock synchronization performed with the selected clock synchronization compensation value is less than or equal to a preset threshold;
[0067] If it is less than or equal to the preset threshold, the selected system load, the selected clock synchronization compensation value and the operating system model are stored as a set of associated data, and the step of selecting a clock synchronization compensation value that has not been selected from the compensation value record table is returned;
[0068] If it is greater than the preset threshold, returning to the step of selecting a clock synchronization compensation value that has not been selected from the compensation value record table;
[0069] When the multiple clock synchronization compensation values recorded in the compensation value record table have all been selected, the multiple clock synchronization compensation values recorded in the compensation value record table are set to an unselected state, and the process returns to the step of selecting a system load that has not been selected from the load record table;
[0070] When the multiple system loads recorded in the load record table are all selected, the 1588 network card driver is stored, and a compensation value file corresponding to the operating system is generated and stored based on all the stored group association data.
[0071] In this embodiment, the operating system is started, and the operating system can be selected by the user based on actual needs. After the operating system is started, the 1588 network card driver source code is automatically read from the memory, the 1588 network card driver source code is compiled to obtain the 1588 network card driver, and the network card driver of the operating system is replaced by the 1588 network card driver.
[0072] A system load that has not been selected is selected from the load record table. The load record table records multiple system loads. For example, the load record table records 100 system loads, which are system loads 1 to 100 respectively. The system load consists of a CPU load and a network card load.
[0073] For example, first select system load 1 and set the system load of the operating system to system load 1.
[0074] Then, a clock synchronization compensation value that has not been selected is selected from the compensation value record table, where a plurality of clock synchronization compensation values are recorded. For example, the compensation value record table records 200 clock synchronization compensation values.
[0075] For example, a clock synchronization compensation value of 1 is selected, and it is detected whether the synchronization accuracy error of clock synchronization performed with the selected clock synchronization compensation value is less than or equal to a preset threshold. Specifically, by executing the ptp4l program and combining the clock synchronization compensation value of 1 for clock synchronization, the log file of the ptp4l program is analyzed to determine whether the synchronization accuracy error of clock synchronization performed with the clock synchronization compensation value of 1 is less than or equal to the preset threshold.
[0076] If it is less than or equal to the preset threshold, the selected system load, the selected clock synchronization compensation value and the operating system model are stored as a set of related data, and when there is a clock synchronization compensation value that has not been selected in the compensation value record table, return to the step of selecting a clock synchronization compensation value that has not been selected from the compensation value record table.
[0077] If it is greater than the preset threshold, when there is a clock synchronization compensation value that has not been selected in the compensation value record table, the process returns to the step of selecting a clock synchronization compensation value that has not been selected from the compensation value record table.
[0078] When multiple clock synchronization compensation values recorded in the compensation value record table have all been selected, the multiple clock synchronization compensation values recorded in the compensation value record table are set to an unselected state, and when there is a system load that has not been selected in the load record table, return to the step of selecting a system load that has not been selected from the load record table.
[0079] When the multiple system loads recorded in the load record table are all selected, the 1588 network card driver is stored, and a compensation value file corresponding to the operating system is generated and stored based on all the stored group association data.
[0080] For example, the total group association data stored includes:
[0081] System load 1--clock synchronization compensation value 1--operating system model OS1, system load 1--clock synchronization compensation value 2--operating system model OS1, system load 1--clock synchronization compensation value 3--operating system model OS1, ..., system load 100--clock synchronization compensation value 199--operating system model OS1. The compensation value file corresponding to the operating system model OS1 generated based on all the stored group association data records the clock synchronization compensation values corresponding to different system loads.
[0082] Repeat the above steps to obtain compensation value files corresponding to multiple operating systems.
[0083] The 1588 network card driver and the compensation value file corresponding to the operating system are stored in a field replaceable unit (eg, a solid state hard disk) of the server.
[0084] Through the above steps, when executing step S10, the 1588 network card driver and the compensation value file corresponding to the operating system can be directly read from the field replaceable unit of the server. The step of recompiling the driver is omitted. And by automatically simulating different system loads and determining the appropriate clock synchronization compensation value corresponding to each system load, the service scenario coverage is improved, thereby ensuring the stability of subsequent system services.
[0085] Step S20, replacing the network card driver of the operating system with the 1588 network card driver;
[0086] In this embodiment, the network card driver of the operating system is replaced by the read 1588 network card driver.
[0087] Step S30, obtaining the actual system load, and determining the actual clock synchronization compensation value corresponding to the actual system load according to the compensation value file, and performing clock synchronization with the actual clock synchronization compensation value.
[0088] In this embodiment, the actual system load is obtained. Since the compensation value file records the clock synchronization compensation values corresponding to different system loads, the actual clock synchronization compensation value corresponding to the actual system load can be determined based on the compensation value file, so that clock synchronization is performed with the actual clock synchronization compensation value.
[0089] Further, in one embodiment, referring to Figure 4 , Figure 4 The figure is a detailed flow chart of determining the actual clock synchronization compensation value corresponding to the actual system load according to the compensation value file. Figure 4 As shown, the step of determining the actual clock synchronization compensation value corresponding to the actual system load according to the compensation value file includes:
[0090] Determine from the compensation value file a target system load that matches the actual system load, and multiple clock synchronization compensation values corresponding to the target system load; select a clock synchronization compensation value that has not been selected from the multiple clock synchronization compensation values corresponding to the target system load; detect whether the synchronization accuracy error of clock synchronization performed with the selected clock synchronization compensation value is less than or equal to a preset threshold; if it is less than or equal to the preset threshold, use the selected clock synchronization compensation value as the actual clock synchronization compensation value; if it is greater than the preset threshold, return to the step of selecting a clock synchronization compensation value that has not been selected from the multiple clock synchronization compensation values corresponding to the target system load.
[0091] In this embodiment, the compensation value file determines the system load closest to the actual system load as the target system load matching the actual system load, and multiple clock synchronization compensation values corresponding to the target system load.
[0092] A clock synchronization compensation value that has not been selected is selected from multiple clock synchronization compensation values corresponding to the target system load, and it is detected whether the synchronization accuracy error of clock synchronization performed with the selected clock synchronization compensation value is less than or equal to a preset threshold. For example, by executing the ptp4l program and combining the selected clock synchronization compensation value to perform clock synchronization, the log file of the ptp4l program is analyzed to determine whether the synchronization accuracy error of clock synchronization performed with the selected clock synchronization compensation value is less than or equal to the preset threshold.
[0093] If it is less than or equal to the preset threshold, the selected clock synchronization compensation value is used as the actual clock synchronization compensation value; if it is greater than the preset threshold, return to the step of selecting a clock synchronization compensation value that has not been selected from multiple clock synchronization compensation values corresponding to the target system load.
[0094] Further, in one embodiment, the step of detecting whether the synchronization accuracy error of clock synchronization performed with the selected clock synchronization compensation value is less than or equal to a preset threshold comprises:
[0095] Run the clock synchronization program and perform clock synchronization with the selected clock synchronization compensation value; obtain the log file output by the clock synchronization program; analyze the log file to obtain the synchronization accuracy error of the clock synchronization with the selected clock synchronization compensation value; detect whether the synchronization accuracy error is less than or equal to a preset threshold.
[0096] In this embodiment, a clock synchronization program is run, and clock synchronization is performed with the selected clock synchronization compensation value, wherein the clock synchronization program may use the ptp4l program. A log file output by the clock synchronization program is obtained, and the log file is analyzed to obtain a synchronization accuracy error of clock synchronization with the selected clock synchronization compensation value, and finally, whether the synchronization accuracy error is less than or equal to a preset threshold is detected.
[0097] In this embodiment, the 1588 protocol stack and services are implemented through a general program, which can be decoupled from the hardware and improve the versatility.
[0098] Furthermore, in one embodiment, after step S20, the method further includes:
[0099] Perform clock synchronization with the default clock synchronization offset value;
[0100] It is detected whether the synchronization accuracy error of clock synchronization performed with a default clock synchronization compensation value is less than or equal to a preset threshold.
[0101] In this embodiment, the default clock synchronization compensation value is set according to actual needs, for example, it is set to 0, and the clock synchronization is performed by running the clock synchronization program ptp41 and using the default clock synchronization compensation value. The log file output by the clock synchronization program is obtained, and the log file is analyzed to obtain the synchronization accuracy error of the clock synchronization performed with the selected clock synchronization compensation value, and the synchronization accuracy error is compared with the preset threshold.
[0102] If it is greater than the preset threshold, step S30 is executed.
[0103] That is, in this embodiment, step S30 is executed only if the synchronization accuracy error of clock synchronization performed using the default clock synchronization compensation value is greater than the preset threshold.
[0104] In this embodiment, the operating system is started, the 1588 network card driver and the compensation value file corresponding to the operating system are read, and the compensation value file records the clock synchronization compensation values corresponding to different system loads; the network card driver of the operating system is replaced with the 1588 network card driver; the actual system load is obtained, and the actual clock synchronization compensation value corresponding to the actual system load is determined according to the compensation value file, and the clock synchronization is performed with the actual clock synchronization compensation value. Through this embodiment, the corresponding clock synchronization compensation value can be selected according to the actual system load for clock synchronization, thereby improving the accuracy of clock synchronization.
[0105] Furthermore, in one embodiment, after step S30, the method further includes:
[0106] When the system load change rate is greater than the preset change rate, a new clock synchronization compensation value corresponding to the new system load is determined according to the compensation value file, and clock synchronization is performed with the new clock synchronization compensation value.
[0107] In this embodiment, the system load can be obtained at a preset time interval. When the system load change rate calculated by the system load at a certain moment (i.e., the new system load) and the system load at the previous moment is greater than the preset change rate, a new clock synchronization compensation value corresponding to the new system load is determined according to the compensation value file, and clock synchronization is performed with the new clock synchronization compensation value. The specific implementation of determining the new clock synchronization compensation value corresponding to the new system load according to the compensation value file can refer to the above-mentioned embodiment of determining the actual clock synchronization compensation value corresponding to the actual system load according to the compensation value file, which will not be described in detail here.
[0108] In a third aspect, an embodiment of the present invention further provides a clock synchronization device.
[0109] In one embodiment, referring to Figure 5 , Figure 5 FIG. 1 is a functional module diagram of an embodiment of a clock synchronization device of the present invention. Figure 5 As shown, the clock synchronization device includes:
[0110] A reading module 10 is used to start the operating system, read the 1588 network card driver and the compensation value file corresponding to the operating system, and the compensation value file records the clock synchronization compensation values corresponding to different system loads;
[0111] A replacement module 20, used to replace the network card driver of the operating system with the 1588 network card driver;
[0112] The determination module 30 is used to obtain the actual system load, and determine the actual clock synchronization compensation value corresponding to the actual system load according to the compensation value file, and perform clock synchronization with the actual clock synchronization compensation value.
[0113] Furthermore, in one embodiment, the determination module 30 is further configured to:
[0114] When the system load change rate is greater than the preset change rate, a new clock synchronization compensation value corresponding to the new system load is determined according to the compensation value file, and clock synchronization is performed with the new clock synchronization compensation value.
[0115] Furthermore, in one embodiment, the clock synchronization device further includes a detection module, which is used to:
[0116] Perform clock synchronization with a default clock synchronization compensation value; detect whether a synchronization accuracy error of clock synchronization with the default clock synchronization compensation value is less than or equal to a preset threshold;
[0117] The determination module 30 is used to:
[0118] If it is greater than a preset threshold, the actual system load is obtained, and an actual clock synchronization compensation value corresponding to the actual system load is determined according to the compensation value file, and clock synchronization is performed with the actual clock synchronization compensation value.
[0119] Furthermore, in one embodiment, the determination module 30 is used to:
[0120] Determine a target system load that matches the actual system load and a plurality of clock synchronization compensation values corresponding to the target system load from the compensation value file;
[0121] Selecting a clock synchronization compensation value that has not been selected from a plurality of clock synchronization compensation values corresponding to the target system load;
[0122] Detecting whether a synchronization accuracy error of clock synchronization performed with the selected clock synchronization compensation value is less than or equal to a preset threshold;
[0123] If it is less than or equal to the preset threshold, the selected clock synchronization compensation value is used as the actual clock synchronization compensation value;
[0124] If it is greater than a preset threshold, the process returns to the step of selecting a clock synchronization compensation value that has not been selected from a plurality of clock synchronization compensation values corresponding to the target system load.
[0125] Furthermore, in one embodiment, the determination module 30 is used to:
[0126] Run the clock synchronization program and perform clock synchronization with the selected clock synchronization compensation value;
[0127] Get the log file output by the clock synchronization program;
[0128] Analyze the log file to obtain a synchronization accuracy error of clock synchronization using the selected clock synchronization compensation value;
[0129] Detect whether the synchronization accuracy error is less than or equal to a preset threshold.
[0130] Furthermore, in one embodiment, the clock synchronization device further includes a storage module, which is used to:
[0131] After the operating system starts, read the 1588 network card driver source code;
[0132] Compile the 1588 network card driver source code to obtain the 1588 network card driver, and replace the network card driver of the operating system with the 1588 network card driver;
[0133] Selecting a system load that has not been selected from the load record table, where the load record table records multiple system loads;
[0134] Set the system load of the operating system to the selected system load;
[0135] Selecting a clock synchronization compensation value that has not been selected from the compensation value record table, wherein the compensation value record table records a plurality of clock synchronization compensation values;
[0136] Detecting whether a synchronization accuracy error of clock synchronization performed with the selected clock synchronization compensation value is less than or equal to a preset threshold;
[0137] If it is less than or equal to the preset threshold, the selected system load, the selected clock synchronization compensation value and the operating system model are stored as a set of associated data, and the step of selecting a clock synchronization compensation value that has not been selected from the compensation value record table is returned;
[0138] If it is greater than the preset threshold, returning to the step of selecting a clock synchronization compensation value that has not been selected from the compensation value record table;
[0139] When the multiple clock synchronization compensation values recorded in the compensation value record table have all been selected, the multiple clock synchronization compensation values recorded in the compensation value record table are set to an unselected state, and the process returns to the step of selecting a system load that has not been selected from the load record table;
[0140] When the multiple system loads recorded in the load record table are all selected, the 1588 network card driver is stored, and a compensation value file corresponding to the operating system is generated and stored based on all the stored group association data.
[0141] Among them, the functional implementation of each module in the above-mentioned clock synchronization device corresponds to each step in the above-mentioned clock synchronization method embodiment, and its functions and implementation processes are no longer repeated here.
[0142] In a fourth aspect, an embodiment of the present invention further provides a readable storage medium.
[0143] A clock synchronization program is stored on the readable storage medium of the present invention, wherein when the clock synchronization program is executed by a processor, the steps of the clock synchronization method as described above are implemented.
[0144] Among them, the method implemented when the clock synchronization program is executed can refer to the various embodiments of the clock synchronization method of the present invention, and will not be repeated here.
[0145] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or system including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or system. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or system including the element.
[0146] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
[0147] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, and includes a number of instructions for a terminal device to execute the methods described in each embodiment of the present invention.
[0148] The above are only preferred embodiments of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. A clock synchronization method, characterized in that: The clock synchronization method comprises: Start the operating system, read the 1588 network card driver and the compensation value file corresponding to the operating system, the compensation value file records the clock synchronization compensation values corresponding to different system loads; Replacing the network card driver of the operating system with the 1588 network card driver; Acquire the actual system load, and determine the actual clock synchronization compensation value corresponding to the actual system load according to the compensation value file, and perform clock synchronization with the actual clock synchronization compensation value; Before the step of starting the operating system and reading the 1588 network card driver and the compensation value file corresponding to the operating system, the method further includes: After the operating system starts, read the 1588 network card driver source code; Compile the 1588 network card driver source code to obtain the 1588 network card driver, and replace the network card driver of the operating system with the 1588 network card driver; Selecting a system load that has not been selected from the load record table, where the load record table records multiple system loads; Set the system load of the operating system to the selected system load; Selecting a clock synchronization compensation value that has not been selected from the compensation value record table, wherein the compensation value record table records a plurality of clock synchronization compensation values; Detecting whether a synchronization accuracy error of clock synchronization performed with the selected clock synchronization compensation value is less than or equal to a preset threshold; If it is less than or equal to the preset threshold, the selected system load, the selected clock synchronization compensation value and the operating system model are stored as a set of associated data, and the step of selecting a clock synchronization compensation value that has not been selected from the compensation value record table is returned; If it is greater than the preset threshold, returning to the step of selecting a clock synchronization compensation value that has not been selected from the compensation value record table; When the multiple clock synchronization compensation values recorded in the compensation value record table have all been selected, the multiple clock synchronization compensation values recorded in the compensation value record table are set to an unselected state, and the process returns to the step of selecting a system load that has not been selected from the load record table; When the multiple system loads recorded in the load record table are all selected, the 1588 network card driver is stored, and a compensation value file corresponding to the operating system is generated and stored based on all the stored group association data.
2. The clock synchronization method according to claim 1, characterized in that: After the steps of obtaining the actual system load, determining the actual clock synchronization compensation value corresponding to the actual system load according to the compensation value file, and performing clock synchronization with the actual clock synchronization compensation value, the method further includes: When the system load change rate is greater than the preset change rate, a new clock synchronization compensation value corresponding to the new system load is determined according to the compensation value file, and clock synchronization is performed with the new clock synchronization compensation value.
3. The clock synchronization method according to claim 1, characterized in that: After the step of replacing the network card driver of the operating system with the 1588 network card driver, the method further includes: Perform clock synchronization with the default clock synchronization offset value; Detecting whether a synchronization accuracy error of clock synchronization performed with a default clock synchronization compensation value is less than or equal to a preset threshold; The step of obtaining the actual system load, determining the actual clock synchronization compensation value corresponding to the actual system load according to the compensation value file, and performing clock synchronization with the actual clock synchronization compensation value comprises: If it is greater than a preset threshold, the actual system load is obtained, and an actual clock synchronization compensation value corresponding to the actual system load is determined according to the compensation value file, and clock synchronization is performed with the actual clock synchronization compensation value.
4. The clock synchronization method according to claim 1, characterized in that: The step of determining the actual clock synchronization compensation value corresponding to the actual system load according to the compensation value file comprises: Determine a target system load that matches the actual system load and a plurality of clock synchronization compensation values corresponding to the target system load from the compensation value file; Selecting a clock synchronization compensation value that has not been selected from a plurality of clock synchronization compensation values corresponding to the target system load; Detecting whether a synchronization accuracy error of clock synchronization performed with the selected clock synchronization compensation value is less than or equal to a preset threshold; If it is less than or equal to the preset threshold, the selected clock synchronization compensation value is used as the actual clock synchronization compensation value; If it is greater than a preset threshold, the process returns to the step of selecting a clock synchronization compensation value that has not been selected from a plurality of clock synchronization compensation values corresponding to the target system load.
5. The clock synchronization method according to claim 4, characterized in that: The step of detecting whether the synchronization accuracy error of clock synchronization performed with the selected clock synchronization compensation value is less than or equal to a preset threshold comprises: Run the clock synchronization program and perform clock synchronization with the selected clock synchronization compensation value; Get the log file output by the clock synchronization program; Analyze the log file to obtain a synchronization accuracy error of clock synchronization using the selected clock synchronization compensation value; Detect whether the synchronization accuracy error is less than or equal to a preset threshold.
6. A clock synchronization device, characterized in that: The clock synchronization device comprises: A reading module is used to start the operating system, read the 1588 network card driver and the compensation value file corresponding to the operating system, and the compensation value file records the clock synchronization compensation values corresponding to different system loads; A replacement module, used to replace the network card driver of the operating system with the 1588 network card driver; A determination module, used to obtain an actual system load, and determine an actual clock synchronization compensation value corresponding to the actual system load according to a compensation value file, and perform clock synchronization with the actual clock synchronization compensation value; The clock synchronization device also includes a storage module, which is used to read the 1588 network card driver source code after the operating system is started; compile the 1588 network card driver source code to obtain the 1588 network card driver, and replace the network card driver of the operating system with the 1588 network card driver; select a system load that has not been selected from the load record table, the load record table records multiple system loads; set the system load of the operating system to the selected system load; select a clock synchronization compensation value that has not been selected from the compensation value record table, the compensation value record table records multiple clock synchronization compensation values; detect whether the synchronization accuracy error of clock synchronization performed with the selected clock synchronization compensation value is less than or equal to a preset threshold; if it is less than or equal to the preset threshold, the selected system load, the selected The clock synchronization compensation value and the operating system model are stored as a group of associated data, and the step of selecting a clock synchronization compensation value that has not been selected from the compensation value record table is returned; if it is greater than a preset threshold, the step of selecting a clock synchronization compensation value that has not been selected from the compensation value record table is returned; when multiple clock synchronization compensation values recorded in the compensation value record table have all been selected, the multiple clock synchronization compensation values recorded in the compensation value record table are set to an unselected state, and the step of selecting a system load that has not been selected from the load record table is returned; when multiple system loads recorded in the load record table have all been selected, the 1588 network card driver is stored, and the compensation value file corresponding to the operating system is generated and stored based on all the stored group-associated data.
7. The clock synchronization device according to claim 6, characterized in that: The Determine module is also used to: When the system load change rate is greater than the preset change rate, a new clock synchronization compensation value corresponding to the new system load is determined according to the compensation value file, and clock synchronization is performed with the new clock synchronization compensation value.
8. A clock synchronization device, characterized in that: The clock synchronization device comprises a processor, a memory, and a clock synchronization program stored in the memory and executable by the processor, wherein when the clock synchronization program is executed by the processor, the steps of the clock synchronization method according to any one of claims 1 to 5 are implemented.
9. A readable storage medium, characterized in that: The readable storage medium stores a clock synchronization program, wherein when the clock synchronization program is executed by a processor, the steps of the clock synchronization method according to any one of claims 1 to 5 are implemented.
Citation Information
Patent Citations
IEEE 1588-based synchronization system and synchronization method thereof
CN102104475A
Accurate clock frequency synchronizing method and device based on IEEE1588 (institute of electrical and electronics engineers)
CN102710359A