CN105915308B - A kind of method for synchronizing time, apparatus and system - Google Patents

A kind of method for synchronizing time, apparatus and system Download PDF

Info

Publication number
CN105915308B
CN105915308B CN201610539966.1A CN201610539966A CN105915308B CN 105915308 B CN105915308 B CN 105915308B CN 201610539966 A CN201610539966 A CN 201610539966A CN 105915308 B CN105915308 B CN 105915308B
Authority
CN
China
Prior art keywords
time
transmission
transmission time
reply data
data bag
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.)
Active
Application number
CN201610539966.1A
Other languages
Chinese (zh)
Other versions
CN105915308A (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.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen 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 Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN201610539966.1A priority Critical patent/CN105915308B/en
Publication of CN105915308A publication Critical patent/CN105915308A/en
Application granted granted Critical
Publication of CN105915308B publication Critical patent/CN105915308B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

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
    • 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/0685Clock or time synchronisation in a node; Intranode synchronisation

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Electric Clocks (AREA)

Abstract

This application discloses a kind of method for synchronizing time, apparatus and system, wherein method includes:To target device sending time synchronization request, receive the reply data bag for including sending time stamp that the target device returns, determine from time synchronization request is sent out to the transmission time for receiving the data packet and being spent, according to default time error scope and the expected probability for falling into the time error scope, determine transmission time threshold value, judge whether the transmission time is less than the transmission time threshold value, if, stabbed according to the transmission time and the sending time of the reply data bag, correct the time of the synchronizer.It can be seen from the above that the application note and the influence of transmission time so that the time of the synchronizer of correction of a final proof is more accurate.

Description

A kind of method for synchronizing time, apparatus and system
Technical field
This application involves Time synchronization technique field, more specifically to a kind of method for synchronizing time, device and is System.
Background technology
Time synchronization can also be referred to as " to clock ", i.e., the standard that will be set in the clock of each equipment in system and system Clock alignment.
Time synchronization is of wide application, relatively common as applications client needs to carry out between application server Time synchronization.The prior art initiates time synchronization request when carrying out time synchronization, from applications client to application server, should When receiving request by the use of server applications client, applications client are back to using application server current time as feedback information Carried out the current time in feedback information as the standard time " to clock ".
It can not be measured since feedback information is transmitted to applications client the time it takes from application server, and network prolongs Late generally within thousand milliseconds of ranks, therefore the prior art have ignored error caused by network delay.This solution energy It is enough to be suitable for most of not being very high application service to time synchronization requirement.But as time precision requirement is got in application Come it is higher, the prior art can not be suitable for precise synchronization requirement.
The content of the invention
In view of this, this application provides a kind of method for synchronizing time, apparatus and system, during for providing a kind of high accuracy Between synchronization scenario.
To achieve these goals, it is proposed that scheme it is as follows:
A kind of method for synchronizing time, including:
To target device sending time synchronization request;
Receive the reply data bag for including sending time stamp that the target device returns;
Determine from time synchronization request is sent out to the transmission time for receiving the reply data bag and being spent;
According to default time error scope and the expected probability for falling into the time error scope, transmission time threshold is determined Value;
Judge whether the transmission time is less than the transmission time threshold value;
If so, being stabbed according to the transmission time and the sending time of the reply data bag, the synchronizer is corrected Time.
A kind of time synchronism apparatus, including:
Synchronization request transmitting element, for target device sending time synchronization request;
Time bag receiving unit, the reply data bag for including sending time stamp returned for receiving the target device;
Transmission time determination unit, for determining from time synchronization request is sent out to receiving the reply data The spent transmission time of bag;
Transmission time threshold value determination unit, for according to default time error scope and falling into the time error scope Expected probability, determines transmission time threshold value;
Threshold decision unit, for judging whether the transmission time is less than the transmission time threshold value;
Correction time determination unit, for the threshold decision unit judging result for be when, according to the transmission The sending time of time and the reply data bag is stabbed, and corrects the time of the synchronizer.
A kind of clock synchronization system, including at least one synchronizer and at least one target device, the target device Clock be standard time clock;
The synchronizer is used for, to the target device sending time synchronization request;The target device is received to return Comprising sending time stamp reply data bag;Determine from time synchronization request is sent out to receiving the data packet institute The transmission time of cost;According to default time error scope and the expected probability for falling into the time error scope, transmission is determined Time threshold;Judge whether the transmission time is less than the transmission time threshold value;If so, according to the transmission time and described The sending time stamp of reply data bag, corrects the time of the synchronizer;
The target device is used for, current according to itself when receiving the time synchronization request that the synchronizer is sent Time determines that sending time is stabbed, and the reply data bag for including sending time stamp is returned to the synchronizer.
Method for synchronizing time provided by the embodiments of the present application includes:Synchronizer synchronously please to target device sending time Ask, receive the reply data bag for including sending time stamp that the target device returns, determine from sending out the time synchronization Ask to receive the transmission time that the reply data bag is spent, according to default time error scope and fall into the time The expected probability of error range, determines transmission time threshold value, judges whether the transmission time is less than the transmission time threshold value; If so, being stabbed according to the transmission time and the sending time of the reply data bag, the time of the synchronizer is corrected.Thus As it can be seen that the application is when correcting the time of synchronizer, it is contemplated that sending time synchronization request to receive reply data bag this The transmission time of process, and the sending time stamp of the reply data bag of target device return.The application remembers and transmission time Influence so that finally the time of definite synchronizer is more accurate.
Also, the application is determined according to default time error scope and the expected probability for falling into the time error scope Transmission time threshold value, and chosen using the transmission time threshold value and meet the transmission time of condition.Easy to user flexibility control time The precision of synchronization and taking for time synchronization process.
Brief description of the drawings
In order to illustrate the technical solutions in the embodiments of the present application or in the prior art more clearly, below will be to embodiment or existing There is attached drawing needed in technology description to be briefly described, it should be apparent that, drawings in the following description are only this The embodiment of application, for those of ordinary skill in the art, without creative efforts, can also basis The attached drawing of offer obtains other attached drawings.
Fig. 1 is the schematic diagram that a kind of exemplary synchronizer of the application carries out time synchronization with target device;
Fig. 2 is a kind of method for synchronizing time flow chart disclosed in the embodiment of the present application;
Fig. 3 is the probability density curve schematic diagram of t1-t2 under the exemplary difference RTT of the application;
Fig. 4 is a kind of method flow diagram of definite transmission time threshold value disclosed in the embodiment of the present application;
Fig. 5 is a kind of time synchronism apparatus structure diagram disclosed in the embodiment of the present application;
Fig. 6 is a kind of hardware architecture diagram of synchronizer disclosed in the embodiment of the present application.
Embodiment
Below in conjunction with the attached drawing in the embodiment of the present application, the technical solution in the embodiment of the present application is carried out clear, complete Site preparation describes, it is clear that described embodiments are only a part of embodiments of the present application, instead of all the embodiments.It is based on Embodiment in the application, those of ordinary skill in the art are obtained every other without making creative work Embodiment, shall fall in the protection scope of this application.
Inventor is ignored by carrying out research discovery to existing Time Synchronizing in existing Time Synchronizing Data in a network propagate the time consuming influence of institute, so as to cause time synchronization accuracy not high.And with terminal and answer Development, the requirement to timing tracking accuracy is also higher and higher, and existing Time Synchronizing can not be adapted to currently The requirement of precise synchronization.Lift for example, in multi-person interactive film project, movie player needs at the same time with multiple terminals Show interactive interface, synchronous countdown, disappears at the same time, and the timing tracking accuracy requirement to each terminal is high, and the existing time is same Step scheme can not be suitable for the scene.
For this reason, this application provides a kind of high-precision method for synchronizing time.
The method for synchronizing time of the application is applied to clock synchronization system, and system is comprising at least one synchronizer and at least One target device.Wherein, synchronizer is the equipment of pending time synchronization, and target device is the equipment as time source, Its clock is standard time clock.In practical application, synchronizer can be that mobile phone, IPAD, notebook etc. possess network access facility Electronic equipment.General, time synchronization request can be that some application installed in synchronizer is initiated.Certainly, Can also be that the operating system of synchronizer is initiated.
Target device can be server, such as target device is that the target that time synchronization request is initiated in synchronizer is answered With corresponding application server, or transfer server for providing service for intended application etc..Certainly, target device also may be used To be the electronic equipments such as mobile phone, notebook.
Synchronizer and target device can be set according to specific needs.
In the Time Synchronizing of the application, target device is used for, and is receiving the time synchronization request of synchronizer transmission When, the reply data bag for including sending time stamp is returned to the synchronizer;
Wherein, the time for being used to carry out time synchronization that the sending time stamp of the reply data bag determines for target device The sending time stamp of reply data bag can be that target device receives the time of the time synchronization request or target is set After the time synchronization request is received, the time of reply data bag is returned.
Certainly, taken compared to Internet communication, target device is from receiving time synchronization request to transmission reply data bag Processing time is extremely short, can ignore this fractional error.
Synchronizer is used for, to the target device sending time synchronization request;Receive the bag that the target device returns The reply data bag of the stamp containing sending time, determines from time synchronization request is sent out to receiving the reply data bag institute The transmission time of cost;According to default time error scope and the expected probability for falling into the time error scope, transmission is determined Time threshold;Judge whether the transmission time is less than the transmission time threshold value;If so, according to the transmission time and described The sending time stamp of reply data bag, corrects the time of the synchronizer, to be allowed to keep with the time of the target device Unanimously.
Referring to Fig. 1, Fig. 1 is the schematic diagram that a kind of exemplary synchronizer of the application carries out time synchronization with target device.
In Fig. 1, illustrated so that synchronizer is web front end, target device is server as an example.
As shown in Figure 1:
Web front end initiates time synchronization request, query time at the To moment to server.Since what Internet communication took deposits The time of server time of receipt (T of R) synchronization request is the Ts moment, and there are the time of t1 between To and Ts.Due to server operation Required time can be ignored within 1ms relative to the network time of 100ms magnitudes, therefore the application sets server The sending time stamp of the reply data bag fed back to web front end is Ts.Due to the presence of network time, web front end receives response The time of data packet is the Ts' moment, and there are the time of t2 between Ts and Ts'.
Wherein, can not directly be determined for t1 and t2, and overall transmission time RTT (i.e. t1+t2) can be determined.
It will be further understood that RTT is smaller to mean that time synchronization error is smaller, what time synchronization process was consumed Total time will be bigger.
The application can be preset time error scope by user and fall into the expected probability of the time error scope, And then determine therefrom that transmission time threshold value.Synchronizer is judging that the transmission time that certain is once determined is less than the transmission time threshold During value, the sending time of the reply data bag returned according to this transmission time and target device is stabbed, and correction is described synchronously to be set The standby time, is consistent with the time being allowed to the target device.
Since synchronizer is in correction time, it is contemplated that sending time synchronization request is to receiving reply data bag this mistake The transmission time of journey, and the sending time stamp of reply data bag that target device returns, namely synchronizer note and network Propagate time-consuming influence so that the time of correction of a final proof is more accurate.
Also, the application is determined according to default time error scope and the expected probability for falling into the time error scope Transmission time threshold value, and chosen using the transmission time threshold value and meet the transmission time of condition.Easy to user flexibility control time The precision of synchronization and taking for time synchronization process.
Next, the application is introduced scheme with the angle of synchronizer.
Referring to Fig. 2, Fig. 2 is a kind of method for synchronizing time flow chart disclosed in the embodiment of the present application.
As shown in Fig. 2, this method includes:
Step S200, to target device sending time synchronization request;
Specifically, synchronizer is when determining to need to carry out time synchronization, to target device sending time synchronization request.When Between synchronization request can be in the form of message or data packet send.Time synchronization request can be a segment identification, code or its Its form.
It is understood that being taken to reduce Internet communication, the shared data volume of time synchronization request can be reduced.
Step S210, the reply data bag for including sending time stamp that the target device returns is received;
Wherein, the reply data bag sending time stamp for the target device determine be used for carry out time synchronization Time.Sending time stamp can be that target device receives the time of the time synchronization request or target device receives Time synchronization asks after sum operation the obtained time.
It is understood that being taken to reduce Internet communication, the size of reply data bag can be reduced.For example, will hair Send timestamp to be placed on the header part of reply data bag, the main part of reply data bag is left blank, to reduce the biography of time bag The defeated time.
Step S220, determine from time synchronization request is sent out to the biography for receiving the reply data bag and being spent The defeated time;
Specifically, the difference for receiving the time of time of the reply data bag with sending the time synchronization request is Transmission time RTT.
Step S230, according to default time error scope and the expected probability of the time error scope is fallen into, determines to pass Defeated time threshold;
Specifically, user can set oneself patient time error scope of institute, and time error is controlled in institute State the expected probability in the range of time error.It is understood that time error scope is smaller, expected probability is higher, then correspond to Transmission time RTT it is smaller.For synchronizer to the number of target device sending time synchronization request more, time synchronization mistake The total time of journey consumption is about long.
, can be true according to default time error scope and the expected probability for falling into the time error scope in the present embodiment Determine transmission time threshold value.
Step S240, judge whether the transmission time is less than the transmission time threshold value;If so, step S250 is performed, Step S200 is performed if it is not, returning;
Step S250, stabbed according to the transmission time and the sending time of the reply data bag, correction is described synchronously to be set The standby time.
Specifically, stabbed in this step according to the transmission time and the sending time of reply data bag, to synchronizer The current time is corrected, and is consistent with the time being allowed to the target device.
In the embodiment of the present application, synchronizer receives the target device and returns to target device sending time synchronization request That returns includes the reply data bag of sending time stamp, determines from time synchronization request is sent out to receiving the answer number According to wrapping spent transmission time, according to default time error scope and the expected probability for falling into the time error scope, really Determine transmission time threshold value, judge whether the transmission time is less than the transmission time threshold value;If so, according to the transmission time With the first time, the time of the synchronizer is corrected, is consistent with the time being allowed to the target device.Thus As it can be seen that the application is when correcting the time of synchronizer, it is contemplated that sending time synchronization request to receive reply data bag this The transmission time of process, and the sending time stamp of the reply data bag of target device return.The application remembers and transmission time Influence so that finally the time of definite synchronizer is more accurate.
Also, the application is determined according to default time error scope and the expected probability for falling into the time error scope Transmission time threshold value, and chosen using the transmission time threshold value and meet the transmission time of condition.Easy to user flexibility control time The precision of synchronization and taking for time synchronization process.
Optionally, synchronizer determines that the process of transmission time can have a variety of ways of realization, such as:
Synchronizer records the sending time stamp of the time synchronization request, and, record connecing for the reply data bag Receive timestamp.
Wherein, the sending time stamp of the time synchronization request is the time of synchronizer sending time synchronization request. The receiving time stamp of reply data bag is that synchronizer receives the time of reply data bag.
Based on this, sending time stamp and the reply data bag that synchronizer is asked according to the time synchronization of record Receiving time stamp difference, determine transmission time.
The receiving time stamp of reply data bag subtracts the sending time stamp of time synchronization request, is transmission time.
For another example,
Synchronizer starts timer while to target device sending time synchronization request, timing during initial start Device reading is zero.
Synchronizer terminates the timer while reply data bag that the target device returns is received.
Based on this, synchronizer can determine transmission time according to the timing result of the timer after termination. That is, the reading of the timer after termination is determined as transmission time by synchronizer.
Present inventor has found the size of transmission time RTT to time synchronization essence by the research to transmission time RTT Degree produces certain influence.Now the research process of inventor is introduced.
In this application, it is assumed that:
RTT → 0 (i.e. RTT level off to 0),
When:
(t1-t2)≈0
That is, when RTT level off to 0 when, can be considered t1=t2.
This inference can be simply interpreted as:When RTT (the sum of t1 and t2) is smaller, it is meant that t1 and t2 are in itself (absolute figure) is smaller, then the gap (absolute figure) between them is naturally also smaller.
Simple proof is as follows:
Assuming that under real network environment, t1 and t2 obeys Stochastic Poisson distribution, then RTT (i.e. t1+t2) also obeys pool Pine distribution, the probability distribution of t1-t2 are as shown in Figure 3.
Can intuitively it be found out by Fig. 3, when RTT (i.e. t1+t2) is smaller, the probability density curve of (t1-t2) gets over " high thin ", i.e., (t1-t2) probability fallen in (- 50ms, 50ms) section is higher, i.e. the difference of t1 and t2 are smaller.When (t1-t2) fall (- 50ms, 50ms) during section, it is meant that if being calculated by assuming t1=t2=1/20.5*RTT, its error is less than (10ms grades of 25ms Not).
In figure 3 it can be seen that as RTT=500ms, it there are about 70% probability (t1-t2) and fall in (- 50ms, 50ms) section In, in RTT=1000ms, the probability is only less than 50%.
Understand that, when transmission time RTT is smaller, the probability of t1=t2 is higher based on above-mentioned introduction, therefore the application is synchronous Equipment corrects the process of synchronizer time according to the sending time of transmission time RTT and reply data bag stamp:
Synchronizer is by the product of the transmission time RTT and setting coefficient a, the sending time with the reply data bag Stamp is added, and addition result is determined as the time of synchronizer.
Wherein, it preferably can be 0.5 to set coefficient a, it can also be other numerical value certainly, and the value range of a can be with Be (0,1].
Since transmission time is smaller, the time that correction of a final proof obtains is more accurate, and the application can determine transmission time for this Threshold value, when determining that transmission time is less than setting transmission time threshold value just based on the transmission time and the reply data bag Sending time is stabbed, and corrects the time of synchronizer.
The above embodiments of the present application are it is stated that according to default time error scope and the time error model can be fallen into The expected probability enclosed determines transmission time threshold value.Next, to determining that the process of transmission time threshold value is introduced.
For the ease of statement, the application, which defines transmission time, includes time synchronization request from synchronizer transmission The the first transmission sub- time spent to the target device, and the reply data bag are sent to described same from the target device Walk the second transmission sub- time that equipment is spent.First transmission sub- time was considered as above-mentioned t1, and the second transmission sub- time is permissible Regard above-mentioned t2 as.
Then determine that the process of transmission time threshold value may refer to Fig. 4.
As shown in figure 4, the process includes:
Step S400, the function obeyed according to transmission time is distributed, and determines the first transmission period of the day from 11 p.m. to 1 a.m under different transmission times Between probability density function with the difference of second transmission sub- time;
Specifically, transmission time, the first transmission sub- time, the second transmission sub- time obey identical function distribution, such as Poisson distribution.The application can determine under a series of different transmission times that the first transmission sub- time transmitted the sub- time with second Difference probability density function.Probability density function illustrates the correspondence between difference and probable value.
Step S410, each probability density function is substituted into the default time error scope, calculates time error scope Corresponding probable value;
Specifically, in the present embodiment using time error scope as (x, y) exemplified by, then using time error x and y as The difference of one transmission sub- time and the second transmission sub- time, time error scope pair can be determined by each probability density function The probable value answered.
Wherein, the probable value calculated by different probability density functions is different.
Step S420, the probable value for determining to be calculated exceedes corresponding to the probability density function of default expected probability Transmission time, and a transmission time of maximum is therefrom chosen as transmission time threshold value.
Specifically, the application user can preset the expected probability for the time error scope for falling into setting, Jin Erji In multiple probable values that previous step is drawn, the transmission time corresponding to the probability density function more than expected probability is chosen.And A transmission time of maximum is therefrom chosen as transmission time threshold value.
It is understood that if transmission time is less than transmission time threshold value, time error falls into the time error of setting The expected probability of scope is greater than setting expected probability.
Poisson distribution is obeyed with transmission time RTT, exemplified by the sending time stamp+0.5RTT of correction time=reply data bag Illustrate.
The application can determine under a series of different transmission time RTT that the sub- time t1 and second of the first transmission transmits the period of the day from 11 p.m. to 1 a.m Between t2 difference probability density function.
Referring to Fig. 3, present application illustrates when RTT=500ms, 1000ms, 2000ms, the probability density function pair of t1-t2 The curve answered.
It is assumed that the time error scope of user preset is (- 50ms, 50ms), and error falls into the phase of the time error scope It is 70% to hope probability.
, can be with then by the way that time error scope (- 50ms, 50ms) is substituted into three probability density functions shown in Fig. 3 It is calculated:
During RTT=500ms, (- 50ms, 50ms) corresponding probable value is 71%;
During RTT=1000ms, (- 50ms, 50ms) corresponding probable value is 50%;
During RTT=2000ms, (- 50ms, 50ms) corresponding probable value is 35%.
It follows that in RTT=500ms, (- 50ms, 50ms) corresponding probable value exceedes setting expected probit, and Relatively expected probit, therefore, can choose RTT=500ms as transmission time threshold value.It is less than in definite transmission time During 500ms, the sending time of the reply data bag fed back according to target device is stabbed, and transmission time RTT, calculates timing Between:The sending time stamp of reply data bag adds 0.5RTT.
It follows that time error scope and error that the application is set based on user fall into the phase of the time error scope Hope determine the probability transmission time threshold value, and then the transmission time determined using the transmission time threshold value to time synchronization process is carried out Screening.Application scheme is easy to the precision of user flexibility control time synchronization and taking for time synchronization process.
In order to verify the accuracy of the application time synchronization, now illustrated with the scene of multi-person interactive film.
The server for providing interactive movie content is same as standard time source, multiple synchronizers and server progress time Step.Illustrated in the present embodiment by taking synchronizer includes desktop computer, notebook, Android mobile phone and iPhone as an example.Wherein, Aforementioned four synchronizer (cable network, wireless network, mobile network) under different network environments, according to the scheme of the application Time synchronization is carried out, at a certain moment, 41 divide 15 seconds 8 when server time is 16, the time after each synchronizer time synchronization 41 divide 15 seconds 8 when being also 16.Time between each synchronizer can be maintained at the synchronization accuracy within 0.1 second, in other words, Error level is ten milliseconds of ranks, the other error of hundreds of Milliseconds compared with the prior art, its precision is greatly promoted.
Time synchronism apparatus provided by the embodiments of the present application is described below, time synchronism apparatus described below with Above-described method for synchronizing time can correspond reference.
Referring to Fig. 5, Fig. 5 is a kind of time synchronism apparatus structure diagram disclosed in the embodiment of the present application.
As shown in figure 5, the device includes:
Synchronization request transmitting element 51, for target device sending time synchronization request;
Reply data bag receiving unit 52, the answer number for including sending time stamp returned for receiving the target device According to bag;
The time for being used to carry out time synchronization that the sending time stamp determines for the target device.
Optionally, sending time stamp can be time or the mesh that target device receives the time synchronization request The time obtained after marking device time of receipt (T of R) synchronization request union.
It is understood that in order to reduce network time, the size of reply data bag can be reduced.For example, when will send Between stamp be placed on the header part of reply data bag, the main part of reply data bag is left blank, to reduce the biography of reply data bag The defeated time.
Transmission time determination unit 53, for determining from time synchronization request is sent out to receiving the data packet The transmission time spent;
Specifically, the difference for receiving the time of time of the reply data bag with sending the time synchronization request is Transmission time RTT.
Transmission time threshold value determination unit 54, for according to default time error scope and falling into the time error scope Expected probability, determine transmission time threshold value;
Threshold decision unit 55, for judging whether the transmission time is less than the transmission time threshold value;
Correction time determination unit 56, for the threshold decision unit 54 judging result for be when, according to described Transmission time and the sending time of reply data bag stamp, correct the time of the synchronizer, to be allowed to and the target The time of equipment is consistent.
Sent it is understood that the transmission time includes time synchronization request from the synchronizer to described The first transmission sub- time that target device is spent, and the reply data bag are sent to the synchronizer from the target device The the second transmission sub- time spent.
It is understood that when the judging result of the threshold decision unit 55 is no, it is described same that execution can be triggered Walk request transmitting unit 51.
Optionally, the transmission time threshold value determination unit can include:
Probability density function determination unit, the function for being obeyed according to transmission time is distributed, when determining different transmission Between lower first transmission sub- time and the probability density function of the difference of the second transmission sub- time;
Probable value computing unit, for substituting into each probability density function with the default time error scope, during calculating Between the corresponding probable value of error range;
Transmission time chooses unit, and the probable value for determining to be calculated exceedes the probability density of default expected probability Transmission time corresponding to function, and a transmission time of maximum is therefrom chosen as transmission time threshold value.
Optionally, the time synchronism apparatus of the application can also include:
Time recording unit, for recording the sending time stamp of the time synchronization request;And record the data packet Receiving time stamp;
Based on this, the transmission time determination unit can include:
First transmission time determination subelement, for the sending time stamp asked according to the time synchronization of record and institute The difference of the receiving time stamp of reply data bag is stated, determines transmission time.
Optionally, the time synchronism apparatus of the application can also include:
Chronograph control unit, for while to target device sending time synchronization request, starting timer, initially Timer reading is zero during startup;While the reply data bag that the target device returns is received, the timer is terminated;
Based on this, the transmission time determination unit can include:
Second transmission time determination subelement, for the timing result according to the timer after termination, determines transmission Time.
Optionally, above-mentioned correction time determination unit can include:
First correction time determination subelement, for by the transmission time with setting coefficient product, with the response The sending time stamp of data packet is added, and addition result is determined as the time of the synchronizer.
Wherein, it can be 0.5 to set coefficient.
For the hardware configuration of above-mentioned synchronizer, referring to Fig. 6, Fig. 6 is synchronizer provided by the embodiments of the present application Hardware architecture diagram.As shown in fig. 6, the synchronizer can include:
Processor 1, communication interface 2, memory 3, communication bus 4, and display screen 5;
Wherein processor 1, communication interface 2, memory 3 and display screen 5 complete mutual communication by communication bus 4;
Optionally, communication interface 2 can be the interface of communication module, such as the interface of gsm module;
Processor 1, for executive program;
Memory 3, for storing program;
Program can include program code, and said program code includes the operational order of processor.
Processor 1 is probably a central processor CPU, or specific integrated circuit ASIC (Application Specific Integrated Circuit), or be arranged to implement the embodiment of the present application one or more integrate electricity Road.
Memory 3 may include high-speed RAM memory, it is also possible to further include nonvolatile memory (non-volatile Memory), a for example, at least magnetic disk storage.
Wherein, program can be specifically used for:
To target device sending time synchronization request;
Receive the reply data bag for including sending time stamp that the target device returns;
Determine from time synchronization request is sent out to the transmission time for receiving the reply data bag and being spent;
According to default time error scope and the expected probability for falling into the time error scope, transmission time threshold is determined Value;
Judge whether the transmission time is less than the transmission time threshold value;
If so, being stabbed according to the transmission time and the sending time of the reply data bag, the synchronizer is corrected Time.
Finally, it is to be noted that, herein, relational terms such as first and second and the like be used merely to by One entity or operation are distinguished with another entity or operation, without necessarily requiring or implying these entities or operation Between there are any actual relationship or order.Moreover, term " comprising ", "comprising" or its any other variant meaning Covering non-exclusive inclusion, so that process, method, article or equipment including a series of elements not only include that A little key elements, but also including other elements that are not explicitly listed, or further include for this process, method, article or The intrinsic key element of equipment.In the absence of more restrictions, the key element limited by sentence "including a ...", is not arranged Except also there are other identical element in the process, method, article or apparatus that includes the element.
Each embodiment is described by the way of progressive in this specification, what each embodiment stressed be and other The difference of embodiment, between each embodiment identical similar portion mutually referring to.
The foregoing description of the disclosed embodiments, enables professional and technical personnel in the field to realize or using the application. A variety of modifications to these embodiments will be apparent for those skilled in the art, as defined herein General Principle can be realized in other embodiments in the case where not departing from spirit herein or scope.Therefore, the application The embodiments shown herein is not intended to be limited to, and is to fit to and the principles and novel features disclosed herein phase one The most wide scope caused.

Claims (13)

1. a kind of method for synchronizing time, it is characterised in that applied to synchronizer, this method includes:
To target device sending time synchronization request;
Receive the target device and respond the reply data bag for including sending time stamp that the time synchronization request returns;
Determine from time synchronization request is sent out to the transmission time for receiving the reply data bag and being spent;
According to default time error scope and the expected probability for falling into the time error scope, transmission time threshold value is determined;
Judge whether the transmission time is less than the transmission time threshold value;
If so, being stabbed according to the transmission time and the sending time of the reply data bag, the time of the synchronizer is corrected, The process includes:
By the transmission time and the product of setting coefficient, it is added with the sending time stamp of the reply data bag, addition result It is determined as the time of the synchronizer.
2. according to the method described in claim 1, it is characterized in that, the transmission time includes time synchronization request from institute State synchronizer and send the first transmission sub- time spent to the target device, and the reply data bag is set from the target Preparation send the second transmission sub- time spent to the synchronizer;
It is described according to default time error scope and the expected probability for falling into the time error scope, determine transmission time threshold value The step of, including:
The function obeyed according to transmission time is distributed, and determines the first transmission sub- time and the second transmission under different transmission times The probability density function of the difference of time;
Each probability density function is substituted into the default time error scope, calculates the corresponding probable value of time error scope;
Transmission time of the probable value for determining to be calculated corresponding to more than the probability density function of default expected probability, and from It is middle to choose a maximum transmission time as transmission time threshold value.
3. according to the method described in claim 1, it is characterized in that, further include:
Record the sending time stamp of the time synchronization request;And
Record the receiving time stamp of the reply data bag;
It is described to determine from time synchronization request is sent out to the transmission time for receiving the reply data bag and being spent, bag Include:
The difference that the sending time stamp and the receiving time of the reply data bag asked according to the time synchronization of record stab, Determine transmission time.
4. according to the method described in claim 1, it is characterized in that, further include:
While to target device sending time synchronization request, start timer, timer reading is zero during initial start;
While the reply data bag that the target device returns is received, the timer is terminated;
It is described to determine from time synchronization request is sent out to the transmission time for receiving the reply data bag and being spent, bag Include:
According to the timing result of the timer after termination, transmission time is determined.
5. according to the method described in claim 1, it is characterized in that, further include:
When judging that the transmission time is not less than the transmission time threshold value, triggering is described synchronous to target device sending time The operation of request.
6. according to the method described in claim 1, it is characterized in that, the coefficient that sets is 0.5.
7. a kind of time synchronism apparatus, it is characterised in that applied to synchronizer, which includes:
Synchronization request transmitting element, for target device sending time synchronization request;
Reply data bag receiving unit, sends for receiving the target device response the including for time synchronization request return The reply data bag of timestamp;
Transmission time determination unit, for determining from time synchronization request is sent out to receiving the reply data bag institute The transmission time of cost;
Transmission time threshold value determination unit, for according to default time error scope and the expectation for falling into the time error scope Probability, determines transmission time threshold value;
Threshold decision unit, for judging whether the transmission time is less than the transmission time threshold value;
Correction time determination unit, for the threshold decision unit judging result for be when, according to the transmission time Stabbed with the sending time of the reply data bag, correct the time of the synchronizer;
The correction time determination unit, including:
First correction time determination subelement, for by the transmission time with setting coefficient product, with the reply data The sending time stamp of bag is added, and addition result is determined as the time of the synchronizer.
8. device according to claim 7, it is characterised in that the transmission time, which includes the time synchronization, asks from institute State synchronizer and send the first transmission sub- time spent to the target device, and the reply data bag is set from the target Preparation send the second transmission sub- time spent to the synchronizer;
The transmission time threshold value determination unit includes:
Probability density function determination unit, for the function distribution obeyed according to transmission time, determines under different transmission times First transmission sub- time and the probability density function of the difference of the second transmission sub- time;
Probable value computing unit, for substituting into each probability density function with the default time error scope, calculates time mistake The corresponding probable value of poor scope;
Transmission time chooses unit, and the probable value for determining to be calculated exceedes the probability density function of default expected probability Corresponding transmission time, and a transmission time of maximum is therefrom chosen as transmission time threshold value.
9. device according to claim 7, it is characterised in that further include:
Time recording unit, for recording the sending time stamp of the time synchronization request;And record the reply data bag Receiving time stamp;
The transmission time determination unit includes:
First transmission time determination subelement, the sending time stamp for being asked according to the time synchronization of record are answered with described The difference of the receiving time stamp of data packet is answered, determines transmission time.
10. device according to claim 7, it is characterised in that further include:
Chronograph control unit, for while to target device sending time synchronization request, starting timer, initial start When timer reading be zero;While the reply data bag that the target device returns is received, the timer is terminated;
The transmission time determination unit includes:
Second transmission time determination subelement, for the timing result according to the timer after termination, determines transmission time.
11. device according to claim 7, it is characterised in that when the judging result of the threshold decision unit is no, Triggering performs the synchronization request transmitting element.
12. device according to claim 7, it is characterised in that the coefficient that sets is 0.5.
13. a kind of clock synchronization system, it is characterised in that including at least one synchronizer and at least one target device, institute The clock for stating target device is standard time clock;
The synchronizer is used for, to the target device sending time synchronization request;Receive described in the target device response The reply data bag for including sending time stamp that time synchronization request returns;Determine from time synchronization request is sent out to connecing Receive the transmission time that the data packet is spent;According to default time error scope and the phase for falling into the time error scope Hope probability, determine transmission time threshold value;Judge whether the transmission time is less than the transmission time threshold value;If so, according to institute The sending time stamp of transmission time and the reply data bag is stated, corrects the time of the synchronizer, which includes:By institute Transmission time is stated with setting the product of coefficient, is added with the sending time stamp of the reply data bag, addition result is determined as institute State the time of synchronizer;
The target device is used for, when receiving the time synchronization request that the synchronizer is sent, according to itself current time Determine that sending time is stabbed, the reply data bag for including sending time stamp is returned to the synchronizer.
CN201610539966.1A 2016-07-08 2016-07-08 A kind of method for synchronizing time, apparatus and system Active CN105915308B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610539966.1A CN105915308B (en) 2016-07-08 2016-07-08 A kind of method for synchronizing time, apparatus and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610539966.1A CN105915308B (en) 2016-07-08 2016-07-08 A kind of method for synchronizing time, apparatus and system

Publications (2)

Publication Number Publication Date
CN105915308A CN105915308A (en) 2016-08-31
CN105915308B true CN105915308B (en) 2018-04-27

Family

ID=56754570

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610539966.1A Active CN105915308B (en) 2016-07-08 2016-07-08 A kind of method for synchronizing time, apparatus and system

Country Status (1)

Country Link
CN (1) CN105915308B (en)

Families Citing this family (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106788957B (en) * 2016-12-30 2022-02-11 广州华多网络科技有限公司 Method and device for correcting time error of timer
CN107171763B (en) * 2017-07-05 2018-10-23 北京蓝海讯通科技股份有限公司 A kind of time processing method, device and mobile terminal based on time migration
CN110557823A (en) * 2018-05-31 2019-12-10 华为技术有限公司 clock synchronization method and device, terminal equipment, chip and readable storage medium
CN111083309B (en) * 2018-10-18 2022-04-01 北京魔门塔科技有限公司 Time alignment method of multi-sensor data and data acquisition equipment
CN109565772A (en) * 2018-10-31 2019-04-02 深圳市汇顶科技股份有限公司 Method for synchronizing time, equipment and storage medium
CN109765578B (en) * 2019-02-19 2020-11-03 武汉元光科技有限公司 Bus GPS equipment clock calibration method and device
CN110071778B (en) * 2019-04-24 2021-03-23 江苏紫米软件技术有限公司 Time synchronization method, device, equipment and medium
CN112154614B (en) * 2019-08-29 2023-02-21 上海飞来信息科技有限公司 Sensing system, sensing apparatus, control method thereof, movable platform, and storage medium
CN112532334B (en) * 2021-02-18 2021-05-04 北京拓课网络科技有限公司 Time synchronization method and device and electronic equipment
CN113507338A (en) * 2021-07-22 2021-10-15 深圳市灰度科技有限公司 Time synchronization method and device, computer equipment and storage medium
WO2023130217A1 (en) * 2022-01-04 2023-07-13 Telefonaktiebolaget Lm Ericsson (Publ) Method and apparatus for radio over ethernet

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101960755A (en) * 2008-01-25 2011-01-26 皮尔茨公司 Method and device for transmitting data in a network
CN102739626A (en) * 2011-04-12 2012-10-17 索尼公司 Method and device for time synchronization, time stamping device and trusted time server
CN103220120A (en) * 2012-01-20 2013-07-24 腾讯科技(深圳)有限公司 Time synchronizing method of mobile terminal, mobile terminal and time synchronizing system

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP5534548B2 (en) * 2009-03-10 2014-07-02 日本電気株式会社 Receiving side node for clock synchronization, method and program thereof
CN105577348B (en) * 2014-10-08 2020-06-30 中兴通讯股份有限公司 Frequency deviation monitoring method and device based on time synchronization network

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101960755A (en) * 2008-01-25 2011-01-26 皮尔茨公司 Method and device for transmitting data in a network
CN102739626A (en) * 2011-04-12 2012-10-17 索尼公司 Method and device for time synchronization, time stamping device and trusted time server
CN103220120A (en) * 2012-01-20 2013-07-24 腾讯科技(深圳)有限公司 Time synchronizing method of mobile terminal, mobile terminal and time synchronizing system

Also Published As

Publication number Publication date
CN105915308A (en) 2016-08-31

Similar Documents

Publication Publication Date Title
CN105915308B (en) A kind of method for synchronizing time, apparatus and system
US7668207B2 (en) System, method, and article of manufacture for synchronizing time of day clocks on first and second computers
CN1897494B (en) Ranging scalable time stamp data synchronization method and system
US9298792B2 (en) Database synchronization
CN110245274A (en) A kind of label temperature calculates method, apparatus, electronic equipment and storage medium
CN103109492A (en) Motion initiated time synchronization
EP3792858A1 (en) Blockchain-based financial trading executing method and apparatus, and electronic device
CN109327899A (en) A kind of method, apparatus and system synchronization time of mobile unit synchronization time
CN108228358A (en) Correct method, apparatus, mobile terminal and the storage medium of vertical synchronizing signal
CN112154669A (en) Correlation of video stream frame timestamps based on system clock
US4646291A (en) Synchronization apparatus in transmitting information on a simplex bus
CN104703036A (en) Method, device and system for synchronizing playing course of media file
CN110830138B (en) Information processing method, electronic equipment and server
CN114092252A (en) Block chain transaction execution method, device, equipment and readable storage medium
US8509751B2 (en) System and method of object simulation in an intermittently connected mobile application
CN108964825A (en) Calibration method, correction device and time server
CN104978392A (en) Content output device for outputting content
CN116688491A (en) Object position synchronization system, method and device in virtual scene and electronic equipment
CN111464254A (en) Clock synchronization method and device and electronic equipment
CN114499816B (en) Clock synchronization method and device, terminal equipment and readable storage medium
CN116095534A (en) Method, device and storage medium for collecting test equipment data
CN105933877B (en) The time adjusting method and device of terminal
CN115361084A (en) Method, device, equipment and medium for synchronizing clocks
CN109064248A (en) Order data synchronous method of calibration, device and equipment
US7047433B2 (en) Method and circuit for synchronizing a higher frequency clock and a lower frequency clock

Legal Events

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