Summary of the invention
The technical problem that the embodiment of the invention will solve provides a kind of method, client and system that adjusts clock frequency.
For solving the problems of the technologies described above, the purpose of the embodiment of the invention is achieved through the following technical solutions:
Arrive the dummy clock pulse that frequency and amplitude range are filtered the message recovery that receives by the message that presets; According to the client reception server periodically send travel to and fro between client and server network time delay value half form network transfer delay waveform;
Arrive frequency and amplitude range, the shake of screen propagation delay time waveform by the message that presets; Judgement preset time at interval in, dummy clock and local recovery clock whether differ accumulated value above the limit value that presets, then be left intact if not; If then judge in this preset time interval, whether to exist and surpass the network transfer delay waveform shake that the described message that presets arrives frequency and amplitude range, it is consistent with the dummy clock frequency then to adjust the local recovery clock frequency if not, if then the accumulated value that differs of dummy clock and local recovery clock is reduced;
Perhaps
Arrive the dummy clock pulse that frequency and amplitude range are filtered the message recovery that receives by the message that presets; Obtain the network transfer delay waveform;
Judgement preset time at interval in, dummy clock and local recovery clock whether differ accumulated value above the limit value that presets, then be left intact if not; If then arrive frequency and amplitude range, the shake of screen propagation delay time waveform by the message that presets; Whether judgement exists in this preset time interval surpasses the network transfer delay waveform shake that the described message that presets arrives frequency and amplitude range, it is consistent with the dummy clock frequency then to adjust the local recovery clock frequency if not, if then the accumulated value that differs of dummy clock and local recovery clock is reduced.
Preferably, described method by the pulse of message recovery dummy clock is: the time interval of receiving two messages is set to high level, and the duration that message arrives is set to low level; The time interval of maybe receiving two messages is set to low level, and the duration that message arrives is set to high level.
The embodiment of the invention also provides a kind of client of adjusting clock frequency, and this client comprises: receiving element, Waveform fetch unit, filter element, limit value judging unit, shake judging unit, adjustment unit;
Receiving element is used to receive message;
Waveform fetch unit, be used to obtain the network transfer delay waveform, be used to also to obtain that server periodically sends travels to and fro between half of client and server network time delay value, form network transfer delay waveform by half of these described network delay values of periodically obtaining;
Filter element is used for arriving by the message that presets the scope of frequency and amplitude, filters the dummy clock pulse of the message recovery that receives; The shake of screen propagation delay time waveform;
The limit value judging unit is used for judging at preset time at interval, dummy clock and local recovery clock whether differ accumulated value above the limit value that presets;
The shake judging unit, be used for dummy clock and local recovery clock differ accumulated value when surpassing the limit value preset, judge whether to exist at interval to surpass the described message that presets and arrive frequency and shakes with the network transfer delay waveform of amplitude range at this preset time;
Adjustment unit is used for when there is not the network transfer delay waveform shake that surpasses described message arrival frequency that presets and amplitude range in the shake judging unit, and it is consistent with the dummy clock frequency to adjust the local recovery clock frequency; Obtain existing when surpassing the described message that presets and arriving the network transfer delay waveform shake of frequency and amplitude range at the shake judging unit, recovered clock and local clock differed the accumulated value reduction.
The embodiment of the invention also provides a kind of system that adjusts clock frequency, and this system comprises: server and client;
Server is used for sending message to client, and periodically travels to and fro between half of client and server network time delay value to what client sent statistics;
Client, be used to receive message, the scope that arrives frequency and amplitude by the message that presets is filtered in the dummy clock arteries and veins of the message recovery that receives, and reception is travelled to and fro between half of client and server network time delay value and formed the network transfer delay waveform by described value; Arrive the scope of frequency and amplitude, the shake of screen propagation delay time waveform by the message that presets; Judgement preset time at interval in, dummy clock and local recovery clock whether differ accumulated value above the limit value that presets, then be left intact if not; If then judge in this preset time interval, whether to exist and surpass the network transfer delay waveform shake that the described message that presets arrives frequency and amplitude range, it is consistent with the recovered clock frequency then to adjust the local clock frequency if not, if then the accumulated value that differs of recovered clock and local clock is reduced;
Perhaps
Server is used for sending message to client, and periodically obtains half that travel to and fro between client and server network time delay value; Send to client behind half formation network transfer delay waveform with described network delay value;
Client is used to receive message, receives the network transfer delay waveform; Arrive the scope of frequency and amplitude by the message that presets, filter the dummy clock pulse of the message recovery that receives, the shake of screen propagation delay time waveform; Judgement preset time at interval in, dummy clock and local recovery clock whether differ accumulated value above the limit value that presets, then be left intact if not; If then judge in this preset time interval, whether to exist and surpass the network transfer delay waveform shake that the described message that presets arrives frequency and amplitude range, it is consistent with the recovered clock frequency then to adjust the local clock frequency if not, if then the accumulated value that differs of recovered clock and local clock is reduced.
Above technical scheme as can be seen, server is according to its local clock source timed sending message, client goes out the client recovered clock according to the frequency retrieval that message arrives; Add Handshake Protocol at server end and client simultaneously, under Handshake Protocol, obtain the network delay waveform of PSN by the feedback of client, differ accumulated value when surpassing the limit value preset at recovered clock and local clock, consider the influence of the network delay waveform of PSN, avoid unidirectional message to arrive frequency information and be subjected to the PSN time delay influence to cause mistuning to put in order local recovery clock, thereby can under PSN environment complicated and changeable, obtain the local recovery clock of better quality.
Embodiment
The problem that the embodiment of the invention mainly solves be client can not judge the recovered clock frequency shake owing to the PSN network causes, still since local recovery clock do not cause synchronously with server end clock source.In order to address this problem, adopted the method for obtaining the network delay waveform.After having obtained the network delay waveform, can judge whether to have surpassed the limit value that presets by the network delay waveform at the certain network delay increment of network delay in the time period, surpass the limit value that presets and then thought the influence that network delay causes, thereby avoided mistuning to put in order the local recovery clock frequency to a certain extent.
To know the embodiment of the invention in order introducing, at first to introduce the thinking that obtains the embodiment of the invention:
Because server generally is to be set to the fixed length timed sending according to its local clock source message, therefore the message that sends can be regarded the clock pulse of one section rule as, if every frame is played a bag, just can regard the 8K pulse of a rule as.For example shown in Figure 2, sending message is that one-period is 125us, and frequency is the clock pulse of 8K.
But message is behind process PSN, and the waveform that recovers out in client may change.Influence three factors that mainly contain of this impulse waveform: intrinsic time delay T
f, random delay T
r, packet loss (incorrect order here will be handled as packet loss) is if delivery time is t
n, be T the time of reception
n
T
n=t
n+ T
f+ T
r... ... ... ... ... ... ... ... .... packet loss not
T
n=t
n+ ∞ ... ... ... ... ... ... ... ... ... .... packet loss
So the recovery waveform of client and the contrast timing chart of ideal situation are as shown in Figure 3: after message advanced PSN, will have packet loss and intrinsic time delay T is arranged
f, random delay T
rInfluence.
Intrinsic time delay can not influence the identified result to clock pulse, and random delay can cause the frequency jitter of clock pulse; Packet loss be pulse missing only otherwise the burst long time also little to the identified result influence.Reason can be by shown in Figure 4: just can obtain packet loss to the little conclusion of identified result influence by the recovered clock of the source clock of server and client is carried out the XOR phase demodulation.
Lose a pulse in the middle of the clock pulse that the client that need follow the tracks of receives, the XOR identified result is to have lost a phase demodulation information, do not adjust phase place but can not influence, so the client terminal local recovered clock recovers out clock and need the clock pulse phase difference constant pi/2 of the client reception of tracking not change.
What therefore we mainly should consider was the shake that the elimination Netowrk tape comes.The PDV time delay of real network can be regarded a Gaussian distribution model as a short time the inside, and this model is referring to Fig. 5, and probability density meets following formula:
But with practical conditions as can be seen, for a long time, the μ among Fig. 5 is not a fixed value, and promptly we cannot just regard the network fixed delay as a fixed value, so we call u (t) more accurately to μ, the probability density formula strain of time delay is
The delay volume reaction that meets (1) formula Gaussian Profile is high-frequency clock jitter, and in fact u (t) introducing is exactly the low-frequency clock drift.And because randomized jitter will be considered easily and be removed, so present subject matter is considered the low-frequency clock drift that u (t) introduces exactly, just differentiates current local recovery clock and differing because u (t) causes through the clock pulse behind the PSN network; Still because the clock of client terminal local does not have tracking upward to cause through the recovered clock pulse behind the PSN network.
U (t) is a continuous function, and is a function that the alternating current component frequency is lower, and we here give one example, and supposes u (t)=u
0+ u
1Sin (100
-1T*2 π)+u
2Sin (15
-1T*2 π), suppose that again we have constantly followed the tracks of at t=0, below we analyze, how identified result handles the triggering that the adjustment that just is unlikely to make the client terminal local clock is subjected to u (t), promptly is subjected to the time delay influence of network PSN.
Use the basic principle of digital phase-locked loop, use a high-frequency clock, identified result when being leading forward-backward counter do subtraction, forward-backward counter was done addition when identified result fell behind, set a upper and lower bound, break through the frequency that upward just improves local recovery clock in limited time when forward-backward counter, when breaking down the frequency that just reduces local recovery clock in limited time by a fall, here directly adopt local clock to get final product as high-frequency clock, suppose that present local clock is 100M, if counter zero clearing never, local recovery clock is also constant not to be adjusted and itself can not drift about, look at counter values behind the 50s and the numerical value behind the 100s
Suppose u
1=u
2=10ms, ∑ PhaseOffset (50S) ≈ 1.24E-4S so, so use the 100M clock technology, counter will add up and obtain 124000.Identical computational methods, can calculate 100S after, counter will be accumulated to 15000.
So when the result of forward-backward counter arrives 124000 words of just adjusting the local recovery clock frequency, in fact be exactly the influence that is subjected to PSN, rather than real owing to do not follow the tracks of and go up the recovered clock pulse, the frequency of when being subjected to the PSN web influence, adjusting local recovery clock can cause originally followed the tracks of accurate clock tuningout from.Suppose that the step-length of adjusting is 0.1ppm, 2M clock deviation 0.1ppm just has been offset 200s always so, and forward-backward counter will reach 1us so.This numerical value is added some factors of instability, and Gonna breakthrough 1000s is very easy with interior maximum time interval error limit for height 2us, thereby the mistuning of having carried out influenced by network PSN is put in order.
And the PSN network generally is a center type, and promptly a plurality of clients of server band will make the client recovered clock not be subjected to the influence of network transfer delay, must allow client know the waveform of current network propagation delay time.So the key of problem transforms obtaining for the network transfer delay waveform values; Obtain the network transfer delay waveform, can add Handshake Protocol the server and client side.
The embodiment of the invention mainly is exactly: preset scopes such as the shake of the reception message frequency that PSN brings and range value in prior art, the recovered clock frequency is filtered the influence of a part of network delay shake earlier; Further obtain the network delay waveform, and scopes such as shake by the reception message frequency that presets and range value, the network delay waveform that obtains is filtered, make the network delay waveform also avoid earlier influenced by PSN to a certain degree.Whether that judges dummy clock and local recovery clock then at short notice differs accumulated value above certain limit value, surpass certain limit value if differ accumulated value, then judge whether to need to adjust the local clock frequency by the network delay waveform that has filtered the PSN shake.
Referring to Fig. 6, embodiment of the invention concrete steps are:
Step 601: server sends message; Server generally is that the clock source message according to its this locality is set to the fixed length timed sending, and therefore the message that sends can be regarded the clock pulse of one section rule as, if every frame is played a bag, just can regard the 8K pulse of a rule as.
Step 602: client receives message, obtains the dummy clock frequency according to the frequency that message arrives.
Step 603: client is obtained the network transfer delay waveform.
The method that client is obtained the network transfer delay waveform has two kinds:
First kind referring to Fig. 7:
Step 701: server is periodically to client transmitting time signal calculated, this Time Calculation signal from the time interval of server to client end be t1;
Step 702: user end to server feeds back this Time Calculation signal, and the time of this feedback signal from the client to the server is t2;
Step 703: server is received the time delay that can calculate this trip path behind the Time Calculation signal of feedback.
What but client needed is the value of t1, therefore the t1 network delay can be similar to and think: (t1+t2)/2.Because server is periodic transmitting time signal calculated, therefore can obtain the value of a plurality of network delay t1.
Step 704: after server obtains the value of a plurality of network delay t1, can obtain the network transfer delay waveform according to the value of these t1;
Step 705: after obtaining the network transfer delay waveform, this waveform is sent to client.
Referring to Fig. 8, add Handshake Protocol, client also has another to obtain the method for network transfer delay oscillogram:
Step 801: server periodically sends a Time Calculation signal to client, this Time Calculation signal from the time interval of server to client end be t1;
Step 802: user end to server feeds back this Time Calculation signal, and the time of this feedback signal from the client to the server is t2;
Step 803: server is received the time delay that can calculate this trip path behind the Time Calculation signal of feedback.
What but client needed is the value of t1, therefore the t1 network delay can be similar to and think: (t1+t2)/2.Because server is periodic transmitting time signal calculated, therefore can obtain the value of a plurality of network delay t1.
Step 804: server sends to client with the value of these network delays t1;
Step 805: client is obtained the network transfer delay waveform according to the value of these t1.
More than be two kinds of methods obtaining the network transfer delay waveform.
Step 604: arrive the scope of frequency and amplitude, screen propagation delay time waveform by the message that presets.
This step can be carried out between step 606 and 607, whether promptly filter the network transfer delay shake of back in judging at certain time intervals is filtered, the execution of this step can be compared flexibly opportunity, is not limited in present embodiment and carries out described opportunity.
This step can be come the description of image by Fig. 9, Figure 10.The waveform of the network transfer delay that for example obtains such as Fig. 9: the signal of time T the inside can think that frequency is 10E-3Hz; Amplitude is 2us; The signal of T outside can think that frequency is 1Hz~10E-2Hz and 0.2us amplitude; The signal frequency of T outside and amplitude just can filter out in the scope that filter presets so, the waveform after the formation filtration shake as shown in figure 10.
Step 605: judge that in certain time interval, message arrives frequency, whether what promptly dummy clock and client terminal local recovered clock caused differs accumulated value above certain numerical value; If surpass then execution in step 607; If do not surpass then execution in step 606;
Step 606: be left intact;
Step 607: judge in this preset time interval, whether to exist to surpass the network delay waveform shake that the described message that presets arrives frequency and amplitude range, if there is then execution in step 608; If there is not then execution in step 609;
Step 608: dummy clock and client terminal local recovered clock are differed accumulated value make zero; Perhaps dummy clock and client terminal local clock are differed accumulated value, deduct in this time interval by the network transfer delay waveform obtain by differing that network transfer delay causes.
Step 609: adjust the local recovery clock frequency;
Referring to Figure 11, for example at T in the time period, the waveform of network delay is that the client filter filters and do not go, and client can select not do any clock adjustment at T in the time period; Just judge and make certain decrement treatment on the accumulated value original differing according to this time delay waveform.
The embodiment of the invention does not limit differing the processing that accumulated value does in step 608, can select different processing methods according to actual needs.
By judgement of the invention process, can effectively avoid being subjected to the influence of PSN network delay, the local clock frequency is put in order in mistuning.
The embodiment of the invention also provides a kind of client of avoiding the whole clock frequency of mistuning, and this client comprises: receiving element, Waveform fetch unit, filter element, limit value judging unit, shake judging unit, adjustment unit;
Receiving element is used to receive message;
Waveform fetch unit is used to obtain the network transfer delay waveform; Be used to also to obtain that server periodically sends travels to and fro between half of client and server network time delay value, form network transfer delay waveform by half of these described network delay values of periodically obtaining.
Filter element is used for arriving by the message that presets the scope of frequency and amplitude, filters the dummy clock pulse of the message recovery that receives; The shake of screen propagation delay time waveform;
The limit value judging unit is used for judging at preset time at interval, dummy clock and local recovery clock whether differ accumulated value above the limit value that presets;
The shake judging unit, be used for dummy clock and local recovery clock differ accumulated value when surpassing the limit value preset, judge whether to exist at interval to surpass the network delay waveform that the described message that presets arrives frequency and amplitude range and shakes at this preset time;
Adjustment unit is used for when there is not the network delay waveform shake that surpasses described message arrival frequency that presets and amplitude range in the shake judging unit, and it is consistent with the dummy clock frequency to adjust the local recovery clock frequency; Obtain existing when surpassing the described message that presets and arriving the network delay waveform shake of frequency and amplitude range at the shake judging unit, dummy clock and local recovery clock differed the accumulated value reduction.
Wherein, described adjustment unit specifically comprises: the unit that makes zero, adjustment local clock frequency cells, computing unit;
The unit that makes zero is used for obtaining existing when surpassing the described message that presets and arriving the network delay waveform shake of frequency and amplitude range at the shake judging unit, is changed to the accumulated value that differs of described dummy clock and local recovery clock zero;
Adjust the local clock frequency cells, be used for when there is not the network delay waveform shake that surpasses described message arrival frequency that presets and amplitude range in the shake judging unit, it is consistent with the dummy clock frequency to adjust the local recovery clock frequency.
Computing unit, be used for obtaining existing when surpassing the described message that presets and arriving frequency and shake with the network delay waveform of amplitude range at the shake judging unit, with current dummy clock and local recovery clock differ accumulated value deduct in this time interval by the network transfer delay waveform obtain by differing that network transfer delay causes.
The embodiment of the invention also provides a kind of system that avoids the whole clock of mistuning, and this system comprises: server and client;
Server is used for sending message to client, and periodically travels to and fro between half of client and server network time delay value to what client sent statistics;
Client, be used to receive message, arrive frequency and the scope of amplitude by the message that presets and filter the dummy clock pulse that the message that receives recovers, receive travel to and fro between client and server network time delay value half also by described value formation network transfer delay waveform; Arrive the scope of frequency and amplitude, the shake of screen propagation delay time waveform by the message that presets; Judgement preset time at interval in, dummy clock and local recovery clock whether differ accumulated value above the limit value that presets, then be left intact if not; If then judge in this preset time interval, whether to exist and surpass the network delay waveform shake that the described message that presets arrives frequency and amplitude range, it is consistent with the recovered clock frequency then to adjust the local clock frequency if not, if then the accumulated value that differs of recovered clock and local clock is reduced;
Perhaps
Server is used for sending message to client, and periodically obtains half that travel to and fro between client and server network time delay value; Send to client behind half formation network transfer delay waveform with described network delay value;
Client is used to receive message, receives the network transfer delay waveform; Arrive the scope of frequency and amplitude by the message that presets, filter the dummy clock pulse of the message recovery that receives, the shake of screen propagation delay time waveform; Judgement preset time at interval in, dummy clock and local recovery clock whether differ accumulated value above the limit value that presets, then be left intact if not; If then judge in this preset time interval, whether to exist and surpass the network delay waveform shake that the described message that presets arrives frequency and amplitude range, it is consistent with the recovered clock frequency then to adjust the local clock frequency if not, if then the accumulated value that differs of recovered clock and local clock is reduced.
More than a kind of method, client and system of the whole clock of mistuning of avoiding provided by the present invention is described in detail, used specific case herein principle of the present invention and execution mode are set forth, the explanation of above embodiment just is used for helping to understand method of the present invention and core concept thereof; Simultaneously, for one of ordinary skill in the art, according to thought of the present invention, the part that all can change in specific embodiments and applications, in sum, this description should not be construed as limitation of the present invention.