CN110266420A - Clock synchronizing method, clock synchronization apparatus and computer readable storage medium - Google Patents

Clock synchronizing method, clock synchronization apparatus and computer readable storage medium Download PDF

Info

Publication number
CN110266420A
CN110266420A CN201910355439.9A CN201910355439A CN110266420A CN 110266420 A CN110266420 A CN 110266420A CN 201910355439 A CN201910355439 A CN 201910355439A CN 110266420 A CN110266420 A CN 110266420A
Authority
CN
China
Prior art keywords
clock
moment
server
client
response data
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
CN201910355439.9A
Other languages
Chinese (zh)
Other versions
CN110266420B (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.)
Beijing Dajia Internet Information Technology Co Ltd
Original Assignee
Beijing Dajia Internet 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 Beijing Dajia Internet Information Technology Co Ltd filed Critical Beijing Dajia Internet Information Technology Co Ltd
Priority to CN201910355439.9A priority Critical patent/CN110266420B/en
Publication of CN110266420A publication Critical patent/CN110266420A/en
Application granted granted Critical
Publication of CN110266420B publication Critical patent/CN110266420B/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

Abstract

The application is about a kind of clock synchronizing method, clock synchronization apparatus and computer readable storage medium.The clock synchronizing method includes: the first moment to server tranmitting data register synchronization request and when recording transmission;Receive the response data that the server is sent and the second moment when recording reception, the response data includes the third moment that server receives the clock synchronization request and the 4th moment when server sends the response data;The clock jitter of the client Yu the server is obtained according to first moment to the 4th moment;And the system clock of the client is obtained, the synchronised clock of the server is obtained in conjunction with the clock jitter.The clock synchronizing method is by server tranmitting data register synchronization request, and receive the response data that server is sent back, the clock jitter of client and server is obtained according to the several moment sent and received, so as to adjust the system clock of client, keeps it synchronous with server end clock.

Description

