Change client_check() to calculate the best offset and the best frequency
authorMatthew Dillon <dillon@dragonflybsd.org>
Sun, 24 Apr 2005 09:39:27 +0000 (09:39 +0000)
committerMatthew Dillon <dillon@dragonflybsd.org>
Sun, 24 Apr 2005 09:39:27 +0000 (09:39 +0000)
commit8e4e981395a11a67f49963ba9795e3fefaf133b9
tree5c826974b03d91dadbe9d0d56939eda1af06931f
parent2e8f7384b6696885e2ed1bff46d0f47ab143c2da
Change client_check() to calculate the best offset and the best frequency
correction separately.

The best offset correction now utilizes a standard deviation of the offset
error with a minimum of 4 samples.  An offset correction occurs when the
standard deviation is less then 1/4 the average offset.  When an offset
correction is made, the offset data is cleared (since it becomes invalid
once a correction is made).  This calculation gives the code an almost
human perception of when the offset can be safely adjusted, regardless
of the 'mess' on the internet.

Change tv_delta_micro() into tv_delta_double() since most of the callers
were (previously) dividing the result by 1E6.

NOTE: the correllation for frequency correction is not working quite as
well as I had hoped, it's bouncing around a lot for internet ntp sources.
But the standard deviation on the offset appears to work very well.
usr.sbin/dntpd/client.c
usr.sbin/dntpd/client.h
usr.sbin/dntpd/convert.c
usr.sbin/dntpd/defs.h
usr.sbin/dntpd/ntpreq.c