beware sntp
a Simple Network Time Protocol client/server for windows.
download
version 1.1
bsntp.zip
changes since 1.0
- 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
update: keep the drift feature disabled because it does not work correctly.
features
- small, non bloated, lightweight. no graphics. no nag screens. no GUI.
- 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)
- can run as server so other computers can sync to it.
- syncs accurate to the milisecond with the exception of errors introduced by unstable/asymmetric lag.
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 0.0.0.0.
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, and drift is enabled, make an adjustment of "maxadjustment"
Drift= 0 or 1
enable or disable clock drift correction
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 everytime 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.