[ntp:questions] NTP Shared Memory Driver

Brian Utterback brian.utterback at oracle.com
Tue Jun 26 14:37:22 UTC 2012


On 06/25/12 18:43, Damien Dusha wrote:
> Dear NTP list,
>
> I would like to use the shared memory driver to push time from a GPS
> receiver into NTP (Note 1) - host OS is Linux, using NTP 4.2.6p5.
> According to documentation at
> http://www.eecis.udel.edu/~mills/ntp/html/drivers/driver28.html, I
> need to populate the following structure in shared memory:
>
> struct shmTime {
>    int    mode; /* 0 - if valid set
>                  *       use values,
>                  *       clear valid
>                  * 1 - if valid set
>                  *       if count before and after read of
>                  *       values is equal,
>                  *         use values
>                  *       clear valid
>                  */
>    int    count;
>    time_t clockTimeStampSec;      /* external clock */
>    int    clockTimeStampUSec;     /* external clock */
>    time_t receiveTimeStampSec;    /* internal clock, when external
> value was received */
>    int    receiveTimeStampUSec;   /* internal clock, when external
> value was received */
>    int    leap;
>    int    precision;
>    int    nsamples;
>    int    valid;
>    int    dummy[10];
> };
>
> Whilst "mode" is clearly documented in the designated HTML page, the
> remaining fields are not and it's not obvious as to how they should be
> populated.
>
> For poking around ntpd and gpsd, I have made guesses that:
>    * The timestamps are unix timestamps in UTC
>    * "leap" is an enumeration 0 - 3, though I am not entirely sure of
> its meaning, (3 is unknown leap seconds applied?)
>    * "Precision" is 2^(precision) seconds estimated accuracy
>    * "count" and "valid" are populated according to the "mode" selected
>
> But this is little more than a stab in the dark. Is there a better
> place where these fields are documented that I have missed?
>

I think you have pretty much what you need. The leap values are just 
what they are for the rest of NTP. Since the timestamps are in 
microseconds, you probably want to set precision to -20. You get to 
choose what mode you want to use. The nsamples field is set by ntpd. 
Seems pretty clear.

-- 
blu

Always code as if the guy who ends up maintaining your code will be a
violent psychopath who knows where you live. - Martin Golding
-----------------------------------------------------------------------|
Brian Utterback - Solaris RPE, Oracle Corporation.
Ph:603-262-3916, Em:brian.utterback at oracle.com



More information about the questions mailing list