Clock synchronizing method, clock synchronization apparatus and computer readable storage medium
Technical field
The application belongs to computer software application field more particularly to clock synchronizing method and clock synchronization apparatus.
Background technique
As the fast development of browser technology and the popular of high-performance handheld device are popularized, society is to Web interaction hand The demand of section is higher and higher, and web front end field assumes responsibility for more next in the application program based on B (rowser) S (erver) framework Bigger responsibility.In some scenes for needing to have height timeliness, such as a kind of widely applied online activity (such as swim Play) in, browser page needs to capture the key state of server end asks to execute such as transformation view, refreshing, initiate network The operation, if the key state duration is short, browser page such as ask probably because time irreversibility and miss or mention It is early to execute expected movement, bring experience to perplex to user;In addition currently on the market there is front and back end clock misalignment in large number of equipment Problem, for example, in the equipment that system time is set automatically, due to, there are certain misalignment, causing to set between each synchronisation source It is standby that there is also considerable errors between equipment;In addition, business conduct is based on the time of server, and the time may Not set any synchronization is synchronized with entirely different source, so that the time between client and server can not be synchronous, nothing Method meets timeliness demand.
So being at present that the time between client and server is made to keep to the greatest extent may be used in the scene for needing height timeliness The small error of energy, often obtains the time of server, poll services end state can be effective by network request poll services end Synchronous service state in time, wherein also include server clock, but poll services end state needs frequently to initiate network request, Server-side occupies a large amount of computing resources, and the bandwidth between client and server-side is caused to be wasted, and ROI (rate of return on investment) is low, And server clock will receive the larger impact of network request round-trip delay in transmission process;And reducing poll frequency can save Province runs counter to the occupancy of resource it is apparent that sacrificing timeliness with the target of height timeliness.
Summary of the invention
To overcome the problems in correlation technique, the application discloses a kind of clock synchronizing method and clock synchronization apparatus, By the clock jitter between client and server being obtained, according to clock jitter tune by client tranmitting data register synchronization request The system clock of whole client avoids poll services end bring from occupying resource problem, has also achieved the purpose that high-timeliness.
According to the embodiment of the present application in a first aspect, provide a kind of clock synchronizing method, the clock synchronizing method application In client, comprising:
The first moment when to server tranmitting data register synchronization request and recording transmission;
The response data that the server is sent and the second moment when recording reception are received, the response data includes clothes The 4th moment when third moment and the server that business device receives the clock synchronization request send the response data;
The clock jitter of the client Yu the server is obtained according to first moment to the 4th moment;With And
The system clock for obtaining the client obtains the synchronised clock of the server in conjunction with the clock jitter.
Optionally, described that the client and the server are obtained according to first moment to the 4th moment Clock jitter includes:
It is obtained sending the clock from the client according to the incidence relation at first moment to the 4th moment Synchronization request starts to receiving round-trip network delay caused by the response data;
It is obtained since the server sends the response data according to the round-trip network delay to the client Receive backhaul network time delay caused by the response data;
According to the backhaul network time delay, the 4th moment when sending the response data in conjunction with the server and described The second moment that client receives the response data generates the clock jitter.
Optionally, since the client sending the clock synchronization request to receiving what the response data expended Since first time with the server to the second of the transmission response data consuming receiving the clock synchronization request The difference of time is the round-trip network delay.
Optionally, the sum of the time difference and the backhaul network time delay at the 4th moment and second moment are described Clock jitter.
Optionally, the backhaul network time delay is the half of the round-trip network delay.
Optionally, the first moment and described when the clock synchronization request is sent is obtained using browser performance interface Client receives the second moment when the response data.
Optionally, it is described obtained using browser performance interface the clock synchronization request send when the first moment and The second moment when the client receives the response data includes:
For the uniform resource locator of the clock synchronization request, unique identification is set;
By in the response data the third moment and the 4th moment and the unique identification establish corresponding relationship simultaneously Storage;And
Using unique identification described in browser performance interface position, when obtaining first when the clock synchronization request is sent Carve the second moment when receiving the response data with the client.
Optionally, the clock synchronizing method further include: repeatedly send the clock synchronization request and reception to server The response data obtains the data of round-trip network delay and the clock jitter described in multiple groups, using filtering model filter screen Select the highest clock jitter of a confidence level.
Optionally, it from the data of round-trip network delay and the clock jitter described in multiple groups, is filtered using filtering model Filtering out the highest clock jitter of a confidence level includes:
The repeatedly corresponding multi-group data of the clock synchronization request is acquired, therefrom rejects the round-trip network delay greater than net The data of network delay threshold;
The corresponding clock jitter of all remaining clock synchronization requests is arranged, its is counted and is overlapped section, will gather around There is the corresponding data group in coincidence section of most data groups to screen;
Taking the clock jitter in round-trip that the smallest group data of network delay described in remaining data group to be used as can The highest clock jitter of reliability.
According to a second aspect of the embodiments of the present invention, a kind of clock synchronizing method, the clock synchronizing method application are provided In server end, comprising:
The clock synchronization request that client is sent is received, and stores third moment when reception;
Response data is sent to the client, the response data includes described in the third moment and server transmission The 4th moment when response data, wherein the third moment and the 4th moment mention as the server to client The clock reference of confession, so that the client is sent according to the third moment and the 4th moment in conjunction with the client The first moment when the clock synchronization request and the second moment when the reception response data, obtain client and server The clock jitter at end, the sum of the system clock of the client and the clock jitter are the synchronised clock of the server.
Optionally, the response data further includes communication data.
According to a third aspect of the embodiments of the present invention, a kind of clock synchronization apparatus, the clock synchronization apparatus application are provided In client, comprising:
Request sending module, for the first moment to server tranmitting data register synchronization request and when recording transmission;
First receiving module, the second moment when for receiving the response data of the server transmission and record reception, The response data includes third moment and the server transmission sound that server receives the clock synchronization request Answer the 4th moment when data;
Clock jitter generation module, for obtaining the client and institute according to first moment to the 4th moment State the clock jitter of server;And
Clock synchronization module obtains the clothes in conjunction with the clock jitter for obtaining the system clock of the client The synchronised clock of business device.
Optionally,
The clock jitter generation module includes:
First time delay obtains module, obtains for the incidence relation according to first moment to the 4th moment from institute It states client and sends the clock synchronization request and start to receiving round-trip network delay caused by the response data;
Second time delay obtains module, sends the response for obtaining according to the round-trip network delay from the server Data start to the client to receive backhaul network time delay caused by the response data;
Generation module, for according to the backhaul network time delay, when sending the response data in conjunction with the server The second moment that 4th moment and the client receive the response data generates the clock jitter.
Optionally, since the client sending the clock synchronization request to receiving what the response data expended Since first time with the server to the second of the transmission response data consuming receiving the clock synchronization request The difference of time is the round-trip network delay.
Optionally, the sum of the time difference and the backhaul network time delay at the 4th moment and second moment are described Clock jitter.
Optionally, the backhaul network time delay is the half of the round-trip network delay.
Optionally, the clock synchronization apparatus further includes time-obtaining module, for being obtained using browser performance interface The first moment and the client when clock synchronization request being taken to send receive the second moment when the response data.
Optionally, the time-obtaining module includes:
Identify and arrange module, for unique identification to be arranged for the uniform resource locator of the clock synchronization request;
Relationship establishes module, for by the response data the third moment and the 4th moment and unique mark Knowledge is established corresponding relationship and is stored;And
Locating module, for obtaining the clock synchronization request using unique identification described in browser performance interface position The first moment and the client when transmission receive the second moment when the response data.
Optionally, the clock synchronization apparatus further include:
Filtering screening module, for repeatedly sending the clock synchronization request to server and receiving the response data, The data for obtaining round-trip network delay and the clock jitter described in multiple groups, select a confidence level using filtering model filter screen The highest clock jitter.
Optionally, the filtering screening module includes:
Data acquisition module, for acquiring the repeatedly corresponding multi-group data of the clock synchronization request, therefrom described in rejecting Round-trip network delay is greater than the data of network delay threshold value;
Screening module is counted, for arranging the corresponding clock jitter of all remaining clock synchronization requests, system It counts it and is overlapped section, the corresponding data group in coincidence section for possessing most data groups is screened;
Module is chosen, when for taking described in round-trip that the smallest group data of network delay described in remaining data group Clock deviation is as the highest clock jitter of confidence level.
According to a fourth aspect of the embodiments of the present invention, a kind of clock synchronization apparatus, the clock synchronization apparatus application are provided In server end, comprising:
Second receiving module for receiving the clock synchronization request of client transmission, and stores third moment when reception;
Response data sending module, for sending response data to the client, the response data includes described the Three moment and server send the 4th moment when response data, wherein the third moment and the 4th moment are made For the clock reference that the server is provided to client so that the client according to the third moment and it is described 4th when It carves, the first moment when sending the clock synchronization request in conjunction with the client and when second when receiving the response data It carves, obtains the clock jitter of client and server, the sum of the system clock of the client and the clock jitter are institute State the synchronised clock of server.
Optionally, the response data further includes communication data.
According to a fifth aspect of the embodiments of the present invention, a kind of electronic equipment is provided characterized by comprising
Processor;
Memory for storage processor executable instruction;
Wherein, the processor is configured to executing the clock side of synchronization for being applied to client described in above-mentioned any one Method.
According to a sixth aspect of the embodiments of the present invention, a kind of computer readable storage medium is provided, which is characterized in that described Computer-readable recording medium storage has computer instruction, and it is above-mentioned applied to client that the computer instruction is performed realization Clock synchronizing method.
According to a seventh aspect of the embodiments of the present invention, a kind of electronic equipment is provided characterized by comprising
Processor;
Memory for storage processor executable instruction;
Wherein, the processor is configured to executing synchronous applied to the clock of server end described in above-mentioned any one Method.
According to a eighth aspect of the embodiments of the present invention, a kind of computer readable storage medium is provided, which is characterized in that described Computer-readable recording medium storage has computer instruction, and it is above-mentioned applied to server that the computer instruction is performed realization The clock synchronizing method at end.
The technical solution that embodiments herein provides can include the following benefits:
The clock synchronizing method receives server transmission by by user end to server tranmitting data register synchronization request Response data, and respectively record client tranmitting data register synchronization request when the first moment, server receive clock synchronization request When the third moment, server send response data when the 4th moment, client receive response data when the second moment, root Round-trip network delay when clock synchronization request transmission available according to the first moment to the 4th moment, and client is obtained accordingly With the clock jitter of server-side, the time of client is then adjusted according to clock jitter, keeps it substantially same with the time of server Step.By this method the clock of client browser page is not influenced by misalignment or error system clock, it is only necessary to one Secondary adjustment can be such that the clock of client and server-side is consistent, and meet to the higher scene of clock required precision, simultaneously to the greatest extent The pressure caused by network bandwidth and server-side is possibly reduced, the wasting of resources of server-side is avoided.
The technical solution that another embodiment of the application provides can include the following benefits:
Using the round-trip network delay of half as backhaul network time delay, and by the 4th moment and the second moment when Between difference with the sum of backhaul network time delay be used as clock jitter, adjust the clock of client accordingly so that browser page clock with Server-side clock keeps the error of the worst half time for being a communication trip delay, and network delay is considered in clock In the range of deviation so that the clock of calculated client differs smaller with server clock, obtained synchronised clock can Reliability is higher.
The technical solution that another embodiment of the application provides can include the following benefits:
Repeatedly to server tranmitting data register synchronization request and reception response data, the round-trip network delay of multiple groups and clock are obtained The data of deviation select the highest clock jitter of confidence level using filtering model filter screen, avoid relying solely on single and adopt The method of sample makes clock jitter calculate inaccuracy.
It should be understood that above general description and following detailed description be only it is exemplary and explanatory, not The application can be limited.
Detailed description of the invention
The drawings herein are incorporated into the specification and forms part of this specification, and shows and meets implementation of the invention Example, and be used to explain the principle of the present invention together with specification.
Fig. 1 a is the flow chart of the clock synchronizing method shown according to an exemplary embodiment applied to client;
Fig. 1 b is the flow chart of the clock synchronizing method shown according to an exemplary embodiment applied to server end;
Fig. 2 be in clock synchronizing method shown according to an exemplary embodiment clock synchronization request issue after client and The temporal logic figure of server;
Fig. 3 is the corresponding time category of browser performance interface in clock synchronizing method shown according to an exemplary embodiment Property figure;
Fig. 4 is the flow chart of the clock synchronizing method shown according to an exemplary embodiment summarized;
Fig. 5 is the schematic diagram of screening and filtering clock jitter in clock synchronizing method shown according to an exemplary embodiment;
Fig. 6 is the schematic diagram of the clock synchronization apparatus shown according to an exemplary embodiment applied to client;
Fig. 7 is the schematic diagram of the clock synchronization apparatus shown according to an exemplary embodiment applied to server end;
Fig. 8 is the schematic diagram of the clock synchronization apparatus shown according to an exemplary embodiment summarized;
Fig. 9 is the schematic diagram of the clock synchronization apparatus summarized shown according to another exemplary embodiment;
Figure 10 is a kind of block diagram of electronic equipment for executing clock synchronizing method shown according to an exemplary embodiment;
Figure 11 is a kind of frame of clock synchronization apparatus for executing clock synchronizing method shown according to an exemplary embodiment Figure.
Specific embodiment
Example embodiments are described in detail here, and the example is illustrated in the accompanying drawings.Following description is related to When attached drawing, unless otherwise indicated, the same numbers in different drawings indicate the same or similar elements.Following exemplary embodiment Described in embodiment do not represent all embodiments consistent with the application.On the contrary, they be only with it is such as appended The example of the consistent device and method of some aspects be described in detail in claims, the application.
Fig. 1 a is the flow chart of the clock synchronizing method shown according to an exemplary embodiment applied to client, specifically Include the following steps.
In step s101, the first moment to server tranmitting data register synchronization request and when recording transmission.
To timeliness have height requirement scene in, client (browser page) need and server between when Between keep error as small as possible, to provide timeliness information as synchronous as possible to all users.At this time, it is necessary to client The time that server is obtained by network request achievees the purpose that clock is synchronous, and the synchronous final purpose of clock is so that The variation for showing content and capableing of the service condition of timely response service device of browser page.
The embodiment of the present invention provides a kind of clock synchronizing method, so that when the available synchronization to server of client Clock, and the clock jitter between client and server is obtained, so as to adjust the clock of client.Due to got the two it Between clock jitter as long as obtaining the system clock of client at this time, carry out clock skew compensation then at any time, The clock that can be obtained by server is not needed to obtain synchronised clock to server at any time, be economized on resources, and clock is simultaneously and rapidly Efficiently.
So firstly the need of user end to server tranmitting data register synchronization request, and record first of client when transmission Moment, the present invention implement to indicate using moment t0.After client tranmitting data register synchronization request, needs to receive server feedback and return The clock response come, i.e. next step.
In step s 102, the response data that server is sent and the second moment when recording reception, response data are received The 4th moment when third moment and the server transmission response data of clock synchronization request is received including server.
Client can receive the feedback response from server to after server tranmitting data register synchronization request, so Client needs to receive the response data of server transmission, and records the second moment of client when receiving response data, this Inventive embodiments are indicated with moment t3.Then user end to server initiation asks clock to synchronize at the time of asking as t0, obtains secondary service It is t3 at the time of the response data of device, the two values are all the system times of client corresponding device, then, t3 > t0.
As shown in Fig. 2, Fig. 2 is that clock synchronization request issues in clock synchronizing method shown according to an exemplary embodiment The temporal logic figure of client and server afterwards.The sequential relationship of t3 and t0 such as Fig. 2, it is recognised that receiving response data Second moment was centainly greater than the first moment t0 when client tranmitting data register synchronization request, if not considering network delay, t0-t3 It is then the transmission time of clock synchronization request.
The only time of client, also it is not enough to obtain the synchronised clock of server, so also needing to obtain server Clock, and server can feed back to the clock information of server, will take after the clock synchronization request for receiving client transmission It as the third moment at the time of business device receives clock synchronization request, is indicated with t1, server sends response data to client When at the time of as the 4th moment, indicated with t2, so including third moment and the 4th moment, i.e. number of responses in response data According to the clock information returned including server to client feedback.
Referring again to Fig. 2, t2 > t1, i.e. the sending instant of response data is later than at the time of receive clock synchronization request, clothes Business device needs to provide accurately clock information to client, but server can not determine when tranmitting data register information, and clock is same Step request can be used as the opening point of server tranmitting data register information, and when received after clock synchronization request, server is i.e. to visitor Family end tranmitting data register information.
If without the influence of the other factors such as network delay, the 4th moment t2 that server feedback is returned should be just Second moment t3 of client after client receives this clock information, is adjusted to t2, but practical by the clock of server In, due to the influence of network delay, when client receives the clock information of server transmission, when having already been through certain Between, so the clock jitter for needing to obtain between client and server also needs to consider network delay, such as step S103.
In step s 103, the clock jitter of client and server is obtained according to the first moment to the 4th moment.
Client tranmitting data register synchronization request simultaneously receives response data, network transmission is depended on, so based on Ethernet It is not expected network transfer delay that clock, which synchronizes the maximum problem faced, and network delay is included in and is considered by this step, weighing apparatus The confidence level of the time for the server that amount is obtained by network request.
Due to the misalignment of clock, the size relation being uncertain about between t1, t2 and t0, t3, but due to network transmission when Prolong effect, centainly have: t3-t0 > t2-t1, i.e. client from tranmitting data register synchronization request to receive response data need when Between centainly more than server from receive clock synchronization request to send response data time.
So, the difference in the two sections is round-trip network delay, and round-trip network delay is set as θ, then is had: θ= (t3-t0)-(t2-t1), this is back and forth the network delay of round trip, it should be noted that at bottom-layer network software and hardware Reason data will also consume certain time, therefore θ and non-fully be caused by data packet in transmission over networks, but for clock jitter Influence is identical, so handling according to network delay.
In one embodiment, include according to the first moment to the clock jitter that the 4th moment obtained client and server Three steps:
The first step obtains opening from client tranmitting data register synchronization request according to the incidence relation at the first moment to the 4th moment Begin to round-trip network delay caused by response data is received, the calculating of round-trip network delay has been noted above in above-mentioned steps Process, i.e. θ=(t3-t0)-(t2-t1).It is that client is since tranmitting data register synchronization request to receiving with verbal description Since the first time (t3-t0) and server that response data expends consumed receiving clock synchronization request to transmission response data The difference for the second time (t2-t1) taken is round-trip network delay.
Second step obtains according to round-trip network delay and receives response to client since server sends response data Backhaul network time delay caused by data.Round-trip network delay includes since client tranmitting data register synchronization request to server It receives generated backhaul network delay when clock synchronization request and is terminated since server sends response data to client Receive backhaul network time delay caused by response data, when sending response data according to backhaul network time delay and server the 4th when It carves and clock jitter can be generated with the second moment when client reception response data.
Third step, according to backhaul network time delay, the 4th moment and client when sending response data in conjunction with server are terminated The second moment when receiving response data generates clock jitter.If the not influence of network delay, server sends response data When the 4th moment and client receive response data when the second moment time difference be client and server clock Deviation, but after considering the influence of network delay, the sum of time difference at the 4th moment and the second moment and backhaul network time delay be just Clock jitter.
It fetches the half that journey network delay is round-trip network delay, clock jitter is set as δ, then:
It can not accurately be learnt since θ is specifically distributed in the ratio of " next " and " returning ", i.e. backhaul network delay and backhaul network The ratio that time delay accounts for round-trip network delay can not accurately be learnt, it is assumed that distributing for 1:1, then be disappeared from the t2 moment to the t3 moment The time of the network delay of consumption is θ/2.When the clock in client is at the t3 moment, server clock has been gone at this time:
But the system time t3 in client, it is clear that the difference between them is client clock deviation δ, is then had:
θ is substituted into, is had:
That is:
Thus the clock jitter δ of client and server is just obtained according to the first moment to the 4th moment.
The calculating process of above-mentioned clock jitter is the premise in the round-trip network delay that backhaul network time delay is half Lower progress, in practice, the network delay of round-trip two transmission processes has a little difference, this difference will be synchronous to clock Bring certain error.So then having if the ratio that backhaul network time delay occupies round-trip network delay θ is k:
δ '=t2+k* θ-t3
θ is substituted into, is had:
δ '=t2-t3+k* (t3-t0)-k* (t2-t1)
Clock jitter can be understood as linear function, since the value interval of k is (0,1), and θ > 0, then known to δ ' value Domain is (t1-t0, t2-t3), siding-to-siding block length θ.
The value of k is different, then δ ' value is different, and when k takes 0.5, δ ' is codomain median, the clock jitter obtained at this time Error it is minimum, the clock after then correcting is up to the error of θ/2 (i.e. half δ ' codomain siding-to-siding block length), that is, round-trip net The half of network time delay.And when k takes other values, obtained error is likely larger than the half of round-trip network delay, so still taking Backhaul network time delay is that the half of round-trip network delay is calculated, and in the calculating of all clock jitters later, will be returned Journey network delay takes the half of round-trip network delay, so calculated clock jitter worst error is only round-trip in this way The half of network delay.Obvious θ is smaller, then correcting action δ is smaller, and vice versa.
In step S104, the system clock of client is obtained, obtains the synchronised clock of server in conjunction with clock jitter.
In previous step, it is already possible to obtain the clock jitter δ between client and server, δ is based on, when obtaining any The system clock of the client at quarter, can be obtained the synchronised clock of server at this time, so getting every time in client and being Unite clock after, is added with δ i.e. be believed that and server-side clock be near-synchronous, due to available server synchronization when Clock, and do not need to initiate network request to server every time, the resource of server has been saved, the pressure of server is mitigated.And And the error very little for the clock jitter being calculated, can almost ignore, thus obtained result as synchronised clock, as a result compared with It is accurate.
It is to be appreciated that the embodiment of the present invention is item when the system clock satisfaction based on client and server synchronizes away Part, once that is, both ends clock is synchronous, even without subsequent synchronisation, their walking time error is also within the scope of insignificant. Thus, it is only required to determine a clock jitter, in subsequent Clock Synchronization Procedure, calculated clock jitter is directly taken As a result, the synchronised clock of server can be obtained, it is convenient and efficient.
Using the round-trip network delay of half as backhaul network time delay, and by the 4th moment and the second moment when Between difference with the sum of backhaul network time delay be used as clock jitter, adjust the clock of client accordingly so that browser page clock with Server-side clock keeps the error of the worst half time for being a communication trip delay, and network delay is considered in clock In the range of deviation so that the clock of calculated client differs smaller with server clock, obtained synchronised clock can Reliability is higher.
According to the description of above-mentioned several steps, then the acquisition at above-mentioned first moment to the 4th moment just becomes to Guan Chong It wants.In one embodiment, the first moment when clock synchronization request is sent and client are obtained using browser performance interface End receives the second moment when response data.In order to reduce upper language API (Application Programming to the greatest extent Interface, application programming interfaces) to influence of the time to θ spent by the conversions of data, processing, need more accurately net Network transmission time metric.In the present embodiment, network request mistake is obtained using browser performance interface performance API The timing node in each stage in journey, as shown in figure 3, Fig. 3 is in clock synchronizing method shown according to an exemplary embodiment The corresponding time attribute figure of browser performance interface.
For Performance API for precisive, control, the performance for enhancing browser, this API is measurement net It stands performance, higher precision is provided.The timing attribute of performance object is directed toward an object, it contain it is various with The related time data of browser performance provide the time-consuming in browser processing webpage each stage.For example, performance.t Iming.navigationStart is exactly the starting time of browser processing current web page.It is shown in Fig. 3 The most of attribute for including in performance.timing object.
For example, navigation Start is indicated: the previous webpage of current browser window is closed, and unload thing occurs Unix millisecond timestamp when part.If being equal to fetchStart attribute without previous webpage.
Unload Event Start is indicated: if previous webpage and current web page belong to the same domain name, being returned Unix millisecond timestamp when the unload event of previous webpage occurs.If the net without previous webpage, or before It is not in the same domain name that page, which jumps, then return value is 0.
... (other attributes are the common attribute of those skilled in the art, are not repeated one by one)
Request Start is indicated: when return browser issues HTTP request to server (or start to read local cache When) Unix millisecond timestamp.
Response Start is indicated: being returned to browser from server and is received (or reading from local cache) first character section When Unix millisecond timestamp.
Response End is indicated: being returned to browser from server and is received (or reading from local cache) the last byte When (if HTTP connection before this has been switched off, when returning to closing) Unix millisecond timestamp.
So the node that request Start is indicated can be used as user end to server tranmitting data register synchronization request Node, the i.e. node indicate the first moment t0, and the node that response End is indicated can be used as client and receive service The timing node for the response data that device is sent, i.e. the second moment t3.Therefore, we can by request Start and The two time points of response End calculate the accurate network request time, avoid the processes such as DNS query, data processing Influence to sampled data effectively reduces the worst error value of δ.
Above-mentioned steps are only to obtain the time of client, in concrete implementation, are needed the acquisition of performance Data and the time map of server end are got up, and can be just integrated into this way with a batch of (t0, t1, t2, t3) data.Therefore, Obtained using browser performance interface clock synchronization request send when the first moment and client receive response data when Second moment also included three steps:
The first step is that unique identification is arranged in the uniform resource locator of clock synchronization request.In the clock that client is sent Unique id value is added in the URL (Uniform Resource Locator, uniform resource locator) of synchronization request, URL is again It is called web page address, is the address (Address) of the resource of standard on internet.Each file on internet have one only One URL, the information that it includes point out how the position of file and browser should handle it.For the configuration of clock synchronization request Unique identification information can position quickly.
Second step, by response data the third moment and the 4th moment establish corresponding relationship with unique identification and store. Then the third moment t1, the 4th moment t2 that include in response data are associated with and are cached with the unique identification (i.e. id), Therefore third moment and the 4th moment also establish incidence relation with identification information, when can quickly navigate to third by id It carves and the 4th moment.
Third step, using browser performance interface position unique identification, when obtaining first when clock synchronization request is sent Carve the second moment when receiving response data with client.Have the request of the id parameter followed by performance inquiry, T0, t3 time point are obtained, thus completes the acquisition to the first moment to the 4th moment, and it is higher to obtain result accuracy.Then The calculating for carrying out clock jitter, the clock for completing client are synchronous.
The clock synchronizing method of the present embodiment receives service by by user end to server tranmitting data register synchronization request Device send response data, and respectively record client tranmitting data register synchronization request when the first moment, server receive clock Third moment when synchronization request, server send the 4th moment when response data, and client receives the when response data Two moment, round-trip network delay when being transmitted according to the first moment to the 4th moment available clock synchronization request, and accordingly The clock jitter of client and server-side is obtained, the time of client is then adjusted according to clock jitter, makes itself and server Time is substantially synchronous.Make the clock of client browser page not by misalignment or the shadow of error system clock by this method It rings, it is only necessary to which primary adjustment can be such that the clock of client and server-side is consistent, and meet higher to clock required precision Scene, while the pressure caused by network bandwidth and server-side is reduced as much as possible, avoid the wasting of resources of server-side.
Fig. 1 b is the flow chart of the clock synchronizing method shown according to an exemplary embodiment applied to server end, tool Body includes the following steps.
In step s 201, the clock synchronization request that client is sent is received, and stores third moment when reception.
This step is the operation carried out in server end by server, and server is responsible for providing the clock synchronisation source of authority, Server receives the clock synchronization request of client, and returns to the system time at current server end.Since service logic needs Occupy considerable time loss, therefore server-side is often difficult to make a decision and which link to obtain system time as authority in and be supplied to Client.Clock synchronization request can be used as the node that server sends the server system time, so needing to record server The time of clock synchronization request is received, server-side records two time points, and t1 is the moment for receiving clock synchronization request, i.e., Third moment, t2 are the moment for sending back to response data, i.e. the 4th moment.
In step S202, response data is sent to client, response data includes that third moment and server send and ring Answer the 4th moment when data.
The third moment of record and the 4th moment are sent to client by server, using response data as carrier, by two A temporal information is sent to client, so, response data includes third moment and the 4th moment.And for third moment and Then centainly there were t2 >=t1 at four moment, and a part of data in response is incidentally sent back to client by the two time points.The The clock reference that three moment and the 4th moment provide as server to client, so that client is according to third moment and the 4th Moment, the first moment when in conjunction with client tranmitting data register synchronization request and the second moment when reception response data, obtain visitor The clock jitter at family end and server end, the sum of system clock and clock jitter of client are the synchronised clock of server.
In one embodiment, response data further includes communication data.In actual Web service, it is contemplated that independently ask The sky high cost asked tends not to simultaneously provide separated links for clock, but relies on general service communication incidentally to carry out Clock is synchronous, so response data not only includes temporal information, further includes communication data, the two is transmitted back to client together, Then it is synchronous to carry out clock, saves the resource of server, also can be convenient and quickly obtain synchronised clock.
For example, user end to server sends a service request, while tranmitting data register is synchronous when carrying out service communication Request, server end return response data after having executed service logic, to client feedback, and response data both includes service logic The communication data of generation also includes clock data.
Fig. 4 is the flow chart of the clock synchronizing method shown according to an exemplary embodiment summarized, mainly includes following Step.
The first moment in step S401, when to server tranmitting data register synchronization request and recording transmission;
In step S402, the clock synchronization request that client is sent is received, and store third moment when reception;
In step S403, response data is sent to client, response data includes that third moment and server send and ring Answer the 4th moment when data;
In step s 404, the response data that server is sent and the second moment when recording reception, response data are received The 4th moment when third moment and the server transmission response data of clock synchronization request is received including server;
In step S405, the clock jitter of client and server is obtained according to the first moment to the 4th moment;
In step S406, repeatedly to server tranmitting data register synchronization request and reception response data, it is round-trip to obtain multiple groups The data of network delay and clock jitter select the highest clock jitter of confidence level using filtering model filter screen;
In step S 407, the system clock for obtaining client obtains the synchronised clock of server in conjunction with clock jitter.
The present embodiment is the prioritization scheme of Fig. 1 a and Fig. 1 b, step S401 and S404-S405 and step S407 with figure The step S101-S104 of 1a is identical, is the operation carried out in client, and the step S201- of step S402-S403 and Fig. 1 b S202 is identical, and for the operation carried out in server end, which is not described herein again.Step S406 is another behaviour carried out in client Make.
Clock jitter is calculated by primary network communication, so that the clock of server-side is obtained, it may be due to round-trip network The variation of time delay, so that obtained server-side clock valuation is insincere.Therefore, rely solely on unitary sampling method be easy to by Influence to accidentally uncertain factors such as network jitters chooses suitable clock jitter, such as so needing to carry out multiple repairing weld Shown in step S406.
In step S406, repeatedly to server tranmitting data register synchronization request and reception response data, it is round-trip to obtain multiple groups The data of network delay and clock jitter select the highest clock jitter of confidence level using filtering model filter screen.
The above embodiments summarize, and client carries out the transmission of clock synchronization request by primary network communication, thus At the time of obtaining several important, so that the clock jitter of client and server is calculated, so that the synchronised clock of server-side is obtained, And the error range of synchronised clock adopted this method is obtained.But if round-trip network delay is longer, error Range also increases bigger therewith, and obtained server-side clock valuation is also more insincere.Therefore, the method for unitary sampling is relied solely on It is easy to be influenced by the accidentally uncertain factor such as network jitter.So needing repeatedly to be adopted in the case where permission Sample, from obtained multi-group data, rejecting abnormalities data screen optimal clock jitter, and obtained clock will be more credible.
So client repeatedly sends multiple clock synchronization request to server in different time and receives server hair The response data sent obtains the data at multiple first moment to the 4th moment to get inclined to the round-trip network delay of multiple groups and clock The data of difference, each group of data can be arranged into table.Then filtering model filtering screening from multiple data groups is used A highest clock jitter of confidence level is as final clock jitter out.
In one embodiment, it from the data of the round-trip network delay of multiple groups and clock jitter, is filtered using filtering model Filter out the highest clock jitter of confidence level the following steps are included:
The first step acquires the corresponding multi-group data of multiple clock synchronization request, therefrom rejects round-trip network delay greater than net The data of network delay threshold.Repeatedly to server tranmitting data register synchronization request, most N group data are collected by phased manner, often Group data all include round-trip network delay θ and clock jitter δ, due to the worst error that θ/2 are final synchronised clock, θ With regard to having reacted the confidence level of data.Pre-defined θttRound-trip network delay is more than network delay by as network delay threshold value The data group of threshold value is rejected, that is, rejects all θ greater than θtData, these data are since network delay is too big, so reference price Value is little.
If the data group after rejecting is less than N, continuous collecting is M times most, so that sample number is not less than N, this step Purpose is to guarantee that there is enough data groups to be screened, and the data group screened has reference value Data group.If not being able to satisfy the requirement of sample size after M acquisition still, θ is gradually linearly improvedtValue, lay equal stress on Newly screened.
Second step arranges the corresponding clock jitter of all remaining clock synchronization requests, counts it and be overlapped section, will possess The corresponding data group in coincidence section of most data groups screens.The codomain section (burst error) of the δ of all samples is arranged, It calculates it and is overlapped section, as shown in figure 5, Fig. 5 is screening and filtering in clock synchronizing method shown according to an exemplary embodiment The schematic diagram of clock jitter, abscissa indicate the codomain range of clock jitter, and ordinate indicates round-trip network delay, by all numbers According to group arrangement into Fig. 5, region shown in dotted line is the coincidence section for possessing most data groups in figure, it is considered to be is most connect The interval range of nearly real clock, corresponding data group is considered to have higher reliability, therefore can reject other numbers According to group.
Third step takes the clock jitter in remaining data group in round-trip that the smallest group data of network delay as credible Spend highest clock jitter.That the smallest group of θ in remaining sample is taken, because θ is smaller, the error of obtained clock jitter is got over Small, δ can regard as best offset value, thus select the final clock jitter of client and server, same in clock later In step, it is only necessary to call directly this clock jitter and be adjusted.
In the present embodiment, clock synchronizing method passes through repeatedly to server tranmitting data register synchronization request and reception number of responses According to the data of acquisition multiple groups round-trip network delay and clock jitter select a confidence level highest using filtering model filter screen Clock jitter, avoid the method for relying solely on unitary sampling make clock jitter calculate inaccuracy.
Fig. 6 is the schematic diagram of the clock synchronization apparatus shown according to an exemplary embodiment applied to client, this when Clock synchronizing device 600 includes that request sending module 601, the first receiving module 602, clock jitter generation module 603 and clock are same Walk module 604.
Request sending module 601 is for the first moment to server tranmitting data register synchronization request and when recording transmission;
It at the second moment when first receiving module 602 is used to receive the response data of server transmission and records reception, rings Answer data include server receive clock synchronization request the third moment and server send response data when the 4th moment;
Clock jitter generation module 603 is used to obtain the clock of client and server according to the first moment to the 4th moment Deviation;And
Clock synchronization module 604 is used to obtain the system clock of client, obtains the synchronization of server in conjunction with clock jitter Clock.
The clock synchronization apparatus of the present embodiment receives service by by user end to server tranmitting data register synchronization request Device send response data, and respectively record client tranmitting data register synchronization request when the first moment, server receive clock Third moment when synchronization request, server send the 4th moment when response data, and client receives the when response data Two moment, round-trip network delay when being transmitted according to the first moment to the 4th moment available clock synchronization request, and accordingly The clock jitter of client and server-side is obtained, the time of client is then adjusted according to clock jitter, makes itself and server Time is substantially synchronous.Make the clock of client browser page not by misalignment or the shadow of error system clock by this method It rings, it is only necessary to which primary adjustment can be such that the clock of client and server-side is consistent, and meet higher to clock required precision Scene, while the pressure caused by network bandwidth and server-side is reduced as much as possible, avoid the wasting of resources of server-side.
In one embodiment, clock jitter generation module 603 includes: that the first time delay obtains module, the second time delay obtains Module and generation module.First time delay obtains module for obtaining according to the incidence relation at the first moment to the 4th moment from client End tranmitting data register synchronization request starts to client to receive round-trip network delay caused by response data;Second time delay obtains Module, which is used to be obtained according to round-trip network delay, receives response data institute to client since server sends response data The backhaul network time delay of generation;Generation module is used for according to backhaul network time delay, and the when sending response data in conjunction with server The second moment that four moment and client receive response data generates clock jitter.
Client since tranmitting data register synchronization request to receive response data consuming first time and server from Clock synchronization request is received to start to the difference for sending the second time that response data expends to be round-trip network delay.4th moment It is clock jitter with the sum of the time difference at the second moment and backhaul network time delay.Backhaul network time delay is the one of round-trip network delay Half.
In one embodiment, clock synchronization apparatus 600 further includes time-obtaining module (not shown), for using Browser performance interface come obtain clock synchronization request send when the first moment and client receive response data when second Moment.
Time-obtaining module includes: identify and arrange module, for the uniform resource locator setting for clock synchronization request Unique identification;Relationship establishes module, for by response data the third moment and the 4th moment it is corresponding with unique identification foundation Relationship simultaneously stores;Locating module, for using browser performance interface position unique identification, when obtaining the transmission of clock synchronization request The first moment and client receive response data when the second moment.
Fig. 7 is the schematic diagram of the clock synchronization apparatus shown according to an exemplary embodiment applied to server end, should Clock synchronization apparatus 700 includes the second receiving module 701 and response data sending module 702.
Second receiving module 701 is used to receive the clock synchronization request of client transmission, and when storing third when reception It carves;Response data sending module 702 is used to send response data to client, and response data includes third moment and server hair Send the 4th moment when response data, wherein the clock ginseng that third moment and the 4th moment provide as server to client Examine so that client is according to third moment and the 4th moment, the first moment when in conjunction with client tranmitting data register synchronization request and Receive the second moment when response data, obtain the clock jitter of client and server, the system clock of client and when The sum of clock deviation is the synchronised clock of server.It is in embodiment at one, response data further includes communication data.
Fig. 8 is the schematic diagram of the clock synchronization apparatus shown according to an exemplary embodiment summarized;
Fig. 8 is the optimization to the embodiment of Fig. 6 and Fig. 7, the clock synchronization apparatus 800 remove including request sending module 601, First receiving module 602, clock jitter generation module 603, clock synchronization module 604 and the second receiving module 701 and response Outside data transmission blocks 702 further include: filtering screening module 801.
Filtering screening module 801 is for repeatedly to server tranmitting data register synchronization request and reception response data, obtaining more The data of group round-trip network delay and clock jitter, select the highest clock of a confidence level using filtering model filter screen Deviation.
Optionally, filtering screening module 801 includes: data acquisition module, statistics screening module and selection module.Data are adopted Collection module therefrom rejects round-trip network delay greater than network delay for acquiring the corresponding multi-group data of multiple clock synchronization request The data of threshold value;It is heavy to count its for arranging the corresponding clock jitter of all remaining clock synchronization requests for statistics screening module Section is closed, the corresponding data group in coincidence section for possessing most data groups is screened;Module is chosen for taking remaining data Clock jitter in group in round-trip that the smallest group data of network delay is as the highest clock jitter of confidence level.
In the present embodiment, clock synchronization apparatus repeatedly to server tranmitting data register synchronization request and receives response data, obtains The data for obtaining multiple groups round-trip network delay and clock jitter, select the highest clock of confidence level using filtering model filter screen Deviation avoids the method for relying solely on unitary sampling that clock jitter is made to calculate inaccuracy.
About the clock synchronization apparatus in above-described embodiment, since the function of wherein modules is same in above-mentioned clock It is described in detail in the embodiment of one step process, has thus carried out relatively simple description.
Fig. 9 is the schematic diagram of the clock synchronization apparatus summarized shown according to another exemplary embodiment, the present embodiment Clock synchronization apparatus 900 includes client 910 and server-side 920.Wherein, client 910 includes clock synchronous acquisition module 911 Selecting module 912 is filtered with offset;Server-side 920 includes time service service module 921.
Clock synchronous acquisition module 911 is used for server tranmitting data register synchronization request, and receives response data, specifically Ground, clock synchronous acquisition module 911 include request sending module 9111, the first receiving module 9112 and clock synchronization module 9113, time service service module 921 includes the second receiving module 9211 and response data sending module 9212, request sending module 9111 to server tranmitting data register synchronization request, and the second receiving module 9211 receives clock synchronization request, and response data sends mould Block 9212 sends response data to client, and the first receiving module 9112 receives response data, and when four moment are transmitted to Clock synchronization module 9113 carries out the calculating of clock jitter, so that it is synchronous to carry out clock.
In one embodiment, response data sending module 9212 sends response data, and offset filtering selecting module 912 connects Multi-group data is received, and is screened out from it most suitable one group, carries out the calculating of clock jitter.
Clock synchronization apparatus in this present embodiment is closed, wherein the function of modules is in above-mentioned clock synchronizing method Embodiment in be described in detail, thus carried out relatively simple description.
Figure 10 is a kind of electronic equipment 1000 for above-mentioned clock synchronizing method shown according to an exemplary embodiment Block diagram.For example, electronic equipment 1000 can be mobile phone, computer, digital broadcasting terminal, messaging device, game Console, tablet device, Medical Devices, body-building equipment, personal digital assistant etc..
Referring to Fig.1 0, electronic equipment 1000 may include following one or more components: processing component 1002, memory 1004, electric power assembly 1006, multimedia component 1008, audio component 1010, the interface 1012 of input/output (I/O), sensor Component 1014 and communication component 1016.
The integrated operation of the usual controlling electronic devices 1000 of processing component 1002, such as with display, call, data are logical Letter, camera operation and record operate associated operation.Processing component 1002 may include one or more processors 1020 It executes instruction, to perform all or part of the steps of the methods described above.In addition, processing component 1002 may include one or more Module, convenient for the interaction between processing component 1002 and other assemblies.For example, processing component 1002 may include multimedia mould Block, to facilitate the interaction between multimedia component 1008 and processing component 1002.
Memory 1004 is configured as storing various types of data to support the operation in electronic equipment 1000.These numbers According to example include any application or method for being operated on electronic equipment 1000 instruction, contact data, electricity Talk about book data, message, picture, video etc..Memory 1004 can be by any kind of volatibility or non-volatile memory device Or their combination is realized, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), Erasable Programmable Read Only Memory EPROM (EPROM), programmable read only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, disk or CD.
Power supply module 1006 provides electric power for the various assemblies of electronic equipment 1000.Power supply module 1006 may include power supply Management system, one or more power supplys and other with for electronic equipment 1000 generate, manage, and distribute associated group of electric power Part.
Multimedia component 1008 includes the screen of one output interface of offer between the electronic equipment 1000 and user Curtain.In some embodiments, screen may include liquid crystal display (LCD) and touch panel (TP).If screen includes touching Panel, screen may be implemented as touch screen, to receive input signal from the user.Touch panel includes one or more touchings Sensor is touched to sense the gesture on touch, slide, and touch panel.The touch sensor can not only sense touch or cunning The boundary of movement, but also detect duration and pressure associated with the touch or slide operation.In some embodiments In, multimedia component 1008 includes a front camera and/or rear camera.When electronic equipment 1000 is in operation mould Formula, such as in a shooting mode or a video mode, front camera and/or rear camera can receive external multi-medium data. Each front camera and rear camera can be a fixed optical lens system or have focal length and optical zoom energy Power.
Audio component 1010 is configured as output and/or input audio signal.For example, audio component 1010 includes a wheat Gram wind (MIC), when electronic equipment 1000 is in operation mode, when such as call mode, recording mode, and voice recognition mode, Mike Wind is configured as receiving external audio signal.The received audio signal can be further stored in memory 1004 or via Communication component 1016 is sent.In some embodiments, audio component 1010 further includes a loudspeaker, for exporting audio letter Number.
I/O interface 1012 provides interface, above-mentioned peripheral interface module between processing component 1002 and peripheral interface module It can be keyboard, click wheel, button etc..These buttons may include, but are not limited to: home button, volume button, start button and Locking press button.
Sensor module 1014 includes one or more sensors, for providing the shape of various aspects for electronic equipment 1000 State assessment.For example, sensor module 1014 can detecte the state that opens/closes of electronic equipment 1000, component it is relatively fixed Position, such as the component are the display and keypad of device 1000, and sensor module 1014 can also detect electronic equipment 1000 or 1,000 1 components of electronic equipment position change, the existence or non-existence that user contacts with electronic equipment 1000, electricity The temperature change in sub- 1000 orientation of equipment or acceleration/deceleration and electronic equipment 1000.Sensor module 1014 may include approaching Sensor is configured to detect the presence of nearby objects without any physical contact.Sensor module 1014 may be used also To include optical sensor, such as CMOS or ccd image sensor, for being used in imaging applications.In some embodiments, the biography Sensor component 1014 can also include acceleration transducer, gyro sensor, Magnetic Sensor, pressure sensor or temperature sensing Device.
Communication component 1016 is configured to facilitate the logical of wired or wireless way between electronic equipment 1000 and other equipment Letter.Electronic equipment 1000 can access the wireless network based on communication standard, such as WiFi, carrier network (such as 2G, 3G, 4G or 5G) or their combination.In one exemplary embodiment, communication component 1016 is received via broadcast channel from external wide The broadcast singal or broadcast related information of broadcast management system.In one exemplary embodiment, the communication component 1016 also wraps Near-field communication (NFC) module is included, to promote short range communication.For example, it can be based on radio frequency identification (RFID) technology in NFC module, it is red Outer data association (IrDA) technology, ultra wide band (UWB) technology, bluetooth (BT) technology and other technologies are realized.
In the exemplary embodiment, electronic equipment 1000 can by one or more application specific integrated circuit (ASIC), Digital signal processor (DSP), digital signal processing appts (DSPD), programmable logic device (PLD), field-programmable gate array It arranges (FPGA), controller, microcontroller, microprocessor or other electronic components to realize, for executing above-mentioned clock synchronizing method.
In the exemplary embodiment, a kind of non-transitorycomputer readable storage medium including instruction, example are additionally provided It such as include the memory 1004 of instruction, above-metioned instruction can be executed by the processor 1220 of electronic equipment 1000 to complete above-mentioned side Method.For example, the non-transitorycomputer readable storage medium can be ROM, random access memory (RAM), CD-ROM, magnetic Band, floppy disk and optical data storage devices etc..
Figure 11 is a kind of clock synchronization apparatus for above-mentioned clock synchronizing method shown according to an exemplary embodiment 1100 block diagram.For example, device 1100 may be provided as a server.Referring to Fig.1 1, device 1100 includes processing component 1122, it further comprise one or more processors, and the memory resource as representated by memory 1132, for storing It can be by the instruction of the execution of processing component 1122, such as application program.The application program stored in memory 1132 may include It is one or more each correspond to one group of instruction module.In addition, processing component 1122 is configured as executing instruction, To execute above-mentioned clock synchronizing method.
Device 1100 can also include that a power supply module 1126 be configured as the power management of executive device 1100, and one Wired or wireless network interface 1150 is configured as device 1100 being connected to network and input and output (I/O) interface 1158.Device 1100 can be operated based on the operating system for being stored in memory 1132, such as Windows ServerTM, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM or similar.
Those skilled in the art after considering the specification and implementing the invention disclosed here, will readily occur to its of the application Its embodiment.This application is intended to cover any variations, uses, or adaptations of the application, these modifications, purposes or Person's adaptive change follows the general principle of the application and including the undocumented common knowledge in the art of the application Or conventional techniques.The description and examples are only to be considered as illustrative, and the true scope and spirit of the application are by following Claim is pointed out.
It should be understood that the application is not limited to the precise structure that has been described above and shown in the drawings, and And various modifications and changes may be made without departing from the scope thereof.Scope of the present application is only limited by the accompanying claims.

