Synchronizing time between two devices

by haley.choi / 2016. 05. 10. [06:49]

When developing game, you might need “Synchronizing time between two devices”.

Let’s check this out.
Synchronizing time between two devices is generally the way of using round trip latency (RTT).

Suppose that there are two devices; device A and B
* A->B: Send system time of A.[1]

* B->A: Send [1] as it is.
On A, you can get RTT by subtracting time of [1] from system time of A.

Now, try:

* A->B: Send RTT[2] and present time of A[3].

To get present time of A out of B, calculate:

* Present time of A = [3] + [2]/2
NTP works similary.

But the nature of computer network means that RTT is not accurate when measured for once.
RTT is bit different from time to time. In case of wireless network, gap between measurments can be way bigger.
So, averaging measurments for several times will be much accurate.
In addition, ProudNet(proudnet.com) provides variety of fuctions for time synchronizing .

* CNetClient.GetIndirectServerTimeMs

* CNetClient.GetP2PServerTimeMs

* CNetClient.GetServerTimeMs

ProudNet provides function to get not only RTT of server but also between other clients connected to P2P,

using CNetClient, GetLastPing of CNetServer and GetRecentPing function.

Development Issues