Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Getting the version string programmatically ...

6 views
Skip to first unread message

David J Taylor

unread,
Dec 17, 2009, 2:25:34 AM12/17/09
to
The command:

ntpq -c rv

returns a set of data, including the version of NTP in the format:

version="ntpd 4.2.6-o"

I would like to retrieve the same information (just the version field)
using a UDP interchange with the server rather than running the ntpq
command. Could anyone advise what the packet I send to the server should
contain, and what I might get back? Perhaps if you could point me to the
right Web page, please?

Thanks,
David

Terje Mathisen

unread,
Dec 17, 2009, 4:13:59 AM12/17/09
to

"Use the Source", David!

I.e. just grab the ntpq source code and rip out what you need.

Terje
--
- <Terje.Mathisen at tmsw.no>
"almost all programming can be viewed as an exercise in caching"

David J Taylor

unread,
Dec 17, 2009, 4:28:19 AM12/17/09
to

"Terje Mathisen" <Terje.M...@tmsw.no> wrote in message
news:A5mdnVwBf93Ka7TW...@lyse.net...

> David J Taylor wrote:
>> The command:
>>
>> ntpq -c rv
>>
>> returns a set of data, including the version of NTP in the format:
>>
>> version="ntpd 4.2.6-o"
>>
>> I would like to retrieve the same information (just the version field)
>> using a UDP interchange with the server rather than running the ntpq
>> command. Could anyone advise what the packet I send to the server
>> should
>> contain, and what I might get back? Perhaps if you could point me to
>> the
>> right Web page, please?
>
> "Use the Source", David!
>
> I.e. just grab the ntpq source code and rip out what you need.
>
> Terje

Terje,

I do have the source code, but I find C very difficult to "read". In
which of the 890 files I have would you suggest I start (yes, the ntpq
source will be my first point).

But I had rather hoped that this would be documented somewhere - but I
can't find it as yet.

Thanks,
David

Harlan Stenn

unread,
Dec 17, 2009, 7:00:47 AM12/17/09
to
Using 4.2.6, run a tcpdump against the conversation of:

ntpq -c 'rv 0 version'

--
Harlan Stenn <st...@ntp.org>
http://ntpforum.isc.org - be a member!

Martin Burnicki

unread,
Dec 17, 2009, 8:39:41 AM12/17/09
to
David,

some time ago one of my colleagues has picked up the source code of ntpq and
applied some modifications and extensions so that he could build a DLL
which provides the functionality of ntpq via some API calls exported by
that DLL.

Unfortunatly that colleague is currently out of the office (I think he'll be
back at latest next Monday), but AFAIR that DLL is shipped with the NTP
Time Server Monitor for Windows:
http://www.meinberg.de/english/sw/time-server-monitor.htm#download

If I remember correctly you should have that program running on one or more
of your machines, so you may see if there's a ntpsvcio.dll on those
machines.

Also, if I remember correctly, you are programming in Delphi, so we need to
see if we can define function prototypes in Pascal which lets you Delphi
applications call those DLL API functions. I'm not too familiar with that
DLL, so I'd like to wait until my colleague is back until we can make some
information available how to use that DLL.

Unfortunately those DLL functions are currently not thread-safe, simply
because the source code of ntpq uses some state information in global
variables, which is absolutely OK for ntpq as a standalone application.

Another colleague has recently started to upgrade the source code of the DLL
to use the recent source code of ntpq. Once this has been done we are
planning to see if can make the DLL threadsafe by collecting all those
global variables in a structure, so one instance of that structure can be
used per thread to keep information of the state of a NTP connection.

Martin
--
Martin Burnicki

Meinberg Funkuhren
Bad Pyrmont
Germany

David J Taylor

unread,
Dec 17, 2009, 9:32:19 AM12/17/09
to
"Martin Burnicki" <martin....@meinberg.de> wrote in message
news:ttopv6-...@gateway.py.meinberg.de...
[]

Martin, I do have that DLL, but it's from 08-Nov-2006, so perhaps from an
earlier version of the monitor. Yes, it has some useful looking
functions, and it would be useful to see a Delphi header. At the moment,
I have two functions coded:

- ask the time - does a standard mode 3 client/server interaction and
returns the full packet

- ask for version information - which I've coded to match an "ntp -c rv"
exchange, with the idea of parsing the received packet, which I see
contains a "version=...." string. I'm writing that code right now.

So much simpler than what's in the DLL.

Cheers,
David

David J Taylor

unread,
Dec 17, 2009, 11:19:10 AM12/17/09
to

"Harlan Stenn" <st...@ntp.org> wrote in message
news:ywn9iqc5...@ntp1.isc.org...

> Using 4.2.6, run a tcpdump against the conversation of:
>
> ntpq -c 'rv 0 version'

Thanks for the suggestion, Harlan. I managed to use Wireshark to do that
against: ntpq -c rv which brought me back more information, although it's
only the version string I want for now. An earlier version of the program
is illustrated here, together with a link to the current download:

http://www.satsignal.eu/ntp/NTP-timestamp.html

Cheers,
David

Steve Kostecke

unread,
Dec 17, 2009, 2:24:21 PM12/17/09
to
On 2009-12-17, David J Taylor <david-...@blueyonder.co.uk> wrote:

> "Harlan Stenn" <st...@ntp.org> wrote:
>
>> Using 4.2.6, run a tcpdump against the conversation of:
>>
>> ntpq -c 'rv 0 version'
>
> Thanks for the suggestion, Harlan. I managed to use Wireshark to do
> that against: ntpq -c rv which brought me back more information,
> although it's only the version string I want for now.

Use wireshark again and capture this:

ntpq -crv; ntpq -c'rv 0 version'

Then compare both request packets. The difference should be obvious.

--
Steve Kostecke <kost...@ntp.org>
NTP Public Services Project - http://support.ntp.org/

David J Taylor

unread,
Dec 17, 2009, 4:34:44 PM12/17/09
to
> Use wireshark again and capture this:
>
> ntpq -crv; ntpq -c'rv 0 version'
>
> Then compare both request packets. The difference should be obvious.

Thanks, Steve. Yes, I already did that, and decided to leave the fuller
exchange. I've not had the need to use Wireshark before, and it even
worked on Windows-7.

Cheers,
David

0 new messages