He're the pre-IETF version of NTP. You'll have a whole week to play with this version before I get back from the IETF meeting in sunny Florida. louie System: ntp version 3.4 Patch #: 9 Priority: From: Description: Add dependency for ntpd.o on ntp.h so things sorta work even without doing a "make depend". Trash "ci" rule. Provide default value for number of bits/byte if not defined. Compute the Window shift mask inside of conditional code on XTAL so we get the correct value if configured without a crystal controled clock (!!) New -l option for ntpd to enable logging for clock adjust messages. Changed our idea of a bogus packet in the packet procedure to include a packet received before a poll is sent. Fix stupid bug in delay computation having to do with peer->precision. NOTE: TO GET THE STATISTICS NEEDED TO USE THE stat.pl SCRIPT, YOU MUST SPECIFY THE -l OPTION WHEN INVOKING ntpd. Repeat-By: Fix: Grab the new /pub/ntp.3.4/ntp-test.tar.Z file or apply this patch: From rn, say "| patch -p -N -d DIR", where DIR is your ntp source directory. Outside of rn, say "cd DIR; patch -p -N #define PATCHLEVEL 9 Index: Makefile *** Makefile.old Mon Apr 10 15:58:54 1989 --- Makefile Mon Apr 10 15:58:54 1989 *************** *** 1,6 **** ! # $Source: /usr/users/louie/ntp/RCS/Makefile,v $ $Revision: 3.4.1.4 $ $Date: 89/04/07 18:04:14 $ # # $Log: Makefile,v $ # Revision 3.4.1.4 89/04/07 18:04:14 louie # Add definition of NOSWAP for Ultrix systems. # --- 1,10 ---- ! # $Source: /usr/users/louie/ntp/RCS/Makefile,v $ $Revision: 3.4.1.5 $ $Date: 89/04/10 15:54:19 $ # # $Log: Makefile,v $ + # Revision 3.4.1.5 89/04/10 15:54:19 louie + # Add dependency for ntpd.o on ntp.h so things sorta work even without doing a + # "make depend". Trash "ci" rule. + # # Revision 3.4.1.4 89/04/07 18:04:14 louie # Add definition of NOSWAP for Ultrix systems. # *************** *** 136,144 **** ${CC} ${LDFLAGS} -DTEST -o sock_test ntp_sock.c ${LIBS} ${OBJS}: ntp.h Makefile ! ! ci: ! ci -u Makefile README ${SRCS} ${HDRS} ntp.conf test.c extract.pl stat.pl install: ${DESTDIR}${BINDIR}/ntpd ${DESTDIR}${BINDIR}/ntp ${DESTDIR}${BINDIR}/ntpdc ntest @./ntest --- 140,146 ---- ${CC} ${LDFLAGS} -DTEST -o sock_test ntp_sock.c ${LIBS} ${OBJS}: ntp.h Makefile ! ntpd.o: patchlevel.h install: ${DESTDIR}${BINDIR}/ntpd ${DESTDIR}${BINDIR}/ntp ${DESTDIR}${BINDIR}/ntpdc ntest @./ntest Index: ntp.h *** ntp.h.old Mon Apr 10 15:58:59 1989 --- ntp.h Mon Apr 10 15:59:01 1989 *************** *** 1,7 **** ! /* $Source: /usr/users/louie/ntp/RCS/ntp.h,v $ $Revision: 3.4.1.4 $ $Date: 89/03/31 16:34:50 $ */ /* * $Log: ntp.h,v $ * Revision 3.4.1.4 89/03/31 16:34:50 louie * Add bit in flags which allow a peer to be synced to. Changed a char to a bit * field so that it is always signed. --- 1,12 ---- ! /* $Source: /usr/users/louie/ntp/RCS/ntp.h,v $ $Revision: 3.4.1.5 $ $Date: 89/04/10 15:55:42 $ */ /* * $Log: ntp.h,v $ + * Revision 3.4.1.5 89/04/10 15:55:42 louie + * Provide default value for number of bits/byte if not defined. Compute the + * Window shift mask inside of conditional code on XTAL so we get the correct + * value if configured without a crystal controled clock (!!) + * * Revision 3.4.1.4 89/03/31 16:34:50 louie * Add bit in flags which allow a peer to be synced to. Changed a char to a bit * field so that it is always signed. *************** *** 63,68 **** --- 68,77 ---- #define FD_ZERO(p) bzero((char *)(p), sizeof(*(p))) #endif + #ifndef NBBY + #define NBBY 8 /* number of bits per byte */ + #endif + #define MAXNETIF 10 struct intf { *************** *** 136,147 **** #if XTAL == 0 #define PEER_SHIFT 4 #else #define PEER_SHIFT 8 #endif - #define NTP_WINDOW_SHIFT_MASK 0xff - #define PEER_SHIFT_MASK 0xff /* 2^PEER_SHIFT - 1 */ /* * 5.1 Uniform Phase Adjustments --- 145,156 ---- #if XTAL == 0 #define PEER_SHIFT 4 + #define NTP_WINDOW_SHIFT_MASK 0x0f #else #define PEER_SHIFT 8 + #define NTP_WINDOW_SHIFT_MASK 0xff #endif /* * 5.1 Uniform Phase Adjustments Index: ntp_proto.c *** ntp_proto.c.old Mon Apr 10 15:59:10 1989 --- ntp_proto.c Mon Apr 10 15:59:13 1989 *************** *** 1,5 **** #ifndef lint ! static char *rcsid = "$Source: /usr/users/louie/ntp/RCS/ntp_proto.c,v $ $Revision: 3.4.1.7 $ $Date: 89/04/08 10:36:53 $"; #endif /* --- 1,5 ---- #ifndef lint ! static char *rcsid = "$Source: /usr/users/louie/ntp/RCS/ntp_proto.c,v $ $Revision: 3.4.1.8 $ $Date: 89/04/10 15:57:59 $"; #endif /* *************** *** 11,16 **** --- 11,22 ---- /* * $Log: ntp_proto.c,v $ + * Revision 3.4.1.8 89/04/10 15:57:59 louie + * New -l option for ntpd to enable logging for clock adjust messages. Changed + * our idea of a bogus packet in the packet procedure to include a packet received + * before a poll is sent. Fix stupid bug in delay computation having to do with + * peer->precision. + * * Revision 3.4.1.7 89/04/08 10:36:53 louie * The syslog message for peer selection had to be moved to account for the * anti-peer flapping code just installed. *************** *** 119,125 **** extern int debug; extern void dump_pkt(); #endif ! extern int trusting; extern struct sysdata sys; extern struct list peer_list; extern struct ntp_peer *check_peer(); --- 125,131 ---- extern int debug; extern void dump_pkt(); #endif ! extern int trusting, logstats; extern struct sysdata sys; extern struct list peer_list; extern struct ntp_peer *check_peer(); *************** *** 217,223 **** if (i && peer->reach == 0) { syslog(LOG_INFO, "Lost reachability with %s", ! ntoa(peer->src.sin_addr)); #ifdef DEBUG if (debug) printf("Lost reachability with %s", --- 223,229 ---- if (i && peer->reach == 0) { syslog(LOG_INFO, "Lost reachability with %s", ! ntoa(peer->src.sin_addr)); #ifdef DEBUG if (debug) printf("Lost reachability with %s", *************** *** 450,456 **** bogus = ((pkt->org.int_part != peer->xmt.int_part) || (pkt->org.fraction != peer->xmt.fraction)) ! && (peer->xmt.int_part != 0); peer->pkt_rcvd++; peer->leap = pkt->status & LEAPMASK; --- 456,462 ---- bogus = ((pkt->org.int_part != peer->xmt.int_part) || (pkt->org.fraction != peer->xmt.fraction)) ! || (peer->xmt.int_part == 0); peer->pkt_rcvd++; peer->leap = pkt->status & LEAPMASK; *************** *** 496,502 **** offset = ((t2 - t1) + (t3 - t4)) / 2.0; delay += NTP_MAXSKW + 1.0/(unsigned long)(1L << -sys.precision); ! if (-peer->precision < sizeof(long)) delay += 1.0/(unsigned long)(1L << -peer->precision); if (delay < 0.0) { --- 502,508 ---- offset = ((t2 - t1) + (t3 - t4)) / 2.0; delay += NTP_MAXSKW + 1.0/(unsigned long)(1L << -sys.precision); ! if (peer->precision < 0 && -peer->precision < sizeof(long)*NBBY) delay += 1.0/(unsigned long)(1L << -peer->precision); if (delay < 0.0) { *************** *** 591,604 **** clock_watchdog = 0; /* reset watchdog timer */ if (adj_logical(peer->estoffset) > 0) { register struct ntp_peer *p = peer_list.head; - /* did you know syslog only took 4 parameters? */ sprintf(buf, ! "adjust: STEP %s st %d off %f drft %f cmpl %f", inet_ntoa(peer->src.sin_addr), peer->stratum, peer->estoffset, drift_comp, compliance); syslog(LOG_INFO, buf); - #ifdef DEBUG if (debug) printf("Clockset from %s stratum %d offset %f\n", --- 597,608 ---- clock_watchdog = 0; /* reset watchdog timer */ if (adj_logical(peer->estoffset) > 0) { register struct ntp_peer *p = peer_list.head; /* did you know syslog only took 4 parameters? */ sprintf(buf, ! "adjust: STEP %s st %d off %f drft %f cmpl %f", inet_ntoa(peer->src.sin_addr), peer->stratum, peer->estoffset, drift_comp, compliance); syslog(LOG_INFO, buf); #ifdef DEBUG if (debug) printf("Clockset from %s stratum %d offset %f\n", *************** *** 616,626 **** printf("clock_updates: STEP ADJ\n"); #endif } else { ! sprintf(buf, ! "adjust: SLEW %s st %d off %f drft %f cmpl %f", ! inet_ntoa(peer->src.sin_addr), peer->stratum, ! peer->estoffset, drift_comp, compliance); ! syslog(LOG_INFO, buf); } } } --- 620,634 ---- printf("clock_updates: STEP ADJ\n"); #endif } else { ! if (logstats) { ! sprintf(buf, ! "adjust: SLEW %s st %d off %f drft %f cmpl %f", ! inet_ntoa(peer->src.sin_addr), ! peer->stratum, ! peer->estoffset, drift_comp, ! compliance); ! syslog(LOG_INFO, buf); ! } } } } *************** *** 1001,1007 **** 1.0/(unsigned long)(1L << -sys.precision); /* make sure we don't try to divide by zero */ ! if (-sel_lst[0].peer->precision < sizeof(long)) threshold += 1.0/(unsigned long) (1L << -sel_lst[0].peer->precision); --- 1009,1015 ---- 1.0/(unsigned long)(1L << -sys.precision); /* make sure we don't try to divide by zero */ ! if (-sel_lst[0].peer->precision < sizeof(long)*NBBY) threshold += 1.0/(unsigned long) (1L << -sel_lst[0].peer->precision); Index: ntpd.c *** ntpd.c.old Mon Apr 10 15:59:22 1989 --- ntpd.c Mon Apr 10 15:59:25 1989 *************** *** 1,9 **** #ifndef lint ! static char *rcsid = "$Source: /usr/users/louie/ntp/RCS/ntpd.c,v $ $Revision: 3.4.1.6 $ $Date: 89/04/07 19:09:04 $"; #endif lint /* * $Log: ntpd.c,v $ * Revision 3.4.1.6 89/04/07 19:09:04 louie * Added NOSWAP code for Ultrix systems to lock NTP process in memory. Deleted * unused variable in ntpd.c --- 1,12 ---- #ifndef lint ! static char *rcsid = "$Source: /usr/users/louie/ntp/RCS/ntpd.c,v $ $Revision: 3.4.1.7 $ $Date: 89/04/10 15:58:45 $"; #endif lint /* * $Log: ntpd.c,v $ + * Revision 3.4.1.7 89/04/10 15:58:45 louie + * Add -l option to enable logging of clock adjust messages. + * * Revision 3.4.1.6 89/04/07 19:09:04 louie * Added NOSWAP code for Ultrix systems to lock NTP process in memory. Deleted * unused variable in ntpd.c *************** *** 130,135 **** --- 133,139 ---- int ticked; int selfds; int trusting = 1; + int logstats; double WayTooBig = WAYTOOBIG; unsigned long clock_watchdog; *************** *** 168,174 **** then allow others to override default values */ prog_name = argv[0]; ! while ((cc = getopt(argc, argv, "a:c:dD:stn")) != EOF) { switch (cc) { case 'a': if (strcmp(optarg, "any") == 0) --- 172,178 ---- then allow others to override default values */ prog_name = argv[0]; ! while ((cc = getopt(argc, argv, "a:c:dD:lstn")) != EOF) { switch (cc) { case 'a': if (strcmp(optarg, "any") == 0) *************** *** 217,222 **** --- 221,230 ---- #endif break; + case 'l': + logstats = 1; + break; + case 'c': conf = optarg; break; *************** *** 267,278 **** setlogmask(LOG_UPTO(LOG_INFO)); #endif /* LOG_DAEMON */ ! syslog(LOG_NOTICE, "%s version $Revision: 3.4.1.6 $", prog_name); syslog(LOG_NOTICE, "patchlevel %d", PATCHLEVEL); #ifdef DEBUG if (debug) ! printf("%s version $Revision: 3.4.1.6 $ patchlevel %d\n", prog_name, PATCHLEVEL); #endif (void) setpriority(PRIO_PROCESS, 0, -10); --- 275,286 ---- setlogmask(LOG_UPTO(LOG_INFO)); #endif /* LOG_DAEMON */ ! syslog(LOG_NOTICE, "%s version $Revision: 3.4.1.7 $", prog_name); syslog(LOG_NOTICE, "patchlevel %d", PATCHLEVEL); #ifdef DEBUG if (debug) ! printf("%s version $Revision: 3.4.1.7 $ patchlevel %d\n", prog_name, PATCHLEVEL); #endif (void) setpriority(PRIO_PROCESS, 0, -10); .