NTP Protocol Tcl Commands


Network Time Protocol (NTP) Tcl Commands


dmh::dmh_ntp_install server ?refresh_seconds? ?timeport?

dmh::dmh_ntp_query server ?timeport?



These commands may be used to obtain accurate clock readings from Network Time Protocol servers connected through TCP/IP. The dmh_ntp_query command returns a floating point value giving the offset in time measured in seconds of your system clock and the specified server. The server argument is the hostname or IP address of the NTP server. Any version NTP server should be able to answer the version 1.0 Simple Network Time Protocol (SNTP) client request. The optional timeport argument defaults to 123 which is correct in almost all situations. If the query fails, an empty string is returned. The propogation delay through the network is accounted for in a simple way, and no attempt is made to compensate for variation in the propogation delay.

The dmh_ntp_install command is used to replace the usual localtime Tcl command with a version that is corrected using the time offset returned from the NTP server. The optional refresh_seconds argument is used to specify a refresh interval, measured in seconds, at which the NTP server will be queried. The value 0 is used to indicate that periodic refreshment is not wanted.

The dmh_ntp_status command is used to determine if an NTP server has been successfully queried. The command returns a three element list containing

  1. the integral number of seconds offset
  2. the integral number of microseconds offset
  3. the server that supplied the time values
for the last successful use of the dmh_ntp_query command.


www.ntp.org     localtime     clock


Hume Integration Software. This is licensed and supported software, (C)Copyright 1999 All Rights Reserved.


time date NTP SNTP