From: Harlan Stenn Date: Mon, 19 Aug 2013 02:20:55 +0000 (-0400) Subject: [2085] Fix root distance and root dispersion calculations X-Git-Tag: NTP_4_2_7P385~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9870a581975b136bd8a116906dfa47cc8313face;p=thirdparty%2Fntp.git [2085] Fix root distance and root dispersion calculations bk: 52118107xRXAZMfq-iw0s5WgRmyttg --- diff --git a/ChangeLog b/ChangeLog index d333820ca..d2d999c32 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,4 @@ +* [2085] Fix root distance and root dispersion calculations. (4.2.7p384) 2013/08/18 Released by Harlan Stenn * [Bug 2450] --version has bogus short option. (4.2.7p383) 2013/08/10 Released by Harlan Stenn diff --git a/ntpd/ntp_proto.c b/ntpd/ntp_proto.c index ae05982ec..f2d6970ec 100644 --- a/ntpd/ntp_proto.c +++ b/ntpd/ntp_proto.c @@ -1827,9 +1827,30 @@ clock_update( sys_refid = peer->refid; else sys_refid = addr2refid(&peer->srcadr); - dtemp = fabs(sys_offset) + peer->disp + peer->rootdisp + - (peer->delay + peer->rootdelay) / 2 + clock_phi * - (current_time - peer->update) + sys_jitter; + /* + * Root Dispersion (E) is defined (in RFC 5905) as: + * + * E = p.epsilon_r + p.epsilon + p.psi + PHI*(s.t - p.t) + |THETA| + * + * where: + * p.epsilon_r is the PollProc's root dispersion + * p.epsilon is the PollProc's dispersion + * p.psi is the PollProc's jitter + * THETA is the combined offset + * + * NB: Think Hard about where these numbers come from and + * what they mean. When did peer->update happen? Has anything + * interesting happened since then? What values are the most + * defensible? Why? + * + * DLM thinks this equation is probably the best of all worse choices. + */ + dtemp = peer->rootdisp + + peer->disp + + sys_jitter + + clock_phi * (current_time - peer->update) + + fabs(sys_offset); + if (dtemp > sys_mindisp) sys_rootdisp = dtemp; else @@ -2923,6 +2944,30 @@ root_distance( { double dtemp; + /* + * Root Distance (LAMBDA) is defined as: + * (delta + DELTA)/2 + epsilon + EPSILON + phi + * + * where: + * delta is the round-trip delay + * DELTA is the root delay + * epsilon is the remote server precision + local precision + * + (15 usec each second) + * EPSILON is the root dispersion + * phi is the peer jitter statistic + * + * NB: Think hard about why we are using these values, and what + * the alternatives are, and the various pros/cons. + * + * DLM thinks these are probably the best choices from any of the + * other worse choices. + */ + dtemp = (peer->delay + peer->rootdelay) / 2 + + LOGTOD(peer->precision) + + LOGTOD(sys_precision) + + clock_phi * (current_time - peer->update) + + peer->rootdisp + + peer->jitter; /* * Careful squeak here. The value returned must be greater than * the minimum root dispersion in order to avoid clockhop with @@ -2930,9 +2975,6 @@ root_distance( * cannot exceed the sys_maxdist, as this is the cutoff by the * selection algorithm. */ - dtemp = (peer->delay + peer->rootdelay) / 2 + peer->disp + - peer->rootdisp + clock_phi * (current_time - peer->update) + - peer->jitter; if (dtemp < sys_mindisp) dtemp = sys_mindisp; return (dtemp);