BF2142 Query Protocol
Contents |
Basics
This document describes how to query Battlefield 2142 servers.
General Query Information
All Battlefield 2142 servers have a query port, the default being 29900. When you send specifically-crafted UDP packets to that port you will receive a response from the server of up to 3 packets. A relatively busy server will generate a response of around 3500 bytes and, as the max packet length is 1400 bytes, this will be split up into 3 packets. These packets may arrive in any order so correct ordering and parsing will have to be done at the client side.
Query Types and Expected Response
There are a number of queries you can send the server. The initial one must be a challenge / response request, the next one can be a full query or a "lite" query, a term I have coined for a request for minimal server information.
Challenge / Response
EA have implemented a form of challenge / response with BF2142 to make the servers less susceptible to Denial Of Service attacks. What this means is that you must send a inital "Challenge Request" packet, the server responds with a unique "Challenge Response" then you must insert a portion of this response into your request for server information. The correct sequence using example data follows..
1) Send challenge request (FE FD H9 83 58 34 H0)
2) Receive response from server - remove first 5 bytes of response leaving..
2D 31 35 36 39 38 36 37 37 32 39 00
3) Convert what's left to an integer giving you...
-1442591364
4) Convert that to a hex string then remove everything except the last 8 bytes from the string leaving..
2A372375
5) Convert each pair into a byte and insert each pair into a specific location in your next server query.
Full Query
This is a request for full server information. For this query, you must send the following..
FE FD H0 5D AC 81 59 xx xx xx xx FF FF FF 01
Where xx xx xx xx is the response you calculated from the challenge request received from the challenge / response query.
This query may return up to 3 packets which, when converted into a string, show detailed server and player information.
NB - As in BF2 the team scores are still not returned correctly and will always be zero. A single-packet response form an empty server, converted into a string using "\" as delimiters follows..
\]\\Ysplitnum\\\hostname\EA Chicago 5 / Art of War Central\gamename\stella\gamever\0.0.1527.6\ mapname\Verdun\gametype\gpm_ti\gamevariant\bf2142\numplayers\0\maxplayers\64\gamemode\openplaying\ password\0\timelimit\0\roundtime\3\hostport\16567\bf2142_ranked\0\bf2142_anticheat\0\bf2142_autorec\ 0\bf2142_d_idx\http://\bf2142_d_dl\http://\bf2142_voip\1\bf2142_autobalanced\0\bf2142_friendlyfire\ 1\bf2142_tkmode\Punish\bf2142_startdelay\15\bf2142_spawntime\15.000000\bf2142_sponsortext\\ bf2142_sponsorlogo_url\\bf2142_communitylogo_url\\bf2142_scorelimit\0\bf2142_ticketratio\100\ bf2142_teamratio\100.000000\bf2142_team1\Pac\bf2142_team2\EU\bf2142_pure\\bf2142_mapsize\32\ bf2142_reservedslots\0\\\player_\\\score_\\\ping_\\\team_\\\deaths_\\\pid_\\\skill_\\\\\team_t \\Pac\EU\\score_t\\0\0\\\\
"Lite" Query
This is the query as used by the in-game server browser. It is a request for minimal information, just enough to populate the browser.
For this query you must send the following...
FE FD 00 B3 44 FC 01 xx xx xx xx 12 01 06 05 08 0A 04 07 13 03 35 34 39 36 46 47 49 3B 3A 00 00
Where xx xx xx xx is the response you calculated from the challenge request received from the challenge / response query.
From this query you will receive a single packet containing minimal server information as follows..
EA Chicago 5 / Art of War Central\gpm_ti\Verdun\0\64\16567\bf2142\0\0.0.1527.6\0\0\1\0\\32\0\1\0\\
The server information is as follows..
hostname\gametype\mapname\numplayers\maxplayers\gameport\gamevariant\?\gamever\?\?\?\?\\ bf2142_mapsize\?\?\?\\
The question marks have yet to be deciphered, they will be server variables but the order is unknown.
Conclusion
This information has been gleaned from the BF2142 beta, hence some aspects might chance, though I expect the queries to remain static.