Claims (10)

1. a kind of clock synchronizing method, which is characterized in that the clock synchronizing method is applied to client, comprising:
The first moment when to server tranmitting data register synchronization request and recording transmission;
The response data that the server is sent and the second moment when recording reception are received, the response data includes server The third moment and the server for receiving the clock synchronization request send the 4th moment when response data;
The clock jitter of the client Yu the server is obtained according to first moment to the 4th moment;And
The system clock for obtaining the client obtains the synchronised clock of the server in conjunction with the clock jitter.
2. clock synchronizing method according to claim 1, which is characterized in that described according to first moment to described Four moment obtained the client and the clock jitter of the server includes:
It is obtained according to the incidence relation at first moment to the 4th moment synchronous from the client transmission clock Request starts to receiving round-trip network delay caused by the response data;
It is obtained according to the round-trip network delay and is received since the server sends the response data to the client To backhaul network time delay caused by the response data;
The 4th moment and the client according to the backhaul network time delay, when sending the response data in conjunction with the server The second moment that end receives the response data generates the clock jitter;
Preferably, since the client sending the clock synchronization request to receive that the response data expends first Since the time with the server to the second time for sending the response data consuming receiving the clock synchronization request Difference be the round-trip network delay;
Preferably, the sum of the time difference and the backhaul network time delay at the 4th moment and second moment are the clock Deviation;
Preferably, the backhaul network time delay is the half of the round-trip network delay;
Preferably, the first moment when the clock synchronization request is sent and the client are obtained using browser performance interface End receives the second moment when the response data;
Preferably, first moment and described obtained using browser performance interface when the clock synchronization request is sent The second moment when client receives the response data includes:
For the uniform resource locator of the clock synchronization request, unique identification is set;
By in the response data the third moment and the 4th moment establish corresponding relationship with the unique identification and store; And
Using unique identification described in browser performance interface position, obtain the first moment when the clock synchronization request is sent and The client receives the second moment when the response data;
Preferably, the clock synchronizing method, further includes:
The clock synchronization request repeatedly is sent to server and receives the response data, when obtaining round-trip network described in multiple groups Prolong the data with the clock jitter, the highest clock jitter of a confidence level is selected using filtering model filter screen;
Preferably, from the data of round-trip network delay and the clock jitter described in multiple groups, using filtering model filtering screening The highest clock jitter of a confidence level includes: out
The repeatedly corresponding multi-group data of the clock synchronization request is acquired, when therefrom rejecting the round-trip network delay greater than network Prolong the data of threshold value;
The corresponding clock jitter of all remaining clock synchronization requests is arranged, its is counted and is overlapped section, will possess most The corresponding data group in coincidence section of more data groups screens;
Take the clock jitter in round-trip that the smallest group data of network delay described in remaining data group as confidence level The highest clock jitter.
3. a kind of clock synchronizing method, which is characterized in that the clock synchronizing method is applied to server end, comprising:
The clock synchronization request that client is sent is received, and stores third moment when reception;
Response data is sent to the client, the response data includes that the third moment and server send the response The 4th moment when data,
Wherein, the clock reference that the third moment and the 4th moment provide as the server to client, so that The client is according to the third moment and the 4th moment, when sending the clock synchronization request in conjunction with the client The first moment and receive the response data when the second moment, obtain the clock jitter of client and server, it is described The sum of the system clock of client and the clock jitter are the synchronised clock of the server;
Preferably, the response data further includes communication data.
4. a kind of clock synchronization apparatus, the clock synchronization apparatus is applied to client characterized by comprising
Request sending module, for the first moment to server tranmitting data register synchronization request and when recording transmission;
First receiving module, it is the second moment when for receiving the response data of the server transmission and record reception, described Response data includes third moment and the server transmission number of responses that server receives the clock synchronization request According to when the 4th moment;
Clock jitter generation module, for obtaining the client and the clothes according to first moment to the 4th moment The clock jitter of business device;And
Clock synchronization module obtains the server in conjunction with the clock jitter for obtaining the system clock of the client Synchronised clock.
5. clock synchronization apparatus according to claim 4, which is characterized in that the clock jitter generation module includes:
First time delay obtains module, obtains for the incidence relation according to first moment to the 4th moment from the visitor Family end sends the clock synchronization request and starts to receiving round-trip network delay caused by the response data;
Second time delay obtains module, sends the response data for obtaining according to the round-trip network delay from the server Start to receive backhaul network time delay caused by the response data to the client;
Generation module, for sending the 4th when the response data in conjunction with the server according to the backhaul network time delay The second moment that moment and the client receive the response data generates the clock jitter;
Preferably, since the client sending the clock synchronization request to receive that the response data expends first Since the time with the server to the second time for sending the response data consuming receiving the clock synchronization request Difference be the round-trip network delay;
Preferably, the sum of the time difference and the backhaul network time delay at the 4th moment and second moment are the clock Deviation;
Preferably, the backhaul network time delay is the half of the round-trip network delay;
Preferably, the clock synchronization apparatus further includes time-obtaining module, for being obtained using browser performance interface The first moment and the client when clock synchronization request being taken to send receive the second moment when the response data;
Preferably, the time-obtaining module includes:
Identify and arrange module, for unique identification to be arranged for the uniform resource locator of the clock synchronization request;
Relationship establishes module, for by the response data the third moment and the 4th moment build with the unique identification Vertical corresponding relationship simultaneously stores;And
Locating module, for obtaining the clock synchronization request and sending using unique identification described in browser performance interface position When the second moment when receiving the response data of the first moment and the client;
Preferably, the clock synchronization apparatus, further includes:
Filtering screening module is obtained for repeatedly sending the clock synchronization request to server and receiving the response data The data of round-trip network delay and the clock jitter described in multiple groups, select a confidence level highest using filtering model filter screen The clock jitter;
Preferably, the filtering screening module includes:
Data acquisition module is therefrom rejected described round-trip for acquiring the repeatedly corresponding multi-group data of the clock synchronization request Network delay is greater than the data of network delay threshold value;
Screening module is counted, for arranging the corresponding clock jitter of all remaining clock synchronization requests, counts it It is overlapped section, the corresponding data group in coincidence section for possessing most data groups is screened;
Module is chosen, for taking the clock in round-trip that the smallest group data of network delay described in remaining data group inclined Difference is used as the highest clock jitter of confidence level.
6. a kind of clock synchronization apparatus, the clock synchronization apparatus is applied to server end characterized by comprising
Second receiving module for receiving the clock synchronization request of client transmission, and stores third moment when reception;
Response data sending module, for sending response data to the client, when the response data includes the third Carve the 4th moment when sending the response data with server, wherein the third moment and the 4th moment are as institute The clock reference that server is provided to client is stated, so that the client is according to the third moment and the 4th moment, The first moment when sending the clock synchronization request in conjunction with the client and the second moment when receiving the response data, The clock jitter of client and server is obtained, the sum of the system clock of the client and the clock jitter are the clothes The synchronised clock of business device;
Preferably, the response data further includes communication data.
7. a kind of electronic equipment characterized by comprising
Processor;
Memory for storage processor executable instruction;
Wherein, the processor is configured to executing clock synchronizing method described in the claims 1-2 any one.
8. a kind of computer readable storage medium, which is characterized in that the computer-readable recording medium storage has computer to refer to It enables, the computer instruction is performed realization such as the described in any item clock synchronizing methods of claim 1 to 2.
9. a kind of electronic equipment characterized by comprising
Processor;
Memory for storage processor executable instruction;
Wherein, the processor is configured to executing clock synchronizing method described in the claims 3.
10. a kind of computer readable storage medium, which is characterized in that the computer-readable recording medium storage has computer to refer to It enables, the computer instruction, which is performed, realizes clock synchronizing method as claimed in claim 3.
CN201910355439.9A 2019-04-29 2019-04-29 Clock synchronization method, clock synchronization apparatus, and computer-readable storage medium Active CN110266420B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910355439.9A CN110266420B (en) 2019-04-29 2019-04-29 Clock synchronization method, clock synchronization apparatus, and computer-readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910355439.9A CN110266420B (en) 2019-04-29 2019-04-29 Clock synchronization method, clock synchronization apparatus, and computer-readable storage medium

