什么是“频率差”哪个 NTP 尝试同步?

发布于 2024-09-14 19:49:03 字数 143 浏览 4 评论 0原文

正如 NTP rfc 中所定义的

“NTP 算法的目标是最小化 UTC 和系统时钟之间的时间差和频率差。”

我可以理解“时间差”,但是 NTP 尝试同步的“频率差”是什么?

As defined in NTP rfc

"The goal of the NTP algorithms is to minimize both the time difference and frequency difference between UTC and the system clock."

I can understand 'time difference' but what is 'frequency difference' which NTP try to sync ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

你是年少的欢喜 2024-09-21 19:49:03

频率差是您的时钟与 NTP 时钟之间的速度差异(实际上被认为是完美的)。

如果您的时钟每小时增加一分钟(与 NTP 服务器时钟相比),这就是频率差异。也称为漂移。

一个极端、简化的示例:

假设您在每个整点(00:0001:00...)与 NTP 同步,但您的时钟是真的很糟糕,在那一小时里损失了十分钟。

如果您在午夜与 NTP 同步,以便两个时钟都设置为 00:00,那么当(真实)01:00 到来时,您的时钟将显示 < code>00:50(您已经失去了十分钟)。

这意味着您将在零到十分钟之间失步。


那么您将如何以简单的方式解决这个问题呢?

如果同步将您的时钟设置为(真实)午夜的 00:05 会怎样。您可能会晚五分钟,但 NTP 时钟会逐渐靠近您,在00:30 处完美匹配,然后才开始领先您。

然后,在(实际)01:00,您将处于 00:55,因此错误不会超过五分钟。


现在 NTP 将尝试避免执行诸如立即将时间从 00:55 更改为 01:05 之类的事情,因为很多软件(例如 cron )不会太友善地对待它。

更有可能的是在午夜将时钟同步在一起,然后在一小时内逐渐向前移动当地时间以保持它们对齐(例如每五增加一秒,这将有效地恢复一小时内失去的十分钟)痛苦的方式)。

Frequency difference is the difference in speeds between your clock and the NTP clock (effectively deemed to be perfect).

If you clock gains a minute every hour (compared to the NTP server clock), that's the frequency difference. It's also called drift.

An extreme, simplified, example:

Lets say you sync with NTP at the top of every hour (00:00, 01:00, ...) but your clock is really bad and loses ten minutes in that hour.

If you sync with NTP at midnight so that both your clocks are set to 00:00 then, when the (real) 01:00 comes around, your clock will read 00:50 (you've lost your ten minutes).

That means that you will be out of step by anywhere between zero and ten minutes.


So how would you fix that in a simplistic way?

What if the synchronisation set your clock to 00:05 at (real) midnight. You would be out by five minutes but the NTP clock would gradually creep up on you, matching perfectly at 00:30 before it starts getting ahead of you.

Then at (real) 01:00, you would be at 00:55 so that at no point would the error be more than five minutes.


Now NTP will try to avoid doing things like immediately changing your time from 00:55 to 01:05 since a lot of software (like cron) won't take too kindly to it.

It's far more likely to synch the clocks together at midnight then gradually creep the local time forward over the hour to keep them aligned (say adding one second every five, which will effectively recover that lost ten minutes in the hour in a non-gut-wrenching way).

晨光如昨 2024-09-21 19:49:03

频率差是时间差随时间变化的程度。

也就是说,NTP 不仅试图将两个时钟拉得更近,而且实际上将它们保持在一起。

它实际上利用了一些晦涩难懂的知识,即计算机时钟是使用以一定速率(“时钟频率”)振荡的石英晶体实现的。这是时钟“滴答”发生的频率

The frequency difference is how much the time difference changes over ... time.

That is to say, NTP tries not just to pull two clocks closer together, but to actually keep them together.

It's actually drawing on the obscure-for-this-context knowledge that computer clocks are implemented using quartz crystals which oscillate at a certain rate - the "clock frequency". It's how frequently a clock "tick" happens.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文