Copyright: 1995, Gregorian Programmers Guild


Netdate
netdate for Win 3.1

Copyright © 1995, Gregorian Programmers Guild

Steeve McCauley - steeve@eps.mcgill.ca

This is netdate v. 1.04. I wrote netdate to synchronise my desktop PC's clock with my Unix server. The program requires that you give it a host which is providing the time service on Port 37 (most, if not all unix boxes, although some may block this service). Getting time from a unix box you know is using NTP will give you the most accurate time on your desktop PC. This program seems to be accurate to within about +/- 1 sec.

You must also specify your local timezone. Basically there are two methods for specifying the Time Zone. You can either setup a TZ environment variable in DOS (the hard way) or specify a city from the time zone drop down list box. I've also provided a method to adjust the time ahead one half hour for those of you living in Newfoundland, Bombay, Calcutta, Delhi, Rangoon, ...

Click below for a description of netdate options.

Refer to the file rfc868.txt for a description of the time service on port 37.

Author:	Steeve McCauley

eMail:	steeve@eps.mcgill.ca

WWW:	http://www.eps.mcgill.ca/~steeve


Advanced Options


rfc868

Network Working Group	J. Postel - ISI

Request for Comments: 868	K. Harrenstien - SRI

May 1983

Time Protocol

This RFC specifies a standard for the ARPA Internet community. Hosts on the ARPA Internet that choose to implement a Time Protocol are expected to adopt and implement this standard.

This protocol provides a site-independent, machine readable date and time. The Time service sends back to the originating source the time in seconds since midnight on January first 1900.

One motivation arises from the fact that not all systems have a date/time clock, and all are subject to occasional human or machine error. The use of time-servers makes it possible to quickly confirm or correct a system's idea of the time, by making a brief poll of several independent sites on the network.

This protocol may be used either above the Transmission Control Protocol (TCP) or above the User Datagram Protocol (UDP).

When used via TCP the time service works as follows:

S: Listen on port 37 (45 octal).

U: Connect to port 37.

S: Send the time as a 32 bit binary number.

U: Receive the time.

U: Close the connection.

S: Close the connection.

The server listens for a connection on port 37. When the connection is established, the server returns a 32-bit time value and closes the connection. If the server is unable to determine the time at its site, it should either refuse the connection or close it without sending anything.

When used via UDP the time service works as follows:

S: Listen on port 37 (45 octal).

U: Send an empty datagram to port 37.

S: Receive the empty datagram.

S: Send a datagram containing the time as a 32 bit binary number.

U: Receive the time datagram.

The server listens for a datagram on port 37.  When a datagram arrives, the server returns a datagram containing the 32-bit time value.  If the server is unable to determine the time at its site, it should discard the arriving datagram and make no reply.

The Time

The time is the number of seconds since 00:00 (midnight) 1 January 1900 GMT, such that the time 1 is 12:00:01 am on 1 January 1900 GMT; this base will serve until the year 2036.

For example:

the time

2,208,988,800 corresponds to 00:00  1 Jan 1970 GMT,

2,398,291,200 corresponds to 00:00  1 Jan 1976 GMT,

2,524,521,600 corresponds to 00:00  1 Jan 1980 GMT,

2,629,584,000 corresponds to 00:00  1 May 1983 GMT,

-1,297,728,000 corresponds to 00:00 17 Nov 1858 GMT.


Host: Specify a host from which you would like to get time. If you don't know of any try tick.usno.navy.mil or tock.usno.navy.mil. You'll also have to specify your local timezone.


Local Time Zone: If you are not using the TZ environment variable this drop down list allows you to select a city which you know matches your local time zone.

Note: If any of the time zone information in this list is wrong please let me know. Many of the time zones I had to hack since I couldn't find any definitive TZ code lists and the DOS timezone routines do not allow for some of the fancy adjustments possible with many Unix systems.


TZ: The currently selected time zone.


Use Daylight Savings Time: If you live in an area where daylight savings time does not apply click this button off. This effectively subtracts  3600 seconds from the time returned by the host.


Use TZ Environment Variable: If this button is greyed you do not have a TZ environment variable set in DOS. Select a time zone from the Local TZ drop down list. Otherwise, click it on to use the TZ environment variable, or off to select a TZ from the list. If you wish to use the TZ environment variable it should be set in your autoexec.bat file, for example,

set TZ=EST5EDT


Add 30 Minutes: If you live in Newfoundland (or any other locale where local time is not an even number of hours from GMT) click on this button to adjust the time accordingly.


Report Only: If you just want to see the time from the host without actually resetting your system clock click on this button.


Auto Close: If you click on Auto Close the program will automatically close 5 seconds after time is recieved from a remote host. This gives one enough time to turn this option off.


About: Click on the About button to get all the gory details, including how to snarf a copy of my desktop windows program DWM, which is meant to replace that monstrosity Program Manager and, IMHO, does that very nicely. The latest version of dwm is, at the time of this writing, 1.21b but version 2.00 will be out REAL SOON NOW. To get a copy of dwm ftp anonymously to ftp.eps.mcgill.ca and look in the directory /pub/windows for dwm121b.zip (or dwm200.zip).


Get Time: Click this button to manually retrieve the time from the host.


Close: Quit netdate


Date: Current date.


Time: Time recieved from the host


Diff: This is the difference, in seconds, between the time received from the host and the local time (just before the time is reset).


Net Lag: This represents the amount of time (in milliseconds) that it takes for the time data to be returned from the host. Normally the net lag is less than 1 second and so doesn't affect the clock setting. If the net lag is greater than 2000 ms this will have an effect on the final time setting.


Max Adjust: Specify 0 to have no maximum time adjustment. Otherwise, enter an integer between 1 and 65353 representing the largest time adjustment. If the time returned differs from the local time by more than this value a message box will prompt asking whether you want to override the maximum adjustment.


Prompt: the user is prompted to deal with the event


Ignore: the time recieved is automatically ignored


Accept: the time recieved is automatically accepted


Use log: Specify use log to enable logging. You must also specify a logfile. Normal logging records contain the following fields,

  host date TZ Net_Time Cur_Time Diff Total_Net_Lag Action

host:	host from which the time was received

date:	date time recieved

TZ:	time zone

Net_Time:	time recieved from host

Cur_Time:	local time when time recieved

Diff:	Net_Time-Cur_Time

Total_Net_Lag:	Total time communicating with host (ms)

Action:	one of report, reset, ignore, prompt, accept or partial


Verbose: Specify Verbose for extra logging information. Verbose logging records contain the following fields,

host date TZ Net_Time Cur_Time Net_Time_Secs Cur_Time_Secs Diff Total_Net_Lag Connect_Net_Lag Action

host:	host from which the time was received

date:	date time recieved

TZ:	time zone

Net_Time:	time recieved from host

Cur_Time:	local time when time recieved

Net_Time_Secs:	Net_Time in seconds from 00:00:00 January 1 1970 GMT

Cur_Time_Secs:	Cur_Time in secons from 00:00:00 January 1 1970 GMT

Diff:	Net_Time-Cur_Time

Total_Net_Lag:	Total time communicating with host (ms)

Connect_Net_Lag	Time to connect (ms)

Action:	one of report, reset, ignore, prompt, accept or partial


Log File: Click here to select a log file.


Log Path: If filled this represents the file to which all logging is done.


Calibration attempts: Specify the number of times that netdate retrieves the time in order to calibrate the net lag. Since the first connect often takes longer than subsequent connects this eliminates the problem of overestimated net lags. Typically a value of 2 or 3 will be sufficient.