Skip to main content.

TimeSync Instructions

Prerequisites

TimeSync can be installed on NT 3.51 or 4.0, Windows 2000 and Windows XP. I have tested this version on NT 3.51 (build 1057 + Service Pack 5), NT 4.0 (build 1381 + Service Packs 4), Windows 2000 (Service Pack 2) and Windows XP. As Win95/98/ME and Win32s systems do not support Win32 services, TimeSync will not run on them.

To install the service, the user has to have sufficient privilege i.e. Administrator rights. A fairly accurate time source is required. This could be a machine with a radio clock or synchronizes with one that does. Please check the time of the machine where you intend to install TimeSync and ensure that it within 10 minutes of the wall clock time. The reason for this is that TimeSync will not change the time if the difference between the local clock and the remote machine exceeds 10 minutes. This is intentional and done to avoid changing the clock if the reference source is wildly off-course. The normal drift of a computer clock should not exceed 8 seconds a day without any synchronization software but I have seen rogue machines that deviate by more than 20 seconds per day! TimeSync can tame such beasts with ease.

Installation

Copy the executable (TimeSync.exe) to a suitable directory on the local disk. The suggested place is %SYSTEMROOT%\system32. Change directory to wherever you copied it to and type "TimeSync /?". You should see a brief list of accepted arguments. Now type "TimeSync /install <time source>" where <time source> is one or more of the following /domain, /nt_machine, /tcp_machine or /ntp_machine followed by the machine name. For simplified instructions check the install section of the FAQ.

For example, "TimeSync /install /domain=sales" will use the PDC of the domain sales. If the domain name or the entire <time source> argument is omitted, the PDC of the domain of the machine you are installing TimeSync on will be used as the time source.

For other parameters that might be useful at your site, check the section titled Command line arguments. If you have several NT domains I recommend that servers (and domain controllers) be synchronized with a machine outside the domain and workstations should use their PDC (i.e. leave the <time source> specification empty) or another server in the domain. The sample configuration file is supplied for you to customize.

If installation is successful you should see a message to that effect in the console window. TimeSync will now be running. If you would like to customize the startup, open the "Control Panel | Services" applet and click on TimeSync in the list of available services. If manual startup is required, click on "Startup..." and change the radio button in the dialog box. In the services window click on "Start". Within 5 seconds the status should show "Started". If an error occurs check the event log or the specified log file for details.

Once it is successfully started check the event log. You should see a startup message. By default, synching is performed when it starts and every 8 hours after that. If you would like it to sync at a different time, specify it by adding /at=<time> to the command line. For example, /at=15:30 will cause it to sync at 15:30:00. In order to sync as soon as TimeSync starts, omit the /at argument as /at=+0:0:0 is the default.

Maintenance

Check the log once a week to ensure that TimeSync is running smoothly. You should only see informational messages that the clock has been set. If an error is reported the message there should be self-explanatory. The value for the deviation should be considerably less than a second. On my machines they are usually in the order of 30-80 milliseconds with an occasional 200 milliseconds. If you redirected the log to a file instead of the NT event log, there will be no entries in the event log at all; they will be in the log file that you specified during installation.

Deinstallation

In a console window type "TimeSync /remove". The service will be removed and all the registry entries that were added during the install phase will be cleaned up. If errors occur, an appropriate message will be displayed. If you just want to stop and restart the service you may do so from the Control Panel | Services. There, select TimeSync and click on the Stop button followed by the Start button.

Upgrading from a previous version

TimeSync should always be removed using the instructions of the version that is currently running. To upgrade from version 1.0 execute TimeSync /remove in a console window. Copy the new version to %SYSTEMROOT%\System32 and then install it as per your requirements.

All versions of TimeSync prior to 1.0 required the following:

Note that in the current version, the remove control argument first stops the service if it is currently running; version 0.6 and earlier did not do this and hence you have to do both steps manually.

Remarks

The accuracy to which TimeSync can trim the local clock depends very much on the accuracy of the time source that is used. If /tcp_machine is used in the command line one could expect an accuracy of +- 1 second. If /ntp_machine is used on the command line the accuracy could be as high as +- 1 millisecond though in practice it will be +- 5 milliseconds. As the time used by TimeSync is UTC you can specify a time source that is in another time zone or half way around the globe. The network delay is taken into consideration when calculating the time. In other words, half of the time required from the transmission of the request to the receipt of the reply is added to the time. Caveat: this is approximate as it is impossible to know what the real delay was. The assumptions here are that the time for the transmission and reply are the same and, further, that the remote computer does not require any time to answer the request. In practice, however, these assumptions do not distort the result by any appreciable amount.

By default, each time source has to send 5 messages and the average deviation of all 5 are calculated before the time is changed. You may specify up to 10 time sources. The average of all time sources will be used as the reference time. Thus, the reference time may be averaged across multiple messages and multiple machines.

The latest version (after version 1.1) has some fault tolerance features that may interest large sites. With the /select control argument one can decide how many of the specified time sources are to be 'elected'. TimeSync will average the time over the 'elected' time sources. Therefore, one could specify 10 time sources but only use the best 2. TimeSync decides on who are the best by comparing the network delay; this is rough indication of the topological distance. Closer and less loaded servers will therefore get preference. Let's look at a simple example: let us assume that the user installed TimeSync with the following arguments: TimeSync /install /nt_machine=nt1 /nt_machine=nt2 /nt_machine=nt3 /select=1,8. He has specified 3 time sources: nt1, nt2 and nt3. Of these, one machine (due to the 1 in the select argument) will be elected as the time source by first asking all three machines for the time and picking the one with the lowest network delay. Once elected, this machine will be used as the definitive time source for 8 synchronization cycles. When the 8 synchronization cycles are up another election will be held. If the elected machine returns an error before the 8 synchronization cycles are over, an election will be forced at the next synchronization cycle. If the overhead associated with the election process is deemed as prohibitive, restricted mode can be turned on (by appending ",R" to the select parameters shown above) which will cause TimeSync to use the first of the machines that reply as the elected sources and will not ask all the configured time sources for their time.

Clock adjustment will enable the time to be kept within a much tighter range than without this feature. I have run it on several pathological cases and the end result has been very satisfactory. Here are some examples of machines that have been made to behave once TimeSync took over the reins. If, however,  the deviation is so large that adjustment is not practical, TimeSync will set the clock as if /adjust was not in effect. This will only happen if the deviation too large for TimeSync to correct in the time provided.

This and the previous version of TimeSync has been tested by the author on over 20 different machines without exhibiting any serious errors. There are over 1,000,000 machines that are currently using version 1.0 and higher.

TimeSync is meant only for NT systems.The port to Win9x/ME has been running in-house but there are no immediate plans to release it as it has quite a few limitations in comparison to the NT version.

Notes on the implementation

The TimeSync executable contains the installer, deinstaller, the service itself and the text of the event log messages. It stores registry parameters in the following key: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\TimeSync. The command line parameters that were entered during installation will be under the Parameters subkey.

The source was compiled with Microsoft VC++ 6.0 with SP 2.