Browse Source

use RMS for jitter. we're linking with enough libraries that libm is tiny.

ok deraadt
OPENBSD_5_9
tedu 9 years ago
parent
commit
4c1a084e50
2 changed files with 9 additions and 9 deletions
  1. +2
    -2
      src/usr.sbin/ntpd/Makefile
  2. +7
    -7
      src/usr.sbin/ntpd/control.c

+ 2
- 2
src/usr.sbin/ntpd/Makefile View File

@ -1,4 +1,4 @@
# $OpenBSD: Makefile,v 1.15 2015/10/05 17:26:22 deraadt Exp $
# $OpenBSD: Makefile,v 1.16 2015/11/20 18:53:42 tedu Exp $
PROG= ntpd
SRCS= ntpd.c log.c ntp.c ntp_msg.c parse.y config.c \
@ -11,7 +11,7 @@ CFLAGS+= -Wmissing-declarations
CFLAGS+= -Wshadow -Wpointer-arith -Wcast-qual
CFLAGS+= -Wsign-compare
YFLAGS=
LDADD+= -lutil -ltls -lssl -lcrypto
LDADD+= -lm -lutil -ltls -lssl -lcrypto
DPADD+= ${LIBUTIL} ${LIBCRYPTO} ${LIBSSL} ${LIBTLS}
LINKS= ${BINDIR}/ntpd ${BINDIR}/ntpctl
MAN= ntpd.8 ntpd.conf.5 ntpctl.8


+ 7
- 7
src/usr.sbin/ntpd/control.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: control.c,v 1.7 2015/10/23 14:52:20 phessler Exp $ */
/* $OpenBSD: control.c,v 1.8 2015/11/20 18:53:42 tedu Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@ -22,6 +22,7 @@
#include <sys/socket.h>
#include <sys/un.h>
#include <errno.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -33,6 +34,8 @@
#define CONTROL_BACKLOG 5
#define square(x) ((x) * (x))
int
control_init(char *path)
{
@ -354,21 +357,18 @@ build_show_peer(struct ctl_show_peer *cp, struct ntp_peer *p)
cp->delay /= validdelaycnt;
}
/*
* use simple average for jitter calculation, as the
* RFC5905-recommended RMS average needs the math library
*/
jittercnt = 0;
cp->jitter = 0.0;
for (shift = 0; shift < OFFSET_ARRAY_SIZE; shift++) {
if (p->reply[shift].delay > 0.0 && shift != best) {
cp->jitter += p->reply[shift].delay -
p->reply[best].delay;
cp->jitter += square(p->reply[shift].delay -
p->reply[best].delay);
jittercnt++;
}
}
if (jittercnt > 1)
cp->jitter /= jittercnt;
cp->jitter = sqrt(cp->jitter);
if (p->shift == 0)
shift = OFFSET_ARRAY_SIZE - 1;


Loading…
Cancel
Save