r8 - 2011-03-16 - 07:39:46 - DavidTaylorYou are here: NTP >  Support Web > ConfiguringNTP > ConfiguringRefclocks > ConfiguringNMEARefclocks
NTP users are strongly urged to take immediate action to ensure that their NTP daemons are not susceptible to being used in distributed denial-of-service (DDoS) attacks. Please also take this opportunity to defeat denial-of-service attacks by implementing Ingress and Egress filtering through BCP38.

ntp-4.2.8p15 was released on 23 June 2020. It addresses 1 medium-severity security issue in ntpd, and provides 13 non-security bugfixes over 4.2.8p13.

Please see the NTP Security Notice for vulnerability and mitigation details.

Are you using Autokey in production? If so, please contact Harlan - he's got some questions for you.
&#&# REFACTOR See ConfiguringNMEARefclocksDev for discussion of this topic.

6.1.12. Configuring NMEA Refclocks

Generic NMEA refclocks use the 127.127.20.x driver. The configuration directives required depends on the receiver and its internal configuration. The basic ntp.conf configuration is:


For configuration details please see the examples listed below or the distribution documentation Generic NMEA GPS Receiver page.

Configuring NMEA clocks Accord NAV2300 GPS Clock

Accord's NAV2300 GPS Clock generates few standard NMEA sentences and a custom NMEA sentence at 9600B. Unlike the standard NMEA sentences which contain UTC time, the custom NMEA sentence has GPS time as shown below:


It contains the GPS timestamp valid for next PPS pulse. Apart from the familiar fields,

  • 'AA.BB' denotes the signal strength( should be < 05.00 )
  • 'V' denotes the GPS sync status :
    • '0' indicates INVALID time,
    • '1' indicates accuracy of +/-20 ms
    • '2' indicates accuracy of +/-100 ns

Since the NMEA refclock driver was designed to work at 4800B, this GPS Clock cannot be used with NTP. To enable the support, the reference clock driver has been updated with following features:

  • Support for 9600B (default is 4800B)
  • Support for parsing Accord's custom NMEA sentence (contains GPS Time not UTC)

The unused bits of the mode field have been used for this purpose.

  • bit 0 - enables RMC (1)
  • bit 1 - enables GGA (2)
  • bit 2 - enables GLL (4)
  • bit 3 - enables ZGD (8) - Accord GPS Clock's custom sentence with GPS time
  • bit 4 - selects the baudrate for serial port :
    • 0 for 4800B (default)
    • 1 for 9600B

Multiple sentences may be selected except when ZDG is selected. In case of incorrect mode selection, the driver falls back to standard NMEA sentences. The clock generates PPS pulse at TTL levels (with 5 ms on time). A sample configuration for this clock is shown below:

server mode 24
fudge flag2 0
fudge flag3 1

-- VenuGopal - 11 Apr 2008 Garmin GPS18x LVC

The Garmin GPS18x LVC exposes a behaviour that makes the receiver hard to use without PPS support: It seems to center its serial output roughly between the PPS pulses and has a noticeable jitter when doing so. Timing measurements are tricky, but if you use more output sentences per cycle then the GPRMC will have less delay in relation to the PPS pulse.

The Garmin manual states that the NMEA data transmitted is related to the PPS pulse prior to the serial data, and that GPRMC is always output first in a burst.

So at least for the Garmin GPS18x LVC the question about the size of the delay between the PPS pulse and a data sentence depends on the baudrate and the number of sentences to be transmitted. Using GPRMC only at 4800bd gives a delay of roughly 590ms, GPRMC only at 9600bd gives a delay of roughly 510ms.

Using the additional PPS feature of the NMEA driver is highly recommended for the GPS18x LVC: There is jitter of several milliseconds for the serial transmission, which makes synchronisation to this device very slow and sometimes even sluggish. The PPS-aware code of the NMEA driver after NTP-4.2.6p3-RC7 or NTP-4.2.7p72 can substitute the PPS time stamp for the serial receive time stamp when the difference between them is less than 400ms. (This is not the full truth, but see below.) Since the delay between the end of the serial data and the PPS pulse is bigger than that, a fudge time2 of 500 to 600ms is needed to compensate for the delay. Otherwise the driver would either discard the PPS data or even lock to the next second pulse, which gets ntpd off by one second with micro-second accuracy.

