Windows 下 调试ntpd与ntpdate同步

(1)在一台windows系统的机器上(假设网络ip为192.168.2.104),建立并编辑ntp.conf文件,内容:server 120.25.115.20 iburst。 120.25.115.20是“阿里云”提供的NTP授时服务器地址。

(2)运行命令:ntpd.exe -d -c ntp.conf。结果如下:

D:\NTP\ntp-4.2.8p13\ports\winnt\vs2015\x64-out\Debug>ntpd.exe -d -c ntp.conf
 2 Jan 17:29:37 ntpd[22164]: ntpd 4.2.8p13@1.3847-o  2019 10:25:55.52 (UTC+08:00) 12  (8): Starting
 2 Jan 17:29:37 ntpd[22164]: Command line: ntpd.exe -d -c ntp.conf
 2 Jan 17:29:37 ntpd[22164]: Raised to realtime priority class
 2 Jan 17:29:37 ntpd[22164]: Clock interrupt period 15.625 msec
 2 Jan 17:29:37 ntpd[22164]: Performance counter frequency 10.000 MHz
 2 Jan 17:29:37 ntpd[22164]: proto: precision = 0.300 usec (-22)
Finished Parsing!!
 2 Jan 17:29:37 ntpd[22164]: basedate set to 2019-12-19
 2 Jan 17:29:37 ntpd[22164]: gps base set to 2019-12-22 (week 2085)
 2 Jan 17:29:37 ntpd[22164]: Listen and drop on 0 v6wildcard [::]:123
 2 Jan 17:29:37 ntpd[22164]: Listen and drop on 1 v4wildcard 0.0.0.0:123
 2 Jan 17:29:37 ntpd[22164]: Listen normally on 2 VirtualBox Host-Only Network [fe80::2d6b:85f8:6d9c:a7e1%2]:123
hack_restrict: op RESTRICT_FLAGS addr fe80::2d6b:85f8:6d9c:a7e1%2 mask ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff ippeerlimit -4 mflags 00003000 rflags 00000001
 2 Jan 17:29:37 ntpd[22164]: Listen normally on 3 VirtualBox Host-Only Network 169.254.167.225:123
hack_restrict: op RESTRICT_FLAGS addr 169.254.167.225 mask 255.255.255.255 ippeerlimit -4 mflags 00003000 rflags 00000001
 2 Jan 17:29:37 ntpd[22164]: Listen normally on 4 以太网 [fe80::e46d:f887:4c5a:ac72%10]:123
hack_restrict: op RESTRICT_FLAGS addr fe80::e46d:f887:4c5a:ac72%10 mask ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff ippeerlimit -4 mflags 00003000 rflags 00000001
 2 Jan 17:29:37 ntpd[22164]: Listen normally on 5 以太网 192.168.2.104:123
hack_restrict: op RESTRICT_FLAGS addr 192.168.2.104 mask 255.255.255.255 ippeerlimit -4 mflags 00003000 rflags 00000001
 2 Jan 17:29:37 ntpd[22164]: Listen normally on 6 Loopback Pseudo-Interface 1 [::1]:123
hack_restrict: op RESTRICT_FLAGS addr ::1 mask ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff ippeerlimit -4 mflags 00003000 rflags 00000001
 2 Jan 17:29:37 ntpd[22164]: Listen normally on 7 Loopback Pseudo-Interface 1 127.0.0.1:123
hack_restrict: op RESTRICT_FLAGS addr 127.0.0.1 mask 255.255.255.255 ippeerlimit -4 mflags 00003000 rflags 00000001
newpeer(120.25.115.20) found no existing and 0 other associations
newpeer(120.25.115.20) - ippeerlimit -1 ignored
key_expire: at 0 associd 15596
peer_clear: at 0 next 1 associd 15596 refid INIT
event at 0 120.25.115.20 8011 81 mobilize assoc 15596
newpeer: 192.168.2.104->120.25.115.20 mode 3 vers 4 poll 6 10 flags 0x101 0x1 ttl 0 key 00000000
event at 0 0.0.0.0 c012 02 freq_set ntpd 0.000 PPM
event at 0 0.0.0.0 c011 01 freq_not_set
event at 0 0.0.0.0 c016 06 restart
peer_xmit: at 1 192.168.2.104->120.25.115.20 mode 3 len 48 xmt 0xe1b83681.a932da8d
auth_agekeys: at 1 keys 0 expired 0
restrictions: looking up 120.25.115.20
receive: at 1 192.168.2.104<-120.25.115.20 ippeerlimit -1 mode 4 iflags up,broadcast,multicast restrict (none) org 0xe1b83681.a932da8d xmt 0xe1b83681.ae0f89be
receive: at 1 192.168.2.104<-120.25.115.20 mode 4/server:AM_PROCPKT len 48 org 0xe1b83681.a932da8d xmt 0xe1b83681.ae0f89be NOMAC
receive: MATCH_ASSOC dispatch: mode 4/server:AM_PROCPKT
event at 1 120.25.115.20 8014 84 reachable
clock_filter: n 1 off -0.000509 del 0.038961 dsp 7.937500 jit 0.000000
peer_xmit: at 3 192.168.2.104->120.25.115.20 mode 3 len 48 xmt 0xe1b83683.a50f6990
restrictions: looking up 120.25.115.20
receive: at 3 192.168.2.104<-120.25.115.20 ippeerlimit -1 mode 4 iflags up,broadcast,multicast restrict (none) org 0xe1b83683.a50f6990 xmt 0xe1b83683.a9f5af81
receive: at 3 192.168.2.104<-120.25.115.20 mode 4/server:AM_PROCPKT len 48 org 0xe1b83683.a50f6990 xmt 0xe1b83683.a9f5af81 NOMAC
receive: MATCH_ASSOC dispatch: mode 4/server:AM_PROCPKT
clock_filter: n 2 off -0.000135 del 0.038467 dsp 3.937508 jit 0.000374
peer_xmit: at 5 192.168.2.104->120.25.115.20 mode 3 len 48 xmt 0xe1b83685.a4f6001f
restrictions: looking up 120.25.115.20
receive: at 5 192.168.2.104<-120.25.115.20 ippeerlimit -1 mode 4 iflags up,broadcast,multicast restrict (none) org 0xe1b83685.a4f6001f xmt 0xe1b83685.a9d401a8
receive: at 5 192.168.2.104<-120.25.115.20 mode 4/server:AM_PROCPKT len 48 org 0xe1b83685.a4f6001f xmt 0xe1b83685.a9d401a8 NOMAC
receive: MATCH_ASSOC dispatch: mode 4/server:AM_PROCPKT
clock_filter: n 3 off -0.000313 del 0.038558 dsp 1.937516 jit 0.000187
peer_xmit: at 7 192.168.2.104->120.25.115.20 mode 3 len 48 xmt 0xe1b83687.a51c294b
restrictions: looking up 120.25.115.20
receive: at 7 192.168.2.104<-120.25.115.20 ippeerlimit -1 mode 4 iflags up,broadcast,multicast restrict (none) org 0xe1b83687.a51c294b xmt 0xe1b83687.ab2c51d2
receive: at 7 192.168.2.104<-120.25.115.20 mode 4/server:AM_PROCPKT len 48 org 0xe1b83687.a51c294b xmt 0xe1b83687.ab2c51d2 NOMAC
receive: MATCH_ASSOC dispatch: mode 4/server:AM_PROCPKT
clock_filter: n 4 off 0.002471 del 0.042369 dsp 0.937521 jit 0.002794
select: combine offset 0.002471197 jitter 0.000000000
event at 7 120.25.115.20 901a 8a sys_peer
clock_update: at 7 sample 7 associd 15596
event at 7 0.0.0.0 c614 04 freq_mode
local_clock: offset 0.002471197 jit 0.000873700 freq 0.000 stab 0.000 poll 6
peer_xmit: at 9 192.168.2.104->120.25.115.20 mode 3 len 48 xmt 0xe1b83689.a54f21c5
restrictions: looking up 120.25.115.20
receive: at 9 192.168.2.104<-120.25.115.20 ippeerlimit -1 mode 4 iflags up,broadcast,multicast restrict (none) org 0xe1b83689.a54f21c5 xmt 0xe1b83689.a9f3494f
receive: at 9 192.168.2.104<-120.25.115.20 mode 4/server:AM_PROCPKT len 48 org 0xe1b83689.a54f21c5 xmt 0xe1b83689.a9f3494f NOMAC
receive: MATCH_ASSOC dispatch: mode 4/server:AM_PROCPKT
clock_filter: n 5 off -0.001331 del 0.038885 dsp 0.437525 jit 0.002098
peer_xmit: at 11 192.168.2.104->120.25.115.20 mode 3 len 48 xmt 0xe1b8368b.a5b42792
restrictions: looking up 120.25.115.20
receive: at 11 192.168.2.104<-120.25.115.20 ippeerlimit -1 mode 4 iflags up,broadcast,multicast restrict (none) org 0xe1b8368b.a5b42792 xmt 0xe1b8368b.aa1bd3dd
receive: at 11 192.168.2.104<-120.25.115.20 mode 4/server:AM_PROCPKT len 48 org 0xe1b8368b.a5b42792 xmt 0xe1b8368b.aa1bd3dd NOMAC
receive: MATCH_ASSOC dispatch: mode 4/server:AM_PROCPKT
clock_filter: n 6 off -0.001832 del 0.037904 dsp 0.187528 jit 0.002267
select: combine offset -0.001831549 jitter 0.000000000
clock_update: at 11 sample 11 associd 15596

(3)由于ntp与ntpdate都用到端口123,需要在另一台机器上(ip地址为192.168.2.108)运行ntpdate 192.168.2.104。结果如下:

sudo ./ntpdate 192.168.2.104
 2 Jan 17:31:38 ntpdate[2344]: adjust time server 192.168.2.104 offset 0.003999 sec
同步成功

(4)运行ntpd的机器新增打印:

peer_xmit: at 69 192.168.2.104->120.25.115.20 mode 3 len 48 xmt 0xe1b836c5.a5c1f8f0
restrictions: looking up 120.25.115.20
receive: at 69 192.168.2.104<-120.25.115.20 ippeerlimit -1 mode 4 iflags up,broadcast,multicast restrict (none) org 0xe1b836c5.a5c1f8f0 xmt 0xe1b836c5.aa094df9
receive: at 69 192.168.2.104<-120.25.115.20 mode 4/server:AM_PROCPKT len 48 org 0xe1b836c5.a5c1f8f0 xmt 0xe1b836c5.aa094df9 NOMAC
receive: MATCH_ASSOC dispatch: mode 4/server:AM_PROCPKT
clock_filter: n 7 off -0.002373 del 0.038135 dsp 0.062942 jit 0.002502
select: combine offset -0.002373043 jitter 0.000000000
clock_update: at 69 sample 69 associd 15596
restrictions: looking up 192.168.2.108
receive: at 115 192.168.2.104<-192.168.2.108 ippeerlimit -1 mode 3 iflags up,broadcast,multicast restrict (none) org 0000000000.00000000 xmt 0xe1b836f4.9b11365e
receive: at 115 192.168.2.104<-192.168.2.108 mode 3/client:AM_FXMIT len 48 org 0000000000.00000000 xmt 0xe1b836f4.9b11365e NOMAC
receive: MATCH_ASSOC dispatch: mode 3/client:AM_FXMIT
fast_xmit: at 115 192.168.2.104->192.168.2.108 mode 4 len 48
restrictions: looking up 192.168.2.108
receive: at 117 192.168.2.104<-192.168.2.108 ippeerlimit -1 mode 3 iflags up,broadcast,multicast restrict (none) org 0000000000.00000000 xmt 0xe1b836f6.9b102c55
receive: at 117 192.168.2.104<-192.168.2.108 mode 3/client:AM_FXMIT len 48 org 0000000000.00000000 xmt 0xe1b836f6.9b102c55 NOMAC
receive: MATCH_ASSOC dispatch: mode 3/client:AM_FXMIT
fast_xmit: at 117 192.168.2.104->192.168.2.108 mode 4 len 48
restrictions: looking up 192.168.2.108
receive: at 119 192.168.2.104<-192.168.2.108 ippeerlimit -1 mode 3 iflags up,broadcast,multicast restrict (none) org 0000000000.00000000 xmt 0xe1b836f8.9b65548c
receive: at 119 192.168.2.104<-192.168.2.108 mode 3/client:AM_FXMIT len 48 org 0000000000.00000000 xmt 0xe1b836f8.9b65548c NOMAC
receive: MATCH_ASSOC dispatch: mode 3/client:AM_FXMIT
fast_xmit: at 119 192.168.2.104->192.168.2.108 mode 4 len 48
restrictions: looking up 192.168.2.108
receive: at 121 192.168.2.104<-192.168.2.108 ippeerlimit -1 mode 3 iflags up,broadcast,multicast restrict (none) org 0000000000.00000000 xmt 0xe1b836fa.9b5ecc98
receive: at 121 192.168.2.104<-192.168.2.108 mode 3/client:AM_FXMIT len 48 org 0000000000.00000000 xmt 0xe1b836fa.9b5ecc98 NOMAC
receive: MATCH_ASSOC dispatch: mode 3/client:AM_FXMIT
fast_xmit: at 121 192.168.2.104->192.168.2.108 mode 4 len 48
peer_xmit: at 137 192.168.2.104->120.25.115.20 mode 3 len 48 xmt 0xe1b83709.a5c9abc7
restrictions: looking up 120.25.115.20
receive: at 137 192.168.2.104<-120.25.115.20 ippeerlimit -1 mode 4 iflags up,broadcast,multicast restrict (none) org 0xe1b83709.a5c9abc7 xmt 0xe1b83709.aa1e7f26
receive: at 137 192.168.2.104<-120.25.115.20 mode 4/server:AM_PROCPKT len 48 org 0xe1b83709.a5c9abc7 xmt 0xe1b83709.aa1e7f26 NOMAC
receive: MATCH_ASSOC dispatch: mode 4/server:AM_PROCPKT
clock_filter: n 8 off -0.002083 del 0.037903 dsp 0.000728 jit 0.002100
select: combine offset -0.002083189 jitter 0.000000000
clock_update: at 137 sample 137 associd 15596
peer_xmit: at 204 192.168.2.104->120.25.115.20 mode 3 len 48 xmt 0xe1b8374c.a5ac20d0
restrictions: looking up 120.25.115.20
receive: at 204 192.168.2.104<-120.25.115.20 ippeerlimit -1 mode 4 iflags up,broadcast,multicast restrict (none) org 0xe1b8374c.a5ac20d0 xmt 0xe1b8374c.aa2c6c8b
receive: at 204 192.168.2.104<-120.25.115.20 mode 4/server:AM_PROCPKT len 48 org 0xe1b8374c.a5ac20d0 xmt 0xe1b8374c.aa2c6c8b NOMAC
receive: MATCH_ASSOC dispatch: mode 4/server:AM_PROCPKT
clock_filter: n 8 off -0.002162 del 0.038416 dsp 0.000859 jit 0.002065
select: combine offset -0.002162258 jitter 0.000000000
clock_update: at 204 sample 204 associd 15596
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

109702008

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值