Coder Social home page Coder Social logo

Comments (7)

gavineadie avatar gavineadie commented on June 18, 2024

I can verify that if the "device time" is set manually to a time in the future, the "network time" is incorrectly reported to be the same as the device time. I'll take a look at this, though the use case seems unlikely.

from ios-ntp.

jbenet avatar jbenet commented on June 18, 2024

though the use case seems unlikely.

Not so unlikely: the reason i first grabbed this lib was to prevent cheating from players in a game that required accurate time.

from ios-ntp.

gavineadie avatar gavineadie commented on June 18, 2024

Good point! I'll raise my priority, and raise my suspicion levels !!

from ios-ntp.

gavineadie avatar gavineadie commented on June 18, 2024

Found it.

One of the checks for whether a time server's time should be used or ignored is that the server's time should have been set during the previous hour. That hour is, incorrectly, measured from the client's time so if you advance the client's time by more than one hour, ALL the servers will treated as invalid because their last time setting cannot possible be less than one hour before the client's time.

This mistake has been in my code for ever. I will fix it in the next few days ..

from ios-ntp.

gavineadie avatar gavineadie commented on June 18, 2024

This is fixed.

from ios-ntp.

gavineadie avatar gavineadie commented on June 18, 2024

I want to restructure the way the library works. The "NetAssociation" class does too much work just now; not only does it bounce requests off a time server, it also manages the averaging of multiple time values that are returned. I would like to change this so that this class obtains one time value from one server, nothing more. This simple, function is not available in the present library which defeats a common use - quickly (~1 second) deriving a moderately accurate time.

The use of multiple time sources and multiple time samples from each source takes longer but provides more accurate time - it is commonly used in continuously running daemon or server implementations where the time required to select the most accurate servers from a pool and then consolidate their times is no hinderance. That sophisticated ability can be retained in the "NetworkClock" class where it would use the "NetAssociation" class to get the necessary samples.

Is this an improvement?

from ios-ntp.

warpling avatar warpling commented on June 18, 2024

@gavineadie Yes!

from ios-ntp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.