Application of frame synchronization in competitive network games

Source: Internet
Author: User
Tags apc

Application of frame synchronization in competitive network games

Frame synchronization can be found on the Internet less information, about the game is not, but the principle of implementation is relatively simple, in recent days wrote a document about frame synchronization, as to colleagues to sweep literacy, by the way also hair, you can give other people reference

-- Competition Network game design Scheme

First, Preface

Frame synchronization, according to the definition of wiki encyclopedia, a synchronization source for the pixel-level synchronous display of processing technology, for the network of multiple APS, a signal will be sent through the host synchronization to other people, and synchronously displayed on each terminal. Synchronization signals can be pixel data per frame, or they can be key event information that affects data changes.

The application of frame synchronization in the network game, the design is different from the traditional MMORPG game, because can carry a lot of background computation, realize the effect of class single-machine, so it can be applied in similar shooting class, aircraft class to achieve the bomb screen calculation or fighting class of high-precision percussion experience

This article will mainly introduce the similarities and differences between the frame synchronization and the traditional MMORPG design framework, and the related design schemes, finally, the analysis of one of the implementation schemes is carried out, and the related technical difficulties such as anti-Plug and disconnection mechanism are not discussed in this paper.

Second, The application of frame synchronization in game

In the network game, the game service architecture can be divided into 2 modes, namely CS mode and peer

CS Mode framework as shown in Figure 1(c for customer, GSS for game state server)


Figure 1

As shown in Figure 1, the Game state Server (GSS) is deployed separately and is responsible for providing services to each of the providers on the network, sending State synchronization to each recipient when the GSS status changes.

The peer mode framework is shown in figure 2(c for customer, GSS for Game state server):



Figure 2

In Figure 2 , the game state server exists on each client host, and the game state changes directly from the input of each client.

of the above 2 service frameworks, CS mode, because the GSS server only one, the game state can guarantee absolute consistency, but GSS may serve tens of thousands of players at the same time, due to machine performance and network bandwidth and other hardware resource constraints, the server for most of the situation can not be very strict inspection and processing The peer mode is relative to CS mode, while the connected players are limited, so it is possible to perform more sophisticated operations, such as shooting class, aircraft type of bomb screen calculation or fighting class of high-precision percussion experience , but, due to the end-to-end communication mode, with simultaneous access to the user's increase, Traffic exponential growth, so that the number of simultaneous access will be more restrictive, suitable for a small amount of the same-screen games such as athletics.

In-peer mode, due to the existence of multiple GSS, how to ensure that each GSS consistent also needs special consideration, the application of frame synchronization algorithm in the game is mainly to solve the GSS consistency problem in peer-to-peer mode. The implementation principle is to refine the game into frames, for each frame, in the same running environment, to ensure the same input situation, will get the same output results.

Figure 3

Figure 3 , the initial state is 1, the second frame of the sequence frame, the input plus 1 operation, the state becomes 2, the third frame without input, the state is unchanged, the fourth frame, the input plus 1 operation, The status changes to 3. For each client of the same operating environment, the same input condition will result in the relevant output, as shown in figure 4 .


Figure 4

In general, the GSS is set to 20 to 30 frames in order for the user's input to respond in a timely manner and the excessive state of the game can be smoothed. Also, because of the client machine performance or settings differences, the GSS state can not be matched with the game render frame implementation one by one, so the GSS and the presentation layer must be completely separated, otherwise, because some small error is magnified eventually resulting in the game will appear completely different results.


Figure 5

As shown in Figure 5, the output of the non-deterministic render layer is fully driven by the GSS, and the GSS guarantees a stable frame count, even if there is a network delay, and the processing of that frame must be done after ensuring that all input to the frame is received.

Implementation of the scheme, roughly can be divided into 3 kinds, respectively, there is no host structure, host structure, server host structure

U No host structure

In the topology of figure 2 , all GSS functions are equivalent, and the scenario requires special frame handling to ensure that all clients are synchronized and receive all input. However, because each client on the network is fully peering, the scenario is simple and fair but the experience is easily limited , as soon as a user's network condition is delayed or interrupted, and other exceptions are affected by the user's operational experience.

U has host structure


Figure 6

As shown in Figure 6, randomly select one GSS as the host in each client, and also be responsible for frame control and input/output management, other GSS only communicates with GSS host, and GSS does not communicate with each other. The benefit of this scenario is that the game experience is only affected by the host and local network and the condition of the machine, and any other GSS failures will not affect others, and when the GSS host is completely out of contact, other GSS can also re-arbitrate the new GSS host, but the infrastructure host on the client, Easy to plug in the opportunity, the input to the frame and other can be special treatment, resulting in a loss of fairness in the game. This scheme guarantees a player experience, but is less secure

U Server Host Structure

The server host structure is the control of the GSS host in the structure of figure 6 and the input and output management functions on the server, reducing the objective impact of the GSS client, to ensure the experience of most players, and among them, players cheat, can immediately detect, To ensure the fairness of the game, but the structure has been off-peer design, communication traffic with the user increase, the negative amount of exponential growth. The scheme has high security and guarantees the player experience, but it has certain requirements for the service load.

U Other

converged with/without host and server host structure. Server host structure is characterized by control in the service side, in a state of the network game, can effectively prevent game data modification, game acceleration and other plug-in, in the service side of the hardware resources, can increase the host structure to reduce the burden, most of the functions with/without host structure processing, key operations by the server host structure processing, etc. To enable the GSS host and server host to work together

Third, server host structure design

The characteristics of the server host structure as described above, the analysis and design of the structure is further developed here.

Server Design


Figure 7

The server mainly plays the control function, carries on the client's frame control and the input and output management. As shown in Figure 7, each frame of the server is driven by a frame-driven client to perform frame processing, and when the client has input received by the server, the input is synchronously output to each client within the current frame of the server.

On the network due to the various conditions of the client, the number of client frames may not keep up with the server, as shown in figure 8 , if the client has dropped frame, you need to speed up execution after receiving the driver frame, to catch up with the speed of other clients, Users who avoid dropping frames are always responding to past events.

The game should give priority to ensure the normal user experience, so when there is a player card frame situation, should not choose to pause other players, but let him slowly catch up, design, the server can take the normal speed of the client, frame-driven client, but when the network has a sudden situation, as shown 9, when the communication is abnormal, 2 clients are missing the frame number 2, if the server is running as usual, to restore the network condition, the situation is, each client has been stuck a few frames, the acceleration pulled a few frames. Therefore, in response to this situation, increase the client's frame operation, that is, the client executes frame 1th, with the server said can play the second frame, and then the server started to drive the second frame action, consider the network delay situation, can advance to frame nth frame, the effect as shown in figure 9, The second frame operation on the left side of the client causes the server to start pushing the second frames, while the second frame action on the right side of the client does not actually play any role


Figure 8


Figure 9

Pseudo code

The code doesn't stick.

Client Design


Figure Ten

The client design consists of two parts, the GSS module and the rendering module, respectively.

The GSS module contains Item systems, role systems, AI systems, scene systems, and other related systems, along with input and output and frame count controls integrated into the GSS module. The system functions in GSS are:

Item System: Effects of game items and items

Role systems: Roles include player characters, NPCs, and APC

AI System: Control module to drive APC action

Scene System: Scene objects, maps, pathfinding, etc.

Other systems: Other similar skills, status, etc.

Input/Output module: Listen for player input, input the player into the escalation server, and listen to the server input, bind the current frame output

Frame number Control module: Listen to the server drive frame, drive to perform per frame processing

The execution of each system in the GSS module, driven by the number of frames, does not introduce other timelines. such as item duration, status duration, and so on as the number of frames as the only time axis. The playing frequency between frame and frame is controlled by the server uniformly, but because of the influence of network jitter, the frame frequency is not too stable, in order to avoid playing jitter, the frame number controller needs some smoothing.


Figure One

The client's render layer, driven by the GSS module, reduces the coupling between modules, and the GSS module uses the event notification mechanism to drive rendering layer performance. Specific breakdown of the event type as shown in figure 12 (Specific item specific event disassembly)

Since the render layer and GSS only do transaction-level synchronization, and the GSS and render layer can play at different rates, the GSS's logical frames need to be bound to a fixed ratio of render frames for the render layer, such as 1 of the figure , to ensure better performance. : 2, when the GSS logical frame number is not changed, render frame drop frame, can be converted to the current logical frame corresponding to the number of render frames, the number of GSS frames paused, the logical frame is also suspended together


Figure

logical frame and render frame binding algorithm ( pseudo code )

the code doesn't stick.

Where OnUpdate is called by the engine at every frame, Getnewestframe gets the latest frame notification from the logical frame, so that when the keyframe in the logical frame is calculated for damage, the rendered frame does not take off the frame seriously.

Four, anti-Plug and wire break re-connect

Wait for a follow-up article

Application of frame synchronization in competitive network games

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.