Query Mechanism
This wiki is using an old backup from 2020
Some information may be old/missing
The backbone of packets
Byte | PHP | Hexadecimal | Description |
---|---|---|---|
0-3 | "VCMP" | 56 43 4D 50 | The magic of the packet. |
4 | chr('192'); | C0 | The first byte in the server's IP address. |
5 | chr('168'); | A8 | The second byte in the server's IP address. |
6 | chr('200'); | C8 | The third byte in the server's IP address. |
7 | chr('103'); | 67 | The fourth byte in the server's IP address. |
8 | chr('5192' & 0xFF); | 48 | The first byte of the port. |
9 | chr('5192' >> 8 & 0xFF); | 14 | The second byte of the port. |
10 | "i" | 69 | The opcode that you would like to query. |
Opcodes
The packet table
Packet 'opcode' | Description |
---|---|
i | Server information |
p | Ping |
c | Players list |
Recieving the packets
The header of the query response will be the exact same thing that the client sent, except that the header sent by the server will always be MP04, and not VCMP. This acts as a compatibility check due to the differing protocols.
Response from i
Byte | Key | Byte width | Description |
---|---|---|---|
11-22 | Version name | 12 | The version name of the server. |
23 | Password | 1 | A flag indicating if the server is locked, an integer that is 0 or 1. |
24-25 | Players | 2 | The number of players. |
26-27 | MaxPlayers | 2 | The maximum number of players. |
Extra data (500 bytes) | |||
28-31 | strlen | 4 | Size of the server name. |
32+strlen | Server name | strlen | The server name. |
33-36 | strlen | 4 | Size of the gamemode name. |
37+strlen | Gamemode | strlen | The gamemode name. |
38-41 | strlen | 4 | Size of the map name. |
42+strlen | Map name | strlen | The map name. |
Anything thereafter should be treated as garbage.
Response from c
Byte | Key | Byte width | Description |
---|---|---|---|
11-12 | Players Online | 2 | Number of players online. |
Extra data (3000 bytes) | |||
13-14 | strlen | 1 | Size of player name. |
Player name | 14+strlen | strlen | The player name. |
(repeat for however many players there are online) |
Anything thereafter should be treated as garbage. Note that scores are no longer included.
Response from p
The response to a ping packet has the same structure as before, with the modified magic.
Example Implementations
PHP
Here is a PHP class written by stormeus which implements the query protocol rather strictly: http://pastie.org/9501000