FreeBSD NTP Notes 1) Kernel: echo "KERNCONF= PPS-GENERIC" >> /etc/make.conf cd /usr/src/sys/amd64/conf/ echo "include GENERIC" >> PPS-GENERIC #echo "ident PPS-GENERIC" >> PPS-GENERIC echo "options PPS_SYNC" >> PPS-GENERIC 2) NTP portsnap fetch && portsnap update # 'extract' if first run portmaster net/ntp-devel echo 'ntpd_enable="YES"' >> /etc/rc.conf echo 'ntpd_program="/usr/local/sbin/ntpd"' >> /etc/rc.conf 3) Serial port: # u0 is db9, U0 is USB. # so we read PPS from u0, NMEA from U0 echo "link cuau0 pps1" >> /etc/devfs.conf echo "link cuau0 gpspps1" >> /etc/devfs.conf echo "link cuaU0 gps1" >> /etc/devfs.conf echo "initialize the usb nmea" stty -f /dev/cuaU0.init speed 4800 -parenb crtscts cstopb cs8 while read GPGGA ; do echo $GPGGA | grep GPGGA ; done < /dev/cuaU0 cu -l /dev/gps1 -s 4800 #~. 4) ntp.conf echo "wget -O /etc/ntp/leap-seconds.list ftp://time.nist.gov/pub/leap-seconds.list" > /etc/ntp/fetch-leap.sh echo "leapfile /etc/ntp/leap-seconds.list" >> /etc/ntp.conf # ref-clock drivers # http://www.eecis.udel.edu/~mills/ntp/html/drivers/driver22.html # "As the result, performance with minpoll configured at 4 (16s) is generally better than the kernel PPS discipline. # However, fudge flag 3 can be used to enable the kernel PPS discipline if necessary." # flag3: If PPS signal processing is enabled, use the ntpd clock discipline if 0 (default); use the kernel discipline if 1. #server 127.127.22.1 minpoll 4 # PPS - serialpps.sys - on COM1: #fudge 127.127.20.0 flag3 1 # http://www.eecis.udel.edu/~mills/ntp/html/drivers/driver20.html # Mode: NMEA serial port, 0 = 4800 baud, 2 = $GPGGA, 16 = 9600 # flag1: Disable PPS signal processing if 0 (default); enable PPS signal processing if 1. # flag2: If PPS signal processing is enabled, capture the pulse on the rising edge if 0 (default); capture on the falling edge if 1. # flag3: If PPS signal processing is enabled, use the ntpd clock discipline if 0 (default); use the kernel discipline if 1. server 127.127.20.1 minpoll 4 mode 18 prefer fudge 127.127.20.1 flag1 1 flag3 1 # more on kernel discipline: http://www.ntp.org/ntpfaq/NTP-s-algo-kernel.htm # more: http://www.febo.com/pipermail/time-nuts/2009-September/040610.html # "Visually, you can clearly see that the [FreeBSD 7.2] kernel PPS discipline # is superior to the ntpd PPS discipline." pool us.pool.ntp.org iburst 5) stats (from gpsd) # http://www.eecis.udel.edu/~mills/ntp/html/monopt.html statsdir /var/log/ntpstats/ statistics peerstats filegen rawstats file rawstats type day enable filegen peerstats file peerstats type day enable filegen loopstats file loopstats type day enable # mkdir -p /var/log/ntpstats # chown ntp:ntp /var/log/ntpstats awk ' /127\.127\.28\.0/ { sum += $5 * 1000; cnt++; } END { print sum / cnt; } '