Bug 8406 - ntpd issue: the time isn't synchronized after configurating two or more usable NTP servers
Summary: ntpd issue: the time isn't synchronized after configurating two or more usabl...
Status: RESOLVED INVALID
Alias: None
Product: Busybox
Classification: Unclassified
Component: Networking (show other bugs)
Version: 1.19.x
Hardware: Other Linux
: P5 blocker
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-10-19 06:41 UTC by wendy
Modified: 2016-01-03 22:22 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description wendy 2015-10-19 06:41:55 UTC
OS: mips linux
busybox version: 1.19.4

ntpd issue: the time isn't synchronized after configurating two or more usable NTP servers

If I configurate two or more working ntp servers,
For instance: 172.30.50.23 and 172.30.50.21.
/usr/sbin/ntpd -n -l -p 172.30.50.23 -p 172.30.50.21 /sbin/firstusedate &
The date is not updated.

If I configurate one working ntp server and more than one no response ntp servers
For instance: 172.30.50.23, 172.30.50.30, 172.30.50.33
/usr/sbin/ntpd -n -l -p 172.30.50.23 -p 172.30.50.22 /sbin/firstusedate &
And the date is updated.

After track the code of ntpd in busybox, 
I find that if more than one candidates, no peer selected.

logs are as followings,
root@OpenWrt:~# /usr/sbin/ntpd -n -l -p 172.30.50.21 -p 172.30.50.23 -S /sbin/firstusedate
ntpd: ntpd main
ntpd: ntp init
ntpd: filter offset:+0.000000 disp:0.000000 jitter:0.002000
ntpd: ->lastpkt_recv_time=2208989377.515911
ntpd: filter offset:+0.000000 disp:0.000000 jitter:0.002000
ntpd: ->lastpkt_recv_time=2208989377.515911
ntpd: send_query_to_peer begin
ntpd: resolved peer 172.30.50.23 to 172.30.50.23
ntpd: sending query to 172.30.50.23
ntpd: send_query_to_peer begin
ntpd: resolved peer 172.30.50.21 to 172.30.50.21
ntpd: sending query to 172.30.50.21
ntpd: recv_and_process_peer_pkt begin
ntpd: lastpkt_recv_time=2208989377.538691
ntpd: recv_and_process_peer_pkt update the clock
ntpd: filter offset:+1445228474.580437 disp:0.001001 jitter:0.002000
ntpd: no valid datapoints, no peer selected
ntpd: polladj: count:6 
ntpd: chose poll interval:1 (poll_exp:0)
ntpd: recv_and_process_peer_pkt begin
ntpd: lastpkt_recv_time=2208989377.553536
ntpd: recv_and_process_peer_pkt update the clock
ntpd: filter offset:+1445228475.149800 disp:0.001001 jitter:0.002000
ntpd: no valid datapoints, no peer selected
ntpd: polladj: count:12 
ntpd: chose poll interval:1 (poll_exp:0)
ntpd: send_query_to_peer begin
ntpd: sending query to 172.30.50.23
ntpd: send_query_to_peer begin
ntpd: sending query to 172.30.50.21
ntpd: recv_and_process_peer_pkt begin
ntpd: lastpkt_recv_time=2208989378.579830
ntpd: recv_and_process_peer_pkt update the clock
ntpd: filter offset:+1445228474.578943 disp:0.001509 jitter:0.002000
ntpd: no valid datapoints, no peer selected
ntpd: polladj: count:18 
ntpd: chose poll interval:2 (poll_exp:0)
ntpd: recv_and_process_peer_pkt begin
ntpd: lastpkt_recv_time=2208989378.583470
ntpd: recv_and_process_peer_pkt update the clock
ntpd: filter offset:+1445228475.154744 disp:0.001509 jitter:0.002000
ntpd: no valid datapoints, no peer selected
ntpd: polladj: count:24 
ntpd: chose poll interval:2 (poll_exp:0)
ntpd: send_query_to_peer begin
ntpd: sending query to 172.30.50.23
ntpd: send_query_to_peer begin
ntpd: sending query to 172.30.50.21
ntpd: recv_and_process_peer_pkt begin
ntpd: lastpkt_recv_time=2208989380.610805
ntpd: recv_and_process_peer_pkt update the clock
ntpd: filter offset:+1445228474.576810 disp:0.001770 jitter:0.002000
ntpd: no valid datapoints, no peer selected
ntpd: polladj: count:30 
ntpd: chose poll interval:2 (poll_exp:0)
ntpd: recv_and_process_peer_pkt begin
ntpd: lastpkt_recv_time=2208989380.615153
ntpd: recv_and_process_peer_pkt update the clock
ntpd: filter offset:+1445228475.151268 disp:0.001770 jitter:0.002000
ntpd: no valid datapoints, no peer selected
ntpd: polladj: count:36 
ntpd: chose poll interval:1 (poll_exp:0)
ntpd: send_query_to_peer begin
ntpd: sending query to 172.30.50.21
ntpd: recv_and_process_peer_pkt begin
ntpd: lastpkt_recv_time=2208989381.636017
ntpd: recv_and_process_peer_pkt update the clock
ntpd: filter offset:+1445228475.150733 disp:0.001893 jitter:0.002000
ntpd: no valid datapoints, no peer selected
ntpd: polladj: discipline_jitter:0.002000 ++poll_exp=1 
ntpd: chose poll interval:2 (poll_exp:1)
ntpd: send_query_to_peer begin
ntpd: sending query to 172.30.50.23
ntpd: recv_and_process_peer_pkt begin
ntpd: lastpkt_recv_time=2208989382.660165
ntpd: recv_and_process_peer_pkt update the clock
ntpd: filter offset:+1445228474.574957 disp:0.001901 jitter:0.002000
ntpd: no valid datapoints, no peer selected
ntpd: polladj: count:6 
ntpd: chose poll interval:2 (poll_exp:1)
ntpd: send_query_to_peer begin
ntpd: sending query to 172.30.50.21
ntpd: recv_and_process_peer_pkt begin
ntpd: lastpkt_recv_time=2208989383.682160
ntpd: recv_and_process_peer_pkt update the clock
ntpd: filter offset:+1445228475.149043 disp:0.001962 jitter:0.002000
ntpd: no valid datapoints, no peer selected
ntpd: polladj: count:12 
ntpd: chose poll interval:3 (poll_exp:1)
ntpd: disabling burst mode
ntpd: send_query_to_peer begin
ntpd: sending query to 172.30.50.23
ntpd: recv_and_process_peer_pkt begin
ntpd: lastpkt_recv_time=2208989384.701791
ntpd: recv_and_process_peer_pkt update the clock
ntpd: filter offset:+1445228474.573397 disp:0.001966 jitter:0.002645
ntpd: interval: [1445228474.548567 1445228474.573397 1445228474.598227] 172.30.50.23
ntpd: interval: [1445228475.125299 1445228475.149043 1445228475.172788] 172.30.50.21
ntpd: falsetickers:1, candidates:2, no peer selected
ntpd: polladj: count:6 
ntpd: chose poll interval:65 (poll_exp:6)
ntpd: send_query_to_peer begin
ntpd: sending query to 172.30.50.21
ntpd: recv_and_process_peer_pkt begin
ntpd: lastpkt_recv_time=2208989386.723089
ntpd: recv_and_process_peer_pkt update the clock
ntpd: filter offset:+1445228475.145546 disp:0.002004 jitter:0.002381
ntpd: interval: [1445228474.548537 1445228474.573397 1445228474.598258] 172.30.50.23
ntpd: interval: [1445228475.121881 1445228475.145546 1445228475.169210] 172.30.50.21
ntpd: falsetickers:1, candidates:2, no peer selected
ntpd: polladj: count:12 
ntpd: chose poll interval:65 (poll_exp:6)



In function "select_and_cluster" in ntpd.c
If I change the code "if (num_falsetickers * 2 >= num_candidates)" to the following,  
  if (num_falsetickers >= num_candidates) {
                    VERB3 bb_error_msg("falsetickers:%d, candidates:%d%s",
                                    num_falsetickers, num_candidates,
                                    ", no peer selected");
                    return NULL;
            }
The time is updated.
But maybe the change is not fitable, so please help to check the issue,
and give the fitable fix.
Thanks a lot.
Comment 1 Denys Vlasenko 2015-10-19 21:35:55 UTC
ntpd: interval: [1445228474.548537 1445228474.573397 1445228474.598258]
172.30.50.23
ntpd: interval: [1445228475.121881 1445228475.145546 1445228475.169210]
172.30.50.21

As you see, your two ntp servers provide time data which is inconsistent. They are about 0.5 second apart.

ntpd tells you that at least one of them is "falseticker". Since ntpd doesn't know who is it, it refuses to use data from either of them.