Home | History | Annotate | Line # | Download | only in drivers
driver28.html revision 1.1.1.2
      1      1.1    kardel <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
      2      1.1    kardel 
      3      1.1    kardel <html>
      4      1.1    kardel 
      5      1.1    kardel     <head>
      6      1.1    kardel         <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
      7      1.1    kardel         <meta name="GENERATOR" content="Mozilla/4.01 [en] (Win95; I) [Netscape]">
      8  1.1.1.2  christos         <title>Shared Memory Driver</title>
      9      1.1    kardel         <link href="scripts/style.css" type="text/css" rel="stylesheet">
     10      1.1    kardel     </head>
     11      1.1    kardel 
     12      1.1    kardel     <body>
     13      1.1    kardel         <h3>Shared Memory Driver</h3>
     14      1.1    kardel         <hr>
     15      1.1    kardel         <h4>Synopsis</h4>
     16      1.1    kardel         <p>Address: 127.127.28.<i>u</i><br>
     17      1.1    kardel             Reference ID: <tt>SHM</tt><br>
     18      1.1    kardel             Driver ID: <tt>SHM</tt></p>
     19      1.1    kardel 
     20      1.1    kardel         <h4>Description</h4>
     21      1.1    kardel         <p>This driver receives its reference clock info from a shared memory-segment. The shared memory-segment is created with owner-only access for unit 0 and 1, and world access for unit 2 and 3</p>
     22      1.1    kardel 
     23      1.1    kardel         <h4>Structure of shared memory-segment</h4>
     24      1.1    kardel         <pre>struct shmTime {
     25  1.1.1.2  christos         int    mode; /* 0 - if valid is set:
     26  1.1.1.2  christos                       *       use values,
     27  1.1.1.2  christos                       *       clear valid
     28  1.1.1.2  christos                       * 1 - if valid is set:
     29  1.1.1.2  christos                       *       if count before and after read of data is equal:
     30  1.1.1.2  christos                       *         use values
     31  1.1.1.2  christos                       *       clear valid
     32  1.1.1.2  christos                       */
     33  1.1.1.2  christos         volatile int    count;
     34  1.1.1.2  christos         time_t          clockTimeStampSec;
     35  1.1.1.2  christos         int             clockTimeStampUSec;
     36  1.1.1.2  christos         time_t          receiveTimeStampSec;
     37  1.1.1.2  christos         int             receiveTimeStampUSec;
     38  1.1.1.2  christos         int             leap;
     39  1.1.1.2  christos         int             precision;
     40  1.1.1.2  christos         int             nsamples;
     41  1.1.1.2  christos         volatile int    valid;
     42  1.1.1.2  christos         unsigned        clockTimeStampNSec;     /* Unsigned ns timestamps */
     43  1.1.1.2  christos         unsigned        receiveTimeStampNSec;   /* Unsigned ns timestamps */
     44  1.1.1.2  christos         int             dummy[8];
     45      1.1    kardel };</pre>
     46      1.1    kardel 
     47      1.1    kardel         <h4>Operation mode=0</h4>
     48  1.1.1.2  christos         <p>Each second, the value of <code>valid</code> of the shared memory-segment is checked:</p>
     49  1.1.1.2  christos         <p>If set, the values in the record (clockTimeStampSec, clockTimeStampUSec, receiveTimeStampSec, receiveTimeStampUSec, leap, precision) are passed to ntp, and <code>valid</code> is cleared and <code>count</code> is bumped.</p>
     50  1.1.1.2  christos         <p>If not set, <code>count</code> is bumped.</p>
     51      1.1    kardel         <h4>Operation mode=1</h4>
     52  1.1.1.2  christos         <p>Each second, <code>valid</code> in the shared memory-segment is checked:</p>
     53  1.1.1.2  christos         <p>If set, the <code>count</code> field of the record is remembered, and the values in the record (clockTimeStampSec, clockTimeStampUSec, receiveTimeStampSec, receiveTimeStampUSec, leap, precision) are read. Then, the remembered <code>count</code> is compared to current value of <code>count</code> now in the record. If both are equal, the values read from the record are passed to ntp. If they differ, another process has modified the record while it was read out (was not able to produce this case), and failure is reported to ntp. The <code>valid</code> flag is cleared and <code>count</code> is bumped.</p>
     54  1.1.1.2  christos         <p>If not set, <code>count</code> is bumped</p>
     55      1.1    kardel 
     56      1.1    kardel 
     57      1.1    kardel <h4>gpsd</h4>
     58      1.1    kardel 
     59      1.1    kardel <a href="http://gpsd.berlios.de/"><i>gpsd</i></a>
     60      1.1    kardel knows how to talk to many GPS devices.
     61      1.1    kardel It works with <i>ntpd</i> through the SHM driver.
     62      1.1    kardel <P>
     63      1.1    kardel The <i>gpsd</i> man page suggests setting minpoll and maxpoll to 4.
     64      1.1    kardel That was an attempt to reduce jitter.
     65      1.1    kardel The SHM driver was fixed (ntp-4.2.5p138) to collect data each second rather than
     66      1.1    kardel once per polling interval so that suggestion is no longer reasonable.
     67      1.1    kardel <P>
     68      1.1    kardel 
     69      1.1    kardel 
     70      1.1    kardel <h4>Clockstats</h4>
     71      1.1    kardel If flag4 is set when the driver is polled, a clockstats record is written.
     72      1.1    kardel The first 3 fields are the normal date, time, and IP address common to all clockstats records.
     73      1.1    kardel <P>
     74      1.1    kardel The 4th field is the number of second ticks since the last poll.
     75      1.1    kardel The 5th field is the number of good data samples found.  The last 64 will be used by ntpd.
     76      1.1    kardel The 6th field is the number of sample that didn't have valid data ready.
     77      1.1    kardel The 7th field is the number of bad samples.
     78      1.1    kardel The 8th field is the number of times the the mode 1 info was update while nptd was trying to grab a sample.
     79      1.1    kardel <P>
     80      1.1    kardel 
     81      1.1    kardel Here is a sample showing the GPS reception fading out:
     82      1.1    kardel <pre>
     83      1.1    kardel 54364 84927.157 127.127.28.0  66  65   1   0   0
     84      1.1    kardel 54364 84990.161 127.127.28.0  63  63   0   0   0
     85      1.1    kardel 54364 85053.160 127.127.28.0  63  63   0   0   0
     86      1.1    kardel 54364 85116.159 127.127.28.0  63  62   1   0   0
     87      1.1    kardel 54364 85180.158 127.127.28.0  64  63   1   0   0
     88      1.1    kardel 54364 85246.161 127.127.28.0  66  66   0   0   0
     89      1.1    kardel 54364 85312.157 127.127.28.0  66  50  16   0   0
     90      1.1    kardel 54364 85375.160 127.127.28.0  63  41  22   0   0
     91      1.1    kardel 54364 85439.155 127.127.28.0  64  64   0   0   0
     92      1.1    kardel 54364 85505.158 127.127.28.0  66  36  30   0   0
     93      1.1    kardel 54364 85569.157 127.127.28.0  64   0  64   0   0
     94      1.1    kardel 54364 85635.157 127.127.28.0  66   0  66   0   0
     95      1.1    kardel 54364 85700.160 127.127.28.0  65   0  65   0   0
     96      1.1    kardel </pre>
     97      1.1    kardel 
     98      1.1    kardel 	<h4>Fudge Factors</h4>
     99      1.1    kardel         <dl>
    100      1.1    kardel             <dt><tt>time1 <i>time</i></tt>
    101      1.1    kardel             <dd>Specifies the time offset calibration factor, in seconds and fraction, with default 0.0.
    102      1.1    kardel             <dt><tt>time2 <i>time</i></tt>
    103      1.1    kardel             <dd>Not used by this driver.
    104      1.1    kardel             <dt><tt>stratum <i>number</i></tt>
    105      1.1    kardel             <dd>Specifies the driver stratum, in decimal from 0 to 15, with default 0.
    106      1.1    kardel             <dt><tt>refid <i>string</i></tt>
    107      1.1    kardel             <dd>Specifies the driver reference identifier, an ASCII string from one to four characters, with default <tt>SHM</tt>.
    108      1.1    kardel             <dt><tt>flag1 0 | 1</tt>
    109      1.1    kardel             <dd>Not used by this driver.
    110      1.1    kardel             <dt><tt>flag2 0 | 1</tt>
    111      1.1    kardel             <dd>Not used by this driver.
    112      1.1    kardel             <dt><tt>flag3 0 | 1</tt>
    113      1.1    kardel             <dd>Not used by this driver.
    114      1.1    kardel             <dt><tt>flag4 0 | 1</tt>
    115      1.1    kardel             <dd>If flag4 is set, clockstats records will be written when the driver is polled.
    116      1.1    kardel             <h4>Additional Information</h4>
    117      1.1    kardel             <p><a href="../refclock.html">Reference Clock Drivers</a></p>
    118      1.1    kardel         </dl>
    119      1.1    kardel         <hr>
    120      1.1    kardel         <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
    121      1.1    kardel     </body>
    122      1.1    kardel 
    123      1.1    kardel </html>
    124      1.1    kardel 
    125