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]

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM