ntplib icon indicating copy to clipboard operation
ntplib copied to clipboard

Bug due to float imprecision

Open Lucas-dominguez opened this issue 1 year ago • 0 comments

When doing an NTP server,

if we receive a NTP request from a client, the byte data is converted to a float by the NTP_Packet::from_data. More precisely it reassemble the tx_timestamp_high and low into a float

However, when we need to send back the orig_timestamp to the customers, it convert back the float to orig_timestamp_high and low.

However there is a lost of precision and the timestamp are not totally identicals, so if the client compare the 2 times (the one transmit and the one send back by the servers, that should be equals), it'll reject the update. image

A fix was done in this repo : https://github.com/limifly/ntpserver/blob/master/ntpserver.py#L186 by adding new variables (to avoid float conversion)

Best regards.

Lucas-dominguez avatar Apr 30 '24 05:04 Lucas-dominguez