Sysadmin > NtP

Timeserver with ntp

WORK IN PROGRESS

Hardware timestamping

Special Hardware (FPGA-Based)

Commodity Hardware

  • Intel 82580 -- The NIC I'm most familiar with that supports general hw timestamping is the Intel 82580 Gigabit Ethernet Controller. It can timestamp all RX packets in hardware, but only PTP TX packets.
  • Intel i340
  • Neterion X3110/X3120

The current Intel controllers supporting IEEE 1588 are the Intel® 82574, 82576, and 82580 Gigabit Ethernet Controllers, the Intel® 82599 10 Gigabit Ethernet Controller, and Intel® Ethernet Controller I350

CalibrateYourOwnStratum1

RaspberryGpsNtpServer

RaspberryNtpOptimization

Two other things that I have changed were the cpu_scaling and the serial latency:

  • echo "performance" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
  • setserial /dev/ttyAMA0 low_latency

It appears that the Ethernet latency on the Pi is fairly large, but it can be reduced at a slight cost in performance. To do this, edit your:

/boot/cmdline.txt and add:

smsc95xx.turbo_mode=0 (or smsc95xx.turbo_mode=N ??) along with all the other parameters that are being set.

This disables a feature of the Ethernet controller that tries to pack multiple received frames into a single USB transfer. In order to do this, the controller waits after receiving a frame (in the hope of receiving another frame) before passing any data back to the host. Setting turbo_mode to 0 reduced a ping RTT (Round Trip Time) from 500-600 µs down to 300-350 µs.

befor
root@raspberrypi:/boot# ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 GPS_NMEA(0)     .GPS.            0 l    1   16  377    0.000  140.392  29.463
 PPS(0)          .PPS.            0 l    -   16  377    0.000   -1.375   0.049
*ntp1.ntp.servic .PPS.            1 u  510 1024  377    0.775   -2.563   1.636
+ntp1.bff.iv.bfi .PPS.            1 u  827 1024  377    8.559   -2.145   1.633
+ntp3.ntp.servic .PPS.            1 u  227 1024  377    1.449   -1.314   1.630
+ntp3.mgm.zivit. .GPS.            1 u  105 1024  377    7.959   -2.168   1.510

after
root@raspberrypi:~# ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 GPS_NMEA(0)     .GPS.            0 l    3   16  377    0.000   94.814 106.070
 PPS(0)          .PPS.            0 l    3   16  377    0.000    0.085   0.004
*ntp1.ntp.servic .PPS.            1 u   19   64  377    0.708    0.110   0.026
-ntp1.bff.iv.bfi .PPS.            1 u   40   64  377    8.244    0.018   0.195
+ntp3.ntp.servic .PPS.            1 u   37   64  377    1.318    0.250   0.272
+ntp3.mgm.zivit. .GPS.            1 u   30   64  377    7.461    0.033   0.068
root@raspberrypi:/var/tmp# ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 GPS_NMEA(0)     .GPS.            0 l    7   16  377    0.000  385.235  24.709
 PPS(0)          .PPS.            0 l    7   16  377    0.000    0.006   0.004
*ntp1.ntp.servic .PPS.            1 u   49  128  377    0.731    0.022   0.087
-ntp1.bff.iv.bfi .PPS.            1 u  108  128  377    8.208   -0.065   0.845
+ntp3.ntp.servic .PPS.            1 u   64  128  377    1.281    0.231   0.224
+ntp3.mgm.zivit. .GPS.            1 u  118  128  377    7.740    0.067   0.059
root@raspberrypi:~# ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 GPS_NMEA(0)     .GPS.            0 l    3   16  377    0.000  219.705  68.095
 PPS(0)          .PPS.            0 l    3   16  377    0.000    0.220   0.019
*ntp1.ntp.servic .PPS.            1 u  414 1024  377    0.760    0.125   1.953
+ntp1.bff.iv.bfi .PPS.            1 u  467 1024  377    8.515   -0.458   2.012
+ntp3.ntp.servic .PPS.            1 u  393 1024  377    1.443   -0.105   1.482
+ntp3.mgm.zivit. .GPS.            1 u  247 1024  377    7.778   -0.257   1.565

WatchInterrupts

  • watch -n1 "cat /proc/interrupts"

MonitorNtpWithGnuplot

cat peerstats.201410 | awk 'function abs(x){return ((x < 0.0) ? -x : x)} {if ($6 < 0.2 && abs($5) < 0.04) print}' > peerstats.201410.2

plot "peerstats.201410.2" using 6:5 with dots

What does .RATE. mean?

# ntpq -p
     remote refid st t when poll reach delay offset jitter
==============================================================================
-ntp1.ntp.servic .RATE. 16 u 956 1024 212 0.534 -0.329 0.014
+ntp1.bff.iv.bfi .PPS. 1 u 587 1024 377 6.340 -0.235 0.016
*ntp3.ntp.servic .RATE. 16 u 696 1024 376 1.010 -0.243 0.073
+ntp3.mgm.zivit. .GPS. 1 u 148 1024 377 6.631 0.094 0.029

Sometimes the ntp-client asks too often the peer time server and answers with a "slow-down"-packet.

In this case you can try to disable iburst and set a maxpoll option or you can disable the limited and kod flags in the restrict command.

Howto setup a time server with ntpd

WORK IN PROGRESS

Minimal setup

Use a minimal ntp.conf

driftfile /var/lib/ntp/ntp.drift
server 0.pool.ntp.org iburst
server 1.pool.ntp.org iburst
server 2.pool.ntp.org iburst
server 3.pool.ntp.org iburst

Tuning your time server

Calibrate your fudge time1

On Sat, 24 Apr 2004 01:57:25 +0200, Wes Irish wrote:

> 1) How bet to determine the correct time1 fudge value to properly adjust
> my local reference clock for the various hardware and software delays of
> my particular configuration.

First, fudge the GPS to a high stratum. At least higher than the servers
you sunc you time against to make sure you will not sync the time with
the GPS. Then, in ntpdc type in "enable calibrate". This command will try
to change the time1 value so the offset will be minimal. Leave it for at
least an hour for things to stabilize. Note the number of time1 (check in
ntpq with the cv command). and enter it in the ntp.conf.