[ntp:questions] Confused about pool rotation
oneingray at gmail.com
Fri Feb 8 07:26:12 UTC 2013
>>>>> Hal Murray <hal-usenet at ip-64-139-1-69.sjc.megapath.net> writes:
>>>>> no-one at no-place.org writes:
[Cross-posting to news:free.comp.dns.]
>> I am trying to get to know SNTP by doing some Winsock programming.
>> In particular, I am using
>> getaddrinfo("pool.ntp.org", "123", &hints, &gaires);
>> where hints has been set up to define a socket type of SOCK_DGRAM
>> and family of AF_INET. As expected, the Internet address returned
>> in *gaires does change from time to time. But it seems that it
>> often returns the same value if I call it again after a short time.
>> But if I wait a minute or two then I get a different address. What
>> is the rotation mechanism and why doesn't it give me a new address
>> every time?
> There are two levels of change.
> When you do a DNS opration, you probably talk to a cache. That cache
> returns a clump of addresses in random order. You are seeing the
> first one.
As per the Wikipedia article , struct addrinfo * is a linked
list. Thus, the proper algorithm would probably be to stuff the
addresses received into a list, and then use and discard one of
its elements each time an NTP server is to be used. Once the
list is empty, getaddrinfo () is to be run again, for a new
batch of NTP servers.
> When the cache times out, it asks the real server which will return a
> new clump of addresses and a TTL (time to live) for the cache.
> Play around with dig a bit and you can see it in operation.
$ dig aaaa pool.ntp.org
$ dig a pool.ntp.org
(Is the pool lacking IPv6-capable NTP servers, BTW?)
FSF associate member #7257 np. ml_tcod.xm
More information about the questions