[ntp:questions] help with setting up NTP on windows with a USB GPS

unruh unruh at wormhole.physics.ubc.ca
Wed Dec 2 04:07:00 UTC 2009

On 2009-12-01, jack <j.jack.wang at gmail.com> wrote:
> On Dec 1, 5:11?pm, Dave Hart <daveh... at gmail.com> wrote:
>> On Dec 1 16:58?UTC, jack wrote:
>> > I have a related question: given that my system clock is synced to an
>> > external GPS within ms, how do I read time that gives me the same
>> > accuracy? When I tried to read time at 60Hz, I found that the times
>> > returned are not periodic, sometimes even the same.
>> Depending on the version of Windows, hardware, and the interface used
>> (GetSystemTime[AsFileTime] vs timeGetTime/GetTickCount) the best
>> resolution you can get for the clock is 0.5ms, the worst about
>> 15.625ms. ?To do better you need to query ntpd using the NTP protocol
>> -- gin up a mode 3 (client) packet and send it to UDP or ::1
>> port 123 and grab the time from the resulting mode 4 response. ?You
>> can look at the sntp source code (not yet ported to Windows) for a
>> guide.
>> Cheers,
>> Dave Hart
> Dave,
> Thanks for the query suggestion. That is what I plan to do. I am now
> looking at ntpq code. I plan to query ntpd periodically and use the
> high performance counter to keep time in between. If the query time is
> negligible, I should get very accurate time. However, I have no way of
> calibrating the query time.

ntp does that for you. It sends out the query with the local time. It
receives back the time that the system received the query and replied to
the query, and finally times when it gets the packet back. of course
with your situation it is really a bit irrelevant, since the problem is
that you then need to use that time in whatever program you want to use.
(ie, it is true that ntp does not and cannot figure out how much time
there is between your receiving the time and your using the time. )

> Jack

More information about the questions mailing list