CN109873876B - Method for interaction and calculation load balanced distribution of distributed virtual environment - Google Patents

Method for interaction and calculation load balanced distribution of distributed virtual environment Download PDF

Info

Publication number
CN109873876B
CN109873876B CN201910227648.5A CN201910227648A CN109873876B CN 109873876 B CN109873876 B CN 109873876B CN 201910227648 A CN201910227648 A CN 201910227648A CN 109873876 B CN109873876 B CN 109873876B
Authority
CN
China
Prior art keywords
client
virtual environment
event
synchronization message
instruction
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910227648.5A
Other languages
Chinese (zh)
Other versions
CN109873876A (en
Inventor
郑非
陈俊羽
李金龙
戢凯文
于星橦
姜博文
邓文杰
鲜文瀚
孙朝岳
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
University of Science and Technology of China USTC
Original Assignee
University of Science and Technology of China USTC
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by University of Science and Technology of China USTC filed Critical University of Science and Technology of China USTC
Priority to CN201910227648.5A priority Critical patent/CN109873876B/en
Publication of CN109873876A publication Critical patent/CN109873876A/en
Application granted granted Critical
Publication of CN109873876B publication Critical patent/CN109873876B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Abstract

The invention discloses a method for interaction and calculation load balanced distribution of a distributed virtual environment, which comprises the following steps: setting a server for executing a computing task, and rendering the virtual environment by a client; in the initial stage, the server side sends state synchronization messages and event synchronization messages to related clients, and each client responds to the event synchronization messages and loads and renders corresponding virtual environment scenes according to the content of the state synchronization messages; and in the execution stage, each client preprocesses a received instruction input by a user and sends the instruction to the server, the server generates a corresponding state synchronization message and an event synchronization message from the received instruction and feeds the state synchronization message and the event synchronization message back to the corresponding client, and the client responds to the event synchronization message and changes the current virtual environment scene and/or the interactive relationship of objects in the virtual environment scene according to the content of the state synchronization message. The method can reduce the client load and the total load, and simultaneously keep the synchronization and the consistency of all the clients.

Description

Method for interaction and calculation load balanced distribution of distributed virtual environment
Technical Field
The invention relates to the technical field of virtual environment simulation, in particular to a method for interaction and computing load balanced distribution of a distributed virtual environment.
Background
With the rapid development of information technology, the threshold of analog simulation software development is lower and lower. Many simulation software runs on a single machine, but in some cases, the simulation software must perform networking interaction, such as multi-person simulation driving, multi-party simulation war and the like. For multi-player interactive virtual environments, the game world has proposed a well-established solution, such as CN 101521874. However, the users of the general simulation software do not have enough computing resources as the game providers, and meanwhile, if a weak server is adopted for networking and the computing task is distributed to the clients of each simulation software, the consistency of all the clients is difficult to achieve. For example, if there are complex physical interactions in the virtual environment, when two people are driving in a simulation, the two vehicles collide, and the computation results of the clients of each person may not be consistent. The network delay and the host configuration of the client are different, if one client has larger delay or the host configuration is too low, abnormal data is likely to be transmitted to all the clients through the server, which is the root cause that most network games often have BUG and are difficult to stop plug-ins.
Since the virtual environment is more focused on reality and consistency than a game, the method of setting up a communication server and distributing computing tasks to clients like the game as described above is not suitable for the virtual environment. It can be seen that there is no good solution at present, which can keep synchronization and consistency while realizing interaction in the network in each single machine virtual environment.
Disclosure of Invention
The invention aims to provide a method for interaction and calculation load balanced distribution of a distributed virtual environment, which does not need to run two sets of physical engines at a client and a server and reduces the load and the total load of the client; while maintaining synchronization and consistency for all clients.
The purpose of the invention is realized by the following technical scheme:
a method of interactive and computational load balancing distribution for a distributed virtual environment, comprising:
setting a client for executing a computing task as a server, and performing rendering tasks of the virtual environment by the other clients;
in the initial stage, the server side sends state synchronization messages and event synchronization messages to related clients, and each client responds to the event synchronization messages and loads and renders corresponding virtual environment scenes according to the content of the state synchronization messages;
in the execution stage, each client preprocesses a received instruction input by a user and sends the instruction to the server, the server generates a corresponding state synchronization message and an event synchronization message from the received instruction and feeds the state synchronization message and the event synchronization message back to the corresponding client, and the client responds to the event synchronization message and changes the current virtual environment scene and/or the interactive relation of objects in the virtual environment scene according to the content of the state synchronization message.
The technical scheme provided by the invention can be seen that the method for performing distributed virtual environment simulation by directly using the client as the server reduces the performance consumption of the whole simulation system and solves the problems of synchronization and consistency of simulation environments among different clients.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on the drawings without creative efforts.
Fig. 1 is an interaction diagram of a client and a server in a method for interaction and computation load balancing distribution in a distributed virtual environment according to an embodiment of the present invention;
fig. 2 is a schematic diagram illustrating a process of a server on input and output data according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention are clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments of the present invention without making any creative effort, shall fall within the protection scope of the present invention.
The embodiment of the invention provides a method for interaction and calculation load balance distribution of a distributed virtual environment, which comprises the following steps:
1. and setting one client side for executing the calculation task as a server side, and performing the rendering task of the virtual environment by the other client sides.
In the embodiment of the invention, the client and the server are loaded with two identical programs, or the server is an authoritative client. The difference is that the client program does not perform specific physical judgment (information of the position, angle and the like of an object in the environment), hardly needs to perform any calculation task, and is mainly responsible for rendering. The rendering at the server side can reduce the requirement or directly cancel the rendering, and the main resources are concentrated on physical computation. Therefore, in the virtual environment scene of the server, all objects controlled by the client are included, and the server needs to send all object information participating in interaction to the client in real time.
2. In the initial stage, the server side sends state synchronization messages and event synchronization messages to related clients, and each client responds to the event synchronization messages and loads and renders corresponding virtual environment scenes according to the content of the state synchronization messages.
3. In the execution stage, each client preprocesses a received instruction input by a user and sends the instruction to the server, the server generates a corresponding state synchronization message and an event synchronization message from the received instruction and feeds the state synchronization message and the event synchronization message back to the corresponding client, and the client responds to the event synchronization message and changes the current virtual environment scene and/or the interactive relation of objects in the virtual environment scene according to the content of the state synchronization message.
In the above method provided by the embodiment of the present invention, the communication interaction process between the client and the server may be as shown in fig. 1.
In the embodiment of the invention, a server needs to send synchronous messages to related clients, and the synchronous messages are divided into state synchronous messages and event synchronous messages:
1) the state synchronization message is used for synchronizing the position, the angle and the size of an object in the virtual environment; since the virtual environment scene can be updated tens of times or even hundreds of times in one second, the state synchronization information can be tolerated even if there is a packet loss, because there is no great difference between the previous frame and the next frame. However, the requirement of the state synchronization information on the delay is high, and if the delay is large, the simulation effect and experience of the client are obviously affected. Thus, the state synchronization message is transmitted over a UDP connection.
2) The event synchronization message is used for synchronizing event information; the event information includes: event information fed back by the operation request of each client in the initial stage, for example, the client is executed or rejected when joining a room, the client applies for switching to a certain position and is executed or rejected, whether a game is started or not, and the like; further comprising: combining the instructions of all the clients and the event information generated by the current virtual environment scene in the execution stage; for example, the server determines that a character 1 of a certain client 1 is hit by a bullet, and needs to synchronize the "character 1 is hit" event to the client, so that the client can show the effect of the event, such as the character falling down due to injury, the blood volume reduction of the character 1 displayed on the user interface of the client 1, and the like.
The event synchronization message cannot tolerate packet loss, once the packet loss can cause the death of the role 1 on the similar server, the client does not know the conflict and the like, and the simulation effect and experience are greatly influenced; it is also possible to generate a running error between the client and the server, for example, if the dead message of the server role 1 is not successfully sent, the client 1 continues to send the instruction for controlling the role 1, and at this time, the server does not have a corresponding execution object, and if the exception is not processed, an error is generated. Thus, the event synchronization message is transmitted over a TCP connection.
It is ensured that the information can be successfully sent to the specified client through the above-mentioned transport layer protocol, so it is required to ensure that the information can be correctly executed on the specified article, for example, enemy a is hit to the ground and cannot synchronize to enemy B, therefore, the header in the state synchronization message and the event synchronization message is added with a field aiming at the specified execution object.
In the embodiment of the invention, the client needs to send a series of instructions to the server to control the object in the virtual environment scene.
The instructions sent by the client are input by a user, and the instructions input by the user comprise: the operation instructions of the objects in the virtual environment scene and the pre-operation instructions which do not influence the virtual environment scenes presented by other clients.
For example, for a first-person shooting game, a keyboard operation WASD (control of the top, left, bottom, and right of a character) of a player, a position pointed by a sight of the player, a mouse click operation, and the like may be used as an operation instruction for an object in a virtual environment scene; the visual angle in the game is changed by moving the mouse, namely the visual angle adjusting instruction in the virtual environment scene is adjusted, and the operation does not influence the virtual environment scenes presented by other clients; in addition, in the chess and card game, for example, when a player selects a certain chess piece, the chess piece can generate certain effect, operation is not required to be carried out on a server, and the virtual environment scene presented by other clients cannot be influenced, and the operation is the pre-operation instruction.
If all the instructions input by the user are sent to the server by each client, the data volume may be too large, and some effects do not depend on the server and only depend on the client.
Therefore, the embodiment of the present invention provides a preprocessing mechanism, which removes, through preprocessing, pre-operation instructions that do not affect virtual environment scenes presented by other clients, where the pre-operation instructions are processed by a computing unit in the client; the operation instruction of the object in the virtual environment scene influences the virtual environment scene presented by other clients, and the instruction is handed to the server for processing;
during preprocessing, in addition to removing a pre-operation instruction which does not affect virtual environment scenes presented by other clients, a received operation instruction may need to be transformed and the like to generate a new instruction; in addition, the client can also send the information generated by the client program to the server as an instruction.
In order to enable the instruction of the client to be sent to the server in time, similar to a method from the server to the client, the embodiment of the invention also defines a protocol to transmit the instruction, and the protocol only needs to ensure that the server can analyze the instruction of the client.
In the embodiment of the present invention, the instructions are also divided into two types, namely, a state type instruction and an event request type instruction:
1) the state type instruction is an instruction for an object moving operation, such as operations of up, down, left, right and the like, and the operation instructions are packet loss-allowable, because the player sends the instructions every frame, the influence of the absence of a certain frame of instruction is very little, and therefore the state type instruction is transmitted through a UDP connection.
2) The event request type instruction is an operation instruction for an interaction event between objects, for example, a task in a virtual environment scene picks up an article in the scene, the operation instruction cannot be lost, otherwise, a user finds that the article is not picked up successfully at a certain time, and game experience is greatly influenced, so the event request type instruction is transmitted by adopting TCP connection.
In the embodiment of the present invention, the processing procedure of the server is as shown in fig. 2. The server opens up a fixed buffer area for each client to receive the state type instruction, and when a new state type instruction comes, the new state type instruction covers the original state type instruction; therefore, if packet loss occurs, the server end instruction maintains the instruction sent by the client end in the previous frame; this is very scientific because in most cases the last frame of instructions of the player is the same as this frame, even if the player changes the operation every 0.1 second, if the 0.1 second game runs 10 frames, then the probability that the last frame of operations of the player differs from this frame is only 10%. Meanwhile, even if one frame is lost, the extra delay of 0.01 second is generated, so that the simulation effect is not influenced. During each update, the virtual environment executes instructions. Because how many event request type instructions come in each frame is uncertain, a variable-length queue is developed for each client to store the event request type instructions, the event request type instructions are executed according to the sequence of first execution, and the events in the queue are sequentially executed in each frame of virtual environment.
Similarly, the client is provided with a fixed buffer area for receiving the state synchronization message, and when a new state synchronization message comes, the new state synchronization message covers the original state synchronization message; a variable length queue is also provided to hold event synchronization messages and to execute related events in a first-come-first-executed order.
In addition, when the client receives the state information, an interpolation algorithm including linear interpolation, exponential averaging, speed estimation and other interpolation methods can be adopted, so that the client still has a smooth simulation effect when the network condition is poor.
In the above-mentioned solution of the embodiment of the present invention, the virtual environment is networked, and the logical judgment and the physical judgment of the virtual environment are performed on a server similar to the client, so that two sets of physical engines do not need to be operated on the client and the server, thereby reducing the load and the total load of the client, enabling the client to be mainly responsible for rendering, and simultaneously maintaining the synchronization and the consistency of all the clients.
For ease of understanding, the following description is made with reference to a specific virtual environment.
In this example, a tank battle simulation system is used for illustration, and a client is selected as a server in advance.
In the initial stage, the information to be sent to the client by the server side includes:
state synchronization information: current number of clients in room, bits occupied by client operator
Event synchronization information: the client is executed or rejected when joining the room, the client applies for switching to a certain position to be executed or rejected, and whether the game is started or not.
When the client receives the event synchronization information of the simulation start sent by the server, the game does not really start, the client needs to wait for the initialization of the scene by each client, then sends an event request type instruction of the prepared event to the server, and the server sends the event synchronization information of the game when all the clients are prepared.
After the game is started, the contents to be sent to the server by other clients are as follows:
state type instruction: whether the four WASD keys are pressed or not, and the current turret points to the position.
Event request type instruction: and clicking the mouse to indicate firing.
Client side preprocessing: the current target position of the tank turret is calculated through mouse movement, and the target position is directly used as an instruction.
At this time, the synchronization information to be sent by the server to the client includes:
state synchronization information: the position and angle of the tank controlled by the other client, and the location of the projectile being flown.
Event synchronization information: event information of other tanks or the ground is hit by shells transmitted by a certain client side controlling the tank, information of other tanks or the ground is hit by shells of other tanks, information is hit by shells of other tanks by a certain client side controlling the tank, and information of blood loss is hit by a certain client side tank.
When each frame of the simulation system is rendered, the client reads state and event synchronization information from the buffer area, and directly controls objects in a scene according to the information, mainly the positions and directions of a tank and other tanks controlled by the client. Therefore, the client does not need to do any physical calculation, such as judging the terrain stress of the tank, collision of the tank and other tanks and the like, and all the calculation is completed at the server.
Through the above description of the embodiments, it is clear to those skilled in the art that the above embodiments can be implemented by software, and can also be implemented by software plus a necessary general hardware platform. With this understanding, the technical solutions of the embodiments can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a usb disk, a removable hard disk, etc.), and includes several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods according to the embodiments of the present invention.
The above description is only for the preferred embodiment of the present invention, but the scope of the present invention is not limited thereto, and any changes or substitutions that can be easily conceived by those skilled in the art within the technical scope of the present invention are included in the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims (6)

1. A method for interactive and computational load balancing distribution in a distributed virtual environment, comprising:
setting a client for executing a computing task as a server, and performing rendering tasks of the virtual environment by the other clients;
in the initial stage, the server side sends state synchronization messages and event synchronization messages to related clients, and each client responds to the event synchronization messages and loads and renders corresponding virtual environment scenes according to the content of the state synchronization messages;
in the execution stage, each client preprocesses a received instruction input by a user and sends the instruction to the server, the server generates a corresponding state synchronization message and an event synchronization message from the received instruction and feeds the state synchronization message and the event synchronization message back to the corresponding client, and the client responds to the event synchronization message and changes the current virtual environment scene and/or the interactive relation of objects in the virtual environment scene according to the content of the state synchronization message;
the client preprocessing the received instruction input by the user comprises the following steps:
the instructions input by the user include: operating instructions of objects in the virtual environment scene and pre-operating instructions which cannot influence the virtual environment scene presented by other clients;
the pre-operation instruction which does not influence the virtual environment scenes presented by other clients is directly processed by a computing unit in the client; the operation instruction of the object in the virtual environment scene influences the virtual environment scene presented by other clients, and the instruction is handed to the server for processing; meanwhile, the preprocessing also comprises the step of transforming the related operation instructions to generate new instructions.
2. The method of distributed virtual environment interaction and computation load balancing distribution according to claim 1,
the state synchronization message is used for synchronizing the position, the angle and the size of an object in the virtual environment; the state synchronization message is transmitted over a UDP connection;
the event synchronization message is used for synchronizing event information; the event information includes: event information fed back by aiming at the operation request of each client in the initial stage and event information generated by combining the instruction of each client and the current virtual environment scene in the execution stage; the event synchronization message is transmitted over a TCP connection.
3. The method for interaction and computation load balancing distribution of a distributed virtual environment according to claim 1 or 2, wherein the header in the state synchronization message and the event synchronization message is added with a field for a specified execution object.
4. The method according to claim 1 or 2, wherein a fixed buffer is provided in the client for receiving the status synchronization message, and when a new status synchronization message arrives, the new status synchronization message is overwritten on the original status synchronization message; a variable length queue is also provided to hold event synchronization messages and to execute related events in a first-come-first-executed order.
5. The method of claim 1, wherein the preprocessed instructions comprise: a status type instruction and an event request type instruction;
wherein the state type instruction is an instruction for an object moving operation, which is transmitted through a UDP connection;
the event request type command is an operation command for an interaction event between objects, which is transmitted through a TCP connection.
6. The method according to claim 5, wherein the server opens up a fixed buffer for each client to receive the stateful instructions, and when a new stateful instruction arrives, the new stateful instruction is overwritten with the original stateful instruction; variable length queues are also opened up for each client to hold event-request type instructions and are executed in order of first come first executed.
CN201910227648.5A 2019-03-25 2019-03-25 Method for interaction and calculation load balanced distribution of distributed virtual environment Active CN109873876B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910227648.5A CN109873876B (en) 2019-03-25 2019-03-25 Method for interaction and calculation load balanced distribution of distributed virtual environment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910227648.5A CN109873876B (en) 2019-03-25 2019-03-25 Method for interaction and calculation load balanced distribution of distributed virtual environment

