Raspberry Pi Zero Time Servers Documentation
Now that TGU is selling Pi Zero NTP time servers as part of its packages online we thought we'd go ahead and test them. There's already allot of excellent documentation on the intertubes on how to setup a NTP server using Pi's so we wont go into to much detail here. We will however, provide some of basic info and some of the test results we've obtained.Reference
See the Stratum-1-Microserver HOWTO by the ntpsec people to see how things are done properly.Bill of Materials
System Details
os-release: gcc version 12.2.0 (Raspbian 12.2.0-14+rpi1) uname: Linux .... 6.6.20+rpt-rpi-v6 #1 Raspbian ntpd: ntpsec-1.2.2 hostapd: v2.10 dnsmasq: 2.89 shorewall: 5.2.8-2
Pin Out
--------------------- ------------- | Pi Zero | | GPS Board | |-------------------| |-----------| | Pin 2 5V Power | | | | Pin 4 5V Power |<-------->| VCC | | Pin 6 Ground |<-------->| GND | | Pin 8 GPIO 14 TX |<-------->| RX | | Pin 10 GPIO 15 RX |<-------->| TX | | Pin 12 GPIO 18 |<-------->| PPS | --------------------- -------------
Configs
boot/firmware/config.txt
... [all] enable_uart=1 dtoverlay=pi3-disable-bt-overlay dtoverlay=pi3-miniuart-bt dtoverlay=disable-bt dtoverlay=pps-gpio,gpiopin=18
boot/firmware/cmdline.txt
console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 fsck.repair=yes rootwaiti bcm2708.pps_gpio_pin=18
/etc/default/ntpsec
NTPD_OPTS="-g" IGNORE_DHCP="yes" NTPSEC_CERTBOT_CERT_NAME=""
/etc/ntpsec/ntp.conf
driftfile /var/lib/ntpsec/ntp.drift leapfile /usr/share/zoneinfo/leap-seconds.list refclock shm unit 1 prefer refid PPS refclock shm unit 0 refid GPS restrict -4 default kod nomodify limited restrict 192.168.0.0/8 restrict 10.10.0.0/8 restrict 127.0.0.1 restrict ::1
Testing
For testing we will be using four GPS PPS stratum1 time servers. Two of which will be Pi zero's and the other two are Pi three's that serve network time in the office. For the sake of this test we will call these hosts PiZero1, PiZero2, PiThree1 and PiThree2. Below is some sudo python code demonstrating how the test data was obtained using to "ntprace" command.loops = 20 results = {} for i in loops: for host in hosts: result = subprocess.checkout_output(["ntptrace", ip) results[host][distance] = result[distance] results[host][offset] = result[offset] for host, data in results: print us -> host, offset: sum(data[offset])/loops, distance: sum(data[distance])/loops
The Test Results
From | To | Offset ( Secs ) | Synch Distance ( Secs ) |
---|---|---|---|
PiZero1 | PiThree1 | 0.0000139 | 0.0011013 |
PiZero1 | PiThree2 | 0.0000275 | 0.0011042 |
PiZero1 | PiZero2 | 0.0000153 | 0.0011230 |
PiZero2 | PiThree1 | 0.0000129 | 0.0011252 |
PiZero2 | PiThree2 | 0.0000267 | 0.0010975 |
PiZero2 | PiZero1 | 0.0000185 | 0.0010930 |
PiThree1 | PiThree2 | 0.0000260 | 0.0011110 |
PiThree1 | PiZero1 | 0.0000000 | 0.0011042 |
PiThree1 | PiZero2 | -0.0000055 | 0.0010998 |
PiThree2 | PiThree1 | 0.0000150 | 0.0011230 |
PiThree2 | PiZero1 | 0.0000010 | 0.0011185 |
PiThree2 | PiZero2 | -0.0000050 | 0.0010862 |
Conclusions
Not bad for a couple of Pi Zero's : )
In Memory
To those who gave us time.