中文
English

Implementation of NTP clock synchronization based on NB-IoT Internet of things

Synchronize the world
2020-02-24
Source:Original

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.


Synchronization of device and server clock on 2.IoT platform


2.1 device terminal Pub Topic


2.2 device terminal receives Sub Topic

Topic format /ext/ntp/${productKey}/${deviceName}/response cloud responds to Payload content: {"deviceSendTime": "1000", "serverRecvTime": "1543475763010", "serverSendTime": "1543475763020"}.


2.3 device terminal receives the local timestamp of Sub.


"DeviceRecvTime":1060


2.4 the synchronization time between device terminal and server clock.


DeviceTime = serverTime = (serverRecvTime + serverSendTime + deviceRecvTime deviceSendTime) / 2, 1543475763045= (1543475763010+1543475763020+1060-1000) /2


Read66
share