better test for NTP3 servers

Issue #897 new
Massimo Sala created an issue

In the server response payload, it is not sufficient to test for NTP_LEAP_NOTSYNC.

A stronger check is to compare the server timestamp with a valid, past datetime: if the timestamp is smaller, it is not valid.

The attached file add this check, using as value 1 jan 1970.

Comments (1)

  1. Tildeslash repo owner

    Thanks for patch Massimo.

    I have looked on it, i see few problems:

    1. i think it should convert the network to host order when you compare the timestamp (ntohl) so it works on Big/Little Endian architectures the same
    2. the refference timestamp is 64-bit (8 bytes), not uint32_t (4 bytes) as in the patch. Snip from RFC:
       Reference Timestamp
          This is a 64-bit timestamp established by the server or client
          host as the timestamp (presumably obtained from a reference clock)
          most recently used to update the local clock.  If the local clock
          has never been synchronized, the value is zero.

    3. The value of 1 jan 1970 is 0 … what’s the point testing the reference timestamp with 2208988800U (01/01/2040 @ 12:00am UTC)? The 2208988800U is 5 bytes btw. but you compare it with uint32_t (4 bytes)

  2. Log in to comment