tags:

views:

23

answers:

2

As defined in NTP rfc

"The goal of the NTP algorithms is to minimize both the time difference and frequency difference between UTC and the system clock."

I can understand 'time difference' but what is 'frequency difference' which NTP try to sync ?

A: 

The frequency difference is how much the time difference changes over ... time.

That is to say, NTP tries not just to pull two clocks closer together, but to actually keep them together.

It's actually drawing on the obscure-for-this-context knowledge that computer clocks are implemented using quartz crystals which oscillate at a certain rate - the "clock frequency". It's how frequently a clock "tick" happens.

Borealid
+3  A: 

Frequency difference is the difference in speeds between your clock and the NTP clock (effectively deemed to be perfect).

If you clock gains a minute every hour (compared to the NTP server clock), that's the frequency difference. It's also called drift.

An extreme, simplified, example:

Lets say you sync with NTP at the top of every hour (00:00, 01:00, ...) but your clock is really bad and loses ten minutes in that hour.

If you sync with NTP at midnight so that both your clocks are set to 00:00 then, when the (real) 01:00 comes around, your clock will read 00:50 (you've lost your ten minutes).

That means that you will be out of step by anywhere between zero and ten minutes.


So how would you fix that in a simplistic way?

What if the synchronisation set your clock to 00:05 at (real) midnight. You would be out by five minutes but the NTP clock would gradually creep up on you, matching perfectly at 00:30 before it starts getting ahead of you.

Then at (real) 01:00, you would be at 00:55 so that at no point would the error be more than five minutes.


Now NTP will try to avoid doing things like immediately changing your time from 00:55 to 01:05 since a lot of software (like cron) won't take too kindly to it.

It's far more likely to synch the clocks together at midnight then gradually creep the local time forward over the hour to keep them aligned (say adding one second every five, which will effectively recover that lost ten minutes in the hour in a non-gut-wrenching way).

paxdiablo