# 网络时间协议

**网络时间协议（NTP）** 是一种在分组交换网络上同步计算机时钟的协议，它依据与国家标准时间相连的服务器层级来校准客户端时钟。2023年的一项研究估计，志愿性的NTP池每天收到来自52,000个自治系统中1.58亿客户端约72亿次查询，而更早的一项估计认为，更广泛的公共子网直接或间接包含超过2500万台计算机。<sup>[1](https://dl.acm.org/doi/epdf/10.1145/3639041)</sup><sup> • </sup><sup>[2](https://www.eecis.udel.edu/~mills/ntp/html/warp.html)</sup>

| 关键事实 | 详情 |
|---|---|
| 当前标准 | NTPv4，RFC 5905，废止NTPv3（RFC 1305）和SNTPv4（RFC 4330）；SNTPv4是NTPv4的子集，首部变更保持了互操作性<sup>[3](https://datatracker.ietf.org/doc/html/rfc5905)</sup> |
| 核心计算 | 偏移 = ((T2 + T3) − (T4 + T1)) / 2，延迟 = \|(T4 − T1) − (T3 − T2)\|，基于四个时间戳T1–T4<sup>[4](https://datatracker.ietf.org/doc/draft-ietf-ntp-ntpv5/09/)</sup> |
| 精度 | 主服务器上为数十微秒，快速局域网上为数百微秒，互联网广域网上为数十毫秒<sup>[5](https://www.ntp.org/reflib/reports/ntp4/ntp4.pdf)</sup> |
| 层级体系 | 第1层服务器直接与外部参考时钟同步；每下游一层加一，同步距离大致随层级和往返延迟增长<sup>[4](https://datatracker.ietf.org/doc/draft-ietf-ntp-ntpv5/09/)</sup><sup> • </sup><sup>[5](https://www.ntp.org/reflib/reports/ntp4/ntp4.pdf)</sup> |
| 安全 | NTS（RFC 8915，2020年）增加了基于TLS的密钥建立和AEAD认证的NTP数据包；Khronos（RFC 9523）增加了防范时间偏移的看门狗<sup>[6](https://www.rfc-editor.org/rfc/rfc8915.html)</sup><sup> • </sup><sup>[7](https://datatracker.ietf.org/doc/html/rfc9523.html)</sup> |
| 池规模 | 截至2023年10月9日有4,403台志愿服务器，通过21个地点30个站点的任播提供服务，估计每秒10万至17.5万次查询<sup>[1](https://dl.acm.org/doi/epdf/10.1145/3639041)</sup><sup> • </sup><sup>[8](https://www.sidnlabs.nl/downloads/2F7MA8sBibhmqv0T7rIorf/79ea0f8903ab4560365c66a83d9fcf9b/A_Day_in_the_Life_of_NTP_Analysis_of_NTP_Pool_Traffic.pdf)</sup> |
| 下一版本 | NTPv5处于IETF草案阶段；它沿用NTP MAC（RFC 8573）和NTS（RFC 8915）安全机制<sup>[4](https://datatracker.ietf.org/doc/draft-ietf-ntp-ntpv5/09/)</sup> |

## 历史与协议版本

NTP由David L. Mills开发，与更早的互联网时间服务（如Daytime、Time和ICMP时间戳消息）一同演进；第一份规范以“互联网时钟服务”之名出现在RFC 778中，为HELLO路由协议所需，而NTP本身则在RFC 958中引入。<sup>[9](https://www.eecis.udel.edu/~mills/database/papers/history/history.pdf)</sup><sup> • </sup><sup>[10](https://docs.ntpsec.org/latest/history.html)</sup> 从20世纪80年代初到本世纪，精度已提升至数十纳秒。<sup>[9](https://www.eecis.udel.edu/~mills/database/papers/history/history.pdf)</sup>

版本3被标准化为RFC 1305。NTPv4以RFC 5905发布，废止了RFC 1305和RFC 4330（SNTPv4）；尽管某些首部字段发生了变化，但这些变化不影响NTPv4与早期NTP和SNTP版本之间的互操作性。<sup>[3](https://datatracker.ietf.org/doc/html/rfc5905)</sup> NTPv4增加了针对IPv6的修改首部、用于Autokey公钥认证方案的首部扩展字段，以及一种对硬件频率波动响应更灵敏的新时钟校准算法。<sup>[5](https://www.ntp.org/reflib/reports/ntp4/ntp4.pdf)</sup> Autokey将公钥密码学与伪随机密钥流相结合，因公钥操作可能降低计时质量而谨慎使用，并采用零知识证明身份方案使客户端无法冒充服务器；它后来被NTS废止。<sup>[9](https://www.eecis.udel.edu/~mills/database/papers/history/history.pdf)</sup><sup> • </sup><sup>[11](https://chrony-project.org/comparison.html)</sup> 版本5草案正在IETF中推进，保留了NTPv4的两项安全机制：用于基本完整性的NTP消息认证码（RFC 8573）和用于服务器认证、重放保护及安全密钥建立的NTS（RFC 8915）。<sup>[4](https://datatracker.ietf.org/doc/draft-ietf-ntp-ntpv5/09/)</sup>

## 协议工作原理

每次客户端-服务器交换携带四个时间戳：T1为客户端发送请求时，T2为服务器收到请求时，T3为服务器发送回复时，T4为客户端收到回复时。据此，NTP将时钟偏移计算为((T2 + T3) − (T4 + T1)) / 2，将往返延迟计算为\|(T4 − T1) − (T3 − T2)\|。<sup>[4](https://datatracker.ietf.org/doc/draft-ietf-ntp-ntpv5/09/)</sup> 轮询间隔从8秒到36小时不等，客户端应根据观测到的噪声调整轮询频率。<sup>[2](https://www.eecis.udel.edu/~mills/ntp/html/warp.html)</sup><sup> • </sup><sup>[12](https://tf.nist.gov/general/pdf/2818.pdf)</sup>

**层级。** 直接与外部参考时钟同步的服务器为第1层；与第1层同步的服务器为第2层，层级依此类推。<sup>[4](https://datatracker.ietf.org/doc/draft-ietf-ntp-ntpv5/09/)</sup> 第1层（主）服务器可通过卫星、无线电或电话调制解调器与国家时间服务同步。<sup>[2](https://www.eecis.udel.edu/~mills/ntp/html/warp.html)</sup> 一项称为同步距离的度量大致与层级和测得的往返延迟成正比增长。<sup>[5](https://www.ntp.org/reflib/reports/ntp4/ntp4.pdf)</sup> NIST指南指出，局域网延迟通常比公共互联网路由低几个数量级，并建议局域网客户端按层级组织，第s层服务器的每个直接客户端位于第s + 1层。<sup>[12](https://tf.nist.gov/general/pdf/2818.pdf)</sup>

## 时钟同步算法

咨询多台服务器的客户端必须决定信任谁。NTPv4的数据校准运行一系列算法。*选择算法*应用拜占庭原则从候选服务器群体中剔除虚假报时者，留下真实报时者。<sup>[5](https://www.ntp.org/reflib/reports/ntp4/ntp4.pdf)</sup> *聚类算法*迭代丢弃离群幸存者，*合并算法*从剩余来源产生最终偏移。<sup>[5](https://www.ntp.org/reflib/reports/ntp4/ntp4.pdf)</sup> 面向操作者的描述与此结构一致：时间信号经聚类以拒绝离群服务器，服务器选择考虑层级、偏移和抖动。<sup>[13](https://blog.apnic.net/2026/03/10/securing-ntp/)</sup>

## 精度与性能

NTPv4标称分辨率优于1纳秒，频率分辨率优于每秒1纳秒，但实际达到的精度远较粗糙，且取决于网络路径。<sup>[5](https://www.ntp.org/reflib/reports/ntp4/ntp4.pdf)</sup> 典型主服务器精确到数十微秒以内；快速局域网上的典型辅助服务器和客户端精确到数百微秒以内，轮询间隔可达1024秒；使用NTPv4时，广域服务器和客户端精确到数十毫秒以内，轮询间隔可达36小时。<sup>[5](https://www.ntp.org/reflib/reports/ntp4/ntp4.pdf)</sup> 一项独立调查给出兼容的数据：广域网上为个位数毫秒，局域网上为亚毫秒，连接GPS接收器或铯振荡器等精密时间源时为亚微秒。<sup>[13](https://blog.apnic.net/2026/03/10/securing-ntp/)</sup>

## 数据一览

NTP池是默认pool.ntp.org服务背后的志愿集群，被数亿系统使用，截至2023年10月9日列出4,403台志愿服务器，已运行二十多年。<sup>[1](https://dl.acm.org/doi/epdf/10.1145/3639041)</sup><sup> • </sup><sup>[14](https://www.ntppool.org/en/)</sup> 2023年的一项研究估计，它每天收到来自52,000个自治系统中1.58亿客户端的72亿次查询。<sup>[1](https://dl.acm.org/doi/epdf/10.1145/3639041)</sup> 流量通过任播吸收：分布在21个不同物理位置的30个站点估计每秒处理10万至17.5万次查询。<sup>[8](https://www.sidnlabs.nl/downloads/2F7MA8sBibhmqv0T7rIorf/79ea0f8903ab4560365c66a83d9fcf9b/A_Day_in_the_Life_of_NTP_Analysis_of_NTP_Pool_Traffic.pdf)</sup> GeoDNS层将每个客户端映射到虚拟集群中最近的时间服务器。<sup>[15](https://lwn.net/Articles/1059200/)</sup> NTP项目早先的估计认为，整个公共子网共有数千台服务器，分布在包括南极洲在内的各个大陆，支持超过2500万台计算机。<sup>[2](https://www.eecis.udel.edu/~mills/ntp/html/warp.html)</sup>

## 安全与网络时间安全

在数据包延迟攻击中，中间人非对称地延迟数据包；攻击者能引入的最大误差以往返延迟的一半为界，上限为MAXDIST/2，其中标准MAXDIST值为一秒。<sup>[6](https://www.rfc-editor.org/rfc/rfc8915.html)</sup> 即使有加密和认证，时间偏移仍然可能，因为较弱的中间机器攻击者只需丢弃或延迟数据包即可偏移时间。<sup>[7](https://datatracker.ietf.org/doc/html/rfc9523.html)</sup> NTS同样无法完全防御路径上的攻击者发起的拒绝服务，后者可以用不带认证的伪造Kiss-o'-Death数据包回复NTP请求。<sup>[6](https://www.rfc-editor.org/rfc/rfc8915.html)</sup> 针对该池的测量工作考察了其对垄断攻击的鲁棒性。<sup>[16](https://arxiv.org/pdf/2602.12321v1)</sup>

**NTS（RFC 8915）** 使用TLS和带关联数据的认证加密（AEAD）为NTP客户端-服务器模式提供密码学安全。NTS密钥建立协议（NTS-KE）在TCP端口4460上的TLS连接中运行，可重用CA签名的证书，建立密钥材料，并向客户端提供初始的cookie供应；随后TLS通道关闭，服务器上不留下每客户端状态。<sup>[6](https://www.rfc-editor.org/rfc/rfc8915.html)</sup><sup> • </sup><sup>[15](https://lwn.net/Articles/1059200/)</sup> NTS cookie将会话状态卸载到客户端，唯一标识符扩展字段防止重放，设计目标包括X.509身份、不可链接性、非放大性和可扩展性。<sup>[6](https://www.rfc-editor.org/rfc/rfc8915.html)</sup> 使用多个时间源，或到给定源的多个网络路径，可在攻击者仅控制部分路径时缓解延迟攻击。<sup>[6](https://www.rfc-editor.org/rfc/rfc8915.html)</sup>

**Khronos（RFC 9523）** 是防范时间偏移的后台看门狗。在每个轮询间隔内，Khronos客户端从包含数百台服务器的本地池中随机挑选少量NTP服务器并采样；只要少于2/3的时间样本被攻破，它还能阻止时钟被偏移。Khronos每个间隔查询的服务器数量约为NTPv4典型四台的三倍，但轮询间隔最长可达10倍，从而最小化服务器负载；它不适用于与本地原子钟、GPS设备或专用NTP服务器同步的数据中心。<sup>[7](https://datatracker.ietf.org/doc/html/rfc9523.html)</sup>

## 与PTP及其他方案的比较

**PTP（IEEE 1588）** 面向不同的精度等级。PTP同步时钟预期达到约100纳秒量级，主要取决于专用时钟振荡器和计数器的分辨率与稳定性，而NTP的范围从PPS辅助主服务器的几微秒到广泛分散的互联网网络上的数十毫秒。<sup>[17](https://www.ntp.org/reflib/ptp/)</sup> PTP通常在以太网媒体独立接口处捕获时间戳，硬件时间戳精度通常在100纳秒以内，而NTP除典型定时器中断外无需硬件，其软件时间戳带有1至2微秒的随机延迟。<sup>[17](https://www.ntp.org/reflib/ptp/)</sup> 在局域网上，PTP设备彼此同步可精确到数十纳秒以内，即使是没有硬件时间戳的纯软件PTP也能达到亚毫秒精度。<sup>[18](https://cacm.acm.org/practice/toward-higher-precision/)</sup> 两种协议在算法和范围上也不同：PTP使用最佳主时钟算法，服务于专用局域网段上的特殊用途工业自动化和测量网络，而NTP使用基于拜占庭协议和统计聚类的滤波、选择、聚类和合并算法，服务于全球互联网上的通用工作站和服务器。<sup>[17](https://www.ntp.org/reflib/ptp/)</sup> IEEE 1588-2019定义了PTP在UDP/IPv4、UDP/IPv6和二层IEEE 802.3以太网上的映射。<sup>[19](https://standards.ieee.org/standard/1588-2019.html)</sup> 时间尺度也不同：PTP使用秒和纳秒，假定POSIX纪元为1970年1月1日，而NTP使用秒和秒的小数部分，原点为1900年1月1日。<sup>[17](https://www.ntp.org/reflib/ptp/)</sup>

**SNTP** 是NTPv4的子集，面向简单客户端，NTPv4的首部变更不会破坏与其的互操作性。<sup>[3](https://datatracker.ietf.org/doc/html/rfc5905)</sup>

**实现。** 在chrony项目的模拟Linux客户端测试中，网络抖动为10微秒时，chrony达到35 ± 8微秒精度，而ntp为234 ± 46微秒，openntpd为857 ± 226微秒；抖动为10.0毫秒时，chrony达到1603 ± 447微秒，而ntp为3665 ± 651微秒，openntpd为2014 ± 387微秒。<sup>[11](https://chrony-project.org/comparison.html)</sup> chrony自4.0版起支持NTS，NTS是NTP对称密钥和Autokey认证的继任者。<sup>[20](https://www.systemshardening.com/articles/network/network-time-security-nts/)</sup> chrony的比较指出，Autokey协议（RFC 5906）已被证明不安全并被NTS废止，广播和多播模式本质上不如客户端/服务器模式精确和安全，通常应避免使用。<sup>[11](https://chrony-project.org/comparison.html)</sup>

## 闰秒与时间尺度

NTPv4包含一种机制，可从NIST服务器检索历史闰秒表并在整个NTP子网中分发。<sup>[9](https://www.eecis.udel.edu/~mills/database/papers/history/history.pdf)</sup> 在闰秒时，未涂抹的时钟要么回退一秒，要么暂停；在闰秒涂抹时间尺度下，时钟则在涂抹期内逐渐调整，涂抹期可跨越预定闰秒之前、期间和/或之后的数秒到数小时。<sup>[4](https://datatracker.ietf.org/doc/draft-ietf-ntp-ntpv5/09/)</sup> 各实现的涂抹形状不同：chrony支持6月30日和12月31日的服务器端二次函数闰秒涂抹，而ntp支持任意月份最后一天的余弦涂抹。<sup>[11](https://chrony-project.org/comparison.html)</sup> 该做法的长期未来已在原则上确定：第27届国际计量大会在其2022年第4号决议中决定，UT1 − UTC的最大值将在2035年或之前增大，并请国际计量委员会提出新值，确保UTC至少一个世纪的连续性。<sup>[21](https://ntp.rdem-systems.com/en/leap-second.php)</sup>

## 近期发展

NTS于2020年成为IETF标准，但采用缓慢：NTP参考实现ntpd不支持NTS，NTPsec支持，Canonical在Ubuntu 25.10中将其时间服务器切换为NTS。<sup>[15](https://lwn.net/Articles/1059200/)</sup> NTPsec 1.2.5（2026年7月31日）在pool配置命令中增加了对nts安全标志的原生支持，并用密码学强RNG替换了弱libc random()，用于关联ID、轮询时间散布和mode6响应填充。<sup>[22](https://blog.ntpsec.org/2026/07/31/version-1.2.5.html)</sup> Khronos从草案进展为已发布标准RFC 9523。<sup>[7](https://datatracker.ietf.org/doc/html/rfc9523.html)</sup> NTPv5草案在IETF NTP工作组中继续推进，沿用RFC 8573 MAC和RFC 8915 NTS机制。<sup>[4](https://datatracker.ietf.org/doc/draft-ietf-ntp-ntpv5/09/)</sup> 实现中不断出现新漏洞：在启用NTS的1.7.1之前的ntpd-rs中，远程攻击者可诱导CPU使用率高于正常2至4倍，这一拒绝服务状况被追踪为CVE-2026-26076。<sup>[23](https://nvd.nist.gov/vuln/detail/CVE-2026-26076)</sup>

## References

1. [Deep Dive into NTP Pool's Popularity and Mapping, ACM](https://dl.acm.org/doi/epdf/10.1145/3639041)
2. [How NTP Works, Mills / ntpd documentation](https://www.eecis.udel.edu/~mills/ntp/html/warp.html)
3. [RFC 5905: Network Time Protocol Version 4](https://datatracker.ietf.org/doc/html/rfc5905)
4. [draft-ietf-ntp-ntpv5-09: Network Time Protocol Version 5](https://datatracker.ietf.org/doc/draft-ietf-ntp-ntpv5/09/)
5. [Network Time Protocol Version 4 Reference and Implementation Guide, ntp.org](https://www.ntp.org/reflib/reports/ntp4/ntp4.pdf)
6. [RFC 8915: Network Time Security for the Network Time Protocol](https://www.rfc-editor.org/rfc/rfc8915.html)
7. [RFC 9523: A Secure Selection and Filtering Mechanism for NTP with Khronos](https://datatracker.ietf.org/doc/html/rfc9523.html)
8. [A Day in the Life of NTP: Analysis of NTP Pool Traffic, SIDN Labs](https://www.sidnlabs.nl/downloads/2F7MA8sBibhmqv0T7rIorf/79ea0f8903ab4560365c66a83d9fcf9b/A_Day_in_the_Life_of_NTP_Analysis_of_NTP_Pool_Traffic.pdf)
9. [A Brief History of NTP Time: Memoirs of an Internet Timekeeper, David L. Mills](https://www.eecis.udel.edu/~mills/database/papers/history/history.pdf)
10. [History of NTP, NTPsec documentation](https://docs.ntpsec.org/latest/history.html)
11. [chrony: Comparison of NTP implementations](https://chrony-project.org/comparison.html)
12. [Usage Analysis of the NIST Internet Time Service](https://tf.nist.gov/general/pdf/2818.pdf)
13. [Securing NTP, APNIC Blog](https://blog.apnic.net/2026/03/10/securing-ntp/)
14. [pool.ntp.org: the internet cluster of ntp servers](https://www.ntppool.org/en/)
15. [An effort to secure the Network Time Protocol, LWN.net](https://lwn.net/Articles/1059200/)
16. [On Borrowed Time: Measurement-Informed Understanding of the NTP Pool's Robustness to Monopoly Attacks, arXiv](https://arxiv.org/pdf/2602.12321v1)
17. [IEEE 1588 Precision Time Protocol (PTP), NTP Reference Library](https://www.ntp.org/reflib/ptp/)
18. [Toward Higher Precision, Communications of the ACM](https://cacm.acm.org/practice/toward-higher-precision/)
19. [IEEE 1588-2019, IEEE SA](https://standards.ieee.org/standard/1588-2019.html)
20. [Network Time Security: Authenticated NTP for Infrastructure](https://www.systemshardening.com/articles/network/network-time-security-nts/)
21. [NTP Leap Second: Smear vs Step, Incidents & the 2026 Vote](https://ntp.rdem-systems.com/en/leap-second.php)
22. [NTPsec Version 1.2.5 release notes](https://blog.ntpsec.org/2026/07/31/version-1.2.5.html)
23. [NVD: CVE-2026-26076](https://nvd.nist.gov/vuln/detail/CVE-2026-26076)

---
*Initially written Sep 17, 2026 · Reviewed: Oct 15, 2026 · Edited: Oct 15, 2026; Oct 25, 2026 · Last review: Oct 15, 2026*

Topic: 物质世界与数学 › 测量与时间 › 计时与时间标准 › Time standards, precision, and technical time › Network time synchronization and precision protocols

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/network-time-protocol

English original: https://www.edgepedia.org/network-time-protocol