Publications (2)

Publication Number Publication Date
CN110266420A true CN110266420A (en) 2019-09-20
CN110266420B CN110266420B (en) 2021-02-12

Family

ID=67914114

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910355439.9A Active CN110266420B (en) 2019-04-29 2019-04-29 Clock synchronization method, clock synchronization apparatus, and computer-readable storage medium

Country Status (1)

Country Link
CN (1) CN110266420B (en)

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111107169A (en) * 2020-02-10 2020-05-05 中国人民解放军32021部队 Time management method based on WEB browser
CN111679714A (en) * 2019-12-31 2020-09-18 泰斗微电子科技有限公司 Cross-chip signal synchronization method and device and chip
CN111786741A (en) * 2020-07-20 2020-10-16 哈尔滨海能达科技有限公司 Clock synchronization method and related device for CPRI transmission data
CN111953443A (en) * 2020-09-17 2020-11-17 苏州科达科技股份有限公司 Resource processing method, device, electronic equipment, storage medium and system
CN112130616A (en) * 2020-09-28 2020-12-25 北京小米松果电子有限公司 Clock synchronization method, device and storage medium
CN112817371A (en) * 2021-03-02 2021-05-18 北京深思数盾科技股份有限公司 Time calculation method of virtual clock and electronic equipment
WO2022048075A1 (en) * 2020-09-03 2022-03-10 广州视源电子科技股份有限公司 Clock synchronization method and apparatus, and storage medium
CN114258126A (en) * 2020-09-25 2022-03-29 上海华为技术有限公司 Data processing method and device

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101227246A (en) * 2008-01-28 2008-07-23 中兴通讯股份有限公司 Method and apparatus for master-salve clock synchronization
CN104468014A (en) * 2014-12-12 2015-03-25 成都天奥电子股份有限公司 Method for improving time synchronization precision under complex network environment
CN105099649A (en) * 2015-08-14 2015-11-25 宋亚玲 Method and system for synchronously inserting network time
CN105680969A (en) * 2015-12-31 2016-06-15 浙江中控技术股份有限公司 Clock synchronization method and device
US9602366B1 (en) * 2010-03-03 2017-03-21 Netscout Systems, Inc. System and method for correcting clock discrepancy in simultaneous network traffic captures
CN106973075A (en) * 2016-01-14 2017-07-21 广州市动景计算机科技有限公司 Share comment method and system, domain name code-transferring method, client and server
CN108737853A (en) * 2017-04-20 2018-11-02 腾讯科技(深圳)有限公司 A kind of the drop code processing method and server of data file

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101227246A (en) * 2008-01-28 2008-07-23 中兴通讯股份有限公司 Method and apparatus for master-salve clock synchronization
US9602366B1 (en) * 2010-03-03 2017-03-21 Netscout Systems, Inc. System and method for correcting clock discrepancy in simultaneous network traffic captures
CN104468014A (en) * 2014-12-12 2015-03-25 成都天奥电子股份有限公司 Method for improving time synchronization precision under complex network environment
CN105099649A (en) * 2015-08-14 2015-11-25 宋亚玲 Method and system for synchronously inserting network time
CN105680969A (en) * 2015-12-31 2016-06-15 浙江中控技术股份有限公司 Clock synchronization method and device
CN106973075A (en) * 2016-01-14 2017-07-21 广州市动景计算机科技有限公司 Share comment method and system, domain name code-transferring method, client and server
CN108737853A (en) * 2017-04-20 2018-11-02 腾讯科技(深圳)有限公司 A kind of the drop code processing method and server of data file

