Download

Specification 1.1 · protocol 5 · bfe-sim-34 · CC BY 4.0

Multiplayer protocol and relay

How a Battlefront Eternal client, dedicated server, directory and relay talk to each other, written so another Battlefront port or tool can implement a compatible piece and use the same words for the same things.

About this specification

Specification
1.130 November 2026
Wire
Protocol 5profile snapshot-delta-v1, simulation bfe-sim-34 (preview 395)
Reference
The codeengine 233d73a56, directory, relay

This page describes what the public code does at the commits named here. The code is the reference: where this text and the code disagree, the code is right, and a report of the difference is welcome. Anything the code did not settle when this was written is marked not specified here rather than guessed.

Must, must not, should and may are used as in RFC 2119. Integers are little endian unless a table says otherwise. A tick is one step of the 60 Hz simulation. "Client", "server", "directory" and "relay" are the four roles below.

This text and its diagrams are licensed under Creative Commons Attribution 4.0 International (CC BY 4.0). The code they describe is licensed under the GNU General Public License, version 3 only.

Roles

Client: the desktop app. Dedicated server: bfeserver, which runs one battle at a time at 60 Hz and is the authority over it; the app's own HOST runs the same server. Directory: the master server at online.battlefronteternal.com, which lists servers, passes signalling between client and server, issues short-lived relay credentials and signs a global ban feed. Relay: a TURN server (coturn) at relay.battlefronteternal.com, used only when no direct path works. A client and a server on one network need neither directory nor relay: they find each other by LAN discovery or an address typed in.

Who talks to whomThe client fetches the server list from the directory over HTTPS and uses its WebSocket signalling. The server registers and sends heartbeats to the directory over HTTPS and keeps a signalling WebSocket open. Game traffic runs from client to server as encrypted BFE-UDP/1 datagrams, directly or, when no direct path works, through the relay, where the server holds a TURN allocation.Directoryonline.battlefronteternal.comClientthe desktop appDedicated serverbfeserver, or the app's HOSTRelay (TURN)relay.battlefronteternal.comHTTPS list, WSS signallingHTTPS register, heartbeat; WSSBFE-UDP/1, direct or punchedplain UDP to the relayed addressTURN allocation held by the server
The game traffic is the same encrypted BFE-UDP/1 whichever path it takes; the directory and the relay never see inside it.

Transport: BFE-UDP/1

Every game datagram is UDP and at most 1,200 bytes. The handshake proves both identities (Ed25519) and agrees keys (X25519, HKDF-SHA256); after it, every packet is sealed with AES-256-GCM. The construction follows established designs: a SIGMA-I handshake as TLS 1.3 uses, QUIC's acknowledgement ranges and loss detection, and WireGuard-style session ids, roaming and replay windows. Inside a sealed packet, frames carry acknowledgements, unreliable datagrams and two reliable ordered streams.

Packet types

The first byte of every datagram is its packet type.

TypeNameDirectionPurposeBytesReference
177INITIATIONclient to serverOpens a handshake: client session id, X25519 ephemeral public key, 16 random bytes, optional RETRY token.1200 to 1200layout.rs:89
178RESPONSEserver to clientServer ephemeral key and random, plus the server's sealed identity proof and signed server hello JSON.186 to 1200layout.rs:98
183CONFIRMclient to serverClient identity proof and signed client hello; completes the 1-RTT handshake.134 to 1200layout.rs:108
179RETRYserver to clientStateless address validation: the client must resend INITIATION carrying the token.9 to 72layout.rs:115
182VERSIONserver to clientTells a client whose INITIATION version byte is not 1 which wire version the server speaks.6 to 6layout.rs:77
180DATAbothEstablished 1-RTT packet, key phase 0. Carries frames.26 to 1200layout.rs:83
181DATA_PHASEbothSame layout as DATA; marks key phase 1 after a key update.26 to 1200connection.rs:174
184PUNCHserver to client candidate addressesNAT hole punching toward up to 8 candidate addresses supplied by the master; no reply expected; the server ignores received PUNCH packets.9 to 9server.rs:19
INITIATION (177) layout
OffsetSizeFieldTypeMeaning
01typeu8177
11versionu8wire version 1; any other value gets a VERSION reply (handshake.rs:249-257)
24sessionu32 LEclient-chosen random session id, never 0 (handshake.rs:38,241-244)
632ephemeralbytesclient X25519 public key
3816randombytesclient random
542tokenLengthu16 LE0..64 (MAX_TOKEN); larger is dropped (handshake.rs:245-248)
56tokenLengthtokenbytesopaque RETRY token echoed back, else absent
56+tokenLengthto 1200paddingzero bytesanti-amplification padding
RESPONSE (178) layout
OffsetSizeFieldTypeMeaning
01typeu8178
11versionu81
24clientSessionu32 LEecho of INITIATION.session
64serverSessionu32 LEserver-chosen random non-zero id, unique among pending and live sessions (handshake.rs:310-320); becomes the receiver id of client DATA
1032ephemeralbytesserver X25519 public key
4216randombytesserver random
582sealedLengthu16 LEbytes after the header = 110 + helloLength + 16; must equal datagram length - 60 (handshake.rs:79)
6044sealed.identitybytesserver Ed25519 public key as SPKI DER (12-byte prefix 30 2a 30 05 06 03 2b 65 70 03 21 00 + 32-byte key)
10464sealed.signaturebytesEd25519 signature over 'BFE-UDP/1 server' || 0x00 || SHA-256(t2 || identity || hello)
1682sealed.helloLengthu16 LE0..1014 (MAX_HELLO)
170helloLengthsealed.helloUTF-8 JSON objectserver hello (see messages.yaml server_hello)
end-1616tagbytesAES-GCM tag

bytes 60..end are AES-256-GCM sealed with the 's hs' handshake key at packet number 0; the 60-byte header is the AAD (handshake.rs:369-373)

CONFIRM (183) layout
OffsetSizeFieldTypeMeaning
01typeu8183
11versionu81
24sessionu32 LERESPONSE.serverSession
62sealedLengthu16 LE110 + helloLength + 16; must equal datagram length - 8 (handshake.rs:413-416)
844sealed.identitybytesclient Ed25519 SPKI DER
5264sealed.signaturebytesEd25519 over 'BFE-UDP/1 client' || 0x00 || SHA-256(t3 || identity || hello)
1162sealed.helloLengthu16 LE0..1014
118helloLengthsealed.helloUTF-8 JSON objectclient hello (messages.yaml hello)
end-1616tagbytesAES-GCM tag

bytes 8..end sealed with the 'c hs' handshake key at packet number 0; the 8-byte header is the AAD (handshake.rs:109)

RETRY (179) layout
OffsetSizeFieldTypeMeaning
01typeu8179
11versionu81
24sessionu32 LEINITIATION.session
62tokenLengthu16 LE1..64; this server always sends 24
8tokenLengthtokenbytesopaque to the client. bfeserver's token: 8-byte LE f64 mint time (ms) + first 16 bytes of HMAC-SHA256(secret, '<time>|<source>|<session>' || clientEphemeral); valid 10 s back, 1 s ahead (crypto.rs:201-277)
VERSION (182) layout
OffsetSizeFieldTypeMeaning
01typeu8182
11versionu8server wire version (1)
24sessionu32 LEINITIATION.session
DATA (180) layout
OffsetSizeFieldTypeMeaning
01typeu8180 (key phase 0) or 181 (key phase 1)
14receiveru32 LEthe receiving side's own session id (server routes by it: server.rs:482-493)
54numberu32 LEsender packet number, 0 upward, never reused; nonce input
91..1175ciphertextbytesencrypted frames
end-1616tagbytesAES-GCM tag

frames sealed with AES-256-GCM under the sender's application key; the 9-byte header is the AAD; the packet number is NOT encrypted (no header protection) (connection.rs:374-376)

PUNCH (184) layout
OffsetSizeFieldTypeMeaning
01typeu8184
18zerozero bytesalways 0

Handshake and keys

A 1-RTT handshake: INITIATION, RESPONSE (the server's proof), CONFIRM (the client's proof), then the server's HANDSHAKE_DONE frame in the first DATA packet. Labels are ASCII; || is concatenation.

Key agreementX25519 (crate x25519-dalek 2, StaticSecret); an all-zero shared secret is refused on both sides (handshake.rs:82,306-309)
SignaturesEd25519 (crate ed25519-dalek 2), verify_strict; public keys must be canonical and not small-order (crypto.rs:182-200)
Hash, KDFSHA-256 (crate sha2); HKDF-SHA256 (crate hkdf 0.12); Extract(salt, ikm); Expand(secret, 'bfe-udp1 ' + label) (crypto.rs:36-46)
SealingAES-256-GCM (crate aes-gcm 0.10), 32-byte key, 12-byte IV, 16-byte detached tag (crypto.rs:279-310)
t1SHA-256('BFE-UDP/1 initiation' || INITIATION[0..54])
t2SHA-256(t1 || RESPONSE[0..58]) (header up to but not including sealedLength)
Handshake secretHKDF-Extract(salt = t2, ikm = X25519 shared secret); server key traffic secret Expand(handshake_secret, 'bfe-udp1 s hs'), client key traffic secret Expand(handshake_secret, 'bfe-udp1 c hs')
Server proofEd25519 sign('BFE-UDP/1 server' || 0x00 || SHA-256(t2 || server SPKI DER || server hello bytes))
t3SHA-256(t2 || RESPONSE[58..end]) (sealedLength, sealed body and tag)
Client proofEd25519 sign('BFE-UDP/1 client' || 0x00 || SHA-256(t3 || client SPKI DER || client hello bytes)); the exact hello bytes are signed
Master secretHKDF-Extract(salt = SHA-256(t3 || whole CONFIRM datagram), ikm = handshake_secret); client to server traffic secret Expand(master, 'bfe-udp1 c ap'), server to client traffic secret Expand(master, 'bfe-udp1 s ap')
Key and IVkey = Expand(secret, 'bfe-udp1 key', 32); iv = Expand(secret, 'bfe-udp1 iv', 12) (crypto.rs:283-287)
NonceIV with its last 4 bytes (big-endian u32) XORed with the packet number (crypto.rs:291-296); handshake packets use number 0
Identity idSHA-256 of the ASCII standard padded base64 text of the 44-byte SPKI DER (crypto.rs:51-56,191); the client pins this 32-byte id from /info, a listing or join data and rejects a RESPONSE with another id (handshake.rs:91-94)
Retransmissionclient resends INITIATION (with its candidate's token) every 250 ms until a RESPONSE; after a RESPONSE it resends the identical CONFIRM every 250 ms until the first authenticated DATA (endpoint.rs:152-160); a duplicate RESPONSE also triggers a CONFIRM resend (handshake.rs:76-78; endpoint.rs:144)
Half-open limits1024 in all, 32 per network prefix, 15000 ms each; RETRY required above 256 pending. per address prefix (IPv4 /32, IPv6 /64) token bucket, bfeserver rate 8/s, burst 16, LRU of 4096 prefixes (server.rs:374-410; udp_server.rs:653-660)
Key updatethe sender rotates to Aead(Expand(current secret, 'bfe-udp1 ku')) when its next packet number is a non-zero multiple of KEY_INTERVAL (1,048,576) and flips DATA<->DATA_PHASE; the receiver tries the current key, then the previous key for numbers below the phase start, then the next key, and commits only after authentication (crypto.rs:288-290; connection.rs:174-186,373)
Replay4096-packet sliding bitmap committed only after AEAD success (codec.rs:111-135; connection.rs:173,189)
A DATA packetA DATA packet starts with a 9-byte header in the clear: the type byte 180 or 181, the receiver's 4-byte session id and the sender's 4-byte packet number. The header is the additional data of the AES-256-GCM seal. Then come the sealed frames, ending in a 16-byte tag, the whole datagram at most 1,200 bytes. Frames inside include ACK, DATAGRAM or FRAGMENT for the state lane, and STREAM for the events stream, where each message is a variable-length length, a kind byte and the payload.DATA (180) · at most 1,200 bytestype1receiver4, u32 LEnumber4, u32 LEsealed framesAES-256-GCM, header as additional datatag16in the clear (9 bytes)ACKrangesDATAGRAM or FRAGMENTstate lane: BNI1, BNA1, BNS1, BNO1STREAMstream 1 (events), offset, length, bytesPING, CLOSE, …One events messagelength (varint)kindpayload (JSON text)
The packet number is not encrypted (there is no header protection); it is the nonce input and never repeats under one key. Varints are QUIC's: the top two bits of the first byte give the length (1, 2, 4 or 8 bytes) and the rest is the big-endian value, at most 253 − 1.

Frames inside a sealed packet

IdFrameFieldsRulesReference
0PADDINGone byte, skippedconnection.rs:207
1PINGack-eliciting (peer ACKs within 25 ms); sent as keepalive after 1000 ms without sending, or on a PTO with nothing to retransmitconnection.rs:210
2ACKlargest varint, delay varint, rangeCount varint, firstRange varint, gap[i] varint, length[i] varintQUIC-style descending ranges; at most one ACK frame per packet; acknowledging a packet number not yet sent is a protocol error; not ack-eliciting. The writer reports the newest 24 (MAX_ACK_RANGES) of up to 256 retained received rangesconnection.rs:43
3DATAGRAMflags u8, length varint, payload bytesunreliable, unordered state lane; never retransmitted; peer ACKs within 40 msstate.rs:47
4FRAGMENTflags u8, id varint, index u8, count u8, length varint, payload bytesa state message too large for the current packet and larger than 1127 bytes of frame (PLAIN-48) is split into ceil(len/1111) parts; the receiver holds 16 assemblies (MAX_PENDING_FRAGMENTS) for 1000 ms each (FRAGMENT_LIFETIME), evicting the oldest; a repeated index or changed count is ignored; invalid count/index/length is a protocol errorstate.rs:30
5STREAMstream u8, offset varint, length varint, data bytesreliable, ordered per stream, independent delivery cursors; lost ranges are retransmitted first; ack-eliciting (25 ms)connection.rs:220
6CLOSEcode varint, reasonLength varint, reason UTF-8 bytesends the connection at once; the closing side keeps keys and re-sends its CLOSE at most every 100 ms for max(1000 ms, 3 PTO) while stray packets arrive; the bfeserver keeps closed sessions draining for 2000 ms (max 256)connection.rs:154
7HANDSHAKE_DONEsent by the server in its first DATA packet after admitting a session (and again for a duplicate CONFIRM); the client treats the first authenticated DATA as establishedconnection.rs:211
8PATH_CHALLENGEdata 8 bytessent toward a new source address after an authenticated newest packet that is not probing-only; one challenge per candidate, new challenges at least 50 ms apart, resent after max(PTO, 50 ms); only the first PATH_CHALLENGE per packet is answeredconnection.rs:196
9PATH_RESPONSEdata 8 bytesanswer on the current path goes in the control queue (max 16 frames); toward another address it is sent at once under a 64-token bucket refilled 128/s; a matching response from the challenged path switches the connection's path (migration)connection.rs:224

Lanes

LaneDeliveryReference
none · stateunreliable, unordered DATAGRAM/FRAGMENT frames; replaceable: a full queue evicts the oldest whole message; never congestion-limitedstate.rs:1
1 · EVENTSreliable, ordered stream of length-prefixed messages; independent of BULKlayout.rs:44
2 · BULKreliable, ordered stream like EVENTS; no message of this tree is observed on it (not confirmed that any sender uses it)layout.rs:45

Close codes

CodeNameSent whenReference
0NORMALclient leaving ('left battle': rust/bfe-client/src/online/client.rs:477); code of an accepted admission (server.rs:150-156)layout.rs:34
1IDLEno authenticated packet for 20000 ms: 'idle timeout' (connection.rs:317); bfeserver session silent 30 s after start, 180 s before start: 'session silent' (game_session.rs:10-12,118-133)layout.rs:35
2PROTOCOLmalformed or unknown frame, repeated ACK, ACK of unsent packet, stream/fragment limit errors (connection.rs:195-198,214,221,227); queue refusal (connection.rs:105-109); reliable data waiting 30 s without ACK progress 'reliable data not acknowledged' (connection.rs:318-321); packet numbers exhausted (connection.rs:372); endpoint poll error (endpoint.rs:163); bfeserver: events message over 65536 bytes 'oversized control frame' or non-object JSON 'invalid json' (game_session.rs:168-188); 'events backlog' over 262144 bytes (udp_peer.rs:281-284); more than 256 messages or 2 MiB in one server tick 'inbound message queue exceeded' (udp_server.rs:520-530,1081-1088); malformed 2005 battle request (udp_server.rs:496)layout.rs:36
3VERSIONadmission: protocol, profile or simulation differ, or (2004 battle) content differs without sitOut; reason = version_refusal text (udp_server.rs:438-455); 2005 match whose required record revision the client cannot take part in (udp_server.rs:502-504)layout.rs:37
4REJECTEDserver full 'The server is full.' (server.rs:635-636; udp_server.rs:486-488); 'Too many players are connected from your network.' (server.rs:637-641); banned 'You are banned from this server.' (udp_server.rs:472-477); password 'This server needs a password.' / 'Wrong password.' (udp_server.rs:458-464); password check answer 'Password accepted.' (udp_server.rs:468-470); spectator refusals (udp_server.rs:479-486); 2005 'match-changed' (udp_server.rs:494-501); older session replaced 'reconnected' (udp_server.rs:1003-1019); 'admission failed: <err>' after gameplay-error (local_server.rs:279-290)layout.rs:38
5KICKEDoperator kick with the operator's reason (local_server.rs:1300-1309; udp_server.rs:850); 2005 match: source over the inbound limit five seconds in a row 'inbound rate over the limit' (udp_server.rs:979-993; inbound.rs:1-17)layout.rs:39
6SHUTDOWN'Server shutting down' (server.rs:907-919); 'server stopping' at battle hand-over or close (local_server.rs:1359-1369; udp_server.rs:1456-1462)layout.rs:40
7APPLICATIONthe player's updates failed for a second: 'your updates failed: <reason>' (local_server.rs:426-435)layout.rs:41

Limits

Generated in the code from rust/sim/schema/transport-layout.json. Exceeding a limit is a protocol fault unless the table says otherwise.

LimitValueBoundsWhen exceeded
MAX_DATAGRAM1200 bytesany BFE-UDP/1 datagramdropped (handshake.rs:64,395; connection.rs:169; udp_server.rs:902)
TAG16 bytesAES-GCM tagn/a
KEY_BYTES32 bytesAES-256 keyn/a
IV_BYTES12 bytesGCM IVn/a
MAX_MESSAGE1048576 bytesone EVENTS/BULK messagesender: queue refused and connection closed PROTOCOL; receiver: protocol error (streams.rs:46,104)
MAX_TOKEN64 bytesRETRY tokenINITIATION or RETRY ignored (handshake.rs:48,70,246)
MAX_HELLO1014 bytesclient and server hello JSONclient refuses to build; server drops CONFIRM; server does not answer (handshake.rs:34,90,325-327,429)
INITIATION_BYTES1200 bytesexact INITIATION lengthdropped
INITIATION_FIELDS54 bytesINITIATION prefix hashed into t1n/a
FRAGMENT_BYTES1111 bytessender fragment part sizen/a
MAX_FRAGMENTS32 partsparts per state message (so a state message is at most 35,552 bytes)sender: 'state message too large' (state.rs:30) and connection closed PROTOCOL (connection.rs:108); receiver: protocol error
MAX_PENDING_FRAGMENTS16 assembliesconcurrent reassembliesoldest assembly evicted (state.rs:80-81)
FRAGMENT_LIFETIME1000 msincomplete assembly ageassembly discarded (state.rs:79)
MAX_STREAM_BUFFER4194304 bytesunacknowledged send bytes per stream; receive horizon beyond delivered offset; congestion window capsender: close PROTOCOL 'reliable data not acknowledged'; receiver: protocol error 'stream buffer exceeded' (streams.rs:46,136; connection.rs:290)
MAX_STREAM_SEGMENTS1024 rangesout-of-order merged runs per receive streamprotocol error 'stream reassembly limit exceeded' (streams.rs:150)
MAX_STREAM_PARTS4096 piecesstored out-of-order pieces per receive streamprotocol error (streams.rs:127)
MAX_CONTROL_FRAMES16 framesqueued PATH_RESPONSE control framesextra answers dropped (connection.rs:238)
MAX_SENT_PACKETS4096 packetsin-flight packet tableoldest entry declared lost (connection.rs:377)
MAX_QUEUED_DATAGRAMS512 messagesstate queue (and 512*1200 bytes)oldest state message evicted, counted as dropped (state.rs:31)
MAX_ACK_RANGES24 rangesranges written per ACKolder ranges omitted
MAX_DECODED_ACK_RANGES64 rangesranges accepted per ACKprotocol error 'invalid ack' (connection.rs:47)
REPLAY_WINDOW4096 packetsreplay bitmapolder numbers treated as seen and dropped (codec.rs:119-123)
MAX_RECEIVED_RANGES256 rangesretained received-packet ranges for ACKsoldest trimmed (connection.rs:192)
MAX_PACKET_NUMBER4294967295 numberper-connection packet numbersclose PROTOCOL 'packet numbers exhausted' (connection.rs:372)
KEY_INTERVAL1048576 packetspackets per key phasekey update
MAX_SAFE_INTEGER9007199254740991 numbervarint and stream offsets'varint too large' / 'stream offsets exhausted'
KEEPALIVE_MS1000 mssend idlePING sent (connection.rs:326)
IDLE_MS20000 msreceive idleclose IDLE 'idle timeout' (connection.rs:317)
STALL_MS30000 msreliable data without ACK progressclose PROTOCOL 'reliable data not acknowledged'
ack_delay_target25 / 40 msACK deadline after stream/ping/control/path frames (25) or state frames (40)n/a
initial_rtthandshake RTT (min 1); 100 if unknown msRTT seedn/a
ptosrtt + max(4*rttvar, 1) + 25, doubled per consecutive PTO up to 2^6 msprobe timeoutoldest in-flight stream ranges declared lost, else PING (connection.rs:301-303,323-325)
loss_thresholds3 packets (adapts to 16) or 9/8 * max(latest, smoothed) RTT (adapts to 2x) mixedloss declarationranges retransmitted
congestion_window38400 initial, min 9600, max 4194304 bytesreliable stream bytes in flight (NewReno-style: slow start, +1200*acked/window, halve once per recovery)stream data waits; state is not limited
flush_batch256 packetspackets emitted per flushrest next flush
server_datagram_read256 datagramsbfeserver game socket reads per server tickleft in the kernel for the next tick
max_sessionsmax(maxPlayers*2+32, 32) sessionsbfeserver live transport sessionsREJECTED 'The server is full.'

Versions

There is nothing to negotiate: one contract, every part required. Both hellos carry protocol, profile and simulation, and the server refuses any difference before a game session exists; a client refuses a different server the same way. Both show the update-required message, so the player knows which side is out of date.

ValueNowChanges whenA mismatch
protocol5The framing or a format both games share changesRefused before a session exists: close code 3, update required
profilesnapshot-delta-v1The snapshot model changesThe same
simulationbfe-sim-34Any rule the client predicts changes, in either gameThe same, since prediction would fight the server
Record revision (2005 match)Per kind, in the match's record tableA 2005 record format or predicted 2005 rule changesThat match alone refuses the client: close code 3 with the update text
Content digest (per battle)bfe-content-sha256- and 64 hex digitsThe gameplay data prepared from the game changesA 2004 battle refuses the join with the version text; a 2005 match seats the client to sit the battle out

In the code

NameValueGatesReference
wire version (BFE-UDP/1)1every handshake packet; compared in handshake.rs:74-75,250,398layout.rs:2
protocol5application contract in both hellos and /info; compared by server on_admit (udp_server.rs:438-440), by client against /info (info.rs:60) and the signed server hello (info.rs:105-109; match2005.rs:139)transport-layout.json:5
profilesnapshot-delta-v1same places as protocol; welcome also carries snapshotMode 'snapshot-delta-v1' (world_worker.rs:1186-1189)transport-layout.json:6
simulationbfe-sim-34same places as protocol; the number after 'bfe-sim-' picks which side is called oldertransport-layout.json:7
serverAdapterABI4server-local: validate_network_contract refuses a contract manifest with another ABI ('Unsupported engine server adapter ABI'); reported on /healthz networkContract; not in any hello or packetnetwork_contract.rs:49
ownCorrectionSchema11server-local contract field (must be > 0) and the own-correction body schema the engine writes; not negotiated in a hello (not confirmed where clients compare it)network_contract.rs:85
manifestVersion1server-local contract manifestnetwork_contract.rs:67
content fingerprintbfe-content-sha256-<64 lowercase hex>2004 battle: hello content must equal the server fingerprint or its content label unless sitOut; 2005 match: mismatch or null seats the client in the sit-out roleudp_server.rs:383
2005 record revisionsper match table (revisions.rs WRITES / WRITES_SPACE)required kinds in the server's signed battle descriptor vs the client's supportsrevisions.rs:123

Joining a battle

A client finds a server in the directory's list, on the LAN, or by an address typed in. It then runs the transport handshake straight to the server's address (or, when needed, punched or relayed: below). The two hellos inside the handshake decide everything about the join before any game message flows.

The join, step by stepOptional: the client reads the server list from the directory, or finds the server on the LAN. The client sends INITIATION, padded to 1,200 bytes. A busy server may answer RETRY with a token, and the client sends INITIATION again with it. The server answers RESPONSE, signed with its identity and carrying its sealed hello. The client checks the identity and the versions and sends CONFIRM with its own signed hello. The server admits or refuses in a fixed order and closes with a code if it refuses. Admitted, the client receives the entity registry and a welcome on the events stream, then a keyframe snapshot and deltas on the state datagrams. The client shows the fixed-length loading screen, sends start, chooses a class and command post as commands, and the server spawns its soldier.ClientDirectoryServer1 · list and details (optional: or LAN, or typed address)2 · INITIATIONsession id, X25519 key; padded to 1,200 bytes3 · RETRY with a token, when busy (then 2 again)4 · RESPONSEsigned by the server's Ed25519 key; its hello: protocol,profile, simulation, content digest (2005: battle descriptor)5 · checks identityand versions6 · CONFIRMits signed hello: versions, content, name (battle, spectate)7 · Admission, in ordercapacity, versions, password, ban,room, the 2005 match, the rolerefused: CLOSE with a code8 · events: entity registry, then welcome9 · state: keyframe snapshot (baseline 0), then deltas10 · loading screenthe same fixed length for all11 · call start (the server waits up to 180 s)12 · commands: class and command post; the server spawns
Transport packet names are BFE-UDP/1's packet types; the steps after 7 run inside the sealed connection.

The hellos

Both hellos are JSON objects sealed and authenticated inside the handshake. The server's hello carries protocol, profile, simulation, content, fingerprint and transport ({"probing":1}); in a Battlefront II match it adds battle with exactly five keys: family, mode (a playlist token of 1 to 32 lowercase letters, digits or underscores), map (swbf2/ and 1 to 32 of the same characters), match (exactly 32 lowercase hexadecimal digits) and records (the match's table of record kinds and revisions). In a 2005 match fingerprint and content are the match's verified content digest, bfe-content-sha256- and 64 lowercase hexadecimal digits. The client's hello carries protocol, profile, simulation, content (its own digest for the battle's map, or null without it) and name (the client sends at most 32 characters and the server keeps 24, without control characters), and may carry password, check and, in a 2004 battle, sitOut; for a 2005 match it adds battle with the first four keys and supports, the record revisions it implements; a spectator adds spectate.

Client hello fieldTypeRangeRequiredMeaning
protocolintegermust be 5trueapplication protocol; missing reads as 0 and is refused (udp_server.rs:425,438)
profilestringmust be 'snapshot-delta-v1'truesnapshot profile
simulationstringmust be 'bfe-sim-34'truesimulation revision
contentstring or nullclient-computed fingerprint 'bfe-content-sha256-' + 64 lowercase hex of its prepared files for the advertised battle (info.rs:69-80); null when sitting out2004: yes unless sitOut; 2005: no (null or mismatch = sit-out)content fingerprint; the server also accepts its operator content label for a 2004 battle (udp_server.rs:441)
namestringclient strips control characters and keeps 32 chars (info.rs:84); server strips U+0000-001F and U+007F-009F, trims, keeps 24 chars, default 'Player' (udp_server.rs:1609-1629)falsedisplay name
passwordstringany; only when the player gave onewhen the server has a passwordcompared by the server (udp_server.rs:456-464)
checkbooleantruefalsepassword check only: the server answers CLOSE 4 'Password accepted.' (or a password refusal) and never admits (udp_server.rs:465-470)
sitOutbooleantruefalse2004 battle: join without a world (chat and score table only) with content null (info.rs:87-92; udp_server.rs:370-377)
spectatestring'world' or 'scores'falsespectator seat; 'world' only if the server allows world spectators; at most 8 spectators; other values refused 'Unknown spectator view.' (udp_server.rs:479-486)
battleobjectexactly 5 keys: family 'swbf2', mode (mode token), map 'swbf2/<1-32 of a-z0-9_>', match (32 lowercase hex), supports (canonical padded base64 of 5 bytes per kind: kind u8, min u16, max u16, ascending, at most 32 kinds)2005 match: yes (missing: CLOSE 4 'match-changed'; malformed: CLOSE 2)the 2005 match the client asks for and the record revisions it implements (match2005.rs:110-122; revisions.rs:275-305,412-472)

Admission, in order

As bfeserver runs it. A refusal is a CLOSE sent under the new session keys, with the code and a reason the player sees.

  1. The transport: the server already has its maximum of sessions (twice its player limit plus 32, at least 32): close code 4, "The server is full."; too many players from one network (the same IPv4 address or IPv6 /64, loopback exempt): close code 4.
  2. protocol, profile or simulation differ, or in a 2004 battle content differs from the server's digest (unless the client asked to sit out): close code 3 with the version text, which says which side is older.
  3. A password the server needs is missing or wrong: close code 4. A hello with check: true only tests the password and is always closed (code 4, "Password accepted." when it is right).
  4. A banned player: close code 4.
  5. Spectator rules, or no room for another player: close code 4.
  6. A 2005 match: a hello without battle, or naming another match, close code 4 with reason match-changed; a malformed request, close code 2; a required record revision the client does not read, close code 3 with the update text.
  7. The role. In a 2005 match a client whose content is the match's verified digest plays, and any other client sits the battle out (missing-content without a digest, content-mismatch with another one).

Admitted, the server sends HANDSHAKE_DONE, then on the events stream entity-registry and welcome (or, for a client sitting out, the sit-out record and the score table). A new session of the same identity replaces the old one, which is closed with code 4, "reconnected".

Before reading any of a 2005 match's messages, the client checks the signed answer. Meanwhile it holds at most 64 messages and 256 KiB, each reliable message at most 64 KiB and each state datagram at most one datagram's payload; more is a fault. A refusal for the version or match-changed makes the client look for the server's current battle again rather than report a fault: the server may have moved on to its next battle while the client joined.

Loading. After admission the client loads the battle behind a loading screen of a fixed length that every client shares (13.5 seconds for a 2004 battle; a 2005 battle's duration comes from its prepared map data, in ticks), so a faster computer does not get into a battle earlier. Then it sends a call with method start; the server waits up to 180 seconds of silence for it, and 30 seconds once a player has started. The spawn screen's choices (team, class, command post) travel as commands like any other input, and the server spawns the soldier.

Message catalogue

After admission, two kinds of carrier hold the game. The reliable events stream carries JSON text messages, each an object with a type. The unreliable state lane carries binary messages that start with a four-letter magic: BNI1 (input), BNA1 (snapshot acknowledgement), BNS1 (entity snapshot part) and BNO1 (the player's own state). Each stream message is framed as a variable-length integer length (at most 1,048,576), a kind byte (0 binary, 1 text) and the payload; each state message is one DATAGRAM frame, or up to 32 FRAGMENT frames when it is larger. The bulk stream exists in the transport but no message of this release is sent on it.

entity-registry · server to client · EVENTS text

When: first message after admission (2004 and played 2005)

Encoding: JSON

FieldTypeRange or meaning
typestring'entity-registry'
registryobjectcombatDefinitions [names], contentEpoch u32 > 0, classes [[id,name]...] ids from 1, weapons [[id,name]], posts [[id,name]], inputCodes [names], bindingProfiles [[0,{}]]. server's id tables for this battle (world_worker.rs:829-845)
recordsarray2005 scripted battle only: [record message kind 28 REGISTRY]. mission roster (world_worker.rs:2147-2155)

The receiver checks:

  • client: duplicate registry is a fault; contentEpoch must be a non-zero u32; registry must equal the client's own registry built from its content apart from contentEpoch, else fault 'entity content/input registry mismatch' (rust/bfe-client/src/online/receiver.rs:1363-1410)

Reference: world_worker.rs:803

welcome · server to client · EVENTS text

When: after entity-registry

Encoding: JSON

FieldTypeRange or meaning
typestring'welcome'
(all /info fields)mixedthe current /info object is copied in (world_worker.rs:1171-1173)
serverIdstring64 hex. server identity id
unitIdnumberplayer's unit
playerIdnumberplayer id (own entity id the client follows)
generationnumberu32. life generation
teamnumberteam
classNamestringassigned class
spectatorbooleanspectator seat granted
teamSelectbooleanclient must choose a team
ticknumberserver tick
snapshotModestring'snapshot-delta-v1'
flightCeilingnumberfinite f32-representable. 2005 only (world_worker.rs:2164-2170,1196-1198)

The receiver checks:

  • client: welcome before registry or a second welcome is a fault 'unexpected battle welcome'; a 2005 welcome without a usable flightCeiling is a fault (receiver.rs:1411-1435)

Reference: world_worker.rs:1169

reply · server to client · EVENTS text

When: answer to a call

Encoding: JSON

FieldTypeRange or meaning
typestring'reply'
idanyecho of the call id
okbooleantrue for start; false with error 'unknown method' or 'sitting-out'
resultobject{"ok":true}. start only
errorstringon failure

Reference: local_server.rs:320

input-ack · server to client · EVENTS text (superseding)

When: every server tick for an admitted player (observed 60/s); not queued while that player's reliable backlog is over 8192 bytes (udp_server.rs:80-82,1301-1313)

Encoding: JSON

FieldTypeRange or meaning
typestring'input-ack'
epochu32world epoch
serverTicku32current server tick
generationu32player life generation
acku32highest input command sequence received
ackTicku32tick of that command
droppedu32server ticks dropped by overrun
discardedInputu32discarded commands
discardedActionsu32discarded actions
ackActionsnumberalways 0

The receiver checks:

  • client applies it only when epoch and generation match its own (receiver.rs:1441-1456)

Reference: world_worker.rs:999

entity-edge-results · server to client · EVENTS text (superseding; an identical one within 100 ms is not queued)

When: edge outcomes are published

Encoding: JSON

FieldTypeRange or meaning
typestring'entity-edge-results'
epochu32
generationu32
received[u32]edge ids received
results[{id u32, status string, tick u32}]edge outcomes

The receiver checks:

  • client applies only when epoch and generation match (receiver.rs:1457-1466)

Reference: world_worker.rs:1024

gameplay-events · server to client · EVENTS text

When: reliable combat records for this client

Encoding: JSON

FieldTypeRange or meaning
typestring'gameplay-events'
ticku32server tick
records[{kind 'combat', id u32, generation u32, tick u32, schema u32, payload base64}]combat record bodies are engine-owned (layouts not extracted here)

The receiver checks:

  • client parses with events::receive; failure is a fault (receiver.rs:1436-1440)

Reference: world_worker.rs:1070

chat · server to client · EVENTS text

When: relay of a player's chat to started players (team lines to the same team); operator announcement

Encoding: JSON

FieldTypeRange or meaning
typestring'chat'
senderstring<= 80 UTF-16 units at the client. player name or 'Server'
textstring<= 240 UTF-16 units
teamboolean
adminbooleantrue for operator messages

The receiver checks:

  • client refuses longer text or sender (rust/bfe-client/src/online/chat.rs:22-34)

Reference: local_server.rs:113

ping · server to client · EVENTS text

When: every 2000 ms per session

Encoding: JSON

FieldTypeRange or meaning
typestring'ping'
timeintegerserver ms clock

The receiver checks:

  • client queues a pong with the same time (receiver.rs:1495-1500,1529-1540)

Reference: game_session.rs:16

pong · both · EVENTS text

When: answer to ping

Encoding: JSON

FieldTypeRange or meaning
typestring'pong'
timenumberecho

The receiver checks:

  • server: RTT sample if 0 <= now - time < 60000, smoothed 0.8/0.2 (game_session.rs:198-211)

Reference: game_session.rs:192

match · server to client · EVENTS text

When: next battle announced (rotation); sent to joiners while the end table runs

Encoding: JSON

FieldTypeRange or meaning
typestring'match'
querystringnext battle query (a 2005 query names its game; includes padAimAssist=1 when the server enables controller reticle slowdown, config.rs:850)
delayMsintegerms until the next battle

The receiver checks:

  • client: NextMatch::announce validates the query; failure is a fault (receiver.rs:1489-1494)

Reference: udp_server.rs:361

gameplay-error · server to client · EVENTS text

When: world refused to add the player; followed by CLOSE 4 'admission failed: <message>'

Encoding: JSON

FieldTypeRange or meaning
typestring'gameplay-error'
messagestringreason; client shows at most 240 chars

Reference: local_server.rs:279

record · both (2005 only) · EVENTS text

When: 2005 record kinds carried reliably, e.g. SIT_OUT 26 notice {match, mode, reason}, NOTICE 25, BOARD 27 (server); HERO_DECLINE 31 with body {} (client)

Encoding: JSON

FieldTypeRange or meaning
typestring'record'
kindinteger1..255. record kind
revisioninteger1..65535. kind revision
bodyanykind-specific

The receiver checks:

  • exactly these four keys (revisions.rs:591-599); a kind the match does not name or a revision other than the match's is refused, an optional kind the reader does not implement is skipped (revisions.rs:601-609)

Reference: revisions.rs:15

call start · client to server · EVENTS text

When: once, after welcome

Encoding: JSON

FieldTypeRange or meaning
typestring'call' (or 'rpc')
idanythe released client sends 1
methodstring'start'. other methods get reply ok:false 'unknown method'
argsobjectthe released client sends {} ('fields' is accepted as an alias)

The receiver checks:

  • sets the session started (30 s silence limit instead of 180 s); sitting-out peers get reply error 'sitting-out' (game_session.rs:247-262; udp_server.rs:1145-1159)

Reference: client.rs:327

chat (client) · client to server · EVENTS text

When: player chat

Encoding: JSON

FieldTypeRange or meaning
typestring'chat'
textstringclient trims and cuts at 240 UTF-16 units
teambooleanteam channel

The receiver checks:

  • server drops text over 240 UTF-16 units, more than 4 messages per 5 s, strips chars < 32 and U+007F, trims, drops empty (game_session.rs:223-246); only started players are relayed; spectators and sit-outs have no team channel (local_server.rs:332-372)

Reference: chat.rs:6

edge-ack / entity-edge-ack · client to server · server reads it on EVENTS text; the released client sends it as a TEXT state-lane DATAGRAM (input.rs:1480,1679)

When: after edge results arrive

Encoding: JSON

FieldTypeRange or meaning
typestring'entity-edge-ack' (server also accepts 'edge-ack')
epochu32
generationu32
ids[u32]edge outcome ids retired

The receiver checks:

  • server routes only binary state and text events messages (udp_server.rs:1101,1122): a text state datagram matches neither branch and is dropped (see transport.md 'not confirmed')

Reference: input.rs:1458

BNI1 input · client to server · state DATAGRAM, binary

When: client input sends (observed ~46 client DATA packets/s with acks only; the probe sent no BNI1)

Encoding: binary LE, 16..1100 bytes, no trailing bytes allowed

FieldTypeRange or meaning
magicu320x31494e42 ('BNI1')
epochu32world epoch
generationu32life generation
nvu80..8. views
ncu80..8. commands
neu80..32. edges
nau80..1. snapshot ack present
view[nv]structflags u16 (<=1023), profile u16 (must be 0); then by flag: 32 mouseScale f64 (0,2]; 64 aspect f64 (0,10]; 128 viewTick f64 [0,2^32-1]; 256 sensitivity f64 (0,10] and 512 curve f64 [0.1,4] (both need flag 4 flight); 16: 4 axes f64 [-1,1] + buttons u16
command[nc]structsequence u32, tick u32, view index u8 (< nv), held bitmap 16 bytes (bit i = inputCodes[i]; unknown bit refused), lookX f64, lookY f64 (cumulative look totals)
edge[ne]structid u32 (non-zero), tick u32, kind u8 0..5; kind 0 action u8 (index into inputActions; 21 in 2004, 24 in 2005); kind 1 fire flags u8 (bit0 button, bit1 pressed, <=3) + viewTick f64 + aimYaw f64 + aimPitch f64; kind 2 team u8 1..7; kind 3 classId u16 + postId u16; kind 4 suicide, kind 5 cancel spawn (no payload)
acku16 epoch + u32 tickif na=1: last complete snapshot
records2005 onlyrecords section after the ack: count u8 (<=16), per record kind u8, revision u16, length u16, body (revisions.rs:517-564); e.g. PILOT 16

The receiver checks:

  • server: 10..1100 bytes and magic BNI1 with length >= 16 or BNA1 exactly 10, else dropped (udp_peer.rs:118-134); 75 datagrams/s token bucket, burst 360 (game_session.rs:6-8,90-100); full decode checks above (world_worker.rs:182-441); 2005 match: 32,000 B/s (burst 8,000) and 120 datagrams/s (burst 30) per source before decode (inbound.rs:1-17)

Test vector: rust/sim/src/wire/input.rs:116-130 (one view, one command code 22, one spawn edge, ack 65534/4294967295)

Reference: input.rs:48

BNA1 snapshot ack keepalive · client to server · state DATAGRAM, binary

When: acknowledges a complete snapshot when no input carries the ack; spectators may send only this

Encoding: exactly 10 bytes: magic u32 0x31414e42 ('BNA1'), epoch u16, tick u32

FieldTypeRange or meaning
magicu32BNA1
epochu16
ticku32snapshot tick acknowledged

The receiver checks:

  • exact length 10 and magic (world_worker.rs:160-173)

Reference: input.rs:101

BNS1 entity snapshot part · server to client · state DATAGRAM, binary

When: every 3 server ticks (20 Hz) per world_worker.rs:1778-1786; observed 499 snapshots, tick step 3, interval byte 3

Encoding: binary LE, at most 1100 bytes per part, 1..256 parts per snapshot

FieldTypeRange or meaning
magicu320x31534e42 'BNS1'
epoch @4u16world epoch
tick @6u32snapshot tick
interval @10u8ticks between snapshots (3)
baseline @11u32tick of the acknowledged baseline this delta applies to; 0 = keyframe
parts @15u8(index << 4) | count when count <= 15; 0 means extended counters follow
ack @16u320 in entity parts
partIndex @20u16extended only (count > 15)
partCount @22u16extended only
worldLength @20 or 24u16bytes of the world section
worldbytesLEB128 count, then fields: id u32, schema u16, generation u32, op u8 (0 absolute: length u16 + payload; 1 removed; 2 word delta: length u16 + [flag 1, payload length u16, word count u16, bitmap ceil(words/8), changed 8-byte words])
slotCountLEB128records in this part
recordsbytesfirst slot u16, later slots as LEB128 deltas; each record: byte = op (bits 0-1: 1 new identity, 2 removal, 0 update) | group mask << 2; new identity adds class u8 (0 soldier,1 droideka,2 vehicle,3 turret,4 item,5 remote), generation u32, entity id u32, class id u16, team u8, then every group; update writes only changed groups

Field groups: soldier/droideka/vehicle/item/remote: g0 position (mode u8: bit0 absolute, bit1 wide u24, bit7 discontinuity; then 3 x i8 delta or 3 x u16/u24 codes), g1 velocity (wide u8 then 3 x i8 at 0.25 m/s or 3 x i16 at 0.03125 m/s); soldier g2 yaw u16 + pitch i16, g3 health u16, g4 posture|charge<<2 u8 + state u8 + weapon u16 + seat slot u16 (65535 none) + seat index u8, g5 fire counter u8; droideka g3 health u16 + posture u8 + status, g4 mode u8 + flags u8 + anim f32[]; vehicle g2 smallest-three quaternion 6 bytes, g3 health u16 + state u8 + power u16, g4 mount (slot u8, tilt i16, roll i16, walk phase u16, walk blend u8, seat count u8, seats i16 pairs), g5 fire counter; turret g0 yaw/pitch/gunYaw/gunPitch i16, g1 health u16 + state u8 + team u8; item g2 yaw u16, g3 active u8 [+ definition u16 + up 3 x i16]; remote g3 active u8 [+ definition u16 + team u8 + health u16] (codec.rs:96-290; docs/snapshot-delta-design.md:39-46)

The receiver checks:

  • client applies each part to its named baseline, waits for all parts before acknowledging, and treats a missing baseline as loss (docs/snapshot-delta-design.md:84-87)

Reference: codec.rs:9

BNO1 own datagram · server to client · state DATAGRAM, binary

When: with each snapshot, per player; never held back by congestion or staleness (udp_peer.rs:262-280)

Encoding: same 20-byte header as BNS1 with magic 0x314f4e42 'BNO1', 1..2 parts, ack = highest input acknowledged; then flags u8 (bit0 correction, bit1 summaries, bit2 cosmetics, bit3 second datagram) and each present section as u16 length + bytes

FieldTypeRange or meaning
correctionsectionid u32, generation u32, schema u16, then word delta (op 0 absolute length u16 + payload, or op 1 delta) against the baseline (codec.rs:639-641,374-383)
summariessectionworld-section format (private world fields)
cosmeticssectioncosmetic bundle

Reference: codec.rs:613

state budget and staleness (server side) · server to client · state

When: every state send

Encoding: n/a

The receiver checks:

  • state message 1..32768 bytes, events message 1..262144 bytes (udp_peer.rs:24-27,253-261); shared snapshot parts older than 100 ms are dropped and parts are not sent while the path is congested (120 ms enter, 50 ms clear) (udp_peer.rs:29-36,262-280); a snapshot whose part cannot be sent is not sent further to that client (local_server.rs:442-455)

Reference: udp_peer.rs:24

What the server accepts per session

  • per session per server tick: at most 256 messages and 2 MiB, else CLOSE 2 'inbound message queue exceeded' (udp_server.rs:520-530,1081-1088)
  • binary state from a sit-out peer is dropped; a spectator's state must be BNA1 (udp_server.rs:1101-1112)
  • events JSON: > 65536 bytes or not an object -> CLOSE 2; known types ping, pong, edge-ack, entity-edge-ack, record, chat, call, rpc; unknown types ignored (game_session.rs:164-276)
  • silence: CLOSE 1 'session silent' after 30 s (started) or 180 s (not started) without any message (game_session.rs:10-12,118-133)

Input codes and actions

A BNI1 command's 16-byte held bitmap sets bit i for input code i; an action edge names an index into the battle's action list. The server sends the same lists in entity-registry, and a client must refuse a battle whose registry differs from its own. The 104 input codes are the same in both games.

Input codes, in order

0:KeyA 1:KeyB 2:KeyC 3:KeyD 4:KeyE 5:KeyF 6:KeyG 7:KeyH 8:KeyI 9:KeyJ 10:KeyK 11:KeyL 12:KeyM 13:KeyN 14:KeyO 15:KeyP 16:KeyQ 17:KeyR 18:KeyS 19:KeyT 20:KeyU 21:KeyV 22:KeyW 23:KeyX 24:KeyY 25:KeyZ 26:Digit0 27:Digit1 28:Digit2 29:Digit3 30:Digit4 31:Digit5 32:Digit6 33:Digit7 34:Digit8 35:Digit9 36:F1 37:F2 38:F3 39:F4 40:F5 41:F6 42:F7 43:F8 44:F9 45:F10 46:F11 47:F12 48:Numpad0 49:Numpad1 50:Numpad2 51:Numpad3 52:Numpad4 53:Numpad5 54:Numpad6 55:Numpad7 56:Numpad8 57:Numpad9 58:Space 59:Enter 60:Escape 61:Tab 62:Backquote 63:CapsLock 64:ShiftLeft 65:ShiftRight 66:ControlLeft 67:ControlRight 68:AltLeft 69:AltRight 70:ArrowUp 71:ArrowDown 72:ArrowLeft 73:ArrowRight 74:Backspace 75:Delete 76:Insert 77:Home 78:End 79:PageUp 80:PageDown 81:Minus 82:Equal 83:BracketLeft 84:BracketRight 85:Backslash 86:Semicolon 87:Quote 88:Comma 89:Period 90:Slash 91:NumpadEnter 92:NumpadAdd 93:NumpadSubtract 94:NumpadMultiply 95:NumpadDivide 96:NumpadDecimal 97:Mouse0 98:Mouse1 99:Mouse2 100:Mouse3 101:Mouse4 102:WheelUp 103:WheelDown

Actions, Battlefront (2004)

0:jump 1:crouch 2:prone 3:reload 4:use 5:nextPrimary 6:previousPrimary 7:nextSecondary 8:zoom 9:perspective 10:map 11:nextSpawn 12:stats 13:squadMoveOut 14:squadHold 15:squadFollow 16:squadAtEase 17:takeoff 18:trick 19:immelmann 20:targetLock

Actions, Battlefront II (2005)

0:jump 1:crouch 2:prone 3:reload 4:use 5:nextPrimary 6:previousPrimary 7:nextSecondary 8:zoom 9:perspective 10:map 11:nextSpawn 12:stats 13:squadMoveOut 14:squadHold 15:squadFollow 16:squadAtEase 17:takeoff 18:trick 19:immelmann 20:targetLock 21:roll 22:blockPress 23:blockRelease

Not specified here: the bodies of combat records (gameplay-events) and of the 2005 record kinds, which are engine-owned and versioned per kind; the replay file format; and whether the server uses the client's entity-edge-ack, which the released client sends as a text message on the state lane where the server reads only binary messages.

The 60 Hz model

The server steps the battle at a fixed 60 ticks a second (vehicles take 120 Hz substeps inside a tick) and is the only authority. Clients send commands, not results, and draw the world a little in the past for everyone else and a little in the future for themselves.

Ticks, commands and snapshotsThe server's ticks run at 60 Hz. Every third tick, 20 times a second, the server publishes a snapshot, encoded against the last complete snapshot the client acknowledged. The client aims each command at the server tick it should arrive for, predicts its own soldier ahead with those commands, and draws other players between two received snapshots on a playout clock that follows measured jitter. The client's input datagrams carry its acknowledgement of the newest complete snapshot.Server · 60 Hz ticksSnapshot every 3 ticks: 20 a seconddelta from the last complete one the client acknowledgedClientcommands, aimed at the tickthey should arrive for, withthe snapshot acknowledgementOthers: interpolatedbetween two snapshotsYou: predictedreplayed from each correction
Latency drawn to scale with one tick a column; on a real link the arrows are longer.
  • Authority. The server runs every rule: movement, combat, vehicles, bots, command posts and scoring. It validates speed, teleports, damage and ammunition and rejects any result a client sends.
  • Commands. A client aims each command at the server tick it should arrive for (its clock offset plus half the round trip plus a small margin) and adjusts gradually, never by jumps. Held movement and cumulative look totals travel as latest-state datagrams, so a later total recovers motion lost in an earlier packet. Discrete actions and fire edges travel in their own acknowledged sequences, repeated until acknowledged or expired, so a newer movement acknowledgement cannot discard a delayed jump, reload or short trigger press. The server rejects duplicates, stale lives and malformed payloads.
  • Snapshots. Every third tick (20 a second) the server publishes the world, delta-encoded against the last complete snapshot the client acknowledged by epoch and tick; baseline tick 0 is a keyframe. The host keeps 128 snapshot ticks; if a client's baseline is gone, it picks another held one or sends a keyframe. Every relevant entity is in every snapshot, in slot order, split into parts of at most 1,100 bytes each. A lost datagram is never resent: the next snapshot replaces it. A client acknowledges a tick only once every required part has arrived.
  • Your own soldier. The client predicts its own soldier or driven vehicle with the same rules. A correction carries the state needed to replay physics, not just position and velocity. On each one the client restores it, drops the commands it acknowledges and replays the rest; replay history is bounded and recovers explicitly when it no longer covers the authority. Gunners predict their own aim and see the hull interpolated.
  • Everyone else is drawn between received snapshots on a playout clock that follows measured jitter.
  • Events. Kills, captures, spawns, chat and map changes travel reliably on the events stream, numbered so they cover the ticks between snapshots, never inside a snapshot that can be lost.
  • Shots. Blaster bolts are projectiles, not instant hits. The shooter's client draws its bolt at once; the server spawns the real bolt advanced by the shooter's latency and tests the skipped stretch against targets rewound to where the shooter saw them, up to a 300 ms round trip on top of the shooter's lead and playout delay. Old timestamps clamp to the cap and future ones get no compensation.
  • Joining mid-battle: the entity registry and a welcome, then a full snapshot against the empty baseline, then deltas. Map changes: the server announces the next battle, the end screens play, the server builds the new world, and each client loads it and reports ready. Reconnecting within a minute keeps your team, score and slot (matched by player key); after that a bot takes the slot.

Spectators and replays

Spectators. A server may advertise an optional spectators field in discovery, scores or world; a missing or unknown value leaves the ordinary join. A spectator asks for the advertised view in its hello with "spectate":"scores" or "spectate":"world". A scores spectator gets the sit-out role (the score table and public chat). A world spectator must receive a spectator welcome before it starts, then receives snapshots and acknowledges them, with no soldier, no input mailbox, no team channel and no authority over the match. World spectating needs "worldSpectators": true in the server's configuration. Up to eight spectator slots share the server's authentication and address limits; they have no team and do not count towards the player limit. Everything else in the hellos and the required versions stays the same.

Replays. A replay is a local file the client writes; nothing extra travels on the wire. It records the accepted public world state of an Instant Action battle or an online match, under a header naming the game, map, battle, simulation, protocol, content digest and tick rate (60). Personal corrections, credentials and chat never enter the file. The replay file format itself is not specified here.

Directory

The directory is an HTTP JSON API behind HTTPS at https://online.battlefronteternal.com (a client may point elsewhere with BFE_MASTER_URL). Its own API version is 1, independent of the game protocol. It keeps the server list in memory and drops a server 60 seconds after its last heartbeat. It also passes rendezvous messages between players and servers over a WebSocket, issues short-lived relay credentials and publishes a signed global ban feed that each server operator may honour or ignore.

Every request

  • The online notice. Every call except /healthz, /v1/info and OPTIONS carries x-bfe-notice: 2026-10-11, the version of the online notice the player accepted; without it the answer is 428.
  • Signed changes. POST, PUT and DELETE are signed with the caller's Ed25519 key. Headers: x-bfe-key (standard base64 of the 44-byte Ed25519 SPKI DER key), x-bfe-time (Unix seconds, 10 digits, within 60 s of the directory's clock), x-bfe-nonce (16 random bytes as 32 lowercase hex digits) and x-bfe-signature (base64 of the 64-byte signature). The signed text is five lines joined by a newline: the method, the request target exactly as sent (with any query), the time, the nonce, and the lowercase hex SHA-256 of the exact body bytes. A key's id, which is also the server or player id, is the lowercase hex SHA-256 of the base64 key text. A nonce is remembered for 125 seconds; a repeat is refused (401).
  • Limits. Bodies are JSON objects of at most 32,768 bytes. Every caller address (an IPv4 address or an IPv6 /64) gets 120 requests in a fixed 60 s window, and every key 120 changes; over that is 429. Errors are {"error": "text"}. Answers carry access-control-allow-origin: *, so web pages and bots may read the list.

Endpoints

RequestPurposeAuthLimitsReference
GET /healthzlivenessnone (no notice)globalserver.js:331
GET /v1/infodirectory metadata, notice version, signing key, relay URLs, timing limitsnone (no notice)globalserver.js:337
GET /v1/whoamicaller's address as the master sees itnotice headerglobalserver.js:360
GET /v1/serversfull public list (no server-side filters or query parameters)notice headerglobalserver.js:364
GET /v1/servers/{id}one listingnotice headerglobalserver.js:380
POST /v1/serversregister (or re-register) the caller's server; ID = caller key IDsignedglobal + 120 mutations per key per windowserver.js:422
PUT /v1/servers/{id}heartbeat; same body and checks as registersignedglobal + 120 mutations per key per windowserver.js:422
DELETE /v1/servers/{id}unregistersignedglobal + 120 mutations per key per windowserver.js:439
POST /v1/relay-credentialstime-limited TURN REST credentials; with peerId a per-player host grantsignedwithout peerId: 6/key, 24/address bucket; with peerId: min(128, maxPlayers*2)/server key, 128/address bucket, 2/(server,peer); per 60 s windowserver.js:444
POST /v1/signal-ticketsingle-use ticket for the signal WebSocketsigned6 per key per windowserver.js:471
GET (WebSocket upgrade) /v1/signal?ticket={ticket}rendezvous signaling relay between a player and a listed serverticket64 upgrades per address bucket per window (master:src/server.js:506)server.js:502
POST /v1/reportsreport a player or serversigned3 per key, 10 per address bucket, per windowserver.js:478
GET /v1/banssigned global player-ban feed (servers choose to honor it)notice headerglobalserver.js:388

A listing

What a server sends in POST /v1/servers and every heartbeat, and what the list returns. "Text" is 1 to N characters with no control characters. The directory drops any other key.

FieldTypeRule
idstringset by master = key id
publicKeystringset by master = x-bfe-key
namestringrequired text <= 80
protocolintegerrequired 0..65535 (game protocol, 5 at engine 233d73a56)
simulationstringrequired text <= 128 (bfe-sim-34 at 233d73a56)
contentstringrequired text <= 128
rotationarray of string1..64 entries, each text <= 100 matching ^swbf[12]\/[a-z0-9_-]+:[a-z0-9_-]+:[a-z0-9_-]+$
playersintegerrequired 0..128, <= maxPlayers
maxPlayersintegerrequired 1..128
relayPolicystringauto (default) | never | always
endpointsarray<= 4 of {address?: must equal caller and be unicast, port: 1..65535, transport: udp|webrtc}; stored with verified:false; [] when always; per-family merge kept 90 s
fingerprintstring^sha-256 (?:[A-Fa-f0-9]{2}:){31}[A-Fa-f0-9]{2}$ (sha256 of SPKI DER)
locationstring|nulloptional text <= 80 (present but invalid -> 400)
descriptionstring|nulloptional text <= 280, invalid -> null
sponsorobject|null{name: text <= 60, url: https <= 512 no userinfo | null, logo: same}
querystring|null'?' + keys map(required),side,mission [a-z0-9_-]{1,64}, era cw|gcw, ai classic|enhanced|off, seed 1-10 digits, match 32 hex; each once; <= 512
battleobject|nullmap required ^(swbf2/)?[a-z0-9_-]{1,64}$; family only 'swbf2'; mapName text <= 60; side, mode slug; era cw|gcw; invalid members omitted, never null
botsboolean|null
autoAssignTeamsboolean|null
uptimeinteger|null0..315360000 s
passwordtrue|absentonly when input === true; never the password
gamesarray|absent1-2 distinct of swbf1, swbf2 (second-game field)

The second game. A server whose battle is from Battlefront II sends battle.family: "swbf2" and a qualified battle.map such as swbf2/tat2; games lists the games its playlist reaches (swbf1, swbf2). A row without family is a Battlefront (2004) battle. Rotation entries are swbf1/ or swbf2/, then map, era and mode separated by colons.

Addresses. The directory takes no address on trust: an endpoint's address must be the request's own source address, and it is stored with verified: false. A server with relay policy never publishes its port (and the directory its source address); auto and always servers publish no endpoints and are reached through rendezvous, so the browser shows no ping for them.

Registration and heartbeat

  1. If it honours global bans: GET /v1/bans, and on first use GET /v1/info to pin the directory's signing key. The feed is {payload, signature, publicKey}, signed over the payload's bytes; the server refreshes it every 120 seconds.
  2. POST /v1/servers, signed, with the listing. The server's id is its key's id.
  3. POST /v1/relay-credentials with its own id, to learn the relay and STUN host; then POST /v1/signal-ticket and the signalling WebSocket /v1/signal?ticket=…, kept open.
  4. STUN from the game socket to learn its public addresses and whether it is behind NAT (again every 60 seconds).
  5. PUT /v1/servers/{id} every 20 seconds, and at once when the battle changes. DELETE /v1/servers/{id} on shutdown. Without a heartbeat for 60 seconds the listing expires.

The browser

The client reads GET /v1/servers (with If-None-Match for the ETag) every 30 seconds while the browser is open. All filtering is on the client. Ping is a TCP connection to an endpoint's game port (the /info listener), timed to the connect, with a one-second timeout; up to four endpoints per server and sixteen servers at once. The client shows a server as joinable when protocol and simulation match its own and it can play the server's game.

LAN discovery: BFE-LAN/1

JSON datagrams on UDP 18452, at most 2048 bytes, by IPv4 broadcast and the IPv6 link-local multicast group ff02::bf:1. The client sends {"magic":"BFE-LAN/1","type":"discover","nonce":"…"} with a new 32-hex-digit nonce per scan; each server answers the sender alone with {"magic":"BFE-LAN/1","type":"server","nonce":"…","info":{…}}, echoing the nonce, where info is its /info document without description and sponsor. The client takes the address from the datagram's source, not from info, keeps servers by id (an IPv4 answer replaces an IPv6 one), and listens 250 ms. A server answers one query per source address every 250 ms and never sends beacons on its own. No internet, directory or relay is needed.

Direct Connect

The client opens TCP to the address and port (18451 by default) and reads GET /info, a plain HTTP JSON document with the server's id, name, versions, content, rotation, players and settings. It checks the id and versions and pins the handshake to that id (a first contact is trust on first use), then sends BFE-UDP/1 INITIATION to every address the name resolves to (up to 16) every 250 ms until an authentic RESPONSE arrives.

NAT traversal and the relay

A listed server with relay policy auto (the default) or always publishes no address. A client reaches it through the directory's signalling: the two exchange their candidate addresses, try them all at once, and fall back to the relay when nothing direct gets through. The policy never publishes the server's address and allows direct joins only.

Rendezvous and hole punching

  1. The client reads the server's listing, asks POST /v1/relay-credentials for the STUN host (the first turn: URL, else relay.battlefronteternal.com:3478), and learns its own public IPv4 address by STUN. Its candidates are that address, its local route address and, when it has one, a global IPv6 address.
  2. It takes a single-use ticket (POST /v1/signal-ticket, valid 30 seconds), opens /v1/signal, and sends {"to": server id, "type": "offer", "payload": …}. The payload carries udp: 1, a nonce and at most eight candidates. An offer opens a route between the two for 120 seconds; the directory forwards it as {"from": client id, "type": "offer", "payload": …}.
  3. The server answers with its own candidates and its current and next battle, and sends PUNCH packets (type 184, 9 bytes) to the client's public candidates over the next 0 to 1.5 seconds so its NAT opens a path. The client repeats its offer every 2.5 seconds with a new nonce until an answer comes (for up to 10 seconds, or 90 while the server is between battles) and punches every 2 seconds while it loads.
  4. The client sends INITIATION to every candidate every 250 ms. The first authentic RESPONSE wins, and it must come from the server id the listing named.

Signalling messages are JSON text frames of at most 32,768 bytes, payloads at most 24,000 characters, of type offer, answer, candidate, reject, matchProbe or matchReady. One socket per identity (a new one closes the old with 4000), 180 messages per identity a minute, a ping every 30 seconds. A message to an offline peer is dropped.

The relay

The relay is stock coturn speaking TURN (RFC 8656) at relay.battlefronteternal.com; there is no custom relay protocol. Only the game server speaks TURN. When a client needs the relay (the server's policy is always, or auto and the server is behind NAT), the server asks the directory for a grant for that one client and allocates a UDP relay address for it; the client just sends ordinary BFE-UDP/1 datagrams to that address. The game traffic stays end-to-end encrypted through the relay.

The relay pathThe server asks the directory for a grant for one client and receives TURN credentials valid five minutes. It allocates a relayed UDP address on the relay, permits the client's public addresses and tells the client the relayed address through signalling. The client sends plain BFE-UDP/1 datagrams to the relayed address. The relay forwards them to the server inside TURN Data indications or ChannelData, and the server's replies come back the same way.Clientplain UDP, no TURNRelay (coturn)relayed address for this clientUDP 49160 to 49415Serverholds the allocationDirectorygrant: 5-minute credentials1 · grant for this client2 · TURN Allocate, CreatePermission (UDP 3478)3 · relayed address, by signalling4 · BFE-UDP/1ChannelData
The relay sees addresses, sizes and timing; it cannot read the game, and it cannot pose as the server, because the handshake is pinned to the server id.
PortTransportUse
3478UDP and TCPTURN and STUN
5349TCP (TLS)TURN over TLS
49160-49415UDPrelayed allocation addresses (256 ports)
  • Credentials. coturn's TURN REST scheme: the directory and the relay share a secret. POST /v1/relay-credentials returns username "<expiry Unix seconds>:<allocation id>", credential base64(HMAC-SHA1(secret, username)), expires (now plus 300 seconds) and the relay urls. For a server's grant the allocation id is <server id>:<client id>, issued only to the listed server and only for a client that sent it an offer within 120 seconds, never to a never server.
  • Allocation. The server opens a new UDP socket per relayed client and sends Allocate (UDP transport, lifetime 600 s); the unauthenticated first try is answered 401 and repeated with TURN long-term credentials (MESSAGE-INTEGRITY keyed by MD5 of username:realm:password, FINGERPRINT on every message). It then permits the client's public addresses (at most 16 per allocation, same family as the relayed address) and tells the client the relayed address as a candidate (policy auto) or answer (always).
  • Data. The server receives Data indications or ChannelData and replies by Send indication, then binds a channel and uses ChannelData with its 4-byte header.
  • Refresh and teardown. The allocation is refreshed at half its granted lifetime (at least every 30 s), permissions every 240 s, channels every 540 s. An allocation unused by a playing client for 30 seconds is released with a zero-lifetime Refresh; a battle change keeps it; shutdown releases all. Longer sessions rely on coturn accepting refreshes after the credentials' five minutes; moving to a new allocation during a session is not implemented.
  • Limits. 160 allocations in all and 4 per username; 1 MiB/s per session, traffic over it dropped; 256 relay ports; a server holds at most its player limit plus 8 allocations. The relay refuses private, loopback, link-local, carrier-grade NAT and multicast destinations. TURN over TCP or TLS is offered by the relay but not used by the game's transport yet, so a network that blocks UDP cannot join.

Security notes

  • Every datagram is hostile until checked. Sizes and counts are checked before anything is allocated or copied, and the decoders are fuzzed. The limits in the transport tables are part of the contract: exceeding one closes the connection.
  • The server decides. Clients send commands (held keys, action edges, look deltas, spawn choices), never results. Speed, teleports, damage, ammunition, action rates, team and seat access and command tick windows are enforced by the server.
  • Identity is a key. A player is an Ed25519 key pair made by the client; the player id is a hash of the public key and the name is only a label. The client proves it holds the key inside the handshake, bound to the session. Clients check the server's Ed25519 identity against the listing, the server's /info answer or the join data; a first contact by typed address is trust on first use.
  • No secret in the code. Security must not depend on hiding code. A build string or a content claim is not anti-cheat attestation: a modified client can still aim for you or see through walls, so admins have kick, ban, votes and logs.
  • No admin port on the network. /healthz and /admin listen on loopback only.
  • Names, chat and art are untrusted. Decoded strings and image headers are validated before they are shown.
  • Not protected: traffic analysis (packet sizes and timing are visible on the path), a server address already known to an attacker, and denial of service in general. A server's relay policy always keeps a home host's address out of listings and signalling; it cannot hide an address already known.

Conformance

A compatible implementation is one that a released Battlefront Eternal client or server of the same protocol and simulation accepts, and that accepts them. In practice the simulation rules are the hardest part: a client that predicts must step exactly the rules of the named simulation revision, whose reference is rust/sim at the commit above. Everything a player sees and hears (rendering, sound, menus) is the implementation's own choice.

Must

  • Speak BFE-UDP/1 exactly as the transport tables give it: packet types and layouts, padding, the handshake and its keys, sealing, acknowledgement ranges, stream and datagram framing, and every limit, closing with the listed codes.
  • Send protocol 5, profile snapshot-delta-v1 and simulation bfe-sim-34 in its hello, and refuse a peer whose values differ with close code 3 (update required).
  • Prove its identity with an Ed25519 key in the handshake, and check the other side's identity against what the listing, the typed address or the join data named.
  • Validate every size and count before allocating or copying, and refuse what the receiver checks in the message tables refuse.
  • As a client: send commands, never results; acknowledge a snapshot tick only when all of its required parts arrived; offer a content digest only for content it computed by the digest rules, and otherwise sit a 2005 battle out.
  • As a client: keep the battle loading screen at the shared fixed length (13.5 s for a 2004 battle, the map's prepared duration for a 2005 battle) whatever its load speed, so a faster computer does not get into a battle earlier.
  • As a server: be the authority, enforce the input, rate and access rules, and keep the admission order of the join section.

May

  • Skip an optional 2005 record kind it does not implement, by the extent its carrier gives.
  • Implement only part of the system: a directory reader, a LAN finder, a spectator, a server without punching or relay support.
  • Present the battle in its own way, as long as what it sends is what the protocol allows.

Testing against a real server

Run the reference server and connect to it. Download the server archive from https://get.battlefronteternal.com/downloads/latest/ and check it against that folder's SHA256SUMS, or build rust/bfe-server from the engine repository at the commit above; the server repository has the install script and a Docker image. Prepare game data from your own copy of the game, then start it with bfeserver --serve. It uses UDP 18451 for the game, TCP 18451 for /info, UDP 18452 for LAN discovery, and loopback TCP 18450 for /healthz and /admin; the desktop app's HOST runs the same server on UDP and TCP 18461 (game and /info) and loopback 18460. For tests, keep it off the public directory. GET /healthz on loopback reports multiplayerReady only once the advertised contract is valid and a world is admitted. Join it with the desktop app of the same release to see the reference behaviour, then with your implementation.