From: Harlan Stenn Date: Sun, 20 Aug 2000 20:08:26 +0000 (-0000) Subject: Many files: X-Git-Tag: NTP_4_0_99_M~188 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=24afb71c13868b62e9e6566b4e1209cfa79206bc;p=thirdparty%2Fntp.git Many files: * util/ntptime.c (main): Report TAI stuff * ntpq/ntpq.c: CS_COMPLIANCE/CS_JITTER cleanup * ntpd/ntp_loopfilter.c (local_clock): sys_error/sys_jitter cleanup. kernel PPL cleanup. * ntpd/ntp_crypto.c: Check NTP_API if we're doing KERNEL_PLL so we can get the TAI stuff. * ntpd/ntp_control.c: CS_COMPLIANCE now reports "error" instead of "jitter". CS_JITTER now reports jitter. * include/ntpd.h: Added sys_jitter * include/ntp_control.h (CS_JITTER): Added From: Dave Mills bk: 39a03abaoCpAzZJSx21aNTeAEAwG2Q --- diff --git a/ChangeLog b/ChangeLog index 543d80307b..7a6517a8ab 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,17 @@ 2000-08-20 Harlan Stenn + * util/ntptime.c (main): Report TAI stuff + * ntpq/ntpq.c: CS_COMPLIANCE/CS_JITTER cleanup + * ntpd/ntp_loopfilter.c (local_clock): sys_error/sys_jitter cleanup. + kernel PPL cleanup. + * ntpd/ntp_crypto.c: Check NTP_API if we're doing KERNEL_PLL so we + can get the TAI stuff. + * ntpd/ntp_control.c: CS_COMPLIANCE now reports "error" instead of + "jitter". CS_JITTER now reports jitter. + * include/ntpd.h: Added sys_jitter + * include/ntp_control.h (CS_JITTER): Added + From: Dave Mills + * ntpd/cmd_args.c (getCmdOpts): Crack -N at pre-scan, as we do the priority wiggle before the final scan. From: Tom Smith diff --git a/include/ntp_control.h b/include/ntp_control.h index 624925b3ec..0210bf7165 100644 --- a/include/ntp_control.h +++ b/include/ntp_control.h @@ -158,20 +158,21 @@ struct ntp_control { #define CS_OFFSET 11 #define CS_DRIFT 12 #define CS_COMPLIANCE 13 -#define CS_CLOCK 14 -#define CS_PROCESSOR 15 -#define CS_SYSTEM 16 -#define CS_VERSION 17 -#define CS_STABIL 18 -#define CS_VARLIST 19 +#define CS_JITTER 14 +#define CS_CLOCK 15 +#define CS_PROCESSOR 16 +#define CS_SYSTEM 17 +#define CS_VERSION 18 +#define CS_STABIL 19 +#define CS_VARLIST 20 #ifdef PUBKEY -#define CS_FLAGS 20 -#define CS_HOST 21 -#define CS_PUBLIC 22 -#define CS_DHPARAMS 23 -#define CS_REVTIME 24 -#define CS_LEAPTAB 25 -#define CS_TAI 26 +#define CS_FLAGS 21 +#define CS_HOST 22 +#define CS_PUBLIC 23 +#define CS_DHPARAMS 24 +#define CS_REVTIME 25 +#define CS_LEAPTAB 26 +#define CS_TAI 27 #define CS_MAXCODE CS_TAI #else #define CS_MAXCODE CS_VARLIST diff --git a/include/ntpd.h b/include/ntpd.h index 653a77c390..fa9ed48996 100644 --- a/include/ntpd.h +++ b/include/ntpd.h @@ -286,7 +286,8 @@ extern int tc_counter; /* poll-adjust counter */ extern u_long last_time; /* time of last clock update (s) */ extern double last_offset; /* last clock offset (s) */ extern double allan_xpt; /* Allan intercept (s) */ -extern double sys_error; /* system standard error (s) */ +extern double sys_error; /* system RMS error (s) */ +extern double sys_jitter; /* system RMS jitter (s) */ /* ntp_monitor.c */ extern struct mon_data mon_mru_list; diff --git a/ntpd/ntp_control.c b/ntpd/ntp_control.c index 4c40fd74f8..527ac3012a 100644 --- a/ntpd/ntp_control.c +++ b/ntpd/ntp_control.c @@ -106,21 +106,22 @@ static struct ctl_var sys_var[] = { { CS_STATE, RO, "state" }, /* 10 */ { CS_OFFSET, RO, "phase" }, /* 11 */ { CS_DRIFT, RO, "frequency" }, /* 12 */ - { CS_COMPLIANCE, RO, "jitter" }, /* 13 */ - { CS_CLOCK, RO, "clock" }, /* 14 */ - { CS_PROCESSOR, RO, "processor" }, /* 15 */ - { CS_SYSTEM, RO, "system" }, /* 16 */ - { CS_VERSION, RO, "version" }, /* 17 */ - { CS_STABIL, RO, "stability" }, /* 18 */ - { CS_VARLIST, RO, "sys_var_list" }, /* 19 */ + { CS_COMPLIANCE, RO, "error" }, /* 13 */ + { CS_JITTER, RO, "jitter" }, /* 14 */ + { CS_CLOCK, RO, "clock" }, /* 15 */ + { CS_PROCESSOR, RO, "processor" }, /* 16 */ + { CS_SYSTEM, RO, "system" }, /* 17 */ + { CS_VERSION, RO, "version" }, /* 18 */ + { CS_STABIL, RO, "stability" }, /* 19 */ + { CS_VARLIST, RO, "sys_var_list" }, /* 20 */ #ifdef PUBKEY - { CS_FLAGS, RO, "flags" }, /* 20 */ - { CS_HOST, RO, "hostname" }, /* 21 */ - { CS_PUBLIC, RO, "publickey" }, /* 22 */ - { CS_DHPARAMS, RO, "params" }, /* 23 */ - { CS_REVTIME, RO, "refresh"}, /* 24 */ - { CS_LEAPTAB, RO, "leaptable" }, /* 25 */ - { CS_TAI, RO, "tai"}, /* 26 */ + { CS_FLAGS, RO, "flags" }, /* 21 */ + { CS_HOST, RO, "hostname" }, /* 22 */ + { CS_PUBLIC, RO, "publickey" }, /* 23 */ + { CS_DHPARAMS, RO, "params" }, /* 24 */ + { CS_REVTIME, RO, "refresh"}, /* 25 */ + { CS_LEAPTAB, RO, "leaptable" }, /* 26 */ + { CS_TAI, RO, "tai"}, /* 27 */ #endif /* PUBKEY */ { 0, EOV, "" } }; @@ -147,8 +148,9 @@ static u_char def_sys_var[] = { CS_CLOCK, CS_STATE, CS_OFFSET, - CS_DRIFT, CS_COMPLIANCE, + CS_JITTER, + CS_DRIFT, CS_STABIL, #ifdef PUBKEY CS_FLAGS, @@ -1220,6 +1222,10 @@ ctl_putsys( 1e3); break; + case CS_JITTER: + ctl_putdbl(sys_var[CS_JITTER].text, sys_jitter * 1e3); + break; + case CS_CLOCK: get_systime(&tmp); ctl_putts(sys_var[CS_CLOCK].text, &tmp); diff --git a/ntpd/ntp_crypto.c b/ntpd/ntp_crypto.c index b98e8b087f..431499cf29 100644 --- a/ntpd/ntp_crypto.c +++ b/ntpd/ntp_crypto.c @@ -15,6 +15,10 @@ #include "ntp_string.h" #include "ntp_crypto.h" +#ifdef KERNEL_PLL +#include "ntp_syscall.h" +#endif /* KERNEL_PLL */ + /* * Extension field message formats * @@ -312,6 +316,11 @@ crypto_recv( u_int rsalen = sizeof(R_RSA_PUBLIC_KEY) - sizeof(u_int) + 4; u_int bits; int j; +#ifdef KERNEL_PLL +#if NTP_API > 3 + struct timex ntv; /* kernel interface structure */ +#endif /* NTP_API */ +#endif /* KERNEL_PLL */ #endif /* PUBKEY */ /* @@ -788,6 +797,15 @@ crypto_recv( peer->flash &= ~TEST10; crypto_flags |= CRYPTO_FLAG_TAI; sys_tai = temp / 4 + TAI_1972 - 1; +#ifdef KERNEL_PLL +#if NTP_API > 3 + ntv.modes = MOD_TAI; + ntv.constant = sys_tai; + if (ntp_adjtime(&ntv) == TIME_ERROR) + msyslog(LOG_ERR, + "kernel TAI update failed"); +#endif /* NTP_API */ +#endif /* KERNEL_PLL */ /* * Initialize leapseconds table and extension @@ -1553,6 +1571,11 @@ crypto_tai( u_int len; char *rptr; int rval, i; +#ifdef KERNEL_PLL +#if NTP_API > 3 + struct timex ntv; /* kernel interface structure */ +#endif /* NTP_API */ +#endif /* KERNEL_PLL */ /* * Open the key file and discard comment lines. If the first @@ -1624,6 +1647,14 @@ crypto_tai( tai_leap.sig = emalloc(private_key.bits / 8); crypto_flags |= CRYPTO_FLAG_TAI; sys_tai = len / 4 + TAI_1972 - 1; +#ifdef KERNEL_PLL +#if NTP_API > 3 + ntv.modes = MOD_TAI; + ntv.constant = sys_tai; + if (ntp_adjtime(&ntv) == TIME_ERROR) + msyslog(LOG_ERR, "kernel TAI update failed"); +#endif /* NTP_API */ +#endif /* KERNEL_PLL */ /* diff --git a/ntpd/ntp_loopfilter.c b/ntpd/ntp_loopfilter.c index 5b62c1e81a..d507659803 100644 --- a/ntpd/ntp_loopfilter.c +++ b/ntpd/ntp_loopfilter.c @@ -97,7 +97,7 @@ static double clock_offset; /* clock offset adjustment (s) */ double drift_comp; /* clock frequency (ppm) */ double clock_stability; /* clock stability (ppm) */ double clock_max = CLOCK_MAX; /* max offset allowed before step (s) */ -static double clock_panic = CLOCK_PANIC; /* max offset allowed before panic */ +static double clock_panic = CLOCK_PANIC; /* max offset before panic */ u_long pps_control; /* last pps sample time */ static void rstclock P((int)); /* state transition function */ @@ -129,7 +129,8 @@ 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_error; /* system standard error (s) */ +double sys_error; /* system RMS error (s) */ +double sys_jitter; /* system RMS jitter (s) */ #if defined(KERNEL_PLL) /* Emacs cc-mode goes nuts if we split the next line... */ @@ -218,9 +219,9 @@ local_clock( /* * Update the jitter estimate. */ - oerror = sys_error; - dtemp = SQUARE(sys_error); - sys_error = SQRT(dtemp + (epsil - dtemp) / CLOCK_AVG); + oerror = sys_jitter; + dtemp = SQUARE(sys_jitter); + sys_jitter = SQRT(dtemp + (epsil - dtemp) / CLOCK_AVG); /* * Clock state machine transition function. This is where the @@ -507,23 +508,19 @@ local_clock( * If the kernel pps discipline is working, monitor its * performance. */ - if (ntv.status & STA_PPSTIME) { + if (ntv.status & STA_PPSTIME && ntv.status & + STA_PPSSIGNAL) { if (!pps_control) NLOG(NLOG_SYSEVENT)msyslog(LOG_INFO, "pps sync enabled"); pps_control = current_time; #ifdef STA_NANO if (pll_nano) - record_peer_stats( - &loopback_interface->sin, - ctlsysstatus(), ntv.offset / 1e9, - 0, ntv.jitter / 1e9, 0); + sys_jitter = ntv.jitter / 1e9; else #endif /* STA_NANO */ - record_peer_stats( - &loopback_interface->sin, - ctlsysstatus(), ntv.offset / 1e6, - 0, ntv.jitter / 1e6, 0); + sys_jitter = ntv.jitter / 1e6; + sys_poll = ntv.shift; } } #endif /* KERNEL_PLL */ @@ -551,7 +548,7 @@ local_clock( */ if (state == S_SYNC) { if (clock_stability < CLOCK_MAXSTAB && - fabs(clock_offset) < CLOCK_PGATE * sys_error) { + fabs(clock_offset) < CLOCK_PGATE * sys_jitter) { tc_counter += sys_poll; if (tc_counter > CLOCK_LIMIT) { tc_counter = CLOCK_LIMIT; @@ -577,11 +574,14 @@ local_clock( */ last_time = current_time; last_offset = clock_offset; - dtemp = peer->disp + SQRT(peer->variance + SQUARE(sys_error)); + dtemp = SQUARE(sys_error); + sys_error = SQRT(dtemp + (SQUARE(last_offset) - dtemp) / + CLOCK_AVG); + dtemp = peer->disp + SQRT(peer->variance + SQUARE(sys_jitter)); if ((peer->flags & FLAG_REFCLOCK) == 0 && dtemp < MINDISPERSE) dtemp = MINDISPERSE; sys_rootdispersion = peer->rootdispersion + dtemp; - (void)record_loop_stats(); + record_loop_stats(); #ifdef DEBUG if (debug > 1) printf( @@ -592,9 +592,9 @@ local_clock( #ifdef DEBUG if (debug > 1) printf( - "local_clock: jitter %.6f freq %.3f stab %.3f poll %d count %d\n", - sys_error, drift_comp * 1e6, clock_stability * 1e6, - sys_poll, tc_counter); + "local_clock: err %.6f jit %.6f freq %.3f stab %.3f poll %d cnt %d\n", + sys_error, sys_jitter, drift_comp * 1e6, + clock_stability * 1e6, sys_poll, tc_counter); #endif /* DEBUG */ return (retval); } diff --git a/ntpq/ntpq.c b/ntpq/ntpq.c index 912dc85063..4367b7593a 100644 --- a/ntpq/ntpq.c +++ b/ntpq/ntpq.c @@ -109,12 +109,14 @@ struct ctl_var sys_var[] = { { CS_STATE, UI, "state" }, /* 10 */ { CS_OFFSET, FL, "phase" }, /* 11 */ { CS_DRIFT, FS, "frequency" }, /* 12 */ - { CS_COMPLIANCE, FU, "jitter" }, /* 13 */ - { CS_CLOCK, TS, "clock" }, /* 14 */ - { CS_PROCESSOR, ST, "processor" }, /* 15 */ - { CS_SYSTEM, ST, "system" }, /* 16 */ - { CS_STABIL, FS, "stability" }, /* 17 */ - { CS_VARLIST, ST, "sys_var_list" }, /* 18 */ + { CS_COMPLIANCE, FU, "error" }, /* 13 */ + { CS_JITTER, FU, "jitter" }, /* 14 */ + { CS_CLOCK, TS, "clock" }, /* 15 */ + { CS_PROCESSOR, ST, "processor" }, /* 16 */ + { CS_SYSTEM, ST, "system" }, /* 17 */ + { CS_VERSION, ST, "version" }, /* 18 */ + { CS_STABIL, FS, "stability" }, /* 19 */ + { CS_VARLIST, ST, "sys_var_list" }, /* 20 */ { 0, EOV, "" } }; diff --git a/util/ntptime.c b/util/ntptime.c index 4aaa53f00a..effa1d60b4 100644 --- a/util/ntptime.c +++ b/util/ntptime.c @@ -258,12 +258,18 @@ main( ts.l_uf &= ts_mask; printf(" time %s, (.%0*d),\n", prettydate(&ts), fdigits, (int) time_frac); - printf(" maximum error %lu us, estimated error %lu us.\n", + printf(" maximum error %lu us, estimated error %lu us", (u_long)ntv.maxerror, (u_long)ntv.esterror); - if (rawtime) printf(" ntptime=%x.%x unixtime=%x.%0*d %s", + if (rawtime) + printf(" ntptime=%x.%x unixtime=%x.%0*d %s", (unsigned int) ts.l_ui, (unsigned int) ts.l_uf, (int) ntv.time.tv_sec, fdigits, (int) time_frac, ctime((const time_t *) &ntv.time.tv_sec)); +#if NTP_API > 3 + printf(", TAI offset %d\n", ntv.tai); +#else + printf("\n"); +#endif /* NTP_API */ } status = ntp_adjtime(&ntx); if (status < 0)