Every computer is equipped with at least a clock chip or a general purpose device to provide a timer function. While these timers are certainly precise enough for measuring relatively short periods of time, they are not well suited for keeping the correct time and date over a longer period, since almost every chip drifts by a few seconds per day. Even so called real-time clocks only approximately meet the real time.
External time sources can be used to synchronize the local clock with a much more precise time information. Time signals are disseminated over various systems, the best known are the US american GPS (Global Positioning System) and time signal stations. Time signal stations are available in many countries, they transmit time information over long-wave radio signals; while the coding schemes vary from time signal station to time signal station, the decoding principles are similar.
This paper is a detailed description of my work over the last twelve months to add support for both, GPS and time signal stations, to OpenBSD in a novel way and how these new time related drivers interact with the operating system and applications like OpenNTPD that make use of external time sources.
The paper outlines the general problems of setting a computers clock at runtime, then gives an overview about time signal stations, how they work and what codes they use (detailing the German DCF77 and the Swiss HBG station, and also the Japanese time signal stations); it will then outline how GPS systems can deliver time information to a computer and which precision can be expected. It will then discuss how time is handled in OpenBSD (which is different to most other operating systems) and describe the OpenBSDs own NTP implementation OpenNTPD.
The functionality of the new time related drivers in OpenBSD, udcf(4), nmea(4), and mbg(4) and how they interact with the system is explained. Implementation details of the new drivers are given especially how time signal stations can be decoded with relatively simple receivers using an elegant algorithm.
Marc Balmer, a former lecturor and member of the board of the department Hyperwerk of University of Applied Sciences in Basel, has been working with various BSD based systems for more than 20 years. He is the owner of a UNIX consulting and development company in Basel, Switzerland. He is an active OpenBSD developer since 2004.