]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
ChangeLog, miscopt.htm, ntp.h, ntp_config.h, ntp_loopfilter.c, ntp_proto.c:
authorHarlan Stenn <stenn@ntp.org>
Mon, 23 Apr 2001 21:12:38 +0000 (21:12 -0000)
committerHarlan Stenn <stenn@ntp.org>
Mon, 23 Apr 2001 21:12:38 +0000 (21:12 -0000)
  * html/miscopt.htm: Document the "allan" tinker variable.
  * ntpd/ntp_proto.c (clock_filter): Update comments.  Lose etemp;
  we now use allan_xpt for this.
  * ntpd/ntp_loopfilter.c: Added allan_xpt as a tinker variable.
  Reorganize variables and improve comments.
  (local_clock): Improve comments, use (new) allan_xpt instead of
  CLOCK_ALLAN.  Fix test in S_SYNC state.  Update debug info.
  (rstclock): No longer force allan_xpt to CVLOCK_ALLAN in S_FREQ,
  S_SYNC, or default case.
  (loop_config): Document dangerous tinker variables, and add
  LOOP_ALLAN to the list.
  * include/ntp_config.h (CONF_CLOCK_ALLAN): Added.
  * include/ntp.h (LOOP_ALLAN): Added.
  Allan intercept fixes from Dave Mills.
ChangeLog, aclocal.m4, configure, configure.in:
  * configure.in: 4.0.99k29

bk: 3ae49ac6siGcLO_F8o_Cm2u1MZmrcQ

ChangeLog
configure
configure.in
html/miscopt.htm
include/ntp.h
include/ntp_config.h
ntpd/ntp_loopfilter.c
ntpd/ntp_proto.c

index 1e741c375c19aa0d53d96ea9168e3eafdb0de410..4e6b5afb1f03a01930fc71882b1386d460ae63d2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,22 @@
 2001-04-23  Harlan Stenn  <stenn@whimsy.udel.edu>
 
+       * configure.in: 4.0.99k29
+
+       * html/miscopt.htm: Document the "allan" tinker variable.
+       * ntpd/ntp_proto.c (clock_filter): Update comments.  Lose etemp;
+       we now use allan_xpt for this.
+       * ntpd/ntp_loopfilter.c: Added allan_xpt as a tinker variable.
+       Reorganize variables and improve comments.
+       (local_clock): Improve comments, use (new) allan_xpt instead of
+       CLOCK_ALLAN.  Fix test in S_SYNC state.  Update debug info.
+       (rstclock): No longer force allan_xpt to CVLOCK_ALLAN in S_FREQ,
+       S_SYNC, or default case.
+       (loop_config): Document dangerous tinker variables, and add
+       LOOP_ALLAN to the list.
+       * include/ntp_config.h (CONF_CLOCK_ALLAN): Added.
+       * include/ntp.h (LOOP_ALLAN): Added.
+       Allan intercept fixes from Dave Mills.
+
        * scripts/mkver.in: Use the C locale so  the dates come out in a
        consistent format.
        From: ASANO Naoyuki <n_asano@imjp.co.jp>
index 6e562a34aafb5a0a754c1431dec27395f6d02b9a..175c313dc0786c72e09fd97945e6502cfd0aa6e0 100755 (executable)
--- a/configure
+++ b/configure
@@ -1397,7 +1397,7 @@ fi
 
 # Define the identity of the package.
 PACKAGE=ntp
-VERSION=4.0.99k28
+VERSION=4.0.99k29
 
 cat >>confdefs.h <<EOF
 #define PACKAGE "$PACKAGE"
index 0119cd6be1e66f0dc25c1c2ac4e27e96d2b6a82a..d48da29a2edc53068c7ec12a23ee8cde723383bf 100644 (file)
@@ -5,7 +5,7 @@ AC_CANONICAL_SYSTEM
 AC_DEFINE_UNQUOTED(STR_SYSTEM, "$target")
 AM_CONFIG_HEADER(config.h)
 AC_ARG_PROGRAM
-AM_INIT_AUTOMAKE(ntp, 4.0.99k28)
+AM_INIT_AUTOMAKE(ntp, 4.0.99k29)
 AC_PREREQ(2.49)
 
 ac_cv_var_oncore_ok=no
index 1e62b4bbc1758c94f9080014e21680ec30803b91..7d89d2e2243ad5bf64f70eb55ea51b50788f9321 100644 (file)
@@ -234,6 +234,10 @@ normally 900 s.</dd>
 interval used when configuring multicast client, manycast client
 and , symmetric passive mode association. The value defaults to 6
 (64 s) and has a lower limit of 4 (16 s).</dd>
+
+<dt><tt>allan <i>allan</i></tt></dt>
+
+<dd>The argument becomes the new value for the minimum Allan intercept, which is a parameter of the PLL/FLL clock discipline algorithm. The value defaults to 1024 s, which is also lower limit 1024 s.</dd>
 </dl>
 </dd>
 
