Subject: | invalid precision reported |
Date: | Tue, 12 May 2009 19:32:29 +0200 (CEST) |
To: | bug-Net-NTP [...] rt.cpan.org |
From: | Charles-Francois Natali <neologix [...] free.fr> |
Hi.
The module reports an invalid precision:
$ ./test_ntp.pl localhost
1.2
Version Number = 3
Root Delay = 0.046112060546875
Precision = -18
Leap Indicator = 0
Stratum = 3
Receive Timestamp = 1242149112.56682
Tue May 12 19:25:12 2009
Transmit Timestamp = 1242149112.56689
Tue May 12 19:25:12 2009
Originate Timestamp = 1242149112.27454
Tue May 12 19:25:12 2009
Reference Timestamp = 1242148397.36495
Tue May 12 19:13:17 2009
Poll Interval = 0.0000
Reference Clock Identifier = 212.68.213.58
Root Dispersion = 0.0000
Mode = 4
then: 1242149112.56444 now: 1242149112.56798
Delay: 0.00347
Offset: 0.00064
Mode: server
Stratum: secondary reference (via NTP or SNTP)
Leap Indicator: no warning
whith ntpdate :
$ /usr/sbin/ntpdate -d localhost
12 May 19:25:07 ntpdate[5697]: ntpdate 4.2.4p4@1.1520-o Wed Jan 7 18:06:30 UTC 2009 (1)
transmit(127.0.0.1)
receive(127.0.0.1)
transmit(127.0.0.1)
receive(127.0.0.1)
transmit(127.0.0.1)
receive(127.0.0.1)
transmit(127.0.0.1)
receive(127.0.0.1)
transmit(127.0.0.1)
server 127.0.0.1, port 123
stratum 3, precision -19, leap 00, trust 000
refid [127.0.0.1], delay 0.02571, dispersion 0.00000
transmitted 4, in filter 4
reference time: cdb42cad.5d6d1bb8 Tue, May 12 2009 19:13:17.364
originate timestamp: cdb42f73.2cbcc4b9 Tue, May 12 2009 19:25:07.174
transmit timestamp: cdb42f73.2cbad7d7 Tue, May 12 2009 19:25:07.174
filter delay: 0.02583 0.02571 0.02571 0.02571
0.00000 0.00000 0.00000 0.00000
filter offset: -0.00008 -0.00004 -0.00004 -0.00004
0.000000 0.000000 0.000000 0.000000
delay 0.02571, dispersion 0.00000
offset -0.000046
The problem is that the field is unpacked as un unsigned char, and then substracted 255, but it's off by one.
It's simpler and cleaner to unpack it as a signed char.
Patch attached.
Cheers
Message body is not shown because sender requested not to inline it.