summaryrefslogtreecommitdiff
path: root/usr.sbin/ntpd/client.c
diff options
context:
space:
mode:
authorHenning Brauer <henning@cvs.openbsd.org>2004-07-06 23:26:39 +0000
committerHenning Brauer <henning@cvs.openbsd.org>2004-07-06 23:26:39 +0000
commit685ec648052416336ac93c79aa54817635fdbf04 (patch)
tree3f0941e31f6c5841b64461bacaaf0423d5ec83b5 /usr.sbin/ntpd/client.c
parent9e91f0bb4d0b8ee60f485d09fe67d238d13a4d91 (diff)
Implement the clock filter as descirbed by David Mills:
form the last 8 replied received from a peer, find the one with the lowest delay. Use that as the peer's update taken into account for calculating the local clock's offset. Invalidate that reply and all ones received earlier than it so that they do not get used again.
Diffstat (limited to 'usr.sbin/ntpd/client.c')
-rw-r--r--usr.sbin/ntpd/client.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/usr.sbin/ntpd/client.c b/usr.sbin/ntpd/client.c
index 70560973270..f877e1f944e 100644
--- a/usr.sbin/ntpd/client.c
+++ b/usr.sbin/ntpd/client.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: client.c,v 1.10 2004/07/06 19:06:43 henning Exp $ */
+/* $OpenBSD: client.c,v 1.11 2004/07/06 23:26:38 henning Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -138,16 +138,19 @@ client_dispatch(struct ntp_peer *p)
T2 = lfp_to_d(msg.rectime);
T3 = lfp_to_d(msg.xmttime);
- p->offset[p->shift] = ((T2 - T1) + (T3 - T4)) / 2;
- p->delay[p->shift] = (T2 - T1) - (T3 - T4);
+ p->reply[p->shift].offset = ((T2 - T1) + (T3 - T4)) / 2;
+ p->reply[p->shift].delay = (T4 - T1) - (T2 - T3);
+ p->reply[p->shift].error = (T2 - T1) - (T3 - T4);
+ p->reply[p->shift].rcvd = time(NULL);
+ p->reply[p->shift].good = 1;
p->state = STATE_REPLY_RECEIVED;
p->next = time(NULL) + INTERVAL_QUERY;
p->deadline = 0;
log_debug("reply received from %s: offset %f delay %f",
- log_sockaddr((struct sockaddr *)&fsa), p->offset[p->shift],
- p->delay[p->shift]);
+ log_sockaddr((struct sockaddr *)&fsa), p->reply[p->shift].offset,
+ p->reply[p->shift].delay);
if (++p->shift >= OFFSET_ARRAY_SIZE) {
p->shift = 0;