jbenet / ios-ntp

SNTP implementation for iOS
http://code.google.com/p/ios-ntp/
MIT License
370 stars 112 forks source link

milliseconds #31

Closed kokagaki closed 8 years ago

kokagaki commented 8 years ago

hey all, is it possible to achieve granularity down to the millisecond?

gavineadie commented 8 years ago

I would say, "No". iOS is optimized for human interaction; that takes priority over everything else.

.. Sent by iPhone

On Nov 26, 2015, at 5:58 PM, kokagaki notifications@github.com wrote:

hey all, is it possible to achieve granularity down to the millisecond?

— Reply to this email directly or view it on GitHub.

scottybe commented 8 years ago

With all the hoopla about the Apple Watch being "within 50 milliseconds of the definitive global time standard", I was hoping the iPhone would benefit from that starting with iOS 8.2 (the minimum iOS that supports the Apple Watch). Sadly, that's not the case...it can still get off by quite a few seconds. It would be interesting to know if an iPhone will achieve Apple Watch-accuracy when paired with an Apple Watch.

gavineadie commented 8 years ago

I don’t believe the Apple Watch is constantly within 1/20 second of standard time. My recollection of that article is that it mostly said that Apple used 'stratum 1' time servers. That I do believe, in fact I’d expect it, but it doesn’t mean 'downstream' devices are as accurate, especially if the Watch is getting its time from the iPhone! My first generation iPhone was often way over one minute off true time (that’s why I wrote ios-ntp; tracking satellites moving at 5 miles/sec was giving me positional predictions that were 500 miles off where they actually were).

BTW#1: I don’t use ios-ntp any more, iOS devices now keep good (enough) time for my purposes.

BTW#2: I also know ios-ntp could be a little more accurate, part of the challenge of improving it is having a 'true clock' to compare it with. There are video overlay clocks, driven by GPS time, that are a good comparison source. I don’t have one, but someone on the list does and I need to find some time to work with them.

On Jan 7, 2016, at 1:31 PM, scottybe notifications@github.com wrote:

With all the hoopla about the Apple Watch being "within 50 milliseconds of the definitive global time standard", I was hoping the iPhone would benefit from that starting with iOS 8.2 (the minimum iOS that supports the Apple Watch). Sadly, that's not the case...it can still get off by quite a few seconds. It would be interesting to know if an iPhone will achieve Apple Watch-accuracy when paired with an Apple Watch.

gavineadie commented 8 years ago

I've done a little more digging on this and some experimenting using ios-ntp and I'm a little more optimistic about time derivation. My first discovery is that the collection of time servers that the domain name time.apple.com (14 of them when I did these tests) are all 'stratum 1' which means their clocks are very accurate.

My measurements show that any one server provides about 3mS variability in the time offset from sample to sample, and the variation between servers is about the same. That's what I'd expect because what I'm really measuring is the 'transparency' of the network .. the servers are providing sub-microsecond accuracy and my code is treating them all exactly the same, so any 'wobbles' in the measured time has to come from the network.

Three discoveries about ios-ntp revealed themselves over the last few days. One, upside, is that single measurements are more accurate with recent changes. The other two, downsides, are that ios-ntp doesn't cope with the real built-in ntp client correcting the clock, and it doesn't cope with the system clock being almost exactly right. Both downside failures are related to keeping a running measure of the standard deviation of the time offsets for each server .. I think that may be a self-defeating safety feature!