jbenet/ios-ntp

Question for one-time check

Closed this issue · 4 comments

I'm using NetAssociation for one-time check, and I found sometimes it won't work.
I have check your code, and found you are using UDP socket, I'm not sure but if my problem is due to the UDP protocol? I want to know do you have some work to make sure the one-time check always work well even using UDP.

Please describe more how "it won't work" and how often is "sometimes"?

The network time protocol is a datagram protocol (UDP), you can't change that. If you feel that your network connection is unreliable enough to lose packets on a regular basis, you'll have to keep trying till you get a response from whichever server you are using (by the way, which one are you using?). But modern internet connectivity is usually good enough to ensure that UDP is "reliable" (after all, DNS works for everybody) so I suspect something else is failing.

@gavineadie Thanks for your explains, I'm using cn.pool.ntp.org, and the rate of failure maybe 5%. I think it should due to my bad network. Anyway, thanks again.

I see that you are using a 'pool' address. These addresses resolve to multiple actual time servers and which one you get will vary each time. It may be that one of the servers in the pool is not operating (not too unusual for these regional/national pool) and that you sometimes get that one. It would better to chose one specific server that is known to be reliable, or a pool that is probably monitored (time.asia.apple.com ?).

I don't know who generates the regional/national pool lists, how the members are selected, or how often they are monitored or refreshed. I do know the 'americas' pool has had some had some unreliable members when I've used it. The pools are intended to provide a collection (more that ten typically) of servers which are ALL used to contribute to an average, so it doesn't matter if one or two don't work.

I really appreciate it, your explain is very clear. Thanks a lot.