Time synchronization is the process of coordinating the time of independent clocks. Clocks and time pieces often utilize relatively low cost components that are not particularly precise. Many will drift by several seconds each day. Even clocks that are set to identical times will differ significantly after a relatively short period. In modern computing, clock drift can be a serious problem.
Computer System Clock Synchronization
Computer time synchronization is the process of ensuring that the system clocks of computers are coordinated. The real-time clocks of computers are as susceptible to drift as any other time piece.
However, protocols have been devised especially to maintain the co-ordination of time of networked computers. Network Time Protocol (NTP) and Precision Time Protocol (PTP) are dedicated to co-ordinating system time. The protocols distribute time stamps between one or more master clocks and time clients.
Time synchronization of computer systems is often referred to as ‘External’ or ‘Internal’. External time synchronization is a term used to describe a system that uses a time reference such as GPS or radio to provide accurate time. Internal time synchronization refers to computers being synchronized together but only between themselves and not necessarily accurately.
The Importance of Coordinated Network Time
In modern distributed computer applications, the synchronization of system time between computers is often critical. Time is the only reference that is available that can be used to determine the order of processes or the sequencing of events. In fact, for many applications, the accurate synchronization of computer systems is a legal requirement.
Control environments require tasks, carried out by independent devices, to be performed in an ordered manner. This would be impossible without synchronization. Similarly, event logging or transaction processing can only be carried out with coordinated time in order to determine exactly when events occurred.
In many jurisdictions, financial trading legislation, such as MiFID II, requires the synchronization of all business clocks that are used to record the time of events. Legislation may also specify the regulatory technical standards for the level of accuracy of clocks.
To be admissible in court, networked security cameras and recording equipment may need to be coordinated with a legally traceable source of time. This is in order to undisputedly prove the time that events or crimes actually took place.
Network Time Protocol (NTP)
Network Time Protocol (NTP) was developed to co-ordinate the time of the Internet and networked computers. It is one of the oldest Internet protocols still in use today.
NTP implements a hierarchical system of time references. The hierarchy level, referred to as stratum, represents the distance of a time synchronization server from a source reference clock. The lower the stratum, the closer the reference clock. Stratum 1 devices are connected directly to a hardware clock, such as a GPS or radio time source.
Due to network packet latency, each stratum level degrades accuracy, therefore the closer a time client is to a reference clock, the more accurate it will be.
There are a large number of free-access NTP servers available on the Internet. However, they have a number of drawbacks. Many are misconfigured and cannot always be relied upon. There is no guarantee of service, they can be unreliable, temporarily going off-line. Additionally, Internet network latencies and delays introduce timing inaccuracies. Security can also be an issue due to the requirement to leave a port open in your firewall to allow NTP communication.
Dedicated Stratum-1 GPS NTP servers installed directly on a network can overcome all of the disadvantages of Internet time servers. Network latencies are vastly reduced and security improved because there is no requirement for Internet access.
Time Synchronization Of Windows Operating Systems
Windows has a dedicated time synchronization service called Windows Time (w32time.exe). For peer-to-peer networks, the service is controlled from the Date and Time applet. The service allows the computer clock to synchronize with an Internet or local NTP time server. The domain name or IP address of a time server is entered in the Internet Time tab of the applet. By default, Windows uses the ‘time.windows.com’ server maintained by Microsoft. The system clock is typically updated by the service every week. However, an update can be forced by clicking the “Update now” button, which tests the availability of the selected server. More regular updates can be scheduled by editing the registry key:
Windows Domain Time Synchronization
Windows domains or active directory set time in a hierarchical manner. The Primary Domain Controller (PDC) of the root domain obtains time from an external NTP server (Internet or local).
The PDC of a domain obtains time from any domain controller of the parent domain. All domain controllers set their time from the PDC of the domain. All member machines or workstations obtain time from any domain controller.
Generally, the default time service configuration is sufficient. However, the w32tm.exe command line utility can be used to change or add time servers to the PDC.
w32tm /config /manualpeerlist:”timeserverlist” /syncfromflags:manual /reliable:yes /update
where timeserverlist is a space delimited list of NTP servers enclosed in quotation marks.
The following command can be run on Domain Controllers to configures the machine to use the domain hierarchy (AD) as its time source.
w32tm /config /syncfromflags:domhier /update
In order for any changes to take effect, the w32time service must be restarted with:
net stop w32time net start w32time
Synchronizing Linux and UNIX Operating Systems
Linux and UNIX operating systems use the standard NTP daemon to set the system clock. In most installations, this is installed by default. However, source code for compilation can be obtained from the NTP distribution web site.
The NTP daemon, takes its settings from a configuration file at start-up, the default location is /etc/ntp.conf. The file consists of a number of configuration commands to control the behaviour of the NTP daemon.
A basic NTP configuration file:
# File: /etc/ntp.conf # List of time servers for synchronization server 0.pool.ntp.org server 1.pool.ntp.org server 2.pool.ntp.org # Specify location of drift file driftfile /etc/ntp.drift
The first lines of the configuration file specify the servers that are to be contacted and used in the clock selection algorithm. The server address can either be a fully qualified domain name or an IP address.
It is considered good practice to specify an odd number of servers. This allows servers with erroneous time, or false tickers, to be detected and excluded from the clock selection algorithm.
The drift file specifies the location of a file that can store the frequency error, or drift, of the system clock. The file is updated every hour but needs at least a 24-hour period to calculate a meaningful value.
The file is used to initialize the frequency error used by the NTP daemon at start-up. It is recommended that a drift file is always specified in the configuration file to facilitate synchronization.
NTP also includes a number of utilities to query and debug the service. Most useful is the standard ntp query program – ntpq.
The command line “ntpq -p” can be used to shows the status and working parameters of the reference clock peers used by the NTP service:
remote refid st t when poll reach delay offset jitter ====================================================================== *ntp1.npl.co.uk 22.214.171.124 2 u 522 1024 377 11.661 -1.143 0.229 +ntp2.npl.co.uk 126.96.36.199 2 u 845 1024 377 18.395 2.047 1.016 +ntp1.ja.net 188.8.131.52 2 u 931 1024 377 12.693 1.035 0.331
Status information includes: the domain name and IP address of the reference clock, how often it is polled and when it was last polled. The time taken to contact the peer along with the offset to current system time and the clock quality, or jitter, is also shown.
For a full list of standard query program options, refer to: http://doc.ntp.org/4.1.0/ntpq.htm
Synchronized time and the co-ordination of time of computer systems and networks is of critical importance. Network Time Protocol (NTP) is one of a number of protocols dedicated to maintaining accurate system time. NTP is widely available on many operating systems including Windows, Linux and UNIX. Internet time sources provide a free source of accurate time, but have a number of disadvantages compared to Stratum 1 GPS referenced time synchronization servers.
TimeTools is a leading UK manufacturer of Stratum 1 GPS and GNSS referenced time sources for network timing applications.