The Network Time Protocol (NTP) is a
networking protocol
A communication protocol is a system of rules that allows two or more entities of a communications system to transmit information via any variation of a physical quantity. The protocol defines the rules, syntax, semantics (computer science), sem ...
for
clock synchronization
Clock synchronization is a topic in computer science and engineering that aims to coordinate otherwise independent clocks. Even when initially set accurately, real clocks will differ after some amount of time due to clock drift, caused by clocks ...
between computer systems over
packet-switched
In telecommunications, packet switching is a method of grouping data into short messages in fixed format, i.e. '' packets,'' that are transmitted over a digital network. Packets consist of a header and a payload. Data in the header is used b ...
, variable-
latency data networks. In operation since before 1985, NTP is one of the oldest Internet protocols in current use. NTP was designed by
David L. Mills of the
University of Delaware
The University of Delaware (colloquially known as UD, UDel, or Delaware) is a Statutory college#Delaware, privately governed, state-assisted Land-grant university, land-grant research university in Newark, Delaware, United States. UD offers f ...
.
NTP is intended to
synchronize
Synchronization is the coordination of events to operate a system in unison. For example, the conductor of an orchestra keeps the orchestra synchronized or ''in time''. Systems that operate with all parts in synchrony are said to be synchrono ...
participating computers to within a few
millisecond
A millisecond (from '' milli-'' and second; symbol: ms) is a unit of time in the International System of Units equal to one thousandth (0.001 or 10−3 or 1/1000) of a second or 1000 microseconds.
A millisecond is to one second, as one second i ...
s of
Coordinated Universal Time
Coordinated Universal Time (UTC) is the primary time standard globally used to regulate clocks and time. It establishes a reference for the current time, forming the basis for civil time and time zones. UTC facilitates international communicat ...
(UTC).
It uses the
intersection algorithm, a modified version of
Marzullo's algorithm, to select accurate
time servers and is designed to mitigate the effects of variable
network latency
Network delay is a design and performance characteristic of a telecommunications network. It specifies the latency for a bit of data to travel across the network from one communication endpoint to another. It is typically measured in multiples ...
. NTP can usually maintain time to within tens of milliseconds over the public
Internet
The Internet (or internet) is the Global network, global system of interconnected computer networks that uses the Internet protocol suite (TCP/IP) to communicate between networks and devices. It is a internetworking, network of networks ...
, and can achieve better than one millisecond accuracy in
local area network
A local area network (LAN) is a computer network that interconnects computers within a limited area such as a residence, campus, or building, and has its network equipment and interconnects locally managed. LANs facilitate the distribution of da ...
s under ideal conditions. Asymmetric
routes and
network congestion
Network congestion in data networking and queueing theory is the reduced quality of service that occurs when a network node or link is carrying more data than it can handle. Typical effects include queueing delay, packet loss or the blocking of ...
can cause errors of 100 ms or more.
The protocol is usually described in terms of a
client–server model
The client–server model is a distributed application structure that partitions tasks or workloads between the providers of a resource or service, called servers, and service requesters, called clients. Often clients and servers communicate ov ...
, but can as easily be used in
peer-to-peer
Peer-to-peer (P2P) computing or networking is a distributed application architecture that partitions tasks or workloads between peers. Peers are equally privileged, equipotent participants in the network, forming a peer-to-peer network of Node ...
relationships where both peers consider the other to be a potential time source.
Implementations send and receive
timestamp
A timestamp is a sequence of characters or encoded information identifying when a certain event occurred, usually giving date and time of day, sometimes accurate to a small fraction of a second. Timestamps do not have to be based on some absolu ...
s using the
User Datagram Protocol
In computer networking, the User Datagram Protocol (UDP) is one of the core communication protocols of the Internet protocol suite used to send messages (transported as datagrams in Network packet, packets) to other hosts on an Internet Protoco ...
(UDP) on
port number
In computer networking, a port is a communication endpoint. At the software level within an operating system, a port is a logical construct that identifies a specific process or a type of network service. A port is uniquely identified by a numbe ...
123.
They can also use
broadcasting
Broadcasting is the data distribution, distribution of sound, audio audiovisual content to dispersed audiences via a electronic medium (communication), mass communications medium, typically one using the electromagnetic spectrum (radio waves), ...
or
multicasting, where clients passively listen to time updates after an initial round-trip calibrating exchange.
NTP supplies a warning of any impending
leap second
A leap second is a one-second adjustment that is occasionally applied to Coordinated Universal Time (UTC), to accommodate the difference between precise time (International Atomic Time (TAI), as measured by atomic clocks) and imprecise solar tim ...
adjustment, but no information about local
time zone
A time zone is an area which observes a uniform standard time for legal, Commerce, commercial and social purposes. Time zones tend to follow the boundaries between Country, countries and their Administrative division, subdivisions instead of ...
s or
daylight saving time
Daylight saving time (DST), also referred to as daylight savings time, daylight time (Daylight saving time in the United States, United States and Daylight saving time in Canada, Canada), or summer time (British Summer Time, United Kingdom, ...
is transmitted.
The current protocol is version 4 (NTPv4), which is
backward compatible
In telecommunications and computing, backward compatibility (or backwards compatibility) is a property of an operating system, software, real-world product, or technology that allows for interoperability with an older legacy system, or with inpu ...
with version 3.
Clock synchronization algorithm

A typical NTP client regularly
polls one or more NTP servers. The client must compute its time offset and
round-trip delay
In telecommunications, round-trip delay (RTD) or round-trip time (RTT) is the amount of time it takes for a signal to be sent ''plus'' the amount of time it takes for acknowledgement of that signal having been received. This time delay includes p ...
. Time offset ''θ'' is positive or negative (client time > server time) difference in absolute time between the two clocks. It is defined by
and the round-trip delay ''δ'' by
where
*''t''
0 is the client's timestamp of the request packet transmission,
*''t''
1 is the server's timestamp of the request packet reception,
*''t''
2 is the server's timestamp of the response packet transmission and
*''t''
3 is the client's timestamp of the response packet reception.
To derive the expression for the offset, note that for the request packet,
and for the response packet,
Solving for ''θ'' yields the definition of the time offset.
The values for ''θ'' and ''δ'' are passed through filters and subjected to statistical analysis ("mitigation").
Outlier
In statistics, an outlier is a data point that differs significantly from other observations. An outlier may be due to a variability in the measurement, an indication of novel data, or it may be the result of experimental error; the latter are ...
s are discarded and an estimate of time offset is derived from the best three remaining candidates. The clock frequency is then adjusted to reduce the offset gradually ("discipline"), creating a
feedback loop
Feedback occurs when outputs of a system are routed back as inputs as part of a chain of cause and effect that forms a circuit or loop. The system can then be said to ''feed back'' into itself. The notion of cause-and-effect has to be handle ...
.
Accurate synchronization is achieved when both the incoming and outgoing routes between the client and the server have symmetrical nominal delay. If the routes do not have a common nominal delay, a
systematic bias
Systematic may refer to:
Science
* Short for systematic error
* Systematic fault
In engineering, a fault is a defect or problem in a system that causes it to fail or act abnormally. An example of this is the Windows fault screen, commonly r ...
exists of half the difference between the forward and backward travel times. A number of approaches have been proposed to measure asymmetry,
but among practical implementations only chrony seems to have one included.
History

In 1979, network
time synchronization
Time is the continuous progression of existence that occurs in an apparently irreversible succession from the past, through the present, and into the future. It is a component quantity of various measurements used to sequence events, to compa ...
technology was used in what was possibly the first public demonstration of
Internet
The Internet (or internet) is the Global network, global system of interconnected computer networks that uses the Internet protocol suite (TCP/IP) to communicate between networks and devices. It is a internetworking, network of networks ...
services running over a trans-Atlantic satellite network, at the
National Computer Conference in New York. The technology was later described in the 1981 Internet Engineering Note (IEN) 173
and a public protocol was developed from it that was documented in . The technology was first deployed in a local area network as part of the Hello routing protocol and implemented in the
Fuzzball router, an experimental operating system used in network prototyping, where it ran for many years.
Other related network tools were available both then and now. They include the
Daytime
Daytime or day as observed on Earth is the period of the day during which a given location experiences Daylight, natural illumination from direct sunlight. Daytime occurs when the Sun appears above the local horizon, that is, anywhere on the ...
and
Time
Time is the continuous progression of existence that occurs in an apparently irreversible process, irreversible succession from the past, through the present, and into the future. It is a component quantity of various measurements used to sequ ...
protocols for recording the time of events, as well as the
ICMP Timestamp messages and IP Timestamp option (). More complete synchronization systems, although lacking NTP's data analysis and clock disciplining algorithms, include the
Unix
Unix (, ; trademarked as UNIX) is a family of multitasking, multi-user computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, a ...
daemon ''
timed
timed (time daemon) is an operating system program that maintains the system time in synchronization with time servers using the Time Synchronization Protocol (TSP) developed by Riccardo Gusella and Stefano Zatti. Gusella and Zatti had done e ...
'', which uses an election algorithm to appoint a server for all the clients;
and the Digital Time Synchronization Service (DTSS), which uses a hierarchy of servers similar to the NTP stratum model.
In 1985, NTP version 0 (NTPv0) was implemented in both Fuzzball and Unix, and the NTP packet header and
round-trip delay
In telecommunications, round-trip delay (RTD) or round-trip time (RTT) is the amount of time it takes for a signal to be sent ''plus'' the amount of time it takes for acknowledgement of that signal having been received. This time delay includes p ...
and offset calculations, which have persisted into NTPv4, were documented in . Despite the relatively slow computers and networks available at the time, accuracy of better than 100
millisecond
A millisecond (from '' milli-'' and second; symbol: ms) is a unit of time in the International System of Units equal to one thousandth (0.001 or 10−3 or 1/1000) of a second or 1000 microseconds.
A millisecond is to one second, as one second i ...
s was usually obtained on Atlantic spanning links, with accuracy of tens of milliseconds on
Ethernet
Ethernet ( ) is a family of wired computer networking technologies commonly used in local area networks (LAN), metropolitan area networks (MAN) and wide area networks (WAN). It was commercially introduced in 1980 and first standardized in 198 ...
networks.
In 1988, a much more complete specification of the NTPv1 protocol, with associated algorithms, was published in . It drew on the experimental results and clock filter algorithm documented in and was the first version to describe the
client–server and
peer-to-peer
Peer-to-peer (P2P) computing or networking is a distributed application architecture that partitions tasks or workloads between peers. Peers are equally privileged, equipotent participants in the network, forming a peer-to-peer network of Node ...
modes. In 1991, the NTPv1 architecture, protocol and algorithms were brought to the attention of a wider engineering community with the publication of an article by
David L. Mills in the ''
IEEE Transactions on Communications''.
In 1989, was published defining NTPv2 by means of a
state machine
A finite-state machine (FSM) or finite-state automaton (FSA, plural: ''automata''), finite automaton, or simply a state machine, is a mathematical model of computation. It is an abstract machine that can be in exactly one of a finite number o ...
, with
pseudocode
In computer science, pseudocode is a description of the steps in an algorithm using a mix of conventions of programming languages (like assignment operator, conditional operator, loop) with informal, usually self-explanatory, notation of actio ...
to describe its operation. It introduced a management protocol and
cryptographic authentication scheme which have both survived into NTPv4, along with the bulk of the algorithm. However the design of NTPv2 was criticized for lacking
formal correctness by the DTSS community, and the clock selection procedure was modified to incorporate
Marzullo's algorithm for NTPv3 onwards.
In 1992, defined NTPv3. The RFC included an analysis of all sources of error, from the
reference clock down to the final client, which enabled the calculation of a
metric
Metric or metrical may refer to:
Measuring
* Metric system, an internationally adopted decimal system of measurement
* An adjective indicating relation to measurement in general, or a noun describing a specific type of measurement
Mathematics
...
that helps choose the best server where several candidates appear to disagree. Broadcast mode was introduced.
In subsequent years, as new features were added and algorithm improvements were made, it became apparent that a new protocol version was required.
In 2010, was published containing a proposed specification for NTPv4.
Following the retirement of Mills from the
University of Delaware
The University of Delaware (colloquially known as UD, UDel, or Delaware) is a Statutory college#Delaware, privately governed, state-assisted Land-grant university, land-grant research university in Newark, Delaware, United States. UD offers f ...
, the reference implementation is currently maintained as an
open source
Open source is source code that is made freely available for possible modification and redistribution. Products include permission to use and view the source code, design documents, or content of the product. The open source model is a decentrali ...
project led by Harlan Stenn.
On the
IANA
The Internet Assigned Numbers Authority (IANA) is a standards organization that oversees global IP address allocation, autonomous system number allocation, root zone management in the Domain Name System (DNS), media types, and other Internet P ...
side, a ntp (network time ''protocols'') work group is in charge of reviewing proposed drafts.
The protocol has significantly progressed since NTPv4.
, three RFC documents describing updates to the protocol have been published, not counting the numerous peripheral standards
such as Network Time Security. Mills had mentioned plans for a "NTPv5" on his page, but one was never published.
An unrelated draft termed "NTPv5" by M. Lichvar of
chrony
chrony is an implementation of the Network Time Protocol (NTP). It is an alternative to ntpd, a reference implementation of NTP. It runs on Unix-like operating systems (including Linux and macOS) and is released under the GNU General Public Licen ...
was initiated in 2020 and includes security, accuracy, and scaling changes.
SNTP
As NTP replaced the use of the old
Time Protocol
The Time Protocol is a network protocol in the Internet Protocol Suite. Its purpose is to provide a site-independent, machine readable date and time.
The Time Protocol may be implemented over the Transmission Control Protocol (TCP) or the User ...
, some use cases nevertheless found the full protocol too complicated. In 1992, Simple Network Time Protocol (SNTP) was defined to fill this niche. The SNTPv3 standard describes a way to use NTPv3, such that no storage of
state
State most commonly refers to:
* State (polity), a centralized political organization that regulates law and society within a territory
**Sovereign state, a sovereign polity in international law, commonly referred to as a country
**Nation state, a ...
over an extended period is needed. The topology becomes essentially the same as with the Time Protocol, as only one server is used. In 1996, SNTP was updated to SNTPv4 with some features of the then-in-development NTPv4. The current version of SNTPv4 was merged into the main NTPv4 standard in 2010. SNTP is fully interoperable with NTP since it does not define a new protocol. However, the simple algorithms provide times of reduced accuracy and thus it is inadvisable to sync time from an SNTP source.
Clock strata

NTP uses a hierarchical, semi-layered system of time sources. Each level of this hierarchy is termed a ''stratum'' and is assigned a number starting with zero for the reference clock at the top. A server synchronized to a stratum ''n'' server runs at stratum ''n'' + 1. The number represents the distance from the reference clock and is used to prevent cyclical dependencies in the hierarchy. Stratum is not always an indication of quality or reliability; it is common to find stratum 3 time sources that are higher quality than other stratum 2 time sources. A brief description of strata 0, 1, 2 and 3 is provided below.
; Stratum 0
: These are high-precision timekeeping devices such as
atomic clock
An atomic clock is a clock that measures time by monitoring the resonant frequency of atoms. It is based on atoms having different energy levels. Electron states in an atom are associated with different energy levels, and in transitions betwee ...
s,
GNSS
A satellite navigation or satnav system is a system that uses satellites to provide autonomous geopositioning. A satellite navigation system with global coverage is termed global navigation satellite system (GNSS). , four global systems are op ...
(including
GPS) or other
radio clock
A radio clock or radio-controlled clock (RCC), and often colloquially (and incorrectly) referred to as an "atomic clock", is a type of Quartz clock, quartz clock or watch that is automatically Synchronization, synchronized to a time code transmi ...
s, or a
PTP-synchronized clock. They generate a very accurate
pulse per second signal that triggers an
interrupt
In digital computers, an interrupt (sometimes referred to as a trap) is a request for the processor to ''interrupt'' currently executing code (when permitted), so that the event can be processed in a timely manner. If the request is accepted ...
and timestamp on a connected computer. Stratum 0 devices are also known as reference clocks. NTP servers cannot advertise themselves as stratum 0. A stratum field set to 0 in NTP packet indicates an unspecified stratum.
; Stratum 1
: These are computers whose
system time
In computer science and computer programming, system time represents a computer system's notion of the passage of time. In this sense, ''time'' also includes the passing of calendar date, days on the calendar.
System time is measured by a ''sys ...
is synchronized to within a few microseconds of their attached stratum 0 devices. Stratum 1 servers may peer with other stratum 1 servers for
sanity check
A sanity check or sanity test is a basic test to quickly evaluate whether a claim or the result of a calculation can possibly be true. It is a simple check to see if the produced material is rational (that the material's creator was thinking ration ...
and backup.
They are also referred to as primary time servers.
; Stratum 2
: These are computers that are synchronized over a network to stratum 1 servers. Often a stratum 2 computer queries several stratum 1 servers. Stratum 2 computers may also peer with other stratum 2 computers to provide more stable and robust time for all devices in the peer group.
; Stratum 3
: These are computers that are synchronized to stratum 2 servers. They employ the same algorithms for peering and data sampling as stratum 2, and can themselves act as servers for stratum 4 computers, and so on.
The upper limit for stratum is 15; stratum 16 is used to indicate that a device is unsynchronized. The NTP algorithms on each computer interact to construct a
Bellman–Ford shortest-path
spanning tree
In the mathematical field of graph theory, a spanning tree ''T'' of an undirected graph ''G'' is a subgraph that is a tree which includes all of the vertices of ''G''. In general, a graph may have several spanning trees, but a graph that is no ...
, to minimize the accumulated round-trip delay to the stratum 1 servers for all the clients.
In addition to stratum, the protocol is able to identify the synchronization source for each server in terms of a reference identifier (refid).
For servers on stratum 2 and below, the refid is an encoded form of the upstream time server's IP address. For IPv4, this is simply the 32-bit address; for IPv6, it would be the first 32 bits of the MD5 hash of the source address. Refids serve to detect and prevent timing loops to the first degree.
The refid field is filled with status words in the case of kiss-o'-death (KoD) packets, which tell the client to stop sending requests so that the server can rest. Some examples are INIT (initialization), STEP (step time change), and RATE (client requesting too fast). The program output may additionally use codes not transmitted in the packet to indicate error, such as XFAC to indicate a network disconnection.
The IANA maintains a registry for refid source names and KoD codes. Informal assignments can still appear.
Software implementations
Reference implementation
The NTP
reference implementation
In the software development process, a reference implementation (or, less frequently, sample implementation or model implementation) is a program that implements all requirements from a corresponding specification. The reference implementation ...
, along with the protocol, has been continuously developed for over 20 years. Backwards compatibility has been maintained as new features have been added. It contains several sensitive algorithms, especially to discipline the clock, that can misbehave when synchronized to servers that use different algorithms. The software has been
ported to almost every computing platform, including personal computers. It runs as a
daemon
A demon is a malevolent supernatural being, evil spirit or fiend in religion, occultism, literature, fiction, mythology and folklore.
Demon, daemon or dæmon may also refer to:
Entertainment Fictional entities
* Daemon (G.I. Joe), a character ...
called
ntpd under Unix or as a
service
Service may refer to:
Activities
* Administrative service, a required part of the workload of university faculty
* Civil service, the body of employees of a government
* Community service, volunteer service for the benefit of a community or a ...
under Windows. Reference clocks are supported and their offsets are filtered and analysed in the same way as remote servers, although they are usually polled more frequently.
This implementation was audited in 2017, finding 14 potential security issues.
Windows Time
All
Microsoft Windows
Windows is a Product lining, product line of Proprietary software, proprietary graphical user interface, graphical operating systems developed and marketed by Microsoft. It is grouped into families and subfamilies that cater to particular sec ...
versions since
Windows 2000
Windows 2000 is a major release of the Windows NT operating system developed by Microsoft, targeting the server and business markets. It is the direct successor to Windows NT 4.0, and was Software release life cycle#Release to manufacturing (RT ...
include the Windows Time service (W32Time),
which has the ability to synchronize the computer clock to an NTP server.
W32Time was originally implemented for the purpose of the
Kerberos version 5 authentication protocol, which required time to be within 5 minutes of the correct value to prevent
replay attack
A replay attack (also known as a repeat attack or playback attack) is a form of network attack in which valid data transmission is maliciously or fraudulently repeated or delayed. This is carried out either by the originator or by an adversary w ...
s. The network time server in Windows 2000 Server (and Windows XP) does not implement NTP disciplined synchronization, only locally disciplined synchronization with NTP/SNTP correction.
Beginning with
Windows Server 2003
Windows Server 2003, codenamed "Whistler Server", is the sixth major version of the Windows NT operating system produced by Microsoft and the first server version to be released under the Windows Server brand name. It is part of the Windows NT ...
and
Windows Vista
Windows Vista is a major release of the Windows NT operating system developed by Microsoft. It was the direct successor to Windows XP, released five years earlier, which was then the longest time span between successive releases of Microsoft W ...
, the NTP provider for W32Time became compatible with a significant subset of NTPv3.
Microsoft states that W32Time cannot reliably maintain time synchronization with one second accuracy.
If higher accuracy is desired, Microsoft recommends using a newer version of Windows or different NTP implementation.
Beginning with
Windows 10
Windows 10 is a major release of Microsoft's Windows NT operating system. The successor to Windows 8.1, it was Software release cycle#Release to manufacturing (RTM), released to manufacturing on July 15, 2015, and later to retail on July 2 ...
version 1607 and
Windows Server 2016
Windows Server 2016 is the eleventh major version of the Windows NT operating system produced by Microsoft to be released under the Windows Server brand name. It was developed alongside Windows 10 and is the successor to the Windows 8.1-based ...
, W32Time can be configured to reach time accuracy of 1 s, 50 ms or 1 ms under certain specified operating conditions.
OpenNTPD
In 2004, Henning Brauer of
OpenBSD
OpenBSD is a security-focused operating system, security-focused, free software, Unix-like operating system based on the Berkeley Software Distribution (BSD). Theo de Raadt created OpenBSD in 1995 by fork (software development), forking NetBSD ...
presented
OpenNTPD, an NTPv3/SNTPv4 implementation with a focus on security and encompassing a privilege separated design. Whilst it is aimed more closely at the simpler generic needs of OpenBSD users, it also includes some protocol security improvements while still being compatible with existing NTP servers. The simpler code base sacrifices accuracy, deemed unnecessary in this use case.
A portable version is available in Linux package repositories.
NTPsec
NTPsec is a
fork
In cutlery or kitchenware, a fork (from 'pitchfork') is a utensil, now usually made of metal, whose long handle terminates in a head that branches into several narrow and often slightly curved tines with which one can spear foods either to h ...
of the reference implementation that has been systematically
security-hardened. The fork point was in June 2015 and was in response to a series of compromises in 2014. The first production release shipped in October 2017.
Between removal of unsafe features, removal of support for obsolete hardware, and removal of support for obsolete Unix variants, NTPsec has been able to pare away 75% of the original codebase, making the remainder easier to
audit
An audit is an "independent examination of financial information of any entity, whether profit oriented or not, irrespective of its size or legal form when such an examination is conducted with a view to express an opinion thereon." Auditing al ...
.
A 2017 audit of the code showed eight security issues, including two that were not present in the original reference implementation, but NTPsec did not suffer from eight other issues that remained in the reference implementation.
chrony
chrony
chrony is an implementation of the Network Time Protocol (NTP). It is an alternative to ntpd, a reference implementation of NTP. It runs on Unix-like operating systems (including Linux and macOS) and is released under the GNU General Public Licen ...
is an independent NTP implementation mainly sponsored by
Red Hat
Red Hat, Inc. (formerly Red Hat Software, Inc.) is an American software company that provides open source software products to enterprises and is a subsidiary of IBM. Founded in 1993, Red Hat has its corporate headquarters in Raleigh, North ...
, who uses it as the default time program in their distributions.
Being written from scratch, has a simpler codebase allowing for better security
and lower resource consumption.
It does not however compromise on accuracy, instead syncing faster and better than the reference ntpd in many circumstances. It is versatile enough for ordinary computers, which are unstable, go into sleep mode or have intermittent connection to the Internet. It is also designed for virtual machines, a more unstable environment.
has been evaluated as "trustworthy", with only a few incidents.
It is able to achieve improved precision on LAN connections, using hardware timestamping on the network adapter.
Support for Network Time Security (NTS) was added on version 4.0. is available under
GNU General Public License version 2, was created by
Richard Curnow in 1997 and is currently maintained by
Miroslav Lichvar.
ntpd-rs

ntpd-rs is a security-focused implementation of the NTP protocol, founded by the
Internet Security Research Group as part of their Prossimo initiative for the creation of memory safe Internet infrastructure. ntpd-rs is implemented in
Rust programming language
Rust is a general-purpose programming language emphasizing performance, type safety, and concurrency. It enforces memory safety, meaning that all references point to valid memory. It does so without a conventional garbage collector; instea ...
which offers
memory safety
Memory safety is the state of being protected from various software bugs and security vulnerabilities when dealing with memory access, such as buffer overflows and dangling pointers. For example, Java is said to be memory-safe because its ru ...
guarantees in addition to the
Real-time computing
Real-time computing (RTC) is the computer science term for Computer hardware, hardware and software systems subject to a "real-time constraint", for example from Event (synchronization primitive), event to Event (computing), system response. Rea ...
capabilities which are required for an NTP implementation. ntpd-rs is used in security-sensitive environments such as the
Let's Encrypt
Let's Encrypt is a Non-profit organisation, non-profit certificate authority run by Internet Security Research Group (ISRG) that provides X.509 public key certificate, certificates for Transport Layer Security (TLS) encryption at no charge. It is ...
non-profit Certificate Authority. Support for NTS is available. ntpd-rs is part of the "Pendulum" project which also includes a
Precision Time Protocol
The Precision Time Protocol (PTP) is a protocol for clock synchronization throughout a computer network with relatively high precision and therefore ''potentially'' high accuracy. In a local area network (LAN), accuracy can be sub-microsecon ...
implementation "statime". Both projects are available under
Apache
The Apache ( ) are several Southern Athabaskan language-speaking peoples of the Southwestern United States, Southwest, the Southern Plains and Northern Mexico. They are linguistically related to the Navajo. They migrated from the Athabascan ho ...
and
MIT
The Massachusetts Institute of Technology (MIT) is a private research university in Cambridge, Massachusetts, United States. Established in 1861, MIT has played a significant role in the development of many areas of modern technology and sc ...
software licenses.
Others
* was started by
Poul-Henning Kamp
Poul-Henning Kamp () is a Danish computer software developer known for work on various projects including FreeBSD and Varnish cache, Varnish. He currently resides in Slagelse, Denmark.
Involvement in the FreeBSD project
Poul-Henning Kamp has bee ...
of
FreeBSD
FreeBSD is a free-software Unix-like operating system descended from the Berkeley Software Distribution (BSD). The first version was released in 1993 developed from 386BSD, one of the first fully functional and free Unix clones on affordable ...
in 2014 and abandoned in 2015.
The implementation was sponsored by the
Linux Foundation
The Linux Foundation (LF) is a non-profit organization established in 2000 to support Linux development and open-source software projects.
Background
The Linux Foundation started as Open Source Development Labs in 2000 to standardize and prom ...
.
* is the SNTP client built into
systemd
systemd is a software suite that provides an array of system components for Linux operating systems. The main aim is to unify service configuration and behavior across Linux distributions. Its primary component is a "system and service manage ...
. It is used by
Debian
Debian () is a free and open-source software, free and open source Linux distribution, developed by the Debian Project, which was established by Ian Murdock in August 1993. Debian is one of the oldest operating systems based on the Linux kerne ...
since version "bookworm" and the downstream Ubuntu.
Leap seconds
On the day of a
leap second
A leap second is a one-second adjustment that is occasionally applied to Coordinated Universal Time (UTC), to accommodate the difference between precise time (International Atomic Time (TAI), as measured by atomic clocks) and imprecise solar tim ...
event, ntpd receives notification from either a
configuration file
A configuration file, a.k.a. config file, is a computer file, file that stores computer data, data used to configure a software system such as an application software, application, a server (computing), server or an operating system.
Some applic ...
, an attached reference clock, or a remote server. Although the NTP clock is actually halted during the event, because of the requirement that time must appear to be
strictly increasing
In mathematical writing, the term strict refers to the property of excluding equality and equivalence and often occurs in the context of inequality and monotonic functions. It is often attached to a technical term to indicate that the exclusiv ...
, any
processes that query the system time cause it to increase by a tiny amount, preserving the order of events. If a negative leap second should ever become necessary, it would be deleted with the sequence 23:59:58, 00:00:00, skipping 23:59:59.
An alternative implementation, called leap smearing, consists in introducing the leap second incrementally during a period of 24 hours, from noon to noon in UTC time. This implementation is used by Google (both internally and on their public NTP servers), Amazon AWS,
and Facebook. supports leap smear in and configurations, but such use is not to be mixed with a public NTP pool as leap smear is non-standard and will throw off client calculation in a mix.
Security concerns
Because adjusting system time is generally a privileged operation, part or all of NTP code has to be run with some privileges in order to support its core functionality. Only a few other security problems have been identified in the reference implementation of the NTP codebase, but those that appeared in 2009 were cause for significant concern.
The protocol has been undergoing revision and review throughout its history. The codebase for the reference implementation has undergone security audits from several sources for several years.
A
stack buffer overflow
In software, a stack buffer overflow or stack buffer overrun occurs when a program writes to a memory address on the program's call stack outside of the intended data structure, which is usually a fixed-length buffer.
Stack buffer overflow bugs ...
exploit was discovered and patched in 2014.
Apple
An apple is a round, edible fruit produced by an apple tree (''Malus'' spp.). Fruit trees of the orchard or domestic apple (''Malus domestica''), the most widely grown in the genus, are agriculture, cultivated worldwide. The tree originated ...
was concerned enough about this vulnerability that it used its auto-update capability for the first time.
On systems using the reference implementation, which is running with root user's credential, this could allow unlimited access. Some other implementations, such as
OpenNTPD, have smaller code base and adopted other mitigation measures like privilege separation, are not subject to this flaw.
A 2017 security audit of three NTP implementations, conducted on behalf of the Linux Foundation's Core Infrastructure Initiative, suggested that both NTP
NTP SecurityNotice Page
''
NVD NIST Product Search NTP
' and NTPsec
NVD NIST Product Search NTPsec
'' were more problematic than chrony
NVD NIST Product Search Chrony
'' from a security standpoint.
NTP servers can be susceptible to
man-in-the-middle attack
In cryptography and computer security, a man-in-the-middle (MITM) attack, or on-path attack, is a cyberattack where the attacker secretly relays and possibly alters the communications between two parties who believe that they are directly communi ...
s unless packets are cryptographically signed for authentication.
The computational overhead involved can make this impractical on busy servers, particularly during
denial of service
In computing, a denial-of-service attack (DoS attack) is a cyberattack in which the perpetrator seeks to make a machine or network resource unavailable to its intended users by temporarily or indefinitely disrupting services of a host co ...
attacks.
NTP message
spoofing from a man-in-the-middle attack can be used to alter clocks on client computers and allow a number of attacks based on bypassing of cryptographic key expiration.
Some of the services affected by fake NTP messages identified are
TLS,
DNSSEC
The Domain Name System Security Extensions (DNSSEC) is a suite of extension specifications by the Internet Engineering Task Force (IETF) for securing data exchanged in the Domain Name System ( DNS) in Internet Protocol ( IP) networks. The protoco ...
, various caching schemes (such as DNS cache),
Border Gateway Protocol
Border Gateway Protocol (BGP) is a standardized exterior gateway protocol designed to exchange routing and reachability information among autonomous systems (AS) on the Internet. BGP is classified as a path-vector routing protocol, and it ...
(BGP), Bitcoin and a number of persistent login schemes.
NTP has been used in
distributed denial of service attacks.
A small query is sent to an NTP server with the return
IP address spoofed to be the target address. Similar to the
DNS amplification attack, the server responds with a much larger reply that allows an attacker to substantially increase the amount of data being sent to the target. To avoid participating in an attack, NTP server software can be upgraded or servers can be configured to ignore external queries.
Secure extensions
NTP itself includes support for authenticating servers to clients. NTPv3 supports a
symmetric key
Symmetric-key algorithms are algorithms for cryptography that use the same Key (cryptography), cryptographic keys for both the encryption of plaintext and the decryption of ciphertext. The keys may be identical, or there may be a simple transforma ...
mode, which is not useful against MITM. The
public key
Public-key cryptography, or asymmetric cryptography, is the field of cryptographic systems that use pairs of related keys. Each key pair consists of a public key and a corresponding private key. Key pairs are generated with cryptographic alg ...
system known as "autokey" in NTPv4 adapted from
IPSec offers useful authentication,
but is not practical for a busy server.
Autokey was also later found to suffer from several design flaws, with no correction published, save for a change in the
message authentication code
In cryptography, a message authentication code (MAC), sometimes known as an authentication tag, is a short piece of information used for authentication, authenticating and Data integrity, integrity-checking a message. In other words, it is used t ...
. Autokey should no longer be used.
Network Time Security (NTS) is a secure version of NTPv4 with
TLS and
AEAD. The main improvement over previous attempts is that a separate "key establishment" server handles the heavy asymmetric cryptography, which needs to be done only once. If the server goes down, previous users would still be able to fetch time without fear of MITM. NTS is supported by several NTP servers including
Cloudflare
Cloudflare, Inc., is an American company that provides content delivery network services, cybersecurity, DDoS mitigation, wide area network services, reverse proxies, Domain Name Service, ICANN-accredited domain registration, and other se ...
and
Netnod. It can be enabled on , NTPsec, and ntpd-rs.
Microsoft also has an approach to authenticate NTPv3/SNTPv4 packets using a
Windows domain
A Windows domain is a form of a computer network in which all user accounts, computers, printers and other security principals, are registered with a central database located on one or more clusters of central computers known as domain controlle ...
identity, known as MS-SNTP.
This system is implemented in the reference ntpd and chrony, using
samba
Samba () is a broad term for many of the rhythms that compose the better known Brazilian music genres that originated in the Afro-Brazilians, Afro Brazilian communities of Bahia in the late 19th century and early 20th century, It is a name or ...
for the domain connection.
NTP packet header format
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
Timestamps
The 64-bit
binary fixed-point timestamps used by NTP consist of a 32-bit part for seconds and a 32-bit part for fractional second, giving a time scale that
rolls over every 2
32 seconds (136 years) and a theoretical resolution of 2
−32 seconds (233 picoseconds). NTP uses an
epoch
In chronology and periodization, an epoch or reference epoch is an instant in time chosen as the origin of a particular calendar era. The "epoch" serves as a reference point from which time is measured.
The moment of epoch is usually decided b ...
of January 1, 1900. Therefore, the first rollover occurs on February 7, 2036.
NTPv4 introduces a 128-bit date format: 64 bits for the second and 64 bits for the fractional-second. The most-significant 32 bits of this format is the ''Era Number'' which resolves rollover ambiguity in most cases.
According to Mills, "The 64-bit value for the fraction is enough to resolve the amount of time it takes a photon to pass an electron at the speed of light. The 64-bit second value is enough to provide unambiguous time representation until the universe goes dim."
University of Delaware
The University of Delaware (colloquially known as UD, UDel, or Delaware) is a Statutory college#Delaware, privately governed, state-assisted Land-grant university, land-grant research university in Newark, Delaware, United States. UD offers f ...
Digital Systems Seminar presentation by David Mills, 2006-04-26
See also
*
*
*
*
*
*
*
*
Notes
References
Further reading
*
*
External links
*
Official Stratum One Time Servers listIETF NTP working groupMicrosoft Windows accurate time guidean
moreTime and NTP paperNTP Survey 2005Current NIST leap seconds file compatible with ntpd* {{citation , author=David L. Mills , url=https://www.eecis.udel.edu/~mills/database/papers/history.pdf , title=A Brief History of NTP Time: Confessions of an Internet Timekeeper , access-date=2021-02-07
Application layer protocols
Internet Standards
Network time-related software