[ntp:questions] Synchronizing using servers in stratum 1 and 2

David Woolley david at djwhome.demon.co.uk
Tue Feb 13 22:50:44 UTC 2007


In article <45d20bd0$0$329$e4fe514c at news.xs4all.nl>,
Timo Ruiter <timo.ruiter at xs4all.nl> wrote:
> David Woolley schreef:
> > It will synchronize to a mixture of the times from all three servers, but
> > weighted in favour of the stratum 1 one, I believe.  Although it only
> 
> Can anyone confirm this?

For NTPV3, using the PDF version (although I think that the IETF is
right in requiring plain text standards), see pages 84 and 85.  The
weighting is the reciprocal of an error term plus the maximum possible
value of that times the stratum, so for large stratums it is essentially
inverse stratum and, for stratum one, inverse error term.  The error 
term is distance (peer).  Using more than the first choice is optional.
Curioulsy, it's in an appendix.

For the actual implementation of NTPV4 in version 4.2.0 of the reference
implementation it is weighted by reciprocal root distance, but doesn't
seem to include the stratum.

/*
 * clock_combine - combine offsets from selected peers
 */
static double
clock_combine(
        struct peer **peers,
        int     npeers
        )
{
        int     i;
        double  x, y, z;

        y = z = 0;
        for (i = 0; i < npeers; i++) {
                x = root_distance(peers[i]);
                y += 1. / x;
                z += peers[i]->offset / x;
        }
        return (z / y);
}
/*
 * root_distance - compute synchronization distance from peer to root
 */
static double
root_distance(
        struct peer *peer
        )
{
        /*
         * Careful squeak here. The value returned must be greater than
         * zero blamed on the peer jitter, which must be at least the
         * square of sys_precision.
         */
        return ((peer->rootdelay + peer->delay) / 2 +
            peer->rootdispersion + peer->disp + clock_phi *
            (current_time - peer->update) + SQRT(peer->jitter));
}




More information about the questions mailing list