KROYSDOCS
HomeWhat's newv0.1.0
MANUAL / Multiplayer / Network testing

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.

Option--net-sim
VariableKROYS_NET_SIM
Profileslan, broadband, mobile, terrible
01

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.

ProfileLatency each wayJitterLossOther
lan0.5 ms0.2 ms0
broadband40 ms5 ms1%
mobile75 ms20 ms5% in bursts of 30.5% duplicates, 1% reordered, 2 Mbit/s
terrible150 ms50 ms15% in bursts of 22% 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%'
02

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.

03

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
04

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.