I love the complete ecosystem you are step by step building.
This is so great!

Stef

On Feb 26, 2013, at 1:42 PM, Sven Van Caekenberghe <s...@stfx.eu> wrote:

> Hi,
> 
> It is often important, especially for server applications, to know if the 
> current local clock is still OK. The standard way for doing that is part of 
> NTP (http://en.wikipedia.org/wiki/Network_Time_Protocol). I implemented two 
> SNTP clients (one with ZTimestamp's second precision and another one using 
> DateAndTime's nanosecond precision) that can be used to check the difference 
> between the local clock and the clock of any NTP server.
> 
>       ZTimestampPreciseSNTPClient new clockDifference. 
> 
>       -0:00:00:00.005786228
> 
> This reports that the difference between the local and remote clocks is in 
> the order of 5ms, as computed in one specific way. Other queries are related 
> to the Clock synchronisation algorithm.
> 
>       ZTimestampPreciseSNTPClient new localClockOffset. 
> 
>       0:00:00:00.065466869 
> 
>       ZTimestampPreciseSNTPClient new roundtripDelay.
> 
>       0:00:00:00.037001908 
> 
> In practice the following would be a useful practical check.
> 
>       ZTimestampPreciseSNTPClient new
>               enforceClockDifference: 2 seconds
>               ifFail: [ :delta | 
>                       self warn: ('Clock difference {1} > 2s' format: { delta 
> }) ];
>               close. 
> 
> As NTP uses UDP datagrams, this is a nice example for that as well. The code 
> can be found in the following repository:
> 
>       http://mc.stfx.eu/Neo
> 
> It is probably easiest to load the ZTimestamp configuration using the 
> Configuration Browser and then load the bleeding edge version (it is not in 
> de released version). The code is self-contained and loads cleanly.
> 
>       ConfigurationOfZTimestamp project bleedingEdge load.
> 
> The client contacts a server from pool.ntp.org. The code does only deal with 
> a limited aspect of NTP, which is rather complex and wonderful subject matter 
> (http://tools.ietf.org/html/rfc2030). My goal was to get a dependable result, 
> not be be super accurate.
> 
> Enjoy.
> 
> Sven
> 
> --
> Sven Van Caekenberghe
> http://stfx.eu
> Smalltalk is the Red Pill
> 
> 


Reply via email to