Skip to content

Harden multiplayer networking and adapt frame timing - #83

Closed
ZivDero wants to merge 14 commits into
OpenTS-Developers:mainfrom
ZivDero:network-hardening
Closed

Harden multiplayer networking and adapt frame timing#83
ZivDero wants to merge 14 commits into
OpenTS-Developers:mainfrom
ZivDero:network-hardening

Conversation

@ZivDero

@ZivDero ZivDero commented Aug 30, 2026

Copy link
Copy Markdown
Member

Reworks thbe networking:

  1. Hardens network packet handling
    Defended against too small, too large packets, malformed packets, unknown packets.
    Also covers the entire abuse set of sending packets as another player's house, so now the only way to cheat here is to fake stuff on the actual network transport layer.

  2. Improve connection-level timing
    Partly based on Add fast retransmit of lost packets and packet redundancy CnCNet/yrpp-spawner#75
    Improves actual connection timing to better reflect connection quality on a per-connection basis to not stall everyone unnecessarily.

  3. Improve lockstep timing
    An evolution of "protocol zero", improving the selection of FrameSendRate and MaxAhead based on the connection quality.
    Includes downgrading for bad connections and limited upgrading (to prevent ping-pong when connection quality varies).

Closes #21, closes #22, closes #23, closes #24, closes #25, closes #26, closes #35

@ZivDero ZivDero changed the title Network hardening Harden multiplayer networking and adapt frame timing Aug 30, 2026
@ZivDero
ZivDero marked this pull request as ready for review August 30, 2026 23:25
@github-actions

Copy link
Copy Markdown

Development builds of 4230f5a:

The links work without a GitHub account. Artifacts expire after 90 days, and this comment follows the latest successful build.

@ZivDero
ZivDero marked this pull request as draft August 31, 2026 08:18
@ZivDero

ZivDero commented Aug 31, 2026

Copy link
Copy Markdown
Member Author

Gonna split this up

@ZivDero ZivDero closed this Aug 31, 2026
@11EJDE11

Copy link
Copy Markdown
Contributor

Nice. Stacked PRs might help? https://github.github.com/gh-stack/

I tested it earlier and it was a worse experience. Added some logging and fed them to Codex:

So my conclusion is: the PR’s adaptive approach can work, but its current RTT estimator has a sampling-starvation bug
under a sudden latency increase. It then chooses exactly the wrong timing—too little headroom and too much packet
traffic. The next fix should age or invalidate RTT samples when no eligible acknowledgements arrive, carry
retransmission backoff into subsequent packets, and make repeated retransmissions force conservative timing rather
than continuing to report a fresh 10 ms RTT.
networkstats.zip

Also there were issues getting mpdebug working. I haven't checked or verified, but Codex said:

• It’s legacy design, not a LAN issue. MPDEBUG was originally a reserved panel rather than a true overlay:

  • Physical output: 640×480.
  • Gameplay viewport: 640×400.
  • Diagnostics: rows 400–479.

The bgfx renderer migration accidentally collapsed those dimensions. C:/Users/QWE/source/repos/OpenTS/code/
startup.cpp:605 now sets the entire video surface to 640×400 before creating it, while C:/Users/QWE/source/repos/
OpenTS/code/mainloop.cpp:841 draws from y=400 onward. Everything is therefore clipped outside valid rows 0–399.

Simply removing the resolution override is insufficient: Multiplayer_Debug_Print() currently runs before Map.Render(),
whose final blit would overwrite the diagnostics.

@ZivDero

ZivDero commented Aug 31, 2026

Copy link
Copy Markdown
Member Author

MPDEBUG is finnicky in TS yeah. In Vinifera I implemented an ImGui window that included it. Maybe now is a good time for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants