Break Caton how to do? Tencent college game Experts on the online game synchronization technology [turn]

Editor's note: online game synchronization technology affect the player's experience, if not done, the player may make a huge loss. Tencent college game expert Donald, in this game on the network synchronization technology in systematic introduction, we want to help.

This article will overview on the online game synchronization technology, including the following: the famous game network synchronization program summary, network transport protocol (Network Transport Protocol), network synchronization model (Network Model), network topology (Network Topology), a network of environmental quality.

Famous gaming network synchronization scheme summarized

network synchronization programs of the famous game for himself summarized in the following table, we have tried to add a reference source.

With this table, the reader can try to think: Why would they take such a scheme? Look around to see whether what the law? I believe after reading below, should be able to find out.

NOTE: herein lockstep synchronization (Lockstep) specific to only deterministic lockstep synchronization synchronization (Deterministic Lockstep). This article does not discuss snapshot synchronization (Snapshot Synchronization, Snapshot Interpolation), which is equivalent to that the synchronization state (State Synchronization).


Network transport protocol (Network Transport Protocol)

article network transport protocol (Network Transport Protocol), mainly refers to the UDP protocol and TCP protocol.

In the TCP / IP protocol suite (Internet protocol suite, Internet Protocol Suite) in, UDP and TCP transport layer is located (Transport Layer), independently Talia more dependent on the IP protocol layer of the bottom layer interconnection network (Internet Layer) of (Internet protocol, Internet protocol).

Berkeley sockets (Berkeley Sockets) is a standard API TCP or UDP communication, belonging to the POSIX standard, so Socket, Berkeley Socket, POSIX Socket,all referring to the same thing.

Through the Socket class and its methods can be very simple TCP or UDP communication.

By analyzing the protocol header (Header), you can quickly and accurately know what the protocol adds features.

UDP header as follows:

UDP header

UDP over the IP, the concept of increasing the port (Port), the transceiver can both good agreement so that several ports to communicate different functions; checksum increased in order to increase the ability of certain check.

So you could see that UDP for network games, and IP almost very similar characteristics:

does not guarantee reliable transmission sequence (Unsequenced Unreliable Transmission), namely transmission order can not be maintained, nor ensure up, a specific data in the process of packet transmission, it is possible lost; may also packet arrives, but such data error check fails, Socket also discarded;
fast transmission, thanks is unreliable, not waste time and bandwidth Socket, of lost packets retransmission;
UDP packets to ensure success to get the application through the Socket is correct;
connect quickly, because there is no connection. Thanks unreliable, so the sender and receiver for each communication is stateless, it is not required prior to establishing a communication connection;
simple, the upper application can be implemented, if desired additional transmission characteristics (the QoS), such as preserving order unreliable, reliability can not be maintained sequence, sequence guarantee reliability, the latest state of the transmission (Most recent state), fast redundant transmission (Quickest Possible Delivery), and the like;
small header, saving bandwidth.

TCP is a lot of complexity, TCP header as follows:

TCP header

In addition there are ports, external verification, TCP provides major additional:

  • Guarantee reliable transmission order (Sequenced Reliable Transmission), achieved by a header Sequence number, Acknowledgement Number, Window Size field and the like;
  • Flow Control (Flow Control), header by Window Size achieve the recipient to his expectations traffic presented to the sender, the sender transmits data to prevent excessive speed at the receiver;
  • Congestion Control (Congestion Control), header by Sequence number, Acknowledgement number and other fields, as well as mechanisms to achieve by Timer, whereby both parties can send and receive data to determine packet loss, and deduce whether the current network congestion, and take some measures to mitigate data send.


TCP itself is complex enough, it did not closer look at their specific principles, features only briefly and synchronization-related online games:

  • Paul order to provide reliable transmission itself, without additional work for the game, it is suitable for the game turn, the RPG-peer communication type game infrequently;
  • Transmission is slow, because of TCP itself to all packets sent, are considered reliable protection order, flow control, congestion control (includes slow start (Slow-Start), and these types of functions for most of the game, especially fast-paced ( Fast Paced) game is not suitable, since this type of game the high frequency communications, require low latency communications, new hair may be more important than the data packet sent the data packet (packet data such as a game status, a game state changes frequently, their old state retransmission data packet, it would be discarded, a new state quickly transfer packet);
  • Slow connection, communication needs to be the first time the famous three-way handshake connection;
  • Black box complex and difficult to expand;
  • Header large, does not apply to the case where the number of data packets.


In summary, most of the online games using UDP.

TCP is more suitable for turn-based and other slow-paced game.
Another World of Warcraft uses TCP, and made a brilliant commercial success, so there are many MMORPG also use TCP, nevertheless, TCP might not be the best choice. [9]

Network synchronization model (Network Model)

main network model are: the lockstep synchronization (Lockstep) and synchronous state (State Synchronization).

Paper "frame" in the following two terms are defined:

logical frame, will be referred to herein as Tick, the game process is discrete logic level, i.e. a logical frame may be considered a logical frame performs a logical operation, a logical frame number It refers to the game logic levels currently in the first few frames;

rendered frame, known as frame in this article will, in the game screen showing the level is discrete process, which can be considered to be a picture of the picture presented to the player, rendering frame numbers refer to the game pieces of the current picture is the first presentation;

logical frame rate and frame rate of the game is rendered independent of one another, such as a game logic may be 20 frames per second, 60 frames per second rendering.

Game logic is a logical frame a logical frame lasts discrete carried out, it can be abstracted as:


Game logic 0 at the first frame, according to the player and the game configuration information P C, initialize computation g, obtain a set of initialization state S0; game logic during the k-th frame, a set of Sk-1 and a game configuration according to the previous state C, set according to an external change factor k-th frame received Ik, t logical operation, obtain the k-th frame of the new game logic state sets Sk.

I is a collection of the root causes of the game state changes, often each player operation.

S is the set state of the game, the number of subsets state, which has the following two important subsets defined:


Wherein the object O is a significant number of players that can be observed in a set of states, M being a number that can be used to derive a set of final states of the intermediate state.

When the network synchronization, said process information sent from the client network for an uplink transmission, said network clients through the process of received transmission information is the downlink, the lock-step synchronization is nature, the upper and lower row contains only external game change factor set Ik; nature state synchronization is downlink operation comprises only the result status of the game subset Ok, comprising Ik uplink and / or status of a subset of Mk.

NOTE: lock-step synchronization herein refers specifically only lock-step synchronization uncertainty synchronization (Deterministic Lockstep). This article does not discuss snapshot synchronization (Snapshot Synchronization, Snapshot Interpolation), which is equivalent to that state synchronization.

A brief history of network synchronization model

of the 1990s will have been carried out to stop waiting for (stop-and-wait-type ) network synchronization method for each step (step, turn), that is, the client step by step to put their information to other clients This information may be a state of the home network client objects, or may be operated by the player [13] [14].

Over the same period, P2P (see below network topology a) is connected to the network topology is more prevalent. But stop waiting for synchronization program P2P has lookahead-cheating type of plug-in, such as the use of plug-in client A at the step k deliberately wait until someone else to step k information arrives, only to perform logical operations and send their first k further information, equal after the game the decision-making of others before making their own decisions, to derive an unfair benefit upper hand client a is always peeping.

So, in 2001, Nathaniel Baughman and Brian Neil Levine on this basis, the proposed lock-step synchronization (Lockstep) [14] against the plug. All before sending each client plaintext k-th step, to encrypt plaintext for generating information calculation "pre-submitted hash value (commitment hash)" sent to other clients, until the client receives the first step k after the client a hash of the pre-end, before sending a clear message to the step k their other clients, until the receipt of any other step k plaintext client, the client is a plaintext hash value generated by one of these plaintext message and pre-commit and compare the hash value, the hash value of the plaintext if found to client B and pre-filed hash value range, represents the client B is a plug.

At this point, lock step synchronization client is both can synchronize player operation, the client can synchronize network object authority also states. So it does not require certainty.

Then, it is also in 2001, Mark Terrano and Paul Bettner in Age of Empires (Age of Empire) game in order to solve the problem of the game massive network entity, based on lock-step synchronization, lodge a deterministic lockstep synchronization (Deterministic Lockstep) [ 15], i.e., each step of synchronizing, with only a player operation data, the network does not contain object data.

Further, in 1999, Christophe Diot and Laurent Gautier proposed Bucket Synchronization [13], i.e., the fixed time duration (approximately 40ms) is divided into Bucket, the data in the duration attributed to the Bucket. Has a longer playing time delay (Playout Delay, about 100ms) at the beginning, waiting for the other clients transmit data arrive Bucket. Data did not arrive in time will not be applied directly, but can also be saved for extrapolation (Extrapolation) such as dead reckoning (Dead Reckoning) may occur.

Which Bucket, i.e. in fact the concept of logical frames (the Tick) a.

Bucket Synchronization

Finally, in 2003, Ho Lee, who conducted the above-mentioned lock-step synchronization for each step of the delay are major disadvantages optimization, learn Bucket Synchronization, proposed Pipelined Lockstep [16].

At this point, it is understood by everyone: the synchronous operation without waiting for the uncertainty lock-step synchronization operation timeout players, finally forming.

All in all, every step to stop waiting for network synchronization very early, but the lack of a short name. In order to "Lockstep" program proposed the use of a wide range of security, it has become synonymous with synchronized stop waiting. When translated into Chinese, introduced the concept of Bucket Synchronization time frame and Lockstep also been used in combination, it puts a "step" translated frame, called "frame sync." Then more narrowly deterministic synchronous lock-step with more and more, it all gradually "Deterministic Lockstep" referred to as "Lockstep", therefore, uncertainty in lock-step synchronization verbal communication is more often referred to as "frame synchronization" sometimes referred to as "synchronous operation."

Therefore, this article also the uncertainty of lock-step synchronization referred to as lock-step synchronization.

Lockstep synchronization (Lockstep)

because the lock-step synchronization only synchronizes changes cause Ik, so the requirements of each client arithmetic logic g, t is strictly deterministic (Deterministic), and all clients to work out strict consistent results Sk. If containing a trace of uncertainty in the calculation process, that would result from an error of a trace operation of Sk each client, then the next logical frame error will increase, leading to the butterfly effect, and ultimately see the respective client the result is completely different state.

When the game known as the king of glory lockstep example, suppose your client and other clients correct inconsistency has occurred, reasonable operation of other players in the correct client made, you have to reach an inconsistent state of the client to do the logical calculus has changed Debu same state results, the result is likely to be unreasonable, so you are likely to see other players heroes are surprised to run around, and even went to the tower to die, or put in front of air skills, and so on.

Game to be strictly deterministic, must do a few things:

  • 不使用浮点数而使用定点数,或限定各客户端所运行的硬件及操作系统从而浮点数的运算是一致的;
  • 确定性的随机数机制;
  • 确定性的容器及算法(增加、移除、排序等);
  • 隔离和封装逻辑层,以防止其他不确定性的调用;
  • 如需,则也须做到确定性的物理机制、导航机制、动画骨骼机制等;
  • 排查所有引起异常(exception)的逻辑。
  • 对锁步同步游戏来说,不同步造成的游戏体验是极差的,偶现的不同步问题是极为头痛的, 因此制定检测不同步的管线流程对锁步同步游戏来说是至关重要的,比如帧状态哈希对比、静态代码扫描分析、帧级别甚至函数级别的高性能日志、外网不同步率统计,等。


Synchronous state (State Synchronization)

because only the sync state synchronization game calculation the result of Sk state, it is necessary to have the state machine authority (Authoritative) is calculated, and transferred to another machine, the other machine will adopt the received status.

This article discusses only the case of only one of the machines authority. Depending on the specific network topology, this machine will be known as the authoritative server (Server) or host (Host), no authority other machine called a client (Client).

Therefore, synchronization status, verbal communications often less accurately referred to as "CS synchronization (Client-Server)".
Including Halo, Unreal, Unity, Overwatch and so on, almost all the famous state synchronization technology, are the ultimate reference to Mark Frohnmayer and Tim Gift released in 1998 The TRIBES Engine Networking Model [1article for implementation.

State synchronization process of developing the most basic and most important, regardless of the client network object is currently in what state, it must be done correctly completely out of the old state, not logic layer residual effect after the exit of the old state, and correctly in the new state authoritative server informed, leading to the logical layer effect of the new state.

Also avoid non-state synchronous mode synchronization state authority, such as a server to the client only transmission Ik (without transferring Sk), so that the client calculate a new state Sk network object locally. This may lead to an inconsistent state between server client. Such as occurs in a network frame to a k-th logic to enter Ik of Sk, and after S no longer change, then the server will send the k-th frame will Ik; if, after reconnection the client or by real-time and other causes death replayed the network object status is reset at the client as S0, but the current server logical frame is greater than k, Ik server will not be transmitted to the client, then the client network object where it has been stuck in error in the S0.

Before lock-step synchronization to discuss certainty refers to the "strict" certainty. Synchronization, occasionally referred to "relaxed" uncertainties (such as the last question [4] Q / A phase) in the state of the discussion, such uncertainty between the client only requires the server to meet the "enough" is determined resistance, so that the client can be pre-performance can be more accurately, because in the end the client will adopt the status of the server, the cumulative correction of errors.

Comparative lockstep synchronization and synchronization status


Network topology (Network Topology)

network topology, refers to the network connection of the machine involved in the game, including peer structure (Peer-to-Peer, P2P structure) and a master-slave structure (Client-Server, CS structure).

P2P network structure is a structure (Mesh Topology), the game is generally P2P fully connected (Full Connected) network structure, as shown below. P2P structure for all clients twenty-two connected, the number of connections is O (n2), equality, the same function.


CS structure is a radial structures (Star Topology), as shown below. CS structures have at least one machine for the server (Server), we only discuss the case only a server or host, and its other clients mainly from the relationship between the client and server connections only, not connected between the client, number of connections is O (n).

When the machine running the server game state only for a logic operation, only for the delivery status to the client, and the client is completely isolated "Headless" machine, the server is called Dedicated Server; server when the machine is running, while also run the client computing, while also being controlled by a player, that server is called Listen server, also known as Host.


Comparison of the two network topology is as follows:


Network synchronization and network topology model is a different concept, their combinations shown in the following table:


Network Environment Quality

Assessment quality network environment, including latency (Latency), loss (Packet Loss), the bandwidth (Bandwidth).

For all major daily use of the environment, the following network environment quality statistics.


There are two kinds of network delay evaluation values, Ping, and RTT (Round Trip Time).

Ping, refers to a signal network connections between the two ends of the transmission network in time spent, Ping described "network delay between the two machines is the number?." Such as start timing signal when the operating system from the terminal A, terminal B is reached immediately and the operating system returns a response signal, the operating system returns to the terminal A after the stop timing, the duration of Ping.

RTT, Round Trip Time, may be generally considered equal to the Ping, but herein, RTT = Ping + WaitTime + ProcessTime , i.e. RTT includes the Ping, wait time before the processed signal two ends, the two ends of the processed signal such RTT describe the "real players to experience the game is how much delay?." After such signals timed from terminal A game logic at terminal A may wait a period of time, it may deal with some other logic, party calls the operating system signals, after the network transmission reaches the terminal B the operating system, the B terminal may also have similar latency and processing other logical time, also including the processing time of the signal itself, before issuing a response signal, the response signal transmission through the network to the terminal a after the operating system, again some similar waiting time, the final a-side game logic receiving a response signal side end timing, when the length of RTT.

Ping RTT value and the value of online gaming in general terms, 20ms is good, 50ms is normal, 100ms general, 200ms for the poor.

4G network self-delay of about 30ms ~ 40ms, 5G network delay itself is 6 ~ 10ms, backbone network in mainland interconnect delay of about 20ms. That era of 4G 4G access network delay itself is the bottleneck, 5G era backbone network latency bottlenecks.

Shanghai and the city's international backbone network latency (ms) in the following table, details can be found in [17].


The direct cause of network packet loss is mainly because wireless networks and / or congestion control, but the root cause of a more pluralistic and complex, so the statistics slightly.

General network game, the network packet loss rate of 2% or less is good, generally 5%, more than 10% as poor.

Compared to traditional applications, network bandwidth synchronous involved smaller, under normal circumstances, the bandwidth will not become a bottleneck in the network game synchronization (unless it is a cloud game: p).

Note that a common traditional network bandwidth is b / s (Bit per Second) , but this paper B / s (Byte per Second) .

Usually lockstep synchronization game requires 2 ~ 4KB / s, a fast-paced game state synchronization needs 5 ~ 10KB / s.

Common online game-related network bandwidth in the following table [18] [19]:


Conclusions

In this paper, network transmission protocol (Network Transport Protocol), network synchronization model (Network Model), network topology (Network Topology) were systematically introduced, and include a case where some of the network game of the selected program, and the program comparison. Also introduced some of the history of the network synchronization, and network quality assessment indicators.

This article does not detail on the realization of the principle, the future will be in the actual project as an example, UDP, state synchronization, the technical details of Client-Server.

References [1] Mark Frohnmayer, Tim Gift, "Networking at The Tribes Engine Model or How to Internet at The Rock for the Make Multi Player Games", 1998. the Available:  https://www.gamedevs.org/uploads/tribes-networking-model .pdf  [Accessed: 2019-01-27] [2] Glenn Fiedler, "State Synchronization Simulations Keeping in Sync by sending State", 2015, the Available:  https://gafferongames.com/post/state_synchronization/ [Accessed: 2019- 01-27] [3] Joshua Glazer, Sanjay Madhav, "Multiplayer Game Programming", Addison-Wesley, 2015.





[4] Tim Ford, "Overwatch Gameplay Architecture and Netcode", GDC, 2017.
[5] Xavier Guilbeault, Frederic Doll, "Deterministic vs Replicated AI Building the Battlefield of For Honor", GDC, 2017.
[6] Matt Delbosc, "Replicating Chaos Vehicle Replication in Watch Dogs 2", GDC, 2017.
[7] Jared Cone, "It IS Rocket Science! The Physics of 'Rocket League' Detailed", GDC, 2018.
[8] Battle(non)sense, "Netcode & Input Lag Analyses", 2017. Available: https://www.youtube.com/playlist ... jhB63KMDTOT5sJ0vWy8[Accessed: 2019-02-08]
[9] Chen-Chi Wu, Kuan-Ta Chen, Chih-Ming Chen, Polly Huang, and Chin-Laung Lei, "On the Challenge and Design of Transport Protocols for MMORPGs". 2019. Available: http://www.iis.sinica.edu.tw/~swc/pub/tcp_mmorpg.html [Accessed: 2019-02-08]
[10] David Aldridge, "I Shot You First: Networking the Gameplay of HALO: REACH", GDC, 2011. Available: https://www.youtube.com/watch?v=h47zZrqjgLc [Accessed: 2016-07-02]
[11] Maksym Kurylovych, "Lockstep protocol", University of Tartu, 2008. Available: http://ds.cs.ut.ee/courses/course-files/Report%20-2.pdf [Accessed: 2019-02-11]
[12] Glenn Fiedler, "What Every Programmer Needs To Know About Game Networking A short history of game networking techniques", 2010. Available: https://gafferongames.com/post/w ... ut_game_networking/ [Accessed: 2019-02-11]
[13] Christophe DIOT, Laurent GAUTIER, "A Distributed Architecture for Multiplayer Interactive Applications on the Internet", IEEE, 1999. Available: https://www.cs.ubc.ca/~krasic/cp ... ot99distributed.pdf[Accessed: 2019-02-12]
[14]Nathaniel E. Baughman, Brian Neil Levine, "Cheat-Proof Playout for Centralized and Distributed Online Games", IEEE INFOCOM, 2001. Available: https://pdfs.semanticscholar.org ... 6056868791854fe.pdf[Accessed: 2019-02-12]
[15] Mark Terrano, Paul Bettner, "1500 Archers on a 28.8: Network Programming in Age of Empires and Beyond", 2001. Available: http://www.gamasutra.com/view/fe ... _a_288_network_.php[Accessed: 2019-02-12]
[16] Ho Lee, Eric Kozlowski, Scott Lenker, Sugih Jamin, "Multiplayer Game Cheating Prevention With Pipelined Lockstep Protocol", 2003. Available: http://www.ekozlowski.com/assets ... ting-prevention.pdf[Accessed: 2019-02-12]
[17] "Internet Backbone Network Latency". Available: https://www.dotcom-tools.com/internet-backbone-latency.aspx [Accessed: 2019-02-15]
[18] "List of interface bit rates". Available: https://en.wikipedia.org/wiki/List_of_interface_bit_rates [Accessed: 2019-02-15]
[19] "5G", Available: https://en.wikipedia.org/wiki/5G#Performance_targets[Accessed: 2019-02-15]

Guess you like

Origin www.cnblogs.com/ogrerun/p/11199859.html