[ntp:questions] Any samples for NTP/SNTP client code?

guuwwe at hotmail.com guuwwe at hotmail.com
Sun Dec 2 16:19:26 UTC 2007


On Dec 2, 7:03 am, da... at ex.djwhome.demon.co.uk.invalid (David
Woolley) wrote:
> In article <68f4c629-f605-40ff-8e02-2ca1deb0f... at w56g2000hsf.googlegroups.com>,
>
> guu... at hotmail.com wrote:
> > > In article <90967f07-83ca-4d79-8acb-1c3056ce3... at l1g2000hsa.googlegroups.com>,
>
> > >  guu... at hotmail.com writes:
> > > >Does anybody know of any *practical* samples on how to
> > > >implement NTP/SNTP client?. The goal is to provide accurate
>
> From your description, NTP is not an option, as implementing NTP requires
> implementing most of the relevant (draft) RFC.  What you are discussing is
> only SNTP.
>
> >  Existing packages set the PC system/CMOS clock, and my application
> >  would have to read it which is not very reliable approach.
>
> If Vista still doesn't interpolate between clock ticks, it is unlikely
> that your application is going to have precise enough scheduling delays for
> things to really matter.  The real problem is you've chose an HCI platform
> for use in a timing critical application.
>
> On a platform that does interpolate clock ticks, you should expect a one to
> two orders of magnitude better time by reading the system clock, synchronised
> by NTP, as compared with doing a one off SNTP exchange.  If the clock ticks
> aren't interpolated, you need a very good understanding of the scheduling
> and interrupt latencies in your system, which will probably make extracting
> the SNTP packet details from the NTP or, better, SNTP specifications, trivial.
> I don't think Vista has been around long enough for such information to become
> available, and most IT managers seem to be avoiding Vista like the plague, so
> it may be some time before someone interested in accurate time makes the
> measurements.
>

 You seem to assume the ticks used by the PC system time, e.g. you get
them
 with GetTickCount(). Most if not all new PC's have an extra hardware
chip called
 high-performance counter (probably located in the processor itself,
maybe even
 use the cycle rate of the processor clock). You read such a counter
with
 QueryPerformanceCounter() directly off the hardware. Windows
 scheduling has no impact here, the drawbacks of tick counts do not
apply here.
 The high-performance counter has frequency 5-20MHz depending on the
PC model,
 i.e. you get resolution of less than 1 microsec/count, directly off
the hardware.
 The issue here is what is the drift of this counter. Once I code my
SNTP client
 I will check it, ans also I will compare to PC ticks.


>
> WinZip, which most power users of Windows seem to have, can handle this.
> Also, to the best of my recollection, gzip compiles easily on Windows and
> there ought to be Windows builds of it around on the net.

The problem with any "free" utilities for Windows is that I have to
spend the time to
 decide which one of them is safe enough to install on my PC.
Nowadays, most of them
are infested with viruses and crapware. I plan to use my very old PC,
now packed in a box.






More information about the questions mailing list