CN111865468A - Precise time synchronization method - Google Patents

Precise time synchronization method Download PDF

Info

Publication number
CN111865468A
CN111865468A CN202010703333.6A CN202010703333A CN111865468A CN 111865468 A CN111865468 A CN 111865468A CN 202010703333 A CN202010703333 A CN 202010703333A CN 111865468 A CN111865468 A CN 111865468A
Authority
CN
China
Prior art keywords
time
server
value
client
synchronization
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202010703333.6A
Other languages
Chinese (zh)
Other versions
CN111865468B (en
Inventor
李朝铭
王建华
孙思清
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Inspur Cloud Information Technology Co Ltd
Original Assignee
Inspur Cloud Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Inspur Cloud Information Technology Co Ltd filed Critical Inspur Cloud Information Technology Co Ltd
Priority to CN202010703333.6A priority Critical patent/CN111865468B/en
Publication of CN111865468A publication Critical patent/CN111865468A/en
Application granted granted Critical
Publication of CN111865468B publication Critical patent/CN111865468B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04JMULTIPLEX COMMUNICATION
    • H04J3/00Time-division multiplex systems
    • H04J3/02Details
    • H04J3/06Synchronising arrangements
    • H04J3/0635Clock or time synchronisation in a network
    • H04J3/0638Clock or time synchronisation among nodes; Internode synchronisation

Abstract

The invention relates to the time synchronization field, and particularly provides an accurate time synchronization method, wherein a server is selected as a time server in a local area network or a wide area network, and a server module is arranged on the time server; the method comprises the steps that a client module is installed on a server needing time synchronization in a local area network or a wide area network, the client module obtains time from the server module according to a specific protocol and synchronizes the time to the server needing time synchronization, and the server needing time synchronization and the time server obtain consistent time through two times of time correction. Compared with the prior art, the method can obtain 0.01 millisecond-level accurate time synchronization under the condition of low cost, and has good popularization value.

Description

Precise time synchronization method
Technical Field
The invention relates to the field of time synchronization, and particularly provides an accurate time synchronization method.
Background
In network environments such as cloud computer rooms and data centers, time synchronization is needed for each computer in a local area network, but the commonly used time synchronization modes such as NTP and SNTP can only provide accuracy of 1ms to 1 second level, generally, tens of milliseconds are provided in most cases, and the requirements cannot be met for occasions with high time accuracy requirements. The use of more accurate GPS time service or atomic clock time service is influenced by factors such as environment and cost, and cannot be widely used in a local area network environment.
Disclosure of Invention
Aiming at the defects of the prior art, the invention provides a precise time synchronization method with strong practicability.
The technical scheme adopted by the invention for solving the technical problems is as follows:
a precise time synchronization method selects a server in a local area network or a wide area network as a time server, and a server module is arranged on the time server;
the method comprises the steps that a client module is installed on a server needing time synchronization in a local area network or a wide area network, the client module obtains time from the server module according to a specific protocol and synchronizes the time to the server needing time synchronization, and the server needing time synchronization and the time server obtain consistent time through two times of time correction.
Preferably, the time server performs accurate time service, and an atomic clock with high accuracy, a GPS time service, or the like can be selected.
Further, the specific protocol is:
the method comprises the steps that a T1 time point on a client sends a first time obtaining request to a server, the time value T2 of the server is immediately sent back to the corresponding client after the first time request is obtained at the T2 time point of the server, and the client records the time point T3 after receiving the time value T2.
Further, if the difference between T3 and T1 is d, d is the time taken by the operation, and d includes the time d1 taken from time point T1 to T2 and the time d2 taken from time points T2 and T3, that is, d is d1+ d 2.
Further, the difference d further includes round-trip network delay and time of sending and receiving processing of the two end networks;
in general, the network delays of round trips are approximately equal, i.e., d 1-d 2-d/2,
the value of T2 plus d2 may be considered to be the time value of the time point T3 client server.
Further, the first time correction is:
continuously operating the requests of the client and the server for a plurality of times, recording the values of T1, T2, T3 and d each time, calculating the arithmetic mean value d0 of d, and calculating the deviation absolute value P1 of the d value and d0 each time;
calculating the percentage P2 of P1 and d0, and if the value of each P2 is smaller than the set first value, considering that the group of values can be subjected to the next time correction through the first time correction;
the process of calculating the offset is time consuming, recording the value of time it takes j, and synchronizing with the value of T2 of the last operation plus d0/2 plus j as the client server's time value, i.e. the offset in time is d0/2 x 5%.
Further, if the values of each P2 cannot all be less than the set first value, a new calibration is required.
Further, the second time correction is:
continuously operating the requests of the client and the server for a plurality of times, recording the values of T1, T2 and T3 each time, theoretically, T2+ d2 is equal to T3 because once correction is performed, but the actual operation still has errors, calculating the arithmetic mean value d3 of d2, calculating the absolute value P3 of the deviation of d2 and d3 each time, then calculating the percentage P4 of P3 and d3, and if the value of P4 is smaller than the preset value each time, considering that the preset value is smaller than the set first value through second time correction;
the above procedure of calculating the deviation is also time-consuming, the time value j taken is recorded, and the T2 value of the last operation is added to d0 and added to j as the time value of the client server for synchronization, and the deviation of the time precision is d0 × 1%.
Further, if the values of each P4 cannot all be smaller than the re-set value, the second correction needs to be performed again.
Furthermore, the client module records the time difference of each correction, calculates the deviation rule, and can calculate the relative accurate time of the current server by adding the time value of the last correction to the deviation value of the deviation rule when the server where the client is located and the time server network are occasionally disconnected.
Compared with the prior art, the accurate time synchronization method has the following outstanding beneficial effects:
the scheme of the invention also needs to set a time server, install a time synchronization server module on the time server, install a time synchronization client module on other servers, and synchronize according to a specific protocol, so that the accurate time synchronization of 0.01 millisecond level can be obtained under the condition of low cost, and the method has good popularization value.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to these drawings without creative efforts.
Fig. 1 is a schematic diagram of a precise time synchronization method.
Detailed Description
The present invention will be described in further detail with reference to specific embodiments in order to better understand the technical solutions of the present invention. It is to be understood that the described embodiments are merely exemplary of the invention, and not restrictive of the full scope of the invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
A preferred embodiment is given below:
as shown in fig. 1, an accurate time synchronization method in this embodiment takes a local area network as an example.
A server is selected from a local area network as a time server, an atomic clock is selected as the server for accurate time service, and a server module is arranged on the time server.
The client module is installed on the server which needs time synchronization in the local area network, the client installs the specific protocol designed by the invention to acquire time from the server module and synchronize the time to the server which needs time synchronization, and the server which needs time synchronization can acquire time consistent with the time server through two times of time correction, and the synchronization precision can reach 0.01 millisecond.
The specific protocol designed by the invention is as follows:
the method comprises the steps that a clock of a server where a client is located is used for timing, and a first time obtaining request is sent to a server at the time point T1 on the client;
after the time point T2 of the server (clocked by the clock of the server where the server is located) obtains the request, the time value T2 (accurate to microseconds) of the server is immediately sent back to the corresponding client, and the client records the time point T3 (clocked by the clock of the server where the client is located) after receiving the time value.
The difference between the operations T3 and T1 is the time d spent in the operation, which includes the time d1 spent from time T1 to T2 and the time d2 spent from time T2 to T3, i.e., d1+ d 2.
Since the value of T2 is not recorded by the same clock as the values of T1 and T3, the values of d1 and d2 in a single operation cannot be calculated, but the values of T1 and T3 are from the same clock, and the difference d is accurate.
The difference d further includes the round-trip network delay and the time of the sending and receiving processes of the two networks. In general, the network delays of round trips are approximately equal, and can be regarded as d1, d2, d/2, so that the value of T2 plus d2 can be regarded as the time value of the client server at the time point T3, and since the value of d changes every time, the time precision of synchronization is not high, and the deviation is equal to d 2.
In order to improve the accuracy of synchronization, a first time of time correction is carried out:
the above operations are performed 10 times without interruption, and the corresponding values of T1, T2, and T3 are recorded each time, and the difference d between T3 and T1 is calculated.
The arithmetic mean d0 of d is calculated 10 times, the absolute value P1 of the deviation of the d value from d0 is calculated each time, then the percentage P2 of P1 and d0 is calculated, if the value of P2 is less than 5% of the first value set in 10 consecutive times, the group of values is considered to pass the first time correction, and the next time correction can be carried out.
If the values of P2 in 10 consecutive times cannot all be less than 5%, the first time correction needs to be performed again.
The process of calculating the deviation is time-consuming, the time value j spent on the calculation is recorded, the T2 value of the last operation is added with d0/2 and j to be used as the time value of the client server for synchronization, the deviation of the time precision is d0/2 x 5%, and the precision is improved by at least 10 times compared with the one operation. The synchronization is the first time synchronization, and after the first time synchronization, in high-speed network environments such as gigabit local area networks and the like, the time synchronization deviation is generally less than 0.01 millisecond.
In order to further improve the synchronization precision, a second time of time correction is performed.
The time obtaining operation to the server is continuously executed several times, in this embodiment, 5 times are taken as an example, and the corresponding values of T1, T2, and T3 are recorded each time, since the first time of time correction is performed, theoretically T2+ d2 is T3, but actually there is a different value of d2 each time.
The arithmetic mean d3 of d2 was calculated 5 times, and the absolute value of the deviation P3 of d2 from d3 was calculated each time, then the percentage P4 of P3 from d3 was calculated. If the value of P4 in 5 consecutive passes is less than the reset value of 1%, the second time correction is passed.
If the values of P2 cannot all be less than 1% in 5 consecutive times, the second time correction needs to be performed again.
The above procedure of calculating the deviation is also time-consuming, the time value j taken is recorded, and the T2 value of the last operation plus d3 plus j can be used as the time value of the client server to perform synchronization, the deviation of the time precision is d3 x 1%, in high-speed network environments such as gigabit local area networks, the value of d3 is generally less than 100 microseconds, and the deviation of the time synchronization is about 1 microsecond.
After two time correction synchronizations, the time of the server where the client is located can be considered to be consistent with the time of the server, but may be affected by the fluctuation of the crystal oscillator frequency, and after one time, the time deviation between the two servers is gradually increased, so the time correction process needs to be executed once every other time.
When the server where the client is located is occasionally disconnected from the time server network, the time correction process is affected. The client module can record the time difference (which can be positive or negative) of each correction, calculate the deviation rule, and when the server where the client is located and the time server network are occasionally disconnected, the time value of the last correction and the deviation value of the deviation rule can be used for calculating the relative accurate time of the current server.
The server module in the scheme can provide more than 10 thousands of concurrent access capabilities and can provide accurate time synchronization service for tens of thousands of servers simultaneously.
When the method is used in a wide area network environment, the related deviation parameters need to be adjusted to be large, and good time synchronization accuracy can be obtained.
The above embodiments are only specific ones of the present invention, and the scope of the present invention includes but is not limited to the above embodiments, and any suitable changes or substitutions that are consistent with the claims of a precise time synchronization method of the present invention and are made by those skilled in the art shall fall within the scope of the present invention.
Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that changes, modifications, substitutions and alterations can be made in these embodiments without departing from the principles and spirit of the invention, the scope of which is defined in the appended claims and their equivalents.

Claims (10)

1. A precise time synchronization method is characterized in that a server is selected from a local area network or a wide area network as a time server, and a server module is arranged on the time server;
The method comprises the steps that a client module is installed on a server needing time synchronization in a local area network or a wide area network, the client module obtains time from the server module according to a specific protocol and synchronizes the time to the server needing time synchronization, and the server needing time synchronization and the time server obtain consistent time through two times of time correction.
2. The method for accurate time synchronization according to claim 1, wherein the time server is accurately timed.
3. The method for precise time synchronization according to claim 1 or 2, wherein the specific protocol is:
the method comprises the steps that a T1 time point on a client sends a first time obtaining request to a server, the time value T2 of the server is immediately sent back to the corresponding client after the first time request is obtained at the T2 time point of the server, and the client records the time point T3 after receiving the time value T2.
4. A method for synchronizing time precisely according to claim 3, wherein if the difference between T3 and T1 is d, d is the time taken by the operation, d includes the time d1 taken from time T1 to T2 and the time d2 taken from time T2 and T3, i.e. d is d1+ d 2.
5. The method of claim 4, wherein the difference d further includes round-trip network delay and time of both end network transmission/reception processing;
in general, the network delays of round trips are approximately equal, i.e., d 1-d 2-d/2,
the value of T2 plus d2 may be considered to be the time value of the time point T3 client server.
6. The method of claim 5, wherein the first time correction is:
continuously operating the requests of the client and the server for a plurality of times, recording the values of T1, T2, T3 and d each time, calculating the arithmetic mean value d0 of d, and calculating the deviation absolute value P1 of the d value and d0 each time;
calculating the percentage P2 of P1 and d0, and if the value of each P2 is smaller than the set first value, considering that the group of values can be subjected to the next time correction through the first time correction;
the process of calculating the offset is time consuming, recording the value of time it takes j, and synchronizing with the value of T2 of the last operation plus d0/2 plus j as the client server's time value, i.e. the offset in time is d0/2 x 5%.
7. A method for accurate time synchronization as claimed in claim 6 wherein if the values of each P2 cannot all be less than the first value set, a new calibration is required.
8. The method of claim 7, wherein the second time correction is:
continuously operating the requests of the client and the server for a plurality of times, recording the values of T1, T2 and T3 each time, theoretically, T2+ d2 is equal to T3 because once correction is performed, but the actual operation still has errors, calculating the arithmetic mean value d3 of d2, calculating the absolute value P3 of the deviation of d2 and d3 each time, then calculating the percentage P4 of P3 and d3, and if the value of P4 is smaller than the preset value each time, considering that the preset value is smaller than the set first value through second time correction;
the above procedure of calculating the deviation is also time-consuming, the time value j taken is recorded, and the T2 value of the last operation is added to d0 and added to j as the time value of the client server for synchronization, and the deviation of the time precision is d0 × 1%.
9. The method of claim 8, wherein if the values of P4 are not all less than the preset value, the second calibration is required.
10. The method according to claim 9, wherein the client module records the time difference between each calibration and calculates the deviation rule, and when the server where the client is located and the time server network are occasionally disconnected, the accurate time of the current server can be calculated by adding the deviation value of the deviation rule to the last time value of the calibration.
CN202010703333.6A 2020-07-21 2020-07-21 Precise time synchronization method Active CN111865468B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010703333.6A CN111865468B (en) 2020-07-21 2020-07-21 Precise time synchronization method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010703333.6A CN111865468B (en) 2020-07-21 2020-07-21 Precise time synchronization method

Publications (2)

Publication Number Publication Date
CN111865468A true CN111865468A (en) 2020-10-30
CN111865468B CN111865468B (en) 2022-09-20

Family

ID=73001362

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010703333.6A Active CN111865468B (en) 2020-07-21 2020-07-21 Precise time synchronization method

Country Status (1)

Country Link
CN (1) CN111865468B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113037418A (en) * 2021-03-17 2021-06-25 广州虎牙科技有限公司 Error correction method for network time service and related device
CN115001615A (en) * 2022-05-25 2022-09-02 中国第一汽车股份有限公司 Synchronization control method, device, system and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040073718A1 (en) * 2000-12-28 2004-04-15 Svein Johannessen Time synchronization in computer network
CN101296048A (en) * 2008-06-17 2008-10-29 杭州华三通信技术有限公司 Time synchronization method and apparatus
CN105187148A (en) * 2015-08-17 2015-12-23 武汉理工大学 ARM-based network clock synchronization system and method
CN111224733A (en) * 2020-01-09 2020-06-02 珠海格力电器股份有限公司 Time calibration method, device, computer equipment and storage medium

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040073718A1 (en) * 2000-12-28 2004-04-15 Svein Johannessen Time synchronization in computer network
CN101296048A (en) * 2008-06-17 2008-10-29 杭州华三通信技术有限公司 Time synchronization method and apparatus
CN105187148A (en) * 2015-08-17 2015-12-23 武汉理工大学 ARM-based network clock synchronization system and method
CN111224733A (en) * 2020-01-09 2020-06-02 珠海格力电器股份有限公司 Time calibration method, device, computer equipment and storage medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113037418A (en) * 2021-03-17 2021-06-25 广州虎牙科技有限公司 Error correction method for network time service and related device
CN115001615A (en) * 2022-05-25 2022-09-02 中国第一汽车股份有限公司 Synchronization control method, device, system and storage medium

Also Published As

Publication number Publication date
CN111865468B (en) 2022-09-20

Similar Documents

Publication Publication Date Title
US11838110B2 (en) Method of remotely monitoring the timing performance of a PTP slave
US7340630B2 (en) Multiprocessor system with interactive synchronization of local clocks
EP3009897B1 (en) Distribution device, distribution system, and distribution method
CN111865468B (en) Precise time synchronization method
US8218576B2 (en) Method, a computer program product, and a carrier for indicating one-way latency in a data network
Derviškadić et al. The white rabbit time synchronization protocol for synchrophasor networks
WO2001050674A1 (en) Synchronization in packet-switched telecommunications system
WO2016168063A1 (en) Methods, systems, and computer readable media for synchronizing timing among network interface cards (nics) in a network equipment test device
CN112486246A (en) Clock delay detection and compensation method, device, terminal and readable storage medium
CN115765909A (en) Clock synchronization method, device and storage medium
CN114785445A (en) Clock synchronization implementation method of wind tunnel pressure measurement system
JP7230690B2 (en) Time synchronization program, information processing device and time synchronization method
CN106647228B (en) Converter station master clock fault judgment system
CN108075853A (en) A kind of method for synchronizing network time between Helicopter Simulator development system
EP2627040B1 (en) Method for eliminating systematical error components in a set of one-way delay measurement results for communications between two or more computing systems in a communication network, apparatus for performing the method and computer program product
CN114035740B (en) Method, device and system for synchronizing clock crystal oscillator
Bulut et al. Implementing a NTP-based time service within a distributed middleware system
CN111614427A (en) High-accuracy time transfer device, method and system based on hospital time plate
CN113589675B (en) Network time synchronization method and system with traceability
CN112019288B (en) Time synchronization method, service single board and network equipment
US11855757B1 (en) Highly accurate time information in hosted machine instances using dedicated timing network
Han et al. Time consistency technique of multi-aircrafts simulation system for cooperative mission
CN114070762B (en) Network monitoring probe assembly, synchronization method and data acquisition and analysis device
Shukui et al. FPGA-based high-precision network time synchronization research and implementation
JP2018189592A (en) Time synchronizing device, time synchronization method, and time synchronizing program

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant