为什么我的 NTP 时间同步根分散度会随着时间的推移而降低?

为什么我的 NTP 时间同步根分散度会随着时间的推移而降低?

我有一个测试网络设置,其中包含具有 4G/LTE 互联网连接的 Mikrotik 路由器,通过以太网线连接到一个 Raspberry Pi,并通过 wifi 连接到另外 30 个 Raspberry Pi。

我设置了 NTP,目的是最大限度地减少 Raspberry Pi 节点之间的时钟漂移,以便我在运行iperf和时可以获得良好的延迟测量结果netperf。我对拥有 Raspberry Pi 车队更感兴趣彼此同意大约比我在他们存在中的时间完全正确,因为练习的全部目的是为 wifi 性能测试提供良好的延迟数据。

为了确保所有 Raspberry Pi 节点都可以访问单个公共时间源,并最大限度地减少 4G/LTE 上行链路中抖动和延迟的潜在影响,我将 Mikrotik 路由器配置为多个互联网时间源的 NTP 客户端:

  • tic.ntp.telstra.net
  • toc.ntp.telstra.net
  • 0.au.pool.ntp.org
  • 1.au.pool.ntp.org
  • 2.au.pool.ntp.org
  • 3.au.pool.ntp.org

并将其配置为本地 LAN 的 NTP 服务器(仅支持单播模式)。

Mikrotik 似乎正在与互联网服务器愉快地同步,具有完全合理的定时特性(根据 LTE 标准):

Mikrotik NTP 客户端状态:

         enabled: yes
            mode: unicast
         servers: tic.ntp.telstra.net,toc.ntp.telstra.net,0.au.pool.ntp.org,1.au.pool.ntp.org,2.au.p
                  3.au.pool.ntp.org
      freq-drift: 3.611 PPM
          status: synchronized
   synced-server: toc.ntp.telstra.net
  synced-stratum: 2
   system-offset: -0.972 ms

Mikrotik NTP 对等计时数据:

type="ucast-client" address=203.14.0.250 refid="203.36.227.3" stratum=2 hpoll=10 ppoll=10 root-delay=55.221 ms 
   root-disp=0.885 ms offset=11.512 ms delay=55.956 ms disp=40.266 ms jitter=49.287 ms 

 type="ucast-client" address=27.124.125.250 refid="162.159.200.1" stratum=4 hpoll=10 ppoll=10 root-delay=3.692 ms 
   root-disp=2.838 ms offset=-5.166 ms delay=22.56 ms disp=0.119 ms jitter=15.666 ms 

 type="ucast-client" address=139.99.222.72 refid="17.253.66.253" stratum=2 hpoll=10 ppoll=10 root-delay=0.305 ms 
   root-disp=1.113 ms offset=-3.321 ms delay=74.975 ms disp=0.173 ms jitter=14.038 ms 

 type="ucast-client" address=13.55.50.68 refid="203.206.205.83" stratum=3 hpoll=10 ppoll=10 root-delay=31.066 ms 
   root-disp=52.902 ms offset=-3.031 ms delay=81.468 ms disp=0.184 ms jitter=13.174 ms 

 type="ucast-client" address=194.0.5.123 refid="8.145.32.135" stratum=2 hpoll=10 ppoll=10 root-delay=27.084 ms 
   root-disp=33.615 ms offset=-0.383 ms delay=79.435 ms disp=0.083 ms jitter=12.289 ms 

 type="ucast-client" address=203.14.0.251 refid="58.163.113.212" stratum=2 hpoll=10 ppoll=10 root-delay=38.833 ms 
   root-disp=2.258 ms offset=0.913 ms delay=34.001 ms disp=0.157 ms jitter=10.431 ms

31 个 Raspberry Pi 均运行 Raspberry Pi OS Lite (bullseye) 64 位版本。我已经通过标准 apt 软件包安装了ntpd它们ntpstatntpd已替换并屏蔽systemd-timesyncd。 Pi NTP 客户端配置为使用 Mikrotik 上运行的 NTP 服务器作为其唯一的时间源。

ntpq -pn在 Raspberry Pi 上运行会返回合理的结果。

在直接连接到 Mikrotik 的节点上:

     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*10.3.0.126      203.14.0.251     3 u   48  128  377    0.506   +0.088   0.232

在代表性 wifi 节点上,延迟和抖动要高出几毫秒:

     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*10.3.0.126      203.14.0.251     3 u   76  128  377    1.541   -1.230   2.011

然而,当我ntpstat在有线 Raspberry Pi 上运行时,我被告知时间同步质量只能达到 70 毫秒,并且随着时间的推移它会变得越来越糟:

synchronised to NTP server (10.3.0.126) at stratum 4
   time correct to within 70 ms
   polling server every 128 s

该“时间校正”值是根据根色散和根延迟计算得出的。当我ntpq -c rv在几分钟内重复运行时,该rootdisp值单调增加。

pi@wired:~ $ ntpq -c rv
associd=0 status=0615 leap_none, sync_ntp, 1 event, clock_sync,
version="ntpd [email protected] Wed Sep 23 11:46:38 UTC 2020 (1)",
processor="aarch64", system="Linux/5.10.92-v8+", leap=00, stratum=4,
precision=-22, rootdelay=73.314, rootdisp=32.686, refid=10.3.0.126,
reftime=e5c848b0.ab2d24bc  Tue, Mar  1 2022 15:24:32.668,
clock=e5c84927.24f1e0bd  Tue, Mar  1 2022 15:26:31.144, peer=41018, tc=7,
mintc=3, offset=-0.165471, frequency=-16.004, sys_jitter=0.000000,
clk_jitter=2.031, clk_wander=0.093

pi@wired:~ $ ntpq -c rv
associd=0 status=0615 leap_none, sync_ntp, 1 event, clock_sync,
version="ntpd [email protected] Wed Sep 23 11:46:38 UTC 2020 (1)",
processor="aarch64", system="Linux/5.10.92-v8+", leap=00, stratum=4,
precision=-22, rootdelay=73.314, rootdisp=32.896, refid=10.3.0.126,
reftime=e5c848b0.ab2d24bc  Tue, Mar  1 2022 15:24:32.668,
clock=e5c84934.f6a1b6af  Tue, Mar  1 2022 15:26:44.963, peer=41018, tc=7,
mintc=3, offset=-0.165471, frequency=-16.004, sys_jitter=0.000000,
clk_jitter=2.031, clk_wander=0.093

pi@wired:~ $ ntpq -c rv
associd=0 status=0615 leap_none, sync_ntp, 1 event, clock_sync,
version="ntpd [email protected] Wed Sep 23 11:46:38 UTC 2020 (1)",
processor="aarch64", system="Linux/5.10.92-v8+", leap=00, stratum=4,
precision=-22, rootdelay=73.314, rootdisp=37.906, refid=10.3.0.126,
reftime=e5c848b0.ab2d24bc  Tue, Mar  1 2022 15:24:32.668,
clock=e5c84a83.a3e47e0e  Tue, Mar  1 2022 15:32:19.640, peer=41018, tc=7,
mintc=3, offset=-0.165471, frequency=-16.004, sys_jitter=0.000000,
clk_jitter=2.031, clk_wander=0.093

pi@wired:~ $ ntpq -c rv
associd=0 status=0615 leap_none, sync_ntp, 1 event, clock_sync,
version="ntpd [email protected] Wed Sep 23 11:46:38 UTC 2020 (1)",
processor="aarch64", system="Linux/5.10.92-v8+", leap=00, stratum=4,
precision=-22, rootdelay=73.314, rootdisp=51.003, refid=10.3.0.126,
reftime=e5c84c4e.ab29eed3  Tue, Mar  1 2022 15:39:58.668,
clock=e5c84d42.f35d7000  Tue, Mar  1 2022 15:44:02.950, peer=41018, tc=7,
mintc=3, offset=-0.714738, frequency=-16.162, sys_jitter=0.000000,
clk_jitter=1.910, clk_wander=0.103

什么可能导致根分散随着时间的推移而增加,以及如何解决它?

由于我实际上不太关心绝对时间精度,只关心节点到节点的误差,所以我可以忽略根分散和根延迟(以及由此报告的“精度” ntpstat)并完全依赖Raspberry Pi- to-Mikrotik 色散/延迟/偏移指标?

我是否应该以某种方式更改此测试设置的 NTP 架构,以改进同步?

相关内容