How do I receive data from NTP server?

前端 未结 2 821
迷失自我
迷失自我 2020-12-22 14:58

I have no idea why send data is 48 bytes 010,0,0..., someone can explain? the problem is buffer for data received, I don\'t know how big he should be, and even if I receive

2条回答
  •  离开以前
    2020-12-22 15:42

    Similar to my issue when trying to query the time from a self-hostet Windows-NTP-Server with the C++ library NTPClient which uses boost for the network tasks, msg[48] = { 010,0,0,0,0,0,0,0,0 }; configures the ntp.flags.mode. After comparing the network traffic of w32tm /stripchart /computer:10.159.96.65 using Wireshark, flag 27 or 11 seem to be the choices for my usecase: Comparison of NTP network packages

    tmit = ntohl(((time_t*)tempBuffer)[6]); extracts the data from the received package. It looks like

    • 4 yields the reference time (last sync with timeserver I assume),
    • 8 the time when server received request and
    • 10 the transmit time (which should be almost equal).

提交回复
热议问题