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
"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"
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
ntpq -c 'rv 0 version'
--
Harlan Stenn <st...@ntp.org>
http://ntpforum.isc.org - be a member!
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
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
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
> "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/
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