From: Harlan Stenn Date: Mon, 23 Apr 2001 21:12:38 +0000 (-0000) Subject: ChangeLog, miscopt.htm, ntp.h, ntp_config.h, ntp_loopfilter.c, ntp_proto.c: X-Git-Tag: NTP_4_0_99_M~43 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c7782324f2f2f62d2937df41c721e02f2cee80cc;p=thirdparty%2Fntp.git ChangeLog, miscopt.htm, ntp.h, ntp_config.h, ntp_loopfilter.c, ntp_proto.c: * 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 --- diff --git a/ChangeLog b/ChangeLog index 1e741c375c..4e6b5afb1f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,22 @@ 2001-04-23 Harlan Stenn + * 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 diff --git a/configure b/configure index 6e562a34aa..175c313dc0 100755 --- 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 < 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). + +
allan allan
+ +
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.
diff --git a/include/ntp.h b/include/ntp.h index b2c56a654a..fa9776f32b 100644 --- a/include/ntp.h +++ b/include/ntp.h @@ -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 diff --git a/include/ntp_config.h b/include/ntp_config.h index 94b5a30884..131b945e0e 100644 --- a/include/ntp_config.h +++ b/include/ntp_config.h @@ -132,6 +132,7 @@ #define CONF_CLOCK_PHI 3 #define CONF_CLOCK_MINSTEP 4 #define CONF_CLOCK_MINPOLL 5 +#define CONF_CLOCK_ALLAN 6 #ifdef PUBKEY /* diff --git a/ntpd/ntp_loopfilter.c b/ntpd/ntp_loopfilter.c index 64aac8753c..6d16f9ed3d 100644 --- a/ntpd/ntp_loopfilter.c +++ b/ntpd/ntp_loopfilter.c @@ -109,15 +109,20 @@ #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; } } diff --git a/ntpd/ntp_proto.c b/ntpd/ntp_proto.c index 8ed65c9825..98f4564ea5 100644 --- a/ntpd/ntp_proto.c +++ b/ntpd/ntp_proto.c @@ -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++) {