-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
get millisecond timestamp #5
Comments
Hello @Vxider. I am glad you enjoyed the tutorial. So as you know the The Still, if you want to combine the two and convert the unit of measure to milliseconds you could do the following. // Seconds since UNIX epoch.
uint32_t txTm = packet.txTm_s - NTP_TIMESTAMP_DELTA;
// Convert seconds to milliseconds.
double milliseconds = (double) txTm * 1000.0;
// Add fractional part.
milliseconds += ((double) packet.txTm_f / 4294967295) * 1000.0;
printf("Milliseconds since UNIX epoch: %f\n", milliseconds); You can check the result with this tool. For dealing with latency, see issue #4. According to the RFC, "With NTPv4, servers and clients are precise within a few tens of milliseconds with poll intervals up to 36 hours." [0] 👍 [0] https://tools.ietf.org/search/rfc5905 |
Thanks for your explanation, and it solved my problem. 👍 |
Thank you for your Tutorial. This code will result ntp time in seconds. How can I get millisecond timestamp, I don't know how to combine
txTm_s
andtxTm_f
. And if NTP server's network latency is less then 1ms, the ntp time error in this code will less then 1ms ?The text was updated successfully, but these errors were encountered: