[fa.tcp-ip] Voting on time

tcp-ip@ucbvax.ARPA (08/21/85)

From: Richard Johnson <raj@uci-icsa>

When DCN1's time got screwed up a while back, I decided to never
completely trust any system again.  Thus I changed my program which
gets the time upon system startup to use a rather involved system
of verification.  This program uses a udp broadcast on the local net
to get time from all local systems.  It also sends special udp requests
to any systems listed on the command line.  After getting all the replies
it averages all the localnet times, throughs out the time farthest from the
average if it's too far away (a parameter), and continues to do this
until it either gets a bunch of times within a specified range or has one
time left.  After all of this, if it has a "usable" average (taken from
more than one number all within the max. range), then it begins looking
through the times received from the "special requests".  The first one
of these it finds which is within another settable range of the local
average, it takes as an authority.

Basically the idea is to avoid asking the operator to set the time
as much as possible.  As a last resort we call a special program "settime"
which allows the operator to type in the date a time in almost any format
he feels like.  We always use "/bin/date" to actually set the time so that
accounting information is updated correctly (this was a fast hack and I
didn't feel like rewriting /bin/date).

This program is available with anonymous ftp (password guest) from
uci-icsa.arpa.  Warning: It has never been run through lint and thus
probably has lots of things in it people will not like.  If anyone makes
improvements, I would like to hear about them.

------------------------------------------------------------------------
Richard Johnson                             raj@uci.arpa          (ARPA)
UCI ICS Research Systems Manager            ucbvax!ucivax!raj     (UUCP)

tcp-ip@ucbvax.ARPA (08/22/85)

From: jsq%tzec.UTEXAS@ut-sally.ARPA (John Quarterman)

	Basically the idea is to avoid asking the operator to set the time
	as much as possible.

Same goal as I had, slightly different assumptions.  I decided not to average
over times from all known time servers because my experience in polling
actual servers is that they tend to cluster in groups of hosts with
times similar to a second or so, but the times of the groups can be
different by as much as a minute or more.  Also, the most accurate group
is almost always the fastest one, not the one in the middle.  And hosts
which set their time directly from WWV or some other accurate outside
source will almost always be more accurate than those which don't,
except for the occasional instances when they're wildly wrong.

Of course, since you choose to poll only your local network, and if
no system on it has a WWV clock, averaging makes much more sense.

Netdate does record the time change in /usr/adm/wtmp properly like /bin/date,
though I neglected to mention it in the manual entry.  I've updated the
manual entry for that and a couple of other omissions, and I've added
a few details to the verbose output option (the network delay is shown).
The result is available by anonymous ftp from ut-sally as ~ftp/pub/netdate.c
and ~ftp/pub/netdate.8.  Also in the same directory are udp.timed.c and
tcp.timed.c, which are implementations of the server end of RFC868,
suitable for use with inetd.  (Chris Kent earlier announced a UDP
time server that doesn't need inetd.)  Some people tried to retrieve
things this morning and couldn't:  we had a hardware problem with
a disk;  it's fixed now.

All these things have been run through lint, and we use them on several
systems here (im4u.ARPA and ut-sally.ARPA run both time servers).
However, they haven't been around long, so don't be surprised if they
have bugs, and please let me know about any you find.