Recently found the NTP, inhibits PTP relevant agreements, but haven't a clue how to use,
To sell online is related server module (advertisements)
And in the case of the game cannot be connected to the Internet, how to time synchronization (networked public event synchronization server),
CodePudding user response:
please great god gladCodePudding user response:
In the process of game development, will find that most of the time need of time synchronization between the two devices,Under normal circumstances, the time synchronization between the two devices use round trip latency (RTT)
Suppose you have A, B two devices,
A - & gt; B: send A system time [1]
B - & gt; A: direct send [1]
A system in A time minus [1] you get RTT.
A - & gt; B: send RTT [2] [3] and A now time,
The above operation can,
Hypothesis in the B to get A time now, calculation method is - & gt; Now A time=[3] - [2]/2.
The NTP is similar to the above mentioned,
Characteristics, through the network for RTT measurement accuracy can not be sure, so the RTT each measure slightly deviation,
Wireless network environment, the more will happen only after repeated measure average will be more accurate,
Want to know more details may reference ProudNet www.Proudnet.com.cn web site provides a variety of time synchronization function,
` ` `
CNetClient. GetIndirectServerTimeMs
CNetClient. GetP2PServerTimeMs
CNetClient. GetServerTimeMs
` ` `
ProudNet is not only to the server, and get the function of the RTT P2P connection to other client,
Only need to use CNetClient and CNetServer GetLastPing and GetRecentPing,
CodePudding user response:
Has a server as all the synchronization time of all servers and other client synchronization with him, and, need to be synchronized demanding game, more is for frame synchronization rather than the time synchronization,