Test multiplayer browser games under real-world network conditions. Simulate latency, jitter, packet loss, duplication, reordering and outages with a seeded simulator (wifi, 4G, 3G, far away, terrible profiles), run two or more clients, and check sync, prediction and reconciliation, interpolation, disconnects and rejoin, cheating and trust, and bandwidth. Use for multiplayer or Bash "playing to...
Download skill (.zip) Files on GitHubGame network testing
Local testing has 0 ms latency, so every multiplayer game “works” on localhost. Always test with a bad network. For Bash multiplayer specifics (rooms, shared state), read Bash’s playing-together skill first.
Simulate the network
assets/net-sim.js wraps any message channel (tested). It’s seeded, so a bad run can be replayed:
import { simulate, wrapWebSocket, PROFILES } from "./net-sim.js";
const sock = wrapWebSocket(new WebSocket(url), PROFILES.mobile3g, { seed: 7 }); // use sock.send / sock.onmessage like a WebSocket
sock.net.set(PROFILES.terrible); // change mid-game
sock.net.pause(3000); // 3 s outage (tunnel / phone switching networks)
console.log(sock.net.stats()); // sent, dropped, duplicated…
Enable it with a URL flag (?net=mobile3g&seed=7) so you can test in the preview without code changes.
Profiles: perfect, lan, wifi (30 ms), mobile4g (70 ms), mobile3g (150 ms, 3% loss), farAway (250 ms), terrible (400 ms ± 200, 15% loss).
Chrome DevTools network throttling also works but only adds latency to HTTP, not to WebSocket messages.
Test with several clients
- Two browser windows / tabs (the viewer’s preview plus a Playwright tab for 2D games), or several Playwright pages in one run.
- Different profiles per client (one on
wifi, one onmobile3g): that’s where unfairness shows.
What to check
| Area | Pass when |
|---|---|
| Responsiveness | Own movement feels instant at 150 ms (client prediction), not delayed by the round trip |
| Smoothness | Other players move smoothly (interpolation ~100 ms behind), no teleporting at 3% loss |
| Reconciliation | Corrections are small and blended, no rubber-banding on mobile4g |
| Consistency | Score, health, pickups agree on all clients after 5 minutes; no double pickups (duplicates!) |
| Order | Out-of-order messages don’t undo newer state (sequence numbers / timestamps) |
| Outage | 3 s pause: game shows “reconnecting”, recovers and resyncs without a refresh |
| Disconnect | Leaving player is removed or replaced by a bot; host leaving doesn’t end everyone’s game (if possible) |
| Rejoin | Refresh mid-game: rejoins the same room with the right state |
| Trust | Server or host validates moves, scores and names; clients can’t set their own score or see hidden info |
| Bandwidth | Messages per second and bytes per message reasonable (send inputs or deltas at 10–30 Hz, not full state at 60 Hz) |
Report
List the profiles tested, the number of clients and the duration, and what broke, with a seed to reproduce it:
“mobile3g, seed 7, 2 clients, 5 min: pickups doubled once (duplicate message, no ID check). Fixed with message IDs; re-ran clean.”