如何在本地网络中同步时钟?

时间:2015-07-05 15:13:41

标签: clock ntp clock-synchronization

我们假设我们在本地网络中连接了许多系统,并且没有连接到互联网。什么是确保每个时钟同步的最佳方法?它们不必与UTC时间同步,但足以在它们之间保持同步。

我曾想过使用NTP,在其中一个系统中设置NTP服务器。但我需要建议一下,与要求相比,这是否会更加麻烦。还建议尝试使用TCP套接字手动计算往返时间和服务器时间吗?

1 个答案:

答案 0 :(得分:0)

即使使用其中一台机器的无纪律的本地时钟,小型本地网络也可以在一个简单的NTP对等网络中进行相互同步的解决方案,如果所有实时源都失败,可以使用本地时钟作为备份进行一次设置

多服务器/对等ntp网络的一个示例。请注意每个ntp如何没有列出相同的服务器。这是为了更好地使用对等同步。因此,对等同步可以匹配不同的时间结果。

1a  1b     1c  1d     1e  1f      outside
. \ / ...... \ / ...... \ / ..............
   2a ---p--- 2b ---p--- 2c        inside
  /|\        /|\        /|\
 / | \      / | \      / | \
3a 3b 3c   3e 3f 3g   3h 3i 3j

Key: 1 = stratum-1, 2 = stratum-2, 3 = stratum-3, p = peer
#Diagram + more info: http://www.ntp.org/ntpfaq/NTP-s-config-adv.htm

ntp服务器A (myntp.server.a)

# Undisciplined Local Clock. This is a fake driver intended for backup
# and when no outside source of synchronized time is available.
server 127.127.1.0
fudge 127.127.1.0 stratum 10

server 0.pool.ntp.org iburst 
server 1.pool.ntp.org iburst 
peer myntp.server.b
peer myntp.server.c

ntp服务器B (myntp.server.b)

server 2.pool.ntp.org iburst 
server 3.pool.ntp.org iburst
peer myntp.server.a
peer myntp.server.c

如果一台服务器(例如myntp.server.a)运行本地时钟,那么所有内容都会同步 - 但不好 - 但至少网络上的时钟会保持在一起 - 请参阅:http://compgroups.net/comp.protocols.time.ntp/undisciplined-local-clocks/1874258#sthash.xnGpZubJ.dpuf < / p>

更多信息:http://doc.ntp.org/4.1.1/confopt.htm