Source: TesterHome Community
A game protocol serves as the core rule set for data communication between game clients and servers in online games.
When a player triggers an in-game action such as clicking a button, the client will encapsulate user requests and corresponding parameters into a standard network packet following predefined rules, then deliver the packet to the server.
The server receives and parses the incoming packet to identify the specific action and parameters. It processes data according to built-in game logic, and returns the processing result in a new network packet. The client finally parses the returned data and presents content to players on the interface.
Two key points to note during data transmission:
TCP is adopted by the majority of online games. It fits game scenarios that do not require ultra-low latency and can tolerate minor network delays.
Advantages
Disadvantages
UDP is the preferred protocol for real-time competitive games including MOBA and FPS titles, as it effectively reduces transmission latency.
Advantages
Disadvantages
WebSocket is an application-layer protocol developed based on HTML5, which is widely applied to H5 games and WeChat Mini Games.
Note: If you are not developing automated test bots, focus your work on server-side parameter verification instead of digging into underlying protocol implementation details.
Most Socket-based game network packets follow a fixed structure. The exact fields may vary across different game projects, so always confirm details with development teams. A complete packet generally includes the following parts:
TCP works in stream mode, which may lead to packet sticking — multiple independent packets are merged into one data stream. Developers use the Packet Length field to split the combined stream and extract complete single packets.
Many access restrictions in games are only implemented on the client side. For instance, the client will block purchase requests and pop up an “Insufficient Funds” prompt when a player does not have enough in-game currency.
However, client-side restrictions only block operations on the local interface. They cannot prevent forged or repeated malicious packets from being sent to the server. Without strict server-side validation, attackers may exploit vulnerabilities to:
The core objective of protocol testing is to fully verify the accuracy and security of server-side business logic.
Protocol analysis relies on monitoring data traffic between clients and servers to capture real network packets.
Commonly used capture tools:
We take WPE as an example to illustrate the packet injection process:
Alternative testing methods:
Testing priorities should be placed on packets sent from clients to servers. Packets returned by the server only affect local interface display and will not change core server data.
The core testing idea is to bypass preset business prerequisites. In other words, send valid standard packets when the corresponding access conditions are not met. The typical test scenarios are listed below:
There is no rigid standard format for protocol test cases. A qualified test case must clearly record protocol information as well as valid and invalid test conditions. You can refer to the template below:
|
Protocol ID |
In-game Action |
Test Scenario |
Expected Server Response |
|
1001 |
Buy items |
Insufficient in-game currency |
Reject the purchase and return the prompt of Insufficient Funds |
|
1002 |
Claim daily reward |
Reward has already been claimed |
Reject the request and return the prompt of Reward Already Claimed |
Apart from verifying the correctness of single packets, you also need to evaluate protocol efficiency and redundant content. These factors directly affect user experience and game performance.
If related rules are not covered by backend validation, add the following inspection items: