NTP clock synchronization based on NB-IoT Internet of things is actually using the NTP protocol algorithm to achieve wireless timing. In fact, that is NTP timing, the following is a detailed description of the algorithm.
1 clock synchronization principle (time difference calculation)
The time difference calculation assumes that the network transmission delay is equal.
Device local time | Server time | |
Device send | 1000 (deviceSendTime) | One trillion and five hundred and forty-three billion four hundred and seventy-five million seven hundred and sixty-two thousand nine hundred and eighty-five |
Server reception | One thousand and twenty-five | 1543475763010 (serverRecvTime) |
Server send | One thousand and thirty-five | 1543475763020 (serverSendTime) |
Device reception | 1060 (deviceRecvTime) | One trillion and five hundred and forty-three billion four hundred and seventy-five million seven hundred and sixty-three thousand and forty-five |
After synchronization | One trillion and five hundred and forty-three billion four hundred and seventy-five million seven hundred and sixty-three thousand and forty-five | One trillion and five hundred and forty-three billion four hundred and seventy-five million seven hundred and sixty-three thousand and forty-five |
Schematic diagram
Note: the error exists in the transmission and receiving process.
Topic format /ext/ntp/${productKey}/${deviceName}/response cloud responds to Payload content: {"deviceSendTime": "1000", "serverRecvTime": "1543475763010", "serverSendTime": "1543475763020"}.
"DeviceRecvTime":1060
DeviceTime = serverTime = (serverRecvTime + serverSendTime + deviceRecvTime deviceSendTime) / 2, 1543475763045= (1543475763010+1543475763020+1060-1000) /2