Skip to content

Feature: Allow simulating outbound networking #579

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

Niaobu
Copy link
Contributor

@Niaobu Niaobu commented Jul 1, 2025

Summary

This PR allows simulating packet loss and delay of outbound packets in addition to the existing inbound latency & loss.
It also adds a new SIMULATE_NETWORK compiler flag that enables network latency and packet loss simulation features in release builds, providing an alternative to requiring DEBUG mode.

Background

We need to be able to test packet loss from the client to the server, and doing this per client is practical compared to setting simulation delay/loss on the server (which applies to all clients).

We are also building internal release builds in Unity and want the ability to simulate latency and packet loss in these builds. Being able to add this debug code without defining DEBUG seems practical and powerful.

Implementation

I have hooked into NetManager.SendRaw to allow dropped/delayed packets to respect resending etc.

Thanks again for a great library!

Edit:
I have cleaned up the initial version and changed simulated latency to apply half the value on outbound and half on inbound packets. This way, a server will correctly interpret the client as being 1/2 Round Trip away, and the total latency remains backwards compatible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant