beware sntp
a Simple Network Time Protocol client/server for windows.
download
current version: 1.5.3
bsntp.zip
features:
- small, non bloated, lightweight. no graphics. no nag screens. no GUI.
- highly accurate. corrects for clock drift. can keep a PC synched to the millisecond in a lan environment.
- can run as server so other computers can sync to it.
- secure: protection against reply poisoning.
- IPv6 support
- runs invisible
- configuration using config files, output using log file.
- can run as NT system service.
- can use multiple servers for redundancy, and uses the average of the replies.
- can reject replies, based on too high lag. (adjustable)
changelog
changes in 1.5.3
- fixed that it was broken on windows 8 and newer
changes in 1.5.2
- fixed a bug which could cause it to crash sometimes
- have at least a delay of 64 seconds between polls in a case where it would be 15 seconds
changes in 1.5.1
- fixed inaccuracy bug happening on windows vista/7 (giving random errors in the order of 10 ms)
- fixed a bug that causes a division by zero crash if one of multiple servers does not respond
- allow listening on multiple explicit IP addresses as necessary to send reply on correct (ipv6) address if running as server
changes in 1.5
- deal with the PC suspending or hibernating
changes in 1.41
- fixed: incorrect handling of failure to resolve hostname, causing crash when network connection is lost.
changes in 1.4
- included a default servers.ini with a working address for ease of use (ntp.bsntp.bircd.org, this currently points to pool.ntp.org)
- requests now come from secure random local ports, and increased lowest random bits from 12 to 16, for security against reply poisoning.
changes in 1.3
- support for IPv6
- fixed the cause of drift correction not working, as well as still being about 10 ms inaccurate, it's now really accurate to the milisecond.
changes in 1.2
- properly interpret stratum 0 as error, and show the error code in ascii
- stop quering a server if some error codes are received (support "kiss of death")
- when generating NTP timestamps, fill in secure random bits for the lowest bits to protect against time poisoning
- log received incorrect timestamps (possibly indicates packet injection attempt)
changes in 1.1
- fixed the bug that sockets are not destroyed and it end up with lots of UDP ports used
- fixed crashes because of socket errors, they are now logged
- program syncs time accurate to 1 ms, for NT clock behavior (tested on 2000)
- 1.0 had problem of setting the time with an error of 30 ms backwards.
- new feature: detect and compensate for drift; the clock being stable but too slow or fast
manual
follow these steps in order to set up beware sntp. i assume you have basic knowledge of windows, networking, editing config files, etc. i am not responsible if you damage something.
make a directory, unzip the contents of the zip into that directory.
bsntp.ini
edit bsntp.ini to options which you prefer
explanation of options:
server= 0 or 1
if "1", program runs as server, allowing other sntp clients to sync to it.
ServerPort= number
port on which the server listens. the NTP port is 123.
ServerInterface= IP
interface on which the server listens. if you dont know what this means, leave it empty. to set multiple IP addresses, give a comma separated list
UpdateFrequency= number
each nnnn seconds, the program conacts NTP servers and adjusts the clock.
TimeOut= number
seconds to wait for a reply of a server before moving on to the next server.
LogFlags= number
which events to log (bitmask): -1 = everything, 2=all adjustments, 4=misc, 8=start/stop,
16=difference between server, 32=drift internal status, 64=network related errors, 128=dns lookups,
256=reponses, 512=response detailed information, 1024=requests from clients, 2048=other errors
UpdateOnce= 0 or 1.
if "1", program contacts servers and updates clock once, then quits.
MaxLag= number (float)
consider replies with more lag, in seconds, than this, invalid.
MaxAdjustment= number
if the adjustment is more than this, in seconds, and drift is enabled, make an adjustment of "maxadjustment"
IgnoreHighestLag= 0 or 1
if enabled, and multiple servers are configured, ignore the reply with the highest latency (useful to deal with lag spikes)
AdjustDrift= 0 or 1
measure drift and update/write the value.
ApplyDrift= 0 or 1
change the PC clock to compensate for known drift, by stepping with 1 ms at a time.
servers.ini
in servers.ini, fill in the hostname or IP address of servers, one per line. optional "host port".
Note that servers.ini is read every time the program performs an update; you can modify it without stopping/starting the program. note that this is *not* windows ini (name=value) format.
automatic startup
windows 9x/ME: in the registry or startup folder, or using a program known as "Custom Startup", put an entry for this program, to cause it to start each time you start the pc.
Windows NT/2000/XP: installing as system service: on the command prompt, being in the directory of bsntp, enter "bsntp install". you can "type output.txt" to see if it succeeded. then you can do "net start bewaresntp" and/or set the service to start automatically, using control panel/services.
uninstalling
if you made one, first remove the auto-start entry.
if you installed the program as NT service, on the command prompt, in the bsntp directory, type "bsntp uninstall", read output.txt to verify correct uninstall.
if the program still runs, stop it (by using Ctrl+Alt+Del).
now you can delete the bsntp folder and its contents.
notes
- if you choose to run bsntp as server for a LAN, it may be wise to block the port to internet, using the firewall. if you have the choice, only have the port listen on the LAN interface. If you don't need it, disable the server functionality. read the "bsntp.ini" section for this.
- bsntp can act as time server without acting as time client, if you use an empty servers.ini. this can be of use if something else synchs the clock.