[ntp:hackers] refclock_atom.c

Mark Martinec Mark.Martinec at ijs.si
Tue Jan 25 08:48:48 PST 2005


Besides the three relatively minor points with RFC-2783 and refclock_atom.c
reported in my mail from Jan 17, here is one that is more serious.

It turns out that the current refclock_atom.c discards all PPS samples
that are slightly ahead of the system time, e.g. dt = 0.999999842 s,
(sec=1, nsec=-158), and only keeps those that are slighty late
(e.g. dt=1.000000026, sec=1, nsec=26).

The culprit is the following code in refclock_atom.c:

        sec = ts.tv_sec - up->ts.tv_sec;
        nsec = ts.tv_nsec - up->ts.tv_nsec;
        up->ts = ts;
#e.g. sec=1, nsec=-158
        if (nsec < 0) {
                sec --;
                nsec += NANOSECOND;
#sec=0, nsec=999999842
        } else if (nsec >= NANOSECOND) {
                sec++;
                nsec -= NANOSECOND;
        }
        switch (sec) {
        case 0:
#sec=0, sample is discarded
                return;

The final effect is that PPS is lost for whole periods
when the system clock is slightly slow, until it catches up,
and then about half the samples are lost on the average.

  Mark



More information about the hackers mailing list