Download

multiplayer lag if listen server goes beyond 120fps

Hello, I’ve been developing a multiplayer game to learn networking and C++ in UE4. I’m using advanced sessions plugin to connect players, one of them acting as a listen-server.

However, I’m having the following issue:

I opened the listen server for connections and the listen server’s game fps goes beyond 120. Client One then joins and both are playing with no lag. Then, Client Two joins, as soon as he joins, network lag starts to happen to both him and Client One, things such as delay, movement snapping, etc. and the game becomes unplayable.

Then, if I cap listen server’s fps to be anything under 121, the network lag stops completely. Literally night and day difference, if the listen server’s fps is > 120 (even 121) and there is more than one client connected, the game suffers with unplayable lag. As soon as I cap listen server’s fps to be <= 120, everything is smooth again.

I tried messing around with the fps cap for the clients, and there is no difference; the only difference is when I mess around with the listen server’s fps cap.

As a starter on UE4 C++ and Networking, I have no idea why this is happening, and I wish the game could go beyond 120 fps. Is this behavior normal for UE4? Thanks!

It’s because your clients and server are hammering each other with packets, and the engine has to work hard to keep on top of them all. Adding an extra client more than doubles the Servers’ workload. In a real-world connection setting you would likely never achieve a stable 120Hz update rate anyway. You should frequently package and test multiplayer projects outside of the editor (and preferably with some data-loss/latency simulation).

You can throttle the network tick rates of the client/server without clamping framerate by modifying some config settings (DefaultEngine.ini). These are some sample settings from one of my projects. The tick-rate settings are self-explanatory, the ‘Rate’ setting determines the bits-per-second before a connection is considered ‘Saturated’ (so 10Kbps here)



[/Script/OnlineSubsystemUtils.IpNetDriver]
MaxNetTickRate=60
NetServerMaxTickRate=60
LanServerMaxTickRate=60
NetClientTicksPerSecond=60
bClampListenServerTickRates=true
MaxClientRate=10000
MaxInternetClientRate=10000


The engine doesn’t do any dynamic bandwidth control. If you keep throwing too much data at it you’ll eventually flood the available buffers. Character Movement also struggles at super-high framerates because you can overflow the Saved Move buffer which results in a lot of logspam and corrections.

thank you very much TheJamsh! Didn’t know about anything you said, I’ll do more testing with the config files

Hello TheJamsh. Thanks for your answer!
I’ve been playing with those settings and I noticed that in your settings you have:

However, my netdriver definitions are:

IPNetDriver is set as the fallback driver, and not the main one, since I’m using advanced sessions.

So are those modifiable settings you showed me still valid if I use the steamnetdriver? I really don’t know the difference between both.

Hello TheJamsh. Thanks for your answer!
I’ve been playing with those settings and I noticed that in your settings you have:

However, my netdriver definitions are:

IPNetDriver is set as the fallback driver, and not the main one, since I’m using advanced sessions.

So are those modifiable settings you showed me still valid if I use the steamnetdriver? I really don’t know the difference between both.

should I modify
[/Script/OnlineSubsystemUtils.IpNetDriver] to
[/Script/OnlineSubsystemUtils.SteamNetDriver] for the settings to work, since it is my main driver? thanks!

Hello TheJamsh. Thanks for your answer!
I’ve been playing with those settings and I noticed that in your settings you have:

However, my netdriver definitions are:

IPNetDriver is set as the fallback driver, and not the main one, since I’m using advanced sessions.

So are those modifiable settings you showed me still valid if I use the steamnetdriver? I really don’t know the difference between both.

should I modify
[/Script/OnlineSubsystemUtils.IpNetDriver] to
[/Script/OnlineSubsystemUtils.SteamNetDriver] for the settings to work, since it is my main driver?

https://docs.unrealengine.com/en-US/…ver/index.html this page of the docs shows that USteamNetDriver inherits from UIpNetDriver, that inherits from UNetDriver, so if I apply those configs to IpNetDriver, SteamNetDriver should inherit them all right?

Hello TheJamsh! Turns out you were absolutely right! After packaging and testing with multiple clients and modified tickrate the game plays fine, it had nothing to do with the frame rate going beyond 120. I didn’t even know about netdrivers, and I’ll be reading their docs and be tweaking their values from now on. If it wasn’t for you, I’d be still playing with framerate values! Thanks!