[ntp:questions] Re: This is tougher than I thought?

David J Taylor david-taylor at blueyonder.co.not-this-bit.nor-this-part.uk.invalid
Sun Jan 22 10:00:19 UTC 2006


Axonn wrote:
> Thanks Richard. Well, it's clear... I'm gonna have to postpone adding
> NTP functionality for my program for now... at least for the following
> two months. This is too much to get myself into, especially
> considering that I got a pretty big amount of development to finish
> at the alarms and address book sections. And for whoever is
> interested and is a Windows user, I will launch a Beta 2 this
> Wednesday (compatible with Windows NT 5.0 or greater) and you can
> e-mail me to put you on the list. The program is pretty stable and is
> very flexible and allows tons of customization.
>
> Anyway, thank you all for your help, I'll be back with questions
> probably when I gather enough courage to get myself into this NTP
> thingy : ).

Axonn,

It's not that difficult!  All you need to do is to complete a single 
packet, send it to a server, and parse the value of one 64-bit returned 
number.  Does the programming language you are using not offer a UDP 
socket / datagram you can use?  Which fields of the packet are you 
uncertain about?

Here's the 64-bit time type:

type
  // NTP uses a 32+32 bit field with whole and fractional seconds
  TTimestamp = record
    seconds:  Longint;     // in network order
    fraction: Longint;     // in network order
  end;

and the packet: (part of a bigger variant record in my program)

      1: (flags: byte;
          stratum: byte;
          poll: byte;
          precision: shortint;
          root_delay: Longint;
          root_dispersion: Longint;
          reference_identifier: Longint;
          reference_timestamp: TTimestamp;
          originate_timestamp: TTimestamp;
          receive_timestamp: TTimestamp;
          transmit_timestamp: TTimestamp;
         );

In my own code, I only fill in the Flags and the Originate Timestamp 
fields!  Simply reading the Transmit Timestamp would give you a 
"reasonable" time value.

Why won't your program also work on Windows NT 4?

Cheers,
David 





More information about the questions mailing list