Publications (2)

Publication Number Publication Date
CN109873876A CN109873876A (en) 2019-06-11
CN109873876B true CN109873876B (en) 2020-10-27

Family

ID=66921203

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910227648.5A Active CN109873876B (en) 2019-03-25 2019-03-25 Method for interaction and calculation load balanced distribution of distributed virtual environment

Country Status (1)

Country Link
CN (1) CN109873876B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111901341B (en) * 2020-07-28 2022-05-24 北京字节跳动网络技术有限公司 State synchronization method and device
CN111841015A (en) * 2020-07-29 2020-10-30 北京字节跳动网络技术有限公司 Game hall interaction method, device, equipment and system based on state machine
CN113572814B (en) * 2021-06-23 2022-09-23 北京开云互动科技有限公司 Multi-user online task data synchronization method based on state prediction and verification

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105031922A (en) * 2015-07-07 2015-11-11 网易(杭州)网络有限公司 Game data processing method, game server and game client

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103138992B (en) * 2013-03-26 2015-10-28 广东威创视讯科技股份有限公司 Network scenario simulation method
CN105376244A (en) * 2015-11-27 2016-03-02 深圳市望尘科技有限公司 Network game implementation method with artificial intelligence and physical simulation computations being performed on basis of cloud server
CN105933380A (en) * 2016-04-01 2016-09-07 宇龙计算机通信科技(深圳)有限公司 Data transmission method, device and terminal
CN108076106B (en) * 2016-11-15 2019-11-19 中国科学院声学研究所 A kind of Stream Processing system and method for facing cloud storing data encryption and decryption
CN106984043B (en) * 2017-03-24 2020-08-07 武汉秀宝软件有限公司 Data synchronization method and system for multiplayer battle game
EP3400991A1 (en) * 2017-05-09 2018-11-14 Trimoo IP Europe B.V. Transport simulation in a location-based mixed-reality game system
CN107959687A (en) * 2017-12-13 2018-04-24 上海曼恒数字技术股份有限公司 A kind of data processing method, system, equipment and storage medium

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105031922A (en) * 2015-07-07 2015-11-11 网易(杭州)网络有限公司 Game data processing method, game server and game client

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
游戏引擎研究与分析;王龙,李韬伟,杨振发;《软件导刊》;20180228;全文 *
网络游戏引擎中同步技术研究综述;邱航,何明耕,陈雷霆;《计算机应用研究》;20071231;全文 *

Also Published As

Publication number Publication date
CN109873876A (en) 2019-06-11

Similar Documents

Publication Publication Date Title
CN109873876B (en) Method for interaction and calculation load balanced distribution of distributed virtual environment
KR20210003687A (en) Customized models for imitating player gameplay in a video game
US8308570B2 (en) Synchronizing mission progress in peer-to-peer cooperative games
CN109731330B (en) Method and device for displaying picture, storage medium and electronic device
CN111767503A (en) Game data processing method and device, computer and readable storage medium
US11724191B2 (en) Network-based video game editing and modification distribution system
CN111744201A (en) Automatic player-controlled takeover in video games
US20220392153A1 (en) Image processing method and apparatus, electronic device, and computer-readable storage medium
JP2015231539A (en) Simulation method and system
KR20110081400A (en) Apparstus and method of providing replay movie in massively multiplayer online role playing game
WO2022183610A1 (en) Game mode switching method and apparatus, and electronic device
CN111589121A (en) Information display method and device, storage medium and electronic device
CN111389004A (en) Control method of virtual role, storage medium and processor
US9977795B1 (en) System and method for multiplayer network gaming
CN114288639A (en) Picture display method, providing method, device, equipment and storage medium
US20230347247A1 (en) Virtual character control method and apparatus, storage medium, and electronic device
Ploss et al. From a single-to multi-server online game: A quake 3 case study using rtf
US11872483B2 (en) Game object control system and method, and computer-readable storage medium
CN112156475B (en) Business data processing method and device, electronic equipment and storage medium
WO2023024078A1 (en) Virtual object control method and apparatus, electronic device, and storage medium
CN112386906B (en) Media resource playing method and device, storage medium and electronic equipment
CN113694521A (en) Injury processing method, apparatus, electronic device and storage medium
US10625160B2 (en) Multi-character interaction scenario
US11607613B2 (en) Method and apparatus for switching game mode, and electronic device
CN113786609A (en) Injury processing method, apparatus, electronic device and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant