[ntp:questions] API for step time server notification

unruh unruh at wormhole.physics.ubc.ca
Mon Jul 26 17:52:58 UTC 2010


On 2010-07-26, Richard B. Gilbert <rgilbert88 at comcast.net> wrote:
> unruh wrote:
>> On 2010-07-26, Thierry MARTIN <thierry-martin at ifrance.com> wrote:
>>> On 26 juil, 16:39, unruh <un... at wormhole.physics.ubc.ca> wrote:
>>>> On 2010-07-26, Thierry MARTIN <thierry-mar... at ifrance.com> wrote:
>>>>
>>>>> Hello,
>>>>> Is there any API that can be used in a program to be "notified" if a
>>>>> "step time server" event occurs?
>>>>> As far as I could see, it is "only" logged.
>>>> You could have something read the logs and notify your program. Or if
>>>> you are on Linux/BSD you could run chrony, which does not step.
>>>> Mind you if ntpd is stepping after having been running for a few hours,
>>>> something is seriously wrong, and needs fixing.
>>>>
>>>>
>>>>
>>>>> Thanks in advance for your answers.
>>>>> / Thierry
>>> Unfortunately, watching the logs does not fit my need.
>>> I will try and explain what are my constraints.
>>>
>>> My program is doing network packet acquisition on several links and
>>> needs to sort them - based on the timestamps.
>>> Also, many network measurements are very badly affected by time
>>> stepping forward or backward.
>>>
>>> This explains why I'd like to be notified of time steps. (It is easy
>>> when time is going backward, but not in the other case).
>>>
>>> I think ntpd ajusts time by step if the system looses connection to
>>> ntp sources for a while (I set up the step threshold to 1s on the ntp
>>> server).
>> 
>> No. ntpd steps if the time is out xby more than 125ms. This is a failure
>> of ntpd, but it is NOT something that should happen. 
>> Your clocks should not step even if they loose connectivity for a fair
>> while if their frequency has been disciplined-- and if  your network
>> looses connectivity, then your network monitoring is screwed anyway. 
>> 
>> You might also want to let the clock freewheel (ie do not use ntp to
>> discipline it) but use ntp to find out how far out your clocks actually
>> are. Then again you can use that info to correct the times of the
>> timestamps after the fact. 
>> 
>> But this stepping is simply a feature of ntpd. If you do not like it,
>> use chrony instead (unless you are on windows). 
>
> Stepping is not exactly a "feature" of NTPD.  It's a last resort for 
> fixing a totally screwed up clock.  If your clock is off by fifteen 
> minutes, do you *really* want to wait three or four weeks for NTPD to 
> fix it "gently"??  There are a few sites that would have no choice but 
> to do so but they are extremely careful to avoid the necessity!

15 min? ntpd steps at .25 sec. And yes, I would have ntp slew faster
when the time is out by a lot. But the algorithm that ntpd uses is
somewhat braindead-- it only remembers one tiny bit of information, the
slew rate, which makes it hard to correct. There are these pious
pronouncements that ntp algorithm is stable and cannot slew faster and
remain stable, but a step is a slew rate of infinity. 
Note I do not mind ntpd stepping when it is started up. I agree that if
your clock reads Mar 30 1998, waiting for it to slew away that error
would be rediculous. But this post is discussing stepping after ntpd has
been running for a while, not startup. 
I also agree that, if you clock has been in contact with an ntpd server
for a long time, a step is an indication that something is seriously
wrong. But say, with the OP, that the clock has for some reason been out
of contact with the net for 3 days (it takes that long for routers to be
fixed sometimes). Even at 1PPM (which could happen due to temp
fluctuations), that will put it out by 2 sec when it comes back online. 
2 sec could easily be slewed away in a few hours at 500PPM, but ntpd
will step.




More information about the questions mailing list