|
The Raspberry Pi as a Stratum-1 NTP ServerAs an experiment, I purchased one of the low-cost credit-card-size Raspberry Pi computers, and have configured it to run NTP (Network Time Protocol). I have also used this board with a GPS receiver with pulse per second (PPS) output to make a stratum-1 NTP server, but as I know little of Linux, it has taken some time to achieve this aim! There are some helpful Linux commands scattered throughout this page. These notes are almost as much for my own records for the next time I need to visit this project, but I hope they may be helpful to others. I start by describing how to get the Raspberry Pi running with just a LAN connection - no display, keyboard or mouse - a so-calledheadless operation. I then describe how to configure NTP for your environment, and adding a GPS/PPS receiver to convert your box into a stratum-1 NTP server including the operating system updates needed. Next, I note a couple of problems I had with the first GPS receiver I tried, and how I cured those with a different GPS receiver to produce a stratum-1 NTP server consuming about 4 watts. The easiest approach with good performance is described here. Since starting this page there have been two developments which make the process somewhat easier - a program has been developed which allows the use of an unmodified operating system by working in user-mode rather than kernel-mode PPS, and a module is now available which plugs directly onto the 26-pin GPIO header of the Raspberry Pi, so no soldering is involved. My thanks to Folkert van Heusden and Anthony Stirk for these developments.
Later additions have included remote monitoring of the NTP server performance, and more general monitoring of the Raspberry Pi using the standard SNMP functions, with an additional CPU temperature monitoring add-on. My main Raspberry Pi page may also be of interest. IntroductionThe Raspberry Pi is a credit-card size computer, available from distributors across the world. I bought an attractive blue case and 5 V, 2 A power-supply from ModMyPi. You can see the Ethernet lead on the left, and the 4 GB SD card with the operating system on the right, together with the micro-USB power lead. There is a model-B (shown and used below), and a lower-spec model-A which may become available at some time in the future. I'm using the 512 MB model-B, introduced in Autumn 2012. What results can I expect?Shown below are the offset results with the Raspberry Pi in three configurations: with WAN-only connections syncing to the Internet (as you might find it a typical home situation), with LAN connections to a local stratum-1 server, and acting as a stratum-1 server itself with two different small GPS/PPS receivers as the reference clock. Any glitches in the live data are likely to be the result of me rebooting, making configuration changes, or the GPS signal being less than normal. The normal NTP configuration is listed here. As expected, syncing from the LAN produces better results than from the Internet (WAN), and making the device into a stratum-1 server results in even lower offsets. Zero offset corresponds to the middle line of the graph, as the utility I use is incapable of plotting negative values. I therefore add half the Y-axis range to the actual values before plotting. Note: these graphs are not all to the same vertical scale! Offset using Internet servers alone - millisecond scaleThe resulting performance is good, but it will depend on both the loading of the link between me and the ISP, and the general load on the ISP's network and the general Internet. Offsets are reported to be with about +/-5 milliseconds (and therefore off-scale once on the graph below). The four-line ntp.conf in use at the time is shown below the graph.
|