NTP Server

Network Time Protocol互联网时间协议

NTP is intended to synchronize all participating computers to within a few milliseconds of Coordinated Universal Time (UTC).[1]:3 It uses a modified version of Marzullo's algorithm to select accurate time servers and is designed to mitigate the effects of variable network latency. NTP can usually maintain time to within tens of milliseconds over the public Internet, and can achieve better than one millisecond accuracy in local area networksunder ideal conditions. Asymmetric routes and network congestion can cause errors of 100 ms or more.[2][3]

NTP旨在几毫秒协调世界时(UTP)的时间内同步所有参与的计算机。NTP使用一个修改的版本来选择精确的时间服务器,并能缓解可变的网络延迟的影响。NTP通常能够在几十毫秒的时间内在公网上维护时间,并且能够比一个在理想状态下的局域网的一个毫秒的精度表现更好。不对称线路和网络拥塞能导致100毫秒或更多的错误。

The protocol is usually described in terms of a client-server model, but can as easily be used in peer-to-peer relationships where both peers consider the other to be a potential time source.[1]:20 Implementations send and receive timestamps using the User Datagram Protocol (UDP) on port number 123.[4][5] They can also usebroadcasting or multicasting, where clients passively listen to time updates after an initial round-trip calibrating exchange.[3] NTP supplies a warning of any impending leap second adjustment, but no information about local time zones or daylight saving time is transmitted.[2][3]

As of June 2010, the current protocol is version 4 (NTPv4), which is a proposed standard as documented in RFC 5905. It is backwards compatible with version 3, specified in RFC 1305.

这个协议通常用 客户端-服务器模型来描述,但是能被容易地用于对等的关系,在这种情况下,两方都放为另一方是一个潜在的时间源。在 123端口使用UDP协议发送和接收时间戳。他们也能使用广播或多播,在这种情况下,客户端在接收到往返时间校准后被地监听时间更新。NTP提供了一个对任何迫近的闰秒的调整警告,但是关于本地时区或夏时令没有给出信息。

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 at the top. 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. Telecommunication systems use a different definition for clock strata.

关于 时间源,NTP 使用了一个分层的,半独立的分层系统。每个层叫作一个“stratum”,并且在最上面被分配了一个从0开始的数字。这个数字代表了与参考时钟的距离,并且被用来防止形成回路。

Stratum 0

These are high-precision timekeeping devices such as atomic (cesium, rubidium) clocksGPS clocks or other radio clocks. They generate a very accurate pulse per second signal that triggers an interrupt and timestamp on a connected computer. Stratum 0 devices are also known as reference clocks.

第0层是高精度的计时设备,如原子的(铯,铷)时钟,GPS时钟或其它电波时钟。它们生成一个很准确的每秒脉冲信号并在连接的计算机上触发一个中断和时间戳。

Stratum 1

These are computers whose system clocks are synchronized to within a few microseconds of their attached stratum 0 devices. Stratum 1 servers may peer with other stratum 1 servers for sanity checking and backup.[6] They are also referred to as primary time servers.[2][3]

第一层是计算机,这些计算机的系统时钟在几微妙一次的与与之连接的第0层的设备进行同步。第一层上的服务器为了完整性检查与备份,可能与其它位于同层的服务器进行连接。他们也被称为主时间服务器。

Stratum 2

These are computers that are synchronized over a network to stratum 1 servers. Often a stratum 2 computer will query 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.

第二层是通过网络与第一层进行时钟同步的计算机。通常一个位于第二层的计算机机将查询好几个位于第一层的服务器。位于第二层的计算机可能与其他层2电脑同行为所有其它位于同一层的设备提供更稳定和健壮的时间。

Stratum 3

These are computers that are synchronized to stratum 2 servers. They employ exactly the same algorithms for peering and data sampling as stratum 2, and can themselves act as servers for stratum 4 computers, and so on.

位于第三层的是与第二层服务器进行同步的计算机。它们使用与第二层同样的同步和数据采集算法,并且它们自己可以作为第四层的服务器,以此类推。

Only strata 0 to 15 are valid; 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, to minimize the accumulated round-trip delay to the stratum 1 servers for all the clients.[1]:20

只有层0到层 15是有效的。层 16 被用来指示一个设备是异步的。在每个计算机上的NTP算法互相作为形成一个 Bellman-Ford最短路径生成树,来最小化所有客户端与层一服务器之间积累的回路延迟。

Timestamps

The 64-bit 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 232 seconds (136 years) and a theoretical resolution of 2−32 seconds (233 picoseconds). NTP uses an epoch of January 1, 1900. The first rollover occurs in 2036,[note 1] prior to the UNIX year 2038 problem.

被NTP使用的64位的时间戳由一个 32位的秒和一个32位的小数部分的秒组成,提供一个每232 (136年) 滚动一次时间范围和一个理论上的0, 2−32 秒(233皮秒)。NTP使用一个新纪元, 1900年1月1 日。第一次的翻转发生在 2036年,在 unix 年的 2038 年之前。

Future versions of NTP may extend the time representation to 128 bits: 64 bits for the second and 64 bits for the fractional-second. The current NTPv4 format has support for Era Number and Era Offset, that when used properly should aid fixing date rollover issues. 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."[7][note 2]

原文地址:https://www.cnblogs.com/quietwalk/p/3526645.html