index b2c56a654a4232d869935ef0f80a4c254cf31451..fa9776f32bc443699c2a34215befec6b713d9dc8 100644 (file)
@@ -671,6 +671,7 @@ struct pkt {
 #define LOOP_PHI               5       /* set dispersion rate */
 #define LOOP_MINSTEP           6       /* set step timeout */
 #define LOOP_MINPOLL           7       /* set min poll interval (log2 s) */
+#define LOOP_ALLAN             8       /* set minimum Allan intercept */
 
 /*
  * Configuration items for the stats printer
index 94b5a30884229ff33add33eef3edf223a8680838..131b945e0e10bb8f6a2d28414b2b78b1ec124885 100644 (file)
 #define CONF_CLOCK_PHI         3
 #define CONF_CLOCK_MINSTEP     4
 #define CONF_CLOCK_MINPOLL     5
+#define CONF_CLOCK_ALLAN       6
 
 #ifdef PUBKEY
 /*
index 64aac8753cf83bf0f95b1335893f83056a90a89a..6d16f9ed3dd831975a07e58f6412c195c04a725e 100644 (file)
 #define PPS_MAXAGE 120         /* kernel pps signal timeout (s) */
 
 /*
- * Program variables
+ * Program variables that can be tinkered.
  */
-static double clock_offset;    /* clock offset adjustment (s) */
-double drift_comp;             /* clock frequency (s/s) */
-double clock_stability;        /* clock stability (s/s) */
 double clock_max = CLOCK_MAX;  /* max offset before step (s) */
 double clock_panic = CLOCK_PANIC; /* max offset before panic (s) */
 double clock_phi = CLOCK_PHI;  /* dispersion rate (s/s) */
 double clock_minstep = CLOCK_MINSTEP; /* step timeout (s) */
+double allan_xpt = CLOCK_ALLAN; /* minimum Allan intercept (s) */
+
+/*
+ * Program variables
+ */
+static double clock_offset;    /* clock offset adjustment (s) */
+double drift_comp;             /* clock frequency (s/s) */
+double clock_stability;        /* clock stability (s/s) */
 u_long pps_control;            /* last pps sample time */
 static void rstclock P((int)); /* state transition function */
 
@@ -149,7 +154,6 @@ int state;                  /* clock discipline state */
 int    tc_counter;             /* poll-adjust counter */
 u_long last_time;              /* time of last clock update (s) */
 double last_offset;            /* last clock offset (s) */
-double allan_xpt;              /* Allan intercept (s) */
 double sys_jitter;             /* system RMS jitter (s) */
 
 #if defined(KERNEL_PLL)
@@ -430,19 +434,20 @@ local_clock(
                         * Compute the FLL and PLL frequency adjustments
                         * conditioned on intricate weighting factors.
                         * For the FLL, the averaging interval is
-                        * clamped not to decrease below the Allan
-                        * intercept and the gain is decreased from
-                        * unity for mu above CLOCK_MINSEC (1024 s) to
-                        * zero below CLOCK_MINSEC (256 s). For the PLL,
-                        * the averaging interval is clamped not to
-                        * exceed the sustem poll interval. These
-                        * measures insure stability of the clock
-                        * discipline even when the rules of fair
-                        * engagement are broken.
+                        * clamped to a minimum of 1024 s and the gain
+                        * is decreased from unity for mu above 1024 s
+                        * to zero below 256 s. For the PLL, the
+                        * averaging interval is clamped not to exceed
+                        * the sustem poll interval. No gain factor is
+                        * necessary, since the frequency steering above
+                        * 1024 s is negligible. Particularly for the
+                        * PLL, these measures allow oversampling, but
+                        * not undersampling and insure stability even
+                        * when the rules of fair engagement are broken.
                         */
                        dtemp = max(mu, allan_xpt);
                        etemp = min(max(0, mu - CLOCK_MINSEC) /
-                           CLOCK_ALLAN, 1.);
+                           allan_xpt, 1.);
                        flladj = fp_offset * etemp / (dtemp *
                            CLOCK_AVG);
                        dtemp = ULOGTOD(SHIFT_PLL + 2 + sys_poll);
@@ -597,14 +602,18 @@ local_clock(
        dtemp = SQUARE(clock_stability);
        etemp = SQUARE(etemp) - dtemp;
        clock_stability = SQRT(dtemp + etemp / CLOCK_AVG);
-       allan_xpt = max(CLOCK_ALLAN, clock_stability * CLOCK_ADF);
 
        /*
-        * In SYNC state, adjust the poll interval.
+        * In SYNC state, adjust the poll interval. The trick here is to
+        * compare the apparent frequency change induced by the system
+        * jitter over the poll interval, or fritter, to the frequency
+        * stability. If the fritter is greater than the stability,
+        * phase noise predominates and the averaging interval is
+        * increased; otherwise, it is decreased. A bit of hysteresis
+        * helps calm the dance. Works best using burst mode.
         */
        if (state == S_SYNC) {
-               if (clock_stability < CLOCK_MAXSTAB &&
-                   fabs(clock_offset) < CLOCK_PGATE * sys_jitter) {
+               if (sys_jitter / mu > clock_stability) {
                        tc_counter += sys_poll;
                        if (tc_counter > CLOCK_LIMIT) {
                                tc_counter = CLOCK_LIMIT;
@@ -638,15 +647,15 @@ local_clock(
 #ifdef DEBUG
        if (debug > 1)
                printf(
-       "local_clock: mu %.0f allan %.0f fadj %.3f fll %.3f pll %.3f\n",
-                   mu, allan_xpt, clock_frequency * 1e6, flladj * 1e6,
-                   plladj * 1e6);
+       "local_clock: mu %.0f fadj %.3f fll %.3f pll %.3f\n",
+                   mu, clock_frequency * 1e6, flladj * 1e6, plladj *
+                   1e6);
 #endif /* DEBUG */
 #ifdef DEBUG
-       if (debug > 1)
+       if (debug)
                printf(
-                   "local_clock: jit %.6f freq %.3f stab %.3f poll %d cnt %d\n",
-                   sys_jitter, drift_comp * 1e6, clock_stability * 1e6,
+                   "local_clock: noise %.3f stabil %.3f poll %d count %d\n",
+                   sys_jitter * 1e6 / mu, clock_stability * 1e6,
                    sys_poll, tc_counter);
 #endif /* DEBUG */
        return (retval);
@@ -732,7 +741,6 @@ rstclock(
         */ 
        case S_FREQ:
                sys_poll = NTP_MINPOLL;
-               allan_xpt = CLOCK_ALLAN;
                last_time = current_time;
                break;
 
@@ -741,7 +749,6 @@ rstclock(
         */
        case S_SYNC:
                sys_poll = NTP_MINPOLL;
-               allan_xpt = CLOCK_ALLAN;
                tc_counter = 0;
                break;
 
@@ -758,7 +765,6 @@ rstclock(
         */
        default:
                sys_poll = NTP_MINPOLL;
-               allan_xpt = CLOCK_ALLAN;
                last_time = current_time;
                last_offset = clock_offset = 0;
                break;
@@ -875,26 +881,34 @@ loop_config(
 #endif /* KERNEL_PLL */
                break;
 
-       case LOOP_MAX:
+       /*
+        * Special tinker variables for Ulrich Windl. Very dangerous.
+        */
+       case LOOP_MAX:                  /* step threshold */
                clock_max = freq;
                break;
 
-       case LOOP_PANIC:
+       case LOOP_PANIC:                /* panic exit threshold */
                clock_panic = freq;
                break;
 
-       case LOOP_PHI:
+       case LOOP_PHI:                  /* dispersion rate */
                clock_phi = freq;
                break;
 
-       case LOOP_MINSTEP:
+       case LOOP_MINSTEP:              /* watchdog bark */
                clock_minstep = freq; 
                break;
 
-       case LOOP_MINPOLL:
+       case LOOP_MINPOLL:              /* ephemeral association poll */
                if (freq < NTP_MINPOLL)
                        freq = NTP_MINPOLL;
                sys_minpoll = (u_char)freq;
+
+       case LOOP_ALLAN:                /* minimum Allan intercept */
+               if (freq < CLOCK_ALLAN)
+                       freq = CLOCK_ALLAN;
+               allan_xpt = freq;
        }
 }
 
index 8ed65c982564ef6e5f23ba7e37c664771ac63ac1..98f4564ea56c1cb5a9a518649e8ed30f7f9294fa 100644 (file)
@@ -1305,11 +1305,10 @@ clock_filter(
         * Update dispersions since the last update and at the same
         * time initialize the distance and index vectors. The distance
         * is a compound metric: If the sample dispersion is less than
-        * MAXDISTANCE and younger than the Allan intercept, use delay.
-        * Otherwise, use MAXDISTANCE plus conventional distance.
+        * MAXDISTANCE and younger than the minimum Allan intercept, use
+        * delay. Otherwise, use MAXDISTANCE plus conventional distance.
         */
        dtemp = clock_phi * (current_time - peer->update);
-       etemp = min(allan_xpt, NTP_SHIFT * ULOGTOD(sys_poll));
        peer->update = current_time;
        for (i = NTP_SHIFT - 1; i >= 0; i--) {
                if (i != 0) {
@@ -1320,7 +1319,7 @@ clock_filter(
                ftemp = peer->filter_delay[j] / 2. +
                    peer->filter_disp[j];
                if (ftemp < MAXDISTANCE && current_time -
-                   peer->filter_epoch[j] < etemp)
+                   peer->filter_epoch[j] < allan_xpt)
                        dst[i] = peer->filter_delay[j];
                else
                        dst[i] = MAXDISTANCE + ftemp;
@@ -1329,7 +1328,7 @@ clock_filter(
        }
 
         /*
-        * Sort the sampsamples in the register by the compound metric.
+        * Sort the samples in the register by the compound metric.
         */
        for (i = 1; i < NTP_SHIFT; i++) {
                for (j = 0; j < i; j++) {