Cited By (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111679714A (en) * 2019-12-31 2020-09-18 泰斗微电子科技有限公司 Cross-chip signal synchronization method and device and chip
CN111107169A (en) * 2020-02-10 2020-05-05 中国人民解放军32021部队 Time management method based on WEB browser
CN111107169B (en) * 2020-02-10 2020-10-02 中国人民解放军32021部队 Time management method based on WEB browser
CN111786741A (en) * 2020-07-20 2020-10-16 哈尔滨海能达科技有限公司 Clock synchronization method and related device for CPRI transmission data
WO2022048075A1 (en) * 2020-09-03 2022-03-10 广州视源电子科技股份有限公司 Clock synchronization method and apparatus, and storage medium
CN111953443A (en) * 2020-09-17 2020-11-17 苏州科达科技股份有限公司 Resource processing method, device, electronic equipment, storage medium and system
CN114258126A (en) * 2020-09-25 2022-03-29 上海华为技术有限公司 Data processing method and device
WO2022063078A1 (en) * 2020-09-25 2022-03-31 华为技术有限公司 Data processing method and apparatus
CN112130616A (en) * 2020-09-28 2020-12-25 北京小米松果电子有限公司 Clock synchronization method, device and storage medium
CN112817371A (en) * 2021-03-02 2021-05-18 北京深思数盾科技股份有限公司 Time calculation method of virtual clock and electronic equipment

Also Published As

Publication number Publication date
CN110266420B (en) 2021-02-12

Similar Documents

Publication Publication Date Title
CN110266420A (en) Clock synchronizing method, clock synchronization apparatus and computer readable storage medium
US20200314382A1 (en) Video frame interpolation method, storage medium and terminal
CN107682715B (en) Video synchronization method and device
US20180336265A1 (en) A recommendation method and device, a device for formulating recommendations
CN107431860A (en) Audio system based on location-based service
CN103402190A (en) Method and device for selecting network as well as terminal
CN106776826A (en) A kind of update method, the apparatus and system of wrist-watch background picture
CN106250430A (en) The sort method of smart machine list and device
CN112130616B (en) Clock synchronization method, device and storage medium
CN109565648A (en) Method for transmitting synchronizing signal and device
CN113810761B (en) Multi-terminal interaction method, device and system
CN109104900A (en) Transmission method, device and the computer readable storage medium of system information
WO2022156721A1 (en) Photographing method and electronic device
CN110223500A (en) Infrared equipment control method and device
CN108205455B (en) Application function implementation method and device and terminal
CN109314845A (en) Car networking synchronous method and device
CN108966339A (en) Base station clock synchronization method, device, equipment and computer readable storage medium
WO2020038157A1 (en) Nan-based intelligent management method and related product
CN203151681U (en) Detection system for remote media playing signal time delay
CN115956239A (en) Time synchronization method and related equipment
CN110310715A (en) Data lead-in method, device, terminal and storage medium
CN110166797A (en) Video transcoding method, device, electronic equipment and storage medium
WO2023134653A1 (en) Communication network prediction method, and terminal and network-side device
US20240064561A1 (en) Apparatus and method for sending and receiving buffer data information
CN116030846B (en) Timing jump synchronization method and electronic equipment

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