[ntp:questions] Sole time source in Linux user space.

unruh unruh at wormhole.physics.ubc.ca
Wed Jun 30 21:51:20 UTC 2010

On 2010-06-30, Michael Eder <meder at whoi.edu> wrote:
> I am working on a project developing ocean observatories and we have a
> highly accurate time source. Unfortunately because of the embedded nature of
> our platform it is not possible have NTP interface to it in any standard
> fashion.  I have some questions about what is the best mechanism to add this
> (sole) time source to NTP.  The time source is composed of a date and time
> string accurate to seconds, and a highly accurate Pulse-Per-Second.  I
> expect the shared memory interface to NTP is the way to do this, but what is
> not clear to me is if I can enter the time as a single source or I should
> separate out the Pulse-Per-Second from the date and time string and
> configure them as separate sources.  The Pulse-Per-Second is highly
> reliable, but I can imagine a situation where the date and time string might
> not be available.  This is especially a concern if the system shuts down and
> restarts.
> My question is what does NTP do for me automatically and what do I need to
> do myself to take into account some of the limitations of my time source?
> Is it possible in NTP to specify that a time source (highly accurate) is
> only seconds?  What is the best way with NTP to handle the situation when
> the Pulse-Per-Second is available but the full time string is not?  
> I have looked at the gpsd and shmpps code but still have some questions how
> NTP handles sources coming in through shared memory.  From looking at these
> my understanding is I would set up one source for the time string (that is
> accurate to approximately a second) and the second time source for the
> highly accurate Pulse-Per-Second.  
> Is there any place where I can find documentation about how NTP handles
> different clocks and different information that clocks may provide?  Where
> do I find documentation of how to configure these shared memory time
> sources?

shmpps simply timestamps the pulse arrival with the local clock and  put
the result into a shared memory segment. This means that the local
clock's second counter must be set somehow else. 
gpsd is a program which will both stamp the PPS AND read the serial port
line to get the seconds ( primarily from a gps receiver, but any other
source which puts out a PPS and puts the time onto the serial port would
also work-- you might have to rewrite gpsd a bit so that the format of
the time put onto the serial line can be read-- gpsd looks specifically
for gps NMEA sentences and interprets those)

gpsd uses the shm driver to input the information into ntpd.

Thus you could do some minor rewriting of gpsd to do exactly what you

The NMEA driver is also there to read the time from the serial port--
again designed for gps. 

> Pointers much appreciated. 
> Michael Eder
> Woods Hole Oceanographic
> www.whoi.edu/programs/ooi

More information about the questions mailing list