Blast Arena
Secure real-time multiplayer over DDS (Data Distribution Service)
A Bomberman-style multiplayer game for 2 to 5 players, written in C on Cyclone DDS, OpenGL and GLFW. It started from the Low-Level Programming course baseline, and we rebuilt it into a server-authoritative, encrypted, smooth-running real-time simulation. Team of 2, with Soh Wei Jie.
The starting point
The course gave us a working but basic client and server. It had three problems we set out to fix.
- Both programs busy-waited, so an empty server used about two full CPU cores just spinning.
- Movement depended on when messages happened to arrive, so players froze and then jumped forward, which looks like rubberbanding.
- There was no security. Anyone on the network could join, read every message, or send fake game state.
Architecture
One authoritative server and up to five clients share a single DDS domain. Nobody sends to an address. Each program publishes samples on named topics, and every reader of that topic receives them. Clients only send their keys, and the server decides movement, bombs, explosions and deaths, so a modified client cannot cheat.

Each topic gets the Quality of Service (QoS) that fits its job.
| Topic | Direction | QoS | Why |
|---|---|---|---|
| JoinRequest | client to server | reliable, keep last 1 | must arrive |
| JoinResponse | server to clients | reliable, keep last 1 | each client reads only the reply matching its own random nonce |
| Input | client to server | reliable, keep last 1 | only the newest input matters, and disposing it means the player left |
| GameState | server to clients | best effort, keep last 1 | a lost snapshot is replaced 33 ms later, so resending would only add lag |
| MapState | server to clients | reliable, transient local | sent only when a tile changes, and late joiners still get the current map |
Neither program busy-waits any more. The server sleeps to an absolute deadline for a steady 60 Hz tick, and both programs block their network thread on a DDS WaitSet until data arrives.
Smooth movement without rubberbanding
Snapshots leave the server every 33 ms but arrive unevenly, anywhere from 15 to 80 ms apart on WSL. Drawing them as they arrived made players freeze whenever one was late, then jump to catch up. The fix is the approach most real-time games use.
- Keep the last 8 snapshots in a ring buffer, each tagged with its server tick.
- Estimate the offset between the server clock and the local clock from the fastest arrivals, and adjust it by at most 1 ms per snapshot so corrections are invisible.
- Draw the world 80 ms in the past, interpolating between the two snapshots around that moment. A late snapshot is not needed yet, so nothing freezes.
- Draw bombs, flames, the map and the HUD from the same delayed snapshot, so a bomb never appears before the player who dropped it.
Measured with a simulated walk at 60 fps and random delivery jitter.
| Jitter | Before: freezes | Before: biggest jump | After: freezes | After: biggest jump |
|---|---|---|---|---|
| 0 to 10 ms | 0 | 2.1x a normal step | 0 | 1.0x |
| 0 to 30 ms | 54 | 3.9x | 0 | 1.06x |
| 0 to 45 ms | 96 | 5.1x | 0 | 1.12x |
Bomb presses are sent as a counter rather than a pressed flag. With keep last 1, a quick tap between two messages could be overwritten, but a counter cannot lose a press, and a repeated message never drops a second bomb.
Performance
- Inputs are sent only when keys change, plus a 1 second heartbeat, instead of every 10 ms while a key is held.
- One GameState message carries every player, and the map has its own topic that is only sent when it changes.
- The lock is held only for in-memory copies, never across network calls.
- Messages use fixed-size arrays and bounded strings, so there is no heap allocation per sample.
- Movement is frame-rate independent, measured in tiles per second.


Security
DDS Security adds three layers, turned on with a single config file and no changes to the game code.

| Threat | Protection |
|---|---|
| An unknown program joins the game | Only participants with a certificate signed by our certificate authority are accepted |
| Someone reads the network traffic | Discovery and all topic data are encrypted with AES-GCM |
| A client sends a fake map or game state | Signed permissions only let the server publish game state, map and join replies |
| A valid client controls another player | Each player slot is bound to the participant that joined, and mismatched inputs are rejected and logged |
| Tampered permission files | Both files are signed, and DDS refuses to start if a signature fails |
| Malformed messages | Player ids are bounds-checked, unknown key bits rejected, and names truncated and made printable |


New players join with a one-time code. The host hands out a player certificate only to someone with the right code, and stops after 20 wrong tries.
Testing
- 13 tests with 99 checks on the game rules, covering the map, movement, bombs, explosions, chain reactions, power-ups, rounds, timeouts and snapshots.
- 17 checks on interpolation, including reordering, server restart, respawn and the jitter simulation.
- Every certificate verified with strict OpenSSL checks, an intruder without a certificate shown never joining, and a one-character change to the permissions file shown stopping the server.
- Builds with AddressSanitizer and UndefinedBehaviorSanitizer, and runs under Valgrind.
Known limitations
- There is no client-side prediction, and the world is drawn 80 ms in the past, so your own player reacts about 100 ms after a key press. That is fine on a LAN.
- All clients share one certificate authority whose key stays on the host, so the host can sign anything.
- The join code is about 40 bits, stretched with PBKDF2. Someone recording the exchange could try to guess it offline, which is acceptable for a LAN game but is why a real system would use TLS or a PAKE.