3

I use ntp with a GPS device with PPS on port /dev/ttyS0. All seems to be fine if the machine is connected to the internet. Output looks correct. But if there is no internet connection I get:

$ ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 fritz.box       .INIT.          16 u    - 1024    0    0.000    0.000   0.000
 GPS_NMEA(0)     .GPS.            0 l    -   16    0    0.000    0.000   0.000

I think because there is no o prefix GPS_NMEA doesn't work. My current ntp configuration is

# /etc/ntp.conf, configuration for ntpd; see ntp.conf(5) for help

driftfile /var/lib/ntp/ntp.drift

# Enable this if you want statistics to be logged.
statsdir /var/log/ntpstats/

statistics clockstats
filegen clockstats file clockstats type day enable

# Specify one or more NTP servers.

# Use servers from the NTP Pool Project. Approved by Ubuntu Technical Board
# on 2011-02-08 (LP: #104525). See http://www.pool.ntp.org/join.html for
# more information.
server 0.ubuntu.pool.ntp.org
server 1.ubuntu.pool.ntp.org
server 2.ubuntu.pool.ntp.org
server 3.ubuntu.pool.ntp.org

# Use Ubuntu's ntp server as a fallback.
server ntp.ubuntu.com

# NMEA refclock driver directly from serial port within ATOM clock support (flag 1)
server 127.127.20.0 mode 18 minpoll 4 maxpoll 4 iburst prefer
fudge 127.127.20.0 flag1 1 flag2 0 flag3 1 flag4 0 time2 0.475

# By default, exchange time with everybody, but don't allow configuration.
restrict -4 default kod notrap nomodify nopeer noquery
restrict -6 default kod notrap nomodify nopeer noquery

# Local users may interrogate the ntp server more closely.
restrict 127.0.0.1
restrict ::1

What do I need to configure that ntp is using the GPS source too if there is no internet connection. I read I need at least two time sources but I think using GPS time with PPS is better than just trust the local isolated clock?

EDIT

I will use it for accurate astronomical pointing. Mostly there is a internet connection availible. But sometimes I have no connection and also want a accurate time.

I removed iburst and the output now is

$ ntpq -pcrv
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
oGPS_NMEA(0)     .GPS.            0 l    7   16  377    0.000   -0.179   0.019
associd=0 status=041d leap_none, sync_uhf_radio, 1 event, kern,
version="ntpd 4.2.6p5@1.2349-o Sun Oct 19 04:29:07 UTC 2014 (1)",
processor="x86_64", system="Linux/3.13.0-37-generic", leap=00, stratum=1,
precision=-20, rootdelay=0.000, rootdisp=0.520, refid=GPS,
reftime=d7effd04.fccd2064  Mon, Oct 20 2014 23:28:36.987,
clock=d7effd0b.5652112f  Mon, Oct 20 2014 23:28:43.337, peer=22523, tc=4,
mintc=3, offset=-0.179, frequency=6.121, sys_jitter=0.019,
clk_jitter=0.000, clk_wander=0.080

But there is one difference to the first approach this afternoon. Now I connect my laptop direct to the server. In the first approach I talking to the server over a FritzBox without an internet connection. As you can see there is an time source entry in the first paste. Maybe the router causes ntpd to stop because there are only two timesources now? I think the normal case would be without a router with no internet connection. Anyway, could I avoid this situation?

  • Can you give some more context here? What is the application for this combination of technologies? – ewwhite Oct 20 '14 at 14:18
  • @ewwhite Sorry I didn't get your point. It seems to be common to use GPS and PPS to synchronize the time via ntpd. – wenzul Oct 20 '14 at 14:22
  • GPS, sometimes... just wondering what the concern with internet access was, or really, more detail about the environment. – ewwhite Oct 20 '14 at 14:23
  • 1
    Always paste the output of ntpq -pcrv when asking ntp questions. It is strange that network access is preventing ntpd from talking to the GPS. iburst makes no sense on a reference clock line. I would remove the iburst option and restart ntpd and see if that helps. If it doesnt help then remove all external servers and see what happens. – dfc Oct 20 '14 at 21:00
  • 1
    FYI: two time sources is the worst number of time sources. ntpd will not know how to break a tie between the difference time sources. – dfc Oct 20 '14 at 21:00
2

Remove the iburst from the reference clock entry. You could also make the following changes to the server entries:

Change:

server 0.ubuntu.pool.ntp.org
server 1.ubuntu.pool.ntp.org
server 2.ubuntu.pool.ntp.org   
server 3.ubuntu.pool.ntp.org

To:

 pool 0.ubuntu.pool.ntp.org iburst
 pool 1.ubuntu.pool.ntp.org iburst
 pool 2.ubuntu.pool.ntp.org iburst
 pool 3.ubuntu.pool.ntp.org iburst

And remove the ntp.ubuntu.com entry. The pool directive implies preempt so it is more tolerant of intermittent network issues.

I am posting the answer that was in my comment in case other people have this problem. Please update your post if this was not adequate.

| improve this answer | |
  • When I have a fritzbox connected, ntp still not use the PPS properly. – wenzul Nov 13 '14 at 19:07
  • Using pool instead of server does the trick. – rudolfbyker Apr 13 '17 at 7:59
1

I would suggest you add true to the server line, among iburst and prefer. Having true lets the server survive NTP's algorithmic weeding of servers.

# NMEA refclock driver directly from serial port within ATOM clock support (flag 1)
server 127.127.20.0 mode 18 minpoll 4 maxpoll 4 true prefer
fudge 127.127.20.0 flag1 1 flag2 0 flag3 1 flag4 0 time2 0.475
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.