NTP client: What is a peer?
pabstraud at compuserve.com
Tue May 11 19:38:13 UTC 2021
Mind me, I am a far-away downstream end-user (OpenWrt <- GL.iNet). While analyzing with Wireshark another issue, I noticed a lot of NTP traffic. Then, I tried to understand the current, original source code†. And even setup my own domain with several NTP sources.
When I add a single peer like
$ ntpd -wddddddp pool.ntp.org
BusyBox queries DNS (A- and AAAA- records) and picks the very first answer, preferable the A record. If there are several IP addresses, only the first IP address is picked. Is that analysis correct?
When I add several peers like
$ ntpd -wddddddp 1.pool.ntp.org -p 2.pool.ntp.org
BusyBox does the above for each peer. Is that analysis correct?
1) For each added peer, I see one NTP query. That means, if I add ten peers, I get ten NTP queries every x seconds. Why does the NTP client not stick to one peer which resolved and answered?
2) How many IP addresses a peer returns do not matter. That means, additional IP addresses are not considered as alternative. Why does the NTP client use only the first IP address and not all IP addresses?
3) IPv6 works only if the peer returns just an AAAA record. That means, if there is a DNS-A record, it is not only preferred but because of (2) the DNS-AAAA record gets ignored. In other words: To get a possible IPv6 alternative server, I *have to* specify a peer which is IPv6*only*. Why does the NTP client not collect (at least) one IP address per DNS record type per peer?
I understand the compiler flag ENABLE_FEATURE_PREFER_IPV4_ADDRESS from the year 2007 which got enabled on default in March 2016. That is OK. I went through the archives of the NTP Pool Project, BusyBox, and read some related RFCs. However, I did not find a statement that you have to make NTP to *all* peers but only *one* of their IP addresses, and preferable *just* via IPv4.
Assume a single peer. That peer is available via IPv4 and IPv6 normally. It offers one IP address for each address type via DNS. Why ever, temporarily, the IPv4 address does not work via NTP. And, the current client code does not even dare to try NTP via IPv6. What?
-> host2sockaddr(peer, port=123)
--> str2sockaddr(peer, port=123, ai_family=AF_UNSPEC, ai_flags=NULL)
---> getaddrinfo(peer, service=NULL, ai_socktype=SOCK_STREAM)
More information about the busybox