|
|
cdde2b |
Backported from ntp-dev-4.2.7p385
|
|
|
cdde2b |
|
|
|
cdde2b |
diff -up ntp-4.2.6p5/ntpd/ntp_proto.c.rootdisp ntp-4.2.6p5/ntpd/ntp_proto.c
|
|
|
cdde2b |
--- ntp-4.2.6p5/ntpd/ntp_proto.c.rootdisp 2013-12-09 15:02:58.394459288 +0100
|
|
|
cdde2b |
+++ ntp-4.2.6p5/ntpd/ntp_proto.c 2013-12-09 15:10:05.770954848 +0100
|
|
|
cdde2b |
@@ -1667,10 +1667,34 @@ clock_update(
|
|
|
cdde2b |
sys_refid = peer->refid;
|
|
|
cdde2b |
else
|
|
|
cdde2b |
sys_refid = addr2refid(&peer->srcadr);
|
|
|
cdde2b |
- dtemp = sys_jitter + fabs(sys_offset) + peer->disp +
|
|
|
cdde2b |
- (peer->delay + peer->rootdelay) / 2 + clock_phi *
|
|
|
cdde2b |
- (current_time - peer->update);
|
|
|
cdde2b |
- sys_rootdisp = dtemp + peer->rootdisp;
|
|
|
cdde2b |
+ /*
|
|
|
cdde2b |
+ * Root Dispersion (E) is defined (in RFC 5905) as:
|
|
|
cdde2b |
+ *
|
|
|
cdde2b |
+ * E = p.epsilon_r + p.epsilon + p.psi + PHI*(s.t - p.t) + |THETA|
|
|
|
cdde2b |
+ *
|
|
|
cdde2b |
+ * where:
|
|
|
cdde2b |
+ * p.epsilon_r is the PollProc's root dispersion
|
|
|
cdde2b |
+ * p.epsilon is the PollProc's dispersion
|
|
|
cdde2b |
+ * p.psi is the PollProc's jitter
|
|
|
cdde2b |
+ * THETA is the combined offset
|
|
|
cdde2b |
+ *
|
|
|
cdde2b |
+ * NB: Think Hard about where these numbers come from and
|
|
|
cdde2b |
+ * what they mean. When did peer->update happen? Has anything
|
|
|
cdde2b |
+ * interesting happened since then? What values are the most
|
|
|
cdde2b |
+ * defensible? Why?
|
|
|
cdde2b |
+ *
|
|
|
cdde2b |
+ * DLM thinks this equation is probably the best of all worse choices.
|
|
|
cdde2b |
+ */
|
|
|
cdde2b |
+ dtemp = peer->rootdisp
|
|
|
cdde2b |
+ + peer->disp
|
|
|
cdde2b |
+ + sys_jitter
|
|
|
cdde2b |
+ + clock_phi * (current_time - peer->update)
|
|
|
cdde2b |
+ + fabs(sys_offset);
|
|
|
cdde2b |
+
|
|
|
cdde2b |
+ if (dtemp > sys_mindisp)
|
|
|
cdde2b |
+ sys_rootdisp = dtemp;
|
|
|
cdde2b |
+ else
|
|
|
cdde2b |
+ sys_rootdisp = sys_mindisp;
|
|
|
cdde2b |
sys_rootdelay = peer->delay + peer->rootdelay;
|
|
|
cdde2b |
sys_reftime = peer->dst;
|
|
|
cdde2b |
|
|
|
cdde2b |
@@ -2810,15 +2834,36 @@ root_distance(
|
|
|
cdde2b |
double dtemp;
|
|
|
cdde2b |
|
|
|
cdde2b |
/*
|
|
|
cdde2b |
+ * Root Distance (LAMBDA) is defined as:
|
|
|
cdde2b |
+ * (delta + DELTA)/2 + epsilon + EPSILON + phi
|
|
|
cdde2b |
+ *
|
|
|
cdde2b |
+ * where:
|
|
|
cdde2b |
+ * delta is the round-trip delay
|
|
|
cdde2b |
+ * DELTA is the root delay
|
|
|
cdde2b |
+ * epsilon is the remote server precision + local precision
|
|
|
cdde2b |
+ * + (15 usec each second)
|
|
|
cdde2b |
+ * EPSILON is the root dispersion
|
|
|
cdde2b |
+ * phi is the peer jitter statistic
|
|
|
cdde2b |
+ *
|
|
|
cdde2b |
+ * NB: Think hard about why we are using these values, and what
|
|
|
cdde2b |
+ * the alternatives are, and the various pros/cons.
|
|
|
cdde2b |
+ *
|
|
|
cdde2b |
+ * DLM thinks these are probably the best choices from any of the
|
|
|
cdde2b |
+ * other worse choices.
|
|
|
cdde2b |
+ */
|
|
|
cdde2b |
+ dtemp = (peer->delay + peer->rootdelay) / 2
|
|
|
cdde2b |
+ + LOGTOD(peer->precision)
|
|
|
cdde2b |
+ + LOGTOD(sys_precision)
|
|
|
cdde2b |
+ + clock_phi * (current_time - peer->update)
|
|
|
cdde2b |
+ + peer->rootdisp
|
|
|
cdde2b |
+ + peer->jitter;
|
|
|
cdde2b |
+ /*
|
|
|
cdde2b |
* Careful squeak here. The value returned must be greater than
|
|
|
cdde2b |
* the minimum root dispersion in order to avoid clockhop with
|
|
|
cdde2b |
* highly precise reference clocks. Note that the root distance
|
|
|
cdde2b |
* cannot exceed the sys_maxdist, as this is the cutoff by the
|
|
|
cdde2b |
* selection algorithm.
|
|
|
cdde2b |
*/
|
|
|
cdde2b |
- dtemp = (peer->delay + peer->rootdelay) / 2 + peer->disp +
|
|
|
cdde2b |
- peer->rootdisp + clock_phi * (current_time - peer->update) +
|
|
|
cdde2b |
- peer->jitter;
|
|
|
cdde2b |
if (dtemp < sys_mindisp)
|
|
|
cdde2b |
dtemp = sys_mindisp;
|
|
|
cdde2b |
return (dtemp);
|