Any samples for NTP/SNTP client code? - NTP

This is a discussion on Any samples for NTP/SNTP client code? - NTP ; Does anybody know of any *practical* samples on how to implement NTP/SNTP client?. The goal is to provide accurate time for a program/client running on Windows Vista. Specifically, what values to include in the the request message, how to process ...

+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 20 of 28

Thread: Any samples for NTP/SNTP client code?

  1. Any samples for NTP/SNTP client code?

    Does anybody know of any *practical* samples on how to
    implement NTP/SNTP client?. The goal is to provide accurate
    time for a program/client running on Windows Vista.

    Specifically, what values to include in the the request message,
    how to process the reply message, etc.

    I am NOT asking how to send/receive UDP datagrams, or where
    to find comprehensive descriptions like RFC documents, or how
    to build or design user interfaces.

    Only a narrow description focused on NTP/SNTP request/reply
    datagrams for a simple PC client, preferably in C/C++ source
    code.




  2. Re: Any samples for NTP/SNTP client code?

    In article
    <90967f07-83ca-4d79-8acb-1c3056ce39a4@l1g2000hsa.googlegroups.com>,
    guuwwe@hotmail.com wrote:

    > Does anybody know of any *practical* samples on how to
    > implement NTP/SNTP client?. The goal is to provide accurate
    > time for a program/client running on Windows Vista.
    >
    > Specifically, what values to include in the the request message,
    > how to process the reply message, etc.
    >
    > I am NOT asking how to send/receive UDP datagrams, or where
    > to find comprehensive descriptions like RFC documents, or how
    > to build or design user interfaces.
    >
    > Only a narrow description focused on NTP/SNTP request/reply
    > datagrams for a simple PC client, preferably in C/C++ source
    > code.


    I've done this in an embedded realtime system. (No, the source code is
    not available.)

    In Appendix A of RFC-1305 you will find the format of the NTPv3
    request/response packet. Send this packet to port 123 of the NTP
    server, and read the reply packet. It's pretty easy.

    The NTPv3 packet format will work with all timeservers of NTPv3 and
    above.

    Joe Gwinn

  3. Re: Any samples for NTP/SNTP client code?

    guuwwe@hotmail.com wrote:
    > Does anybody know of any *practical* samples on how to
    > implement NTP/SNTP client?. The goal is to provide accurate
    > time for a program/client running on Windows Vista.


    Have you seen the sntp directory in the reference implementation tarball?

  4. Re: Any samples for NTP/SNTP client code?

    In article <90967f07-83ca-4d79-8acb-1c3056ce39a4@l1g2000hsa.googlegroups.com>,
    guuwwe@hotmail.com writes:
    >Does anybody know of any *practical* samples on how to
    >implement NTP/SNTP client?. The goal is to provide accurate
    >time for a program/client running on Windows Vista.


    Just curious. Why do you want to roll your own as compared
    to run one of the existing packages?


    >Only a narrow description focused on NTP/SNTP request/reply
    >datagrams for a simple PC client, preferably in C/C++ source
    >code.


    I don't know of any good code you can copy.

    I'd start at:
    http://support.ntp.org/bin/view/Main/SoftwareDownloads
    and look in the sntp directory.


    There are two issues. (maybe more)

    One is getting the time right.

    The other is not screwing up the rest of the network
    or putting an unreasonable load on the servers.

    Please be sure to read:
    NTP server misuse and abuse
    http://en.wikipedia.org/wiki/NTP_ser...suse_and_abuse

    --
    These are my opinions, not necessarily my employer's. I hate spam.


  5. Re: Any samples for NTP/SNTP client code?

    guuwwe@hotmail.com wrote:
    > Does anybody know of any *practical* samples on how to
    > implement NTP/SNTP client?. The goal is to provide accurate
    > time for a program/client running on Windows Vista.

    []

    Why not just run NTP?
    http://www.meinberg.de/english/sw/ntp.htm

    Cheers,
    David



  6. Re: Any samples for NTP/SNTP client code?

    On Dec 1, 3:07 pm, Joseph Gwinn wrote:
    > In article
    > <90967f07-83ca-4d79-8acb-1c3056ce3...@l1g2000hsa.googlegroups.com>,
    >
    > guu...@hotmail.com wrote:
    > > Does anybody know of any *practical* samples on how to
    > > implement NTP/SNTP client?. The goal is to provide accurate
    > > time for a program/client running on Windows Vista.

    >
    > > Specifically, what values to include in the the request message,
    > > how to process the reply message, etc.

    >
    > > I am NOT asking how to send/receive UDP datagrams, or where
    > > to find comprehensive descriptions like RFC documents, or how
    > > to build or design user interfaces.

    >
    > > Only a narrow description focused on NTP/SNTP request/reply
    > > datagrams for a simple PC client, preferably in C/C++ source
    > > code.

    >
    > I've done this in an embedded realtime system. (No, the source code is
    > not available.)
    >
    > In Appendix A of RFC-1305 you will find the format of the NTPv3
    > request/response packet. Send this packet to port 123 of the NTP
    > server, and read the reply packet. It's pretty easy.
    >


    I saw this format. From data comm point of view it is very unusual
    to have the same format for request and reply.

    Sending/receiving the packet to port 123 is the first thing I tried.
    This is not an issue. The issue is to use all the values in
    request and reply correctly and reliably. And the quickest
    way is to get as many ***samples*** as possible, the
    RFC doc ***alone*** is the slowest way.



  7. Re: Any samples for NTP/SNTP client code?

    On Dec 1, 3:40 pm, hal-use...@ip-64-139-1-69.sjc.megapath.net (Hal
    Murray) wrote:
    > In article <90967f07-83ca-4d79-8acb-1c3056ce3...@l1g2000hsa.googlegroups.com>,
    >
    > guu...@hotmail.com writes:
    > >Does anybody know of any *practical* samples on how to
    > >implement NTP/SNTP client?. The goal is to provide accurate
    > >time for a program/client running on Windows Vista.

    >
    > Just curious. Why do you want to roll your own as compared
    > to run one of the existing packages?
    >


    Existing packages set the PC system/CMOS clock, and my application
    would have to read it which is not very reliable approach.
    My app needs direct access to periodic (5-60mins) accurate ***direct*
    timestamps and it will use high frequency counter provided by PC
    between.

    > >Only a narrow description focused on NTP/SNTP request/reply
    > >datagrams for a simple PC client, preferably in C/C++ source
    > >code.

    >
    > I don't know of any good code you can copy.
    >


    I does not have to be a source code but a description/algorithm by
    somebody
    who actually coded reliably.

    > I'd start at:
    > http://support.ntp.org/bin/view/Main/SoftwareDownloads
    > and look in the sntp directory.
    >


    I did find it. However, the packages use gz formats used by Unix.
    My PC does not have any utility to uncompress them.

    > There are two issues. (maybe more)
    >
    > One is getting the time right.
    >
    > The other is not screwing up the rest of the network
    > or putting an unreasonable load on the servers.
    >
    > Please be sure to read:
    > NTP server misuse and abuse
    > http://en.wikipedia.org/wiki/NTP_ser...suse_and_abuse
    >
    > --
    > These are my opinions, not necessarily my employer's. I hate spam.



  8. Re: Any samples for NTP/SNTP client code?

    On 2007-12-01, guuwwe@hotmail.com wrote:

    > On Dec 1, 3:40 pm, (Hal Murray) wrote:
    >
    >> I'd start at: http://support.ntp.org/bin/view/Main/SoftwareDownloads
    >> and look in the sntp directory.

    >
    >I did find it. However, the packages use gz formats used by Unix. My PC
    >does not have any utility to uncompress them.


    I searched for windows+archiver+gz on Google. The first hit led me to
    http://www.gzip.org/ which says:

    | To extract .tar and .tar.gz files on Windows 9x/NT/2000/ME/XP
    | use PowerArchiver 6.1 (freeware) or 7-zip (freeware) or Winzip
    | (commercial). For tar on MSDOS or other systems, see the FAQ of the
    | comp.compression newsgroup.

    The links in the quoted text are:

    PowerArchiver: http://www.sfsu.edu/ftp/win/utils/
    7-zip: http://www.7-zip.org/
    WinZip: http://www.winzip.com/
    Compression FAQ: http://www.faqs.org/faqs/compression-faq/
    Compression Newsgroup: news:comp.compression

    --
    Steve Kostecke
    NTP Public Services Project - http://support.ntp.org/

  9. Re: Any samples for NTP/SNTP client code?

    In article
    <9ce7563d-086b-44d1-a9af-d2d5690dfbd9@d4g2000prg.googlegroups.com>,
    guuwwe@hotmail.com wrote:

    > On Dec 1, 3:07 pm, Joseph Gwinn wrote:
    > > In article
    > > <90967f07-83ca-4d79-8acb-1c3056ce3...@l1g2000hsa.googlegroups.com>,
    > >
    > > guu...@hotmail.com wrote:
    > > > Does anybody know of any *practical* samples on how to
    > > > implement NTP/SNTP client?. The goal is to provide accurate
    > > > time for a program/client running on Windows Vista.

    > >
    > > > Specifically, what values to include in the the request message,
    > > > how to process the reply message, etc.

    > >
    > > > I am NOT asking how to send/receive UDP datagrams, or where
    > > > to find comprehensive descriptions like RFC documents, or how
    > > > to build or design user interfaces.

    > >
    > > > Only a narrow description focused on NTP/SNTP request/reply
    > > > datagrams for a simple PC client, preferably in C/C++ source
    > > > code.

    > >
    > > I've done this in an embedded realtime system. (No, the source code is
    > > not available.)
    > >
    > > In Appendix A of RFC-1305 you will find the format of the NTPv3
    > > request/response packet. Send this packet to port 123 of the NTP
    > > server, and read the reply packet. It's pretty easy.
    > >

    >
    > I saw this format. From data comm point of view it is very unusual
    > to have the same format for request and reply.
    >
    > Sending/receiving the packet to port 123 is the first thing I tried.
    > This is not an issue. The issue is to use all the values in
    > request and reply correctly and reliably. And the quickest
    > way is to get as many ***samples*** as possible, the
    > RFC doc ***alone*** is the slowest way.


    Umm. You might wish to read the rest of RFC-1305. It really was not
    hard to get times from the server, or to be a server. If you want to do
    the full NTP, then the easiest solution is to use NTP itself.

    In the embedded realtime system I mentioned, we were actually
    implementing the timeserver, to allow ordinary UNIX boxes to use NTP to
    synchronize to our purpose-built time hardware, so all boxes in the
    system were using the same timescale.

    Joe Gwinn

  10. Re: Any samples for NTP/SNTP client code?

    In article <68f4c629-f605-40ff-8e02-2ca1deb0f426@w56g2000hsf.googlegroups.com>,
    guuwwe@hotmail.com wrote:

    > > In article <90967f07-83ca-4d79-8acb-1c3056ce3...@l1g2000hsa.googlegroups.com>,
    > >
    > > guu...@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.

    > My app needs direct access to periodic (5-60mins) accurate ***direct*


    Single measurements are unlikely to be particularly accurate.

    > timestamps and it will use high frequency counter provided by PC
    > between.


    I assume this is specialist hardware. On many systems the TSC is used
    to interpolate the clock ticks, by the kernel. There is another thread
    on whether ntpd does this in user space on NT family systems.

    > > >Only a narrow description focused on NTP/SNTP request/reply

    > >datagrams for a simple PC client, preferably in C/C++ source
    > >code.


    NTP distribution contains an SNTP client. But if you really
    want to examples of packet formats, install and run WinDump to get protocol
    traces from the real software.

    However, as you seem to be wanting bleeding edge performance on an untried
    system whose predecessors are well known to not be good platforms for
    accurate timing, you shouldn't be attacking the job unless you can deduce
    the necessary information from the documentation and can understand the
    maths in the NTP documentation.

    > I did find it. However, the packages use gz formats used by Unix.
    > My PC does not have any utility to uncompress them.


    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.

  11. Re: Any samples for NTP/SNTP client code?

    On Dec 2, 7:03 am, da...@ex.djwhome.demon.co.uk.invalid (David
    Woolley) wrote:
    > In article <68f4c629-f605-40ff-8e02-2ca1deb0f...@w56g2000hsf.googlegroups.com>,
    >
    > guu...@hotmail.com wrote:
    > > > In article <90967f07-83ca-4d79-8acb-1c3056ce3...@l1g2000hsa.googlegroups.com>,

    >
    > > > guu...@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.




  12. Re: Any samples for NTP/SNTP client code?

    guuwwe@hotmail.com wrote:
    > Does anybody know of any *practical* samples on how to
    > implement NTP/SNTP client?. The goal is to provide accurate
    > time for a program/client running on Windows Vista.
    >
    > Specifically, what values to include in the the request message,
    > how to process the reply message, etc.
    >
    > I am NOT asking how to send/receive UDP datagrams, or where
    > to find comprehensive descriptions like RFC documents, or how
    > to build or design user interfaces.
    >
    > Only a narrow description focused on NTP/SNTP request/reply
    > datagrams for a simple PC client, preferably in C/C++ source
    > code.


    Why not just install ntpd and be done? The source code is available for
    download from ntp.org.

    If you really want to write your own look at RFC4330 and at the NTP v4
    draft now getting ready to become an RFC.

    Also you need to make sure you keep within the limits of how often you
    make a request (normally no more frequently than once every 64 seconds)
    and you need to handle KoD packets and follow the requirements of the draft.

    Danny

  13. Re: Any samples for NTP/SNTP client code?

    On 2007-12-02, guuwwe@hotmail.com wrote:

    > On Dec 2, 7:03 am, (David Woolley) wrote:
    >
    >> 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.


    I'm surprised that you've not asked anyone here to repack a current
    tarball as a ZIP archive.

    I've taken care of that for you... But you'll have to expend a bit
    of effort and download it from the attachment table at the bottom of
    http://support.ntp.org/Main/SteveKostecke

    --
    Steve Kostecke
    NTP Public Services Project - http://support.ntp.org/

  14. Re: Any samples for NTP/SNTP client code?

    guuwwe@hotmail.com wrote:
    > 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.


    WinRAR is safe. I have it on my Windows machine with no issues. It can
    uncompress *.tar, *.gz, *.bz2, and *.z archives, and others listed here:
    http://rarlab.com/otherfmt.htm

    --
    Dennis Hilberg, Jr. timekeeper(at)dennishilberg(dot)com
    NTP Server Information: http://saturn.dennishilberg.com/ntp.php

  15. Re: Any samples for NTP/SNTP client code?

    guuwwe@hotmail.com wrote:
    > On Dec 1, 3:07 pm, Joseph Gwinn wrote:
    >> In article
    >> <90967f07-83ca-4d79-8acb-1c3056ce3...@l1g2000hsa.googlegroups.com>,
    >>
    >> guu...@hotmail.com wrote:
    >>> Does anybody know of any *practical* samples on how to
    >>> implement NTP/SNTP client?. The goal is to provide accurate
    >>> time for a program/client running on Windows Vista.
    >>> Specifically, what values to include in the the request message,
    >>> how to process the reply message, etc.
    >>> I am NOT asking how to send/receive UDP datagrams, or where
    >>> to find comprehensive descriptions like RFC documents, or how
    >>> to build or design user interfaces.
    >>> Only a narrow description focused on NTP/SNTP request/reply
    >>> datagrams for a simple PC client, preferably in C/C++ source
    >>> code.

    >> I've done this in an embedded realtime system. (No, the source code is
    >> not available.)
    >>
    >> In Appendix A of RFC-1305 you will find the format of the NTPv3
    >> request/response packet. Send this packet to port 123 of the NTP
    >> server, and read the reply packet. It's pretty easy.


    > I saw this format. From data comm point of view it is very unusual
    > to have the same format for request and reply.


    Why does that matter? The contents of the sending packet is slightly
    different from the reply. The client sends a mode 4 packet and receives
    back a mode 3 packet. The layout of the two packets are the same, the
    contents are appropriate for the mode.

    > Sending/receiving the packet to port 123 is the first thing I tried.
    > This is not an issue. The issue is to use all the values in
    > request and reply correctly and reliably. And the quickest
    > way is to get as many ***samples*** as possible, the
    > RFC doc ***alone*** is the slowest way..


    Samples probably won't help that much. The draft NTPv4 spec should. You
    can also look at ntpdate which also runs on Vista. Collecting sample
    source code is one way to do it, why reinvent the wheel?

    Can you say why you want to write your own version of an SNTP client? We
    are actually looking for someone to rewrite the one in the NTP
    distribution. It has to run on all supported O/S's but it you want to
    create one and donate it to us we'd be delighted.

    Danny

  16. Re: Any samples for NTP/SNTP client code?

    guuwwe@hotmail.com wrote:
    > On Dec 1, 3:40 pm, hal-use...@ip-64-139-1-69.sjc.megapath.net (Hal
    > Murray) wrote:
    >> In article <90967f07-83ca-4d79-8acb-1c3056ce3...@l1g2000hsa.googlegroups.com>,
    >>
    >> guu...@hotmail.com writes:
    >>> Does anybody know of any *practical* samples on how to
    >>> implement NTP/SNTP client?. The goal is to provide accurate
    >>> time for a program/client running on Windows Vista.

    >> Just curious. Why do you want to roll your own as compared
    >> to run one of the existing packages?
    >>

    >
    > Existing packages set the PC system/CMOS clock, and my application
    > would have to read it which is not very reliable approach.
    > My app needs direct access to periodic (5-60mins) accurate ***direct*
    > timestamps and it will use high frequency counter provided by PC
    > between.


    Can you be sure that you will get a better and more accurate timestamp
    that way? You might want to consider using a refclock instead it it's
    that important to what you are doing.

    >>> Only a narrow description focused on NTP/SNTP request/reply
    >>> datagrams for a simple PC client, preferably in C/C++ source
    >>> code.

    >> I don't know of any good code you can copy.
    >>

    >
    > I does not have to be a source code but a description/algorithm by
    > somebody
    > who actually coded reliably.
    >
    >> I'd start at:
    >> http://support.ntp.org/bin/view/Main/SoftwareDownloads
    >> and look in the sntp directory.
    >>

    >
    > I did find it. However, the packages use gz formats used by Unix.
    > My PC does not have any utility to uncompress them.
    >

    Use Winzip which supports it natively. There are also free binaries
    available for gunzip and for tar.

    Danny

  17. Re: Any samples for NTP/SNTP client code?

    In article <17a3f3c2-3946-4fec-aaa0-6e18ee4e4a1b@n20g2000hsh.googlegroups.com>,
    guuwwe@hotmail.com wrote:

    > QueryPerformanceCounter() directly off the hardware. Windows
    > scheduling has no impact here, the drawbacks of tick counts do not


    Windows scheduling will cause uncertainty in the time you get from
    your SNTP requests which you use to calibrate the performance counters.
    (It will also cause uncertainties in the time of whatever real world
    event is associated with the times being recorded by your software.)

    > The issue here is what is the drift of this counter. Once I code my


    Assuming that you don't have any missed interrupts (if you do, your
    scheduling uncertainty will be large), one would expect it to be the
    same as the uncorrected software clock drift, i.e. of the order of
    10ppm for a good machine, and up to several 100ppm for poor ones. This
    is the ntpd frequency value, that is stored in the drift file.

    This will be the case because the two time sources normally share a
    common crystal oscillator on the motherboard.

    I suspect that the real solution here is to have ntpd provide
    (shared memory?) epoch, slope and intercept data for the high resolution
    timer. As CPU clock modulation may make RDTSC less useful, it may well
    be that ntpd moves to using the performance timers to interpolate, when
    high resolution interpolation is introduce. (These tricks are
    largely only needed where the kernel doesn't interpolate ticks.)


    > The problem with any "free" utilities for Windows is that I have to


    WinZip isn't free, or at least not for commercial use. gzip is open
    source and comes from the highly respected Free Software Foundation,
    so you can look at the source code and verify it has no network code,
    then compile it yourself. WinZip is so widely used that any abuses by
    it would have been discovered by now. (On the other hand, attempts to
    go beyond what users consider reasonable have been discovered in earlier
    versions of Windows!)

  18. Re: Any samples for NTP/SNTP client code?

    Hal Murray wrote:
    > In article
    > <90967f07-83ca-4d79-8acb-1c3056ce39a4@l1g2000hsa.googlegroups.com>,
    > guuwwe@hotmail.com writes:
    >>Does anybody know of any *practical* samples on how to
    >>implement NTP/SNTP client?. The goal is to provide accurate
    >>time for a program/client running on Windows Vista.

    >
    > Just curious. Why do you want to roll your own as compared
    > to run one of the existing packages?
    >
    >
    >>Only a narrow description focused on NTP/SNTP request/reply
    >>datagrams for a simple PC client, preferably in C/C++ source
    >>code.

    >
    > I don't know of any good code you can copy.
    >
    > I'd start at:
    > http://support.ntp.org/bin/view/Main/SoftwareDownloads
    > and look in the sntp directory.


    AFAIK the code in the SNTP subdirectory has not yet been ported to
    Windows ...

    Martin
    --
    Martin Burnicki

    Meinberg Funkuhren
    Bad Pyrmont
    Germany

  19. Re: Any samples for NTP/SNTP client code?

    On Dec 3, 3:34 am, da...@ex.djwhome.demon.co.uk.invalid (David
    Woolley) wrote:
    > In article <17a3f3c2-3946-4fec-aaa0-6e18ee4e4...@n20g2000hsh.googlegroups.com>,
    >
    > guu...@hotmail.com wrote:
    > > QueryPerformanceCounter() directly off the hardware. Windows
    > > scheduling has no impact here, the drawbacks of tick counts do not

    >
    > Windows scheduling will cause uncertainty in the time you get from
    > your SNTP requests which you use to calibrate the performance counters.
    > (It will also cause uncertainties in the time of whatever real world
    > event is associated with the times being recorded by your software.)
    >


    Windows scheduling will NOT cause any bigger uncertainty than many
    other factors including network delays or scheduling on my Linksys
    router
    (probably Unix-like OS) that relays all my incoming/outgoing IP
    traffic.

    The most important thing is that my code will be able to measure
    fairly
    consistently the time between sending a request and receiving a
    reply
    for ***all*** servers in microseconds. I will use at least five
    servers.
    It would not be possible with TICKS but it is possible with high
    frequency
    counters because they operate on different principle as stated. This
    is the
    key difference!!! Consequently, it will be possible to estimate the
    drift of the
    PC counter and come up with servers' polling frequencies that
    satisfy my
    reqs for accuracy.

    So do not make it more complicated than it is. The rest belongs to
    the
    algorithims I will use and you do not know them, and I am not ready
    to
    discusss them.


  20. Re: Any samples for NTP/SNTP client code?

    On Dec 2, 9:34 pm, ma...@ntp.isc.org (Danny Mayer) wrote:
    > guu...@hotmail.com wrote:
    > > On Dec 1, 3:07 pm, Joseph Gwinn wrote:
    > >> In article
    > >> <90967f07-83ca-4d79-8acb-1c3056ce3...@l1g2000hsa.googlegroups.com>,

    >
    > >> guu...@hotmail.com wrote:
    > >>> Does anybody know of any *practical* samples on how to
    > >>> implement NTP/SNTP client?. The goal is to provide accurate
    > >>> time for a program/client running on Windows Vista.
    > >>> Specifically, what values to include in the the request message,
    > >>> how to process the reply message, etc.
    > >>> I am NOT asking how to send/receive UDP datagrams, or where
    > >>> to find comprehensive descriptions like RFC documents, or how
    > >>> to build or design user interfaces.
    > >>> Only a narrow description focused on NTP/SNTP request/reply
    > >>> datagrams for a simple PC client, preferably in C/C++ source
    > >>> code.
    > >> I've done this in an embedded realtime system. (No, the source code is
    > >> not available.)

    >
    > >> In Appendix A of RFC-1305 you will find the format of the NTPv3
    > >> request/response packet. Send this packet to port 123 of the NTP
    > >> server, and read the reply packet. It's pretty easy.

    > > I saw this format. From data comm point of view it is very unusual
    > > to have the same format for request and reply.

    >
    > Why does that matter? The contents of the sending packet is slightly
    > different from the reply. The client sends a mode 4 packet and receives
    > back a mode 3 packet. The layout of the two packets are the same, the
    > contents are appropriate for the mode.
    >


    Actually, the client sends mode 3 and server responds with mode 4.

    In my original post I made an issue of the same ***format*** of NTP/
    SNTP
    request and reply. This is very unusual in data comm.
    Obviously, the requests and replies have to have different
    ***contents***
    otherwise there would be no exchange of information.

    Just look at the NTP/SNTP request format and for ***every*** field
    explain why would a client send it to a server. Do not pick just one
    field like MODE, explain for ***all*** fields.

    > > Sending/receiving the packet to port 123 is the first thing I tried.
    > > This is not an issue. The issue is to use all the values in
    > > request and reply correctly and reliably. And the quickest
    > > way is to get as many ***samples*** as possible, the
    > > RFC doc ***alone*** is the slowest way..

    >
    > Samples probably won't help that much. The draft NTPv4 spec should. You
    > can also look at ntpdate which also runs on Vista. Collecting sample
    > source code is one way to do it, why reinvent the wheel?
    >
    > Can you say why you want to write your own version of an SNTP client? We
    > are actually looking for someone to rewrite the one in the NTP
    > distribution. It has to run on all supported O/S's but it you want to
    > create one and donate it to us we'd be delighted.
    >


    I am already busy with my projects.

+ Reply to Thread
Page 1 of 2 1 2 LastLast