So a recommended config entry in ntp.conf for a Garmin GPS18x LVC (using only GPRMC @ 4800bd) with PPS enabled would look like:

server mode 0 prefer
fudge flag1 1 flag2 0 time2 0.600

Setting flag1 to 1 enables PPS processing within the NMEA driver. Setting flag2 to zero is redundant, but will explicitely tell that we want the 'assert' edge of the PPS signal. The exact value for fudge time2 is not very critical when using PPS; as long as the fudge time2 gets the adjusted receive time stamp into 400ms around the time of the PPS pulse the driver will lock the receive time stamp to the PPS time stamp. So basically setting the fudge time2 to 600ms (because the NMEA data is late for roughly 1/2second plus some ten milliseconds) should get you up and running quite fast.

If you want a good estimation for fudge time2 (perhaps because PPS is not an option for you) you could use the following procedure:

  1. Switch off the PPS processing for the NMEA driver and mark the clock as noselect. Set the fudge time2 to zero. Add a few good public time servers or another clock; here in Germany I can use my DCF77 radio clock for that purpose. Disable all output sentences of the GPS18x LVC but the GPRMC sentence.
  2. Restart the daemon and watch the offset for the NMEA clock. When the value gets stable, use the absolute value of the offset as fudge time2 for the NMEA driver.
  3. Optionally restart ntpd and verify that the offset remains small. Note the jitter, which is probably in the order of 5-10msec. If the offset is small enough (better than 2ms is doable, but takes a long time to stabilise), go to the next step. Otherwise fine-tune fudge time2 and repeat this step.
  4. Enable PPS processing again if you can. After restarting ntpd jitter and offset should decrease rather fast.
  5. Finally, remove the noselect statement and enjoy your fast-locking NMEA clock with a Garmin GPS18x LVC!

And now the truth about the PPS locking: actually only the sub-second part of the difference between PPS time stamp and (receive time stamp - fudge time2) is evaluated and checked. If this difference is less than 400ms or bigger than 600ms (which is equivalent to -400ms) the receive time stamp will be substituted with the properly adjusted PPS time stamp. This might sound a bit complicated, but if you have a device that sends the data before the associated PPS pulse, you can use the proper negative value for fudge time2 and compensate for that behaviour.

-- JuergenPerlinger - 2010-10-26

Note that firmware versions after 3.20 push the NMEA output even further after the PPS transition, perhaps even to the next PPS edge, making the device problematic as a single reference source. Given another refclock which will get the server within a second, it may be best to simply use the PPS signal from the 18x and not the NMEA output.

-- DavidTaylor - 2011-03-08 Sure Electronics GPS evaluation board

I have sucessfully used the Sure Electronics GPS evaluation board (http://www.sureelectronics.net/goods.php?id=99) with NTP. With that board, two patch wires are required to convert the on-board CMOS-level PPS signal to RS-232 level. I have documented those patches here: http://www.satsignal.eu/ntp/Sure-GPS.htm

I also found that with the Windows NTP version, the timing of the NMEA signal was such that NTP worked better when set to use $GPGGA, which is the first sentence sent. The configuration was then:

server minpoll 4 # PPS - serialpps.sys
server minpoll 4 mode 18 prefer # NMEA serial port, 16 = 9600 baud, 2 = $GPGGA

In earlier tests, I had also altered the baud rate, although I no longer believe this is required. With a 115,200 baud rate, the configuration was then:

server minpoll 4 # PPS - serialpps.sys
server minpoll 4 mode 82 prefer # NMEA serial port, 80 = 115200 baud, 2 = $GPGGA

In fact, it seems that the board may lose the baud rate setting after a period of being powered down, so best leave it set at 9600 baud.

-- DavidTaylor - 2011-03-08

Related Topics: NMEARefclockUsers, Generic NMEA GPS Receiver page

Edit | WYSIWYG | Attach | Printable | Raw View | Backlinks: Web, All Webs | History: r12 | r10 < r9 < r8 < r7 | More topic actions...
SSL security by CAcert
Get the CAcert Root Certificate
This site is powered by the TWiki collaboration platform
IPv6 Ready
Copyright & 1999-2021 by the contributing authors. All material on this collaboration platform is the property of the contributing authors. Ideas, requests, problems regarding the site? Send feedback