]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 3067] Root distance calculation needs improvement. HStenn
authorHarlan Stenn <stenn@ntp.org>
Sun, 13 Nov 2016 00:55:59 +0000 (16:55 -0800)
committerHarlan Stenn <stenn@ntp.org>
Sun, 13 Nov 2016 00:55:59 +0000 (16:55 -0800)
bk: 5827ba1fHmv0DxbILr8BYGOJlpjq5A

ChangeLog
NEWS
ntpd/ntp_proto.c

index bc06285ac2837e1e4afd3ca70cb0a431daa273fd..2b52b7b91c5b8ed940ce29a0fe2cb4bd2549f579 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -26,6 +26,7 @@
 * [Bug 3084] update-leap mis-parses the leapfile name.  HStenn.
 * [Bug 3068] Linker warnings when building on Solaris. perlinger@ntp.org
   - applied patch thanks to Andrew Stormont <andyjstormont@gmail.com>
+* [Bug 3067] Root distance calculation needs improvement.  HStenn.
 * [Bug 3066] NMEA clock ignores pps. perlinger@ntp.org
   - PPS-HACK works again.
 * [Bug 3059] Potential buffer overrun from oversized hash <perlinger@ntp.org>
diff --git a/NEWS b/NEWS
index 544c628bc763c7c9a9ebc990693878203e46ddb4..36ebbe4a028a3a243616eeb1473175c7f499bed8 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -107,6 +107,7 @@ Other fixes:
 * [Bug 3084] update-leap mis-parses the leapfile name.  HStenn.
 * [Bug 3068] Linker warnings when building on Solaris. perlinger@ntp.org
   - applied patch thanks to Andrew Stormont <andyjstormont@gmail.com>
+* [Bug 3067] Root distance calculation needs improvement.  HStenn
 * [Bug 3066] NMEA clock ignores pps. perlinger@ntp.org
   - PPS-HACK works again.
 * [Bug 3059] Potential buffer overrun from oversized hash <perlinger@ntp.org>
index d157bfee9cb91ebc08f250d8a0df561ba5d5d27f..68d15fd90f5225798e4f5f8a85c950a5209492d6 100644 (file)
@@ -3074,8 +3074,9 @@ clock_select(void)
                 * Leave the island immediately if the peer is
                 * unfit to synchronize.
                 */
-               if (peer_unfit(peer))
+               if (peer_unfit(peer)) {
                        continue;
+               }
 
                /*
                 * If this peer is an orphan parent, elect the
@@ -3115,8 +3116,9 @@ clock_select(void)
                 * parent in ancestry so are excluded.
                 * See http://bugs.ntp.org/2050
                 */
-               if (peer->stratum > sys_orphan)
+               if (peer->stratum > sys_orphan) {
                        continue;
+               }
 #ifdef REFCLOCK
                /*
                 * The following are special cases. We deal
@@ -3565,15 +3567,15 @@ root_distance(
 
        /*
         * Root Distance (LAMBDA) is defined as:
-        * (delta + DELTA)/2 + epsilon + EPSILON + phi
+        * (delta + DELTA)/2 + epsilon + EPSILON + D
         *
         * where:
         *  delta   is the round-trip delay
         *  DELTA   is the root delay
-        *  epsilon is the remote server precision + local precision
+        *  epsilon is the peer dispersion
         *          + (15 usec each second)
         *  EPSILON is the root dispersion
-        *  phi     is the peer jitter statistic
+        *  D       is sys_jitter
         *
         * NB: Think hard about why we are using these values, and what
         * the alternatives are, and the various pros/cons.
@@ -3582,8 +3584,7 @@ root_distance(
         * other worse choices.
         */
        dtemp = (peer->delay + peer->rootdelay) / 2
-               + LOGTOD(peer->precision)
-                 + LOGTOD(sys_precision)
+               + peer->disp
                  + clock_phi * (current_time - peer->update)
                + peer->rootdisp
                + peer->jitter;
@@ -4463,8 +4464,9 @@ peer_unfit(
         */
        if (   peer->leap == LEAP_NOTINSYNC
            || peer->stratum < sys_floor
-           || peer->stratum >= sys_ceiling)
+           || peer->stratum >= sys_ceiling) {
                rval |= TEST10;         /* bad synch or stratum */
+       }
 
        /*
         * A distance error for a remote peer occurs if the root
@@ -4473,8 +4475,9 @@ peer_unfit(
         */
        if (   !(peer->flags & FLAG_REFCLOCK)
            && root_distance(peer) >= sys_maxdist
-                                     + clock_phi * ULOGTOD(peer->hpoll))
+                                     + clock_phi * ULOGTOD(peer->hpoll)) {
                rval |= TEST11;         /* distance exceeded */
+       }
 
        /*
         * A loop error occurs if the remote peer is synchronized to the
@@ -4482,15 +4485,17 @@ peer_unfit(
         * server as the local peer but only if the remote peer is
         * neither a reference clock nor an orphan.
         */
-       if (peer->stratum > 1 && local_refid(peer))
+       if (peer->stratum > 1 && local_refid(peer)) {
                rval |= TEST12;         /* synchronization loop */
+       }
 
        /*
         * An unreachable error occurs if the server is unreachable or
         * the noselect bit is set.
         */
-       if (!peer->reach || (peer->flags & FLAG_NOSELECT))
+       if (!peer->reach || (peer->flags & FLAG_NOSELECT)) {
                rval |= TEST13;         /* unreachable */
+       }
 
        peer->flash &= ~PEER_TEST_MASK;
        peer->flash |= rval;