Network testing
Put any program behind simulated latency, jitter, loss and bandwidth limits, reproduce a session exactly from its seed, and run the network test suite with fuzzing and soaks.
Simulated conditions
Every program takes --net-sim with a profile, key=value items, or both; later items win. Prefix a key with in. or out. for one direction.
| Profile | Latency each way | Jitter | Loss | Other |
|---|---|---|---|---|
lan | 0.5 ms | 0.2 ms | 0 | |
broadband | 40 ms | 5 ms | 1% | |
mobile | 75 ms | 20 ms | 5% in bursts of 3 | 0.5% duplicates, 1% reordered, 2 Mbit/s |
terrible | 150 ms | 50 ms | 15% in bursts of 2 | 2% duplicates, 5% reordered, 512 kbit/s |
Keys: latency, rtt, jitter, loss, dup, reorder, burst, reorder-delay, queue, bandwidth, seed. Each program prints the effective conditions as a spec that reproduces them exactly. In the editor, the Network panel's Client tab has Network Conditions for the editor client's next connect. Simulation is for testing only.
PowerShell
KroysDedicatedServer --bind 127.0.0.1 --net-sim mobile KroysServerDebug --net-sim "latency=80,jitter=20,loss=2%" KroysGameClient --connect 127.0.0.1:7777 --net-sim "terrible,seed=7" $env:KROYS_NET_SIM = 'broadband,in.loss=5%'
Keep tests on this machine
--bind 127.0.0.1, or the KROYS_NET_BIND environment variable, keeps every socket on loopback: no firewall prompts and nothing reachable from outside.
The test suite
The engine's network tests run in the normal test suite: the conditioner itself, a matrix of handshake, reliable delivery, replication, prediction and lag compensation under every profile, packet fuzzing of the parsers and live sessions, and a short soak.
PowerShell
ctest --test-dir build -C Debug -L KroysNetworkSim --output-on-failure powershell -File Tools/RunNetworkFuzz.ps1 -Iterations 2000000 -Seed 1 -Seeds 4 powershell -File Tools/RunNetworkSoak.ps1 -Minutes 30 -Clients 8 -NetProfile mobile
Reproduce a failure
Results name their profile and seed (handshake+reliable [mobile, seed 602]). Run the case again with that seed and it replays exactly: the transport is in-process and time is virtual.
Fuzzing inputs that broke something are saved; KroysNetworkStress replay <file> says which still fail, and once fixed they join the regression corpus.
PowerShell
build\bin\Debug\KroysNetworkStress.exe matrix --seed 602 --seeds 1 --profiles mobile --quick
KroysEngine 0.1.0 documentation, built from the engine repository by Tools/BuildDocsSite.py.