The habrauser
BarsMonster with his topic
"About the exact time" pushed me to write this note.
In his article, he called on habrauser "Give more Stratum-1 servers", but did not say how (:
The choice of the source of exact time
I did this work about three years ago, when there was much less information on this topic online. The main source of my knowledge was the documentation from the ntp-doc package (/usr/share/doc/ntp-doc/html/refclock.html), and it can also be found on the
web .
The name Stratum-1 itself means that our NTP server is directly connected to the exact time source.
Let's see what we have options for these sources:
- Time radio stations
Nothing complicated, we take the appropriate frequency from the directory , solder the receiver and the converter into an interface convenient for the computer. ^ _ ^
I abandoned this option because Opposite of my old work, the building stood either FAPSI, or some other service, in general, the broadcast was quite noisy (-:
- GSM or CDMA phone
Somehow I do not trust them, although not the worst option.
- GPS or GLONASS receiver
This option seemed to me the most realistic.
We connect
The GLONASS receiver was then difficult to get, so I went to the store and bought a GPS receiver with an RS232 interface and an external antenna. The antenna stuck to the metal window sill outside the window, and the receiver, respectively, connected to the COM port of one of the servers.
First of all, we need to make sure that the receiver "sees" the satellites. My, for example, in this case begins to wink at a fun LED.
A more universal way is to see what it gives to the COM port:
cat / dev / ttyS0
Here we should see a NMEA protocol dump.
')
Customize
For ntpd to work, we need to make symbolic links:
/ dev / gps0 -> / dev / ttyS0
If you use udev, then it will be useful to create a rule /etc/udev/rules.d/10-gps.rules with the following content:
KERNEL == "ttyS0", NAME = "% k", SYMLINK + = "gps0", MODE = "0660", GROUP = "uucp"
Modify ntp.conf:
# Local Clock - if we lose satellites, then reduce the stratum to 10
server 127.127.1.0
fudge 127.127.1.0 stratum 10
# NMEA GPS driver
server 127.127.20.0 prefer
driftfile /var/lib/ntp/ntp.drift
restrict default nomodify notrust # Give time to everyone
restrict 127.0.0.1 # Allow yourself everything
disable auth
logfile / var / log / ntp / messages
In the line server 127.127.20.0, the number 20 is the
answer to the “main question of life, the universe and in general” the number of the corresponding
driver of the exact time source .
Restart the NTPD and see the status. There must be something like this:
ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
LOCAL(0) LOCAL(0) 10 l 52 64 377 0.000 0.000 0.002
*GPS_NMEA(0) .GPS. 0 l 15 64 377 0.000 -0.018 0.004
Everything, the server can be
promoted to register in the
list of stratum-1 servers .
I hope this article will help to increase the number of good NTP servers in RuNet (-;
[Important UPD]A person knocked me in IM, he does not have an account on Habré, asked me to clarify the situation with COM-USB adapters. I quote:
brn:
So, since in the receivers often one of the service pins of the COM connector is connected to a 1PPS signal, which indicates the beginning of the next second, in the case of USB this signal will be lost
And, since the NMEA signal without PPS gives an accuracy of about 50-100 milliseconds, and for an exact time server this is unacceptable
This just explains why I had such a run-up with a colleague from Novosibirsk - my PPS receiver did not support.
To use PPS, you need to replace NMEA with PPS in the ntp config:
# PPS driver
server 127.127.22.0 prefer
enable pps
[UPD2]We
meet new habrakollegu
brn !
He has already managed to write a
topic about NMEA .
BarsMonster , thanks for the invite.