net.MaxChannelSize
net.MaxChannelSize
#Overview
name: net.MaxChannelSize
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
The maximum number of network channels allowed across the entire server, if <= 0 the connection DefaultMaxChannelSize will be used.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of net.MaxChannelSize is to control the maximum number of network channels allowed across the entire server in Unreal Engine’s networking system.
This setting variable is primarily used by the networking subsystem of Unreal Engine, specifically within the NetConnection module. It’s referenced in the Engine’s runtime code, indicating its importance for network communication during gameplay.
The value of this variable is set through a console variable (CVar) system. It’s defined as a TAutoConsoleVariable named CVarMaxChannelSize, which allows it to be modified at runtime through console commands or configuration files.
The associated variable CVarMaxChannelSize directly interacts with net.MaxChannelSize. They share the same value and purpose.
Developers must be aware that:
- If the value is set to 0 or less, the system will default to using the connection’s DefaultMaxChannelSize instead.
- This setting affects the entire server, not individual connections.
- Changing this value can impact network performance and resource allocation.
Best practices when using this variable include:
- Carefully consider the implications of changing this value, as it affects server-wide behavior.
- Monitor network performance when adjusting this value to ensure optimal settings.
- Use in conjunction with other networking settings for a comprehensive network optimization strategy.
- Document any changes made to this variable for easier debugging and maintenance.
Regarding the associated variable CVarMaxChannelSize:
The purpose of CVarMaxChannelSize is to provide a runtime-configurable way to set the net.MaxChannelSize value. It’s implemented as a console variable, allowing for dynamic adjustments during development or even in live environments.
This variable is used directly in the UNetConnection::InitChannelData function to determine the channel size for each network connection. If CVarMaxChannelSize is set to a positive value, it overrides the DefaultMaxChannelSize of the connection.
Developers should be aware that changes to CVarMaxChannelSize take effect immediately and can be made through console commands, which can be useful for testing and debugging but should be used cautiously in production environments.
Best practices for CVarMaxChannelSize include:
- Use it for testing and debugging network issues.
- Consider exposing it as a server configuration option for advanced users or server administrators.
- Monitor its usage and impact on server performance when modified.
- Ensure that any custom networking code respects this variable’s value for consistency across the engine.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/NetConnection.cpp:73
Scope: file
Source code excerpt:
TEXT("Randomize initial packet sequence, can provide some obfuscation"));
static TAutoConsoleVariable<int32> CVarMaxChannelSize(TEXT("net.MaxChannelSize"), 0,
TEXT("The maximum number of network channels allowed across the entire server, if <= 0 the connection DefaultMaxChannelSize will be used."));
#if !UE_BUILD_SHIPPING
static TAutoConsoleVariable<int32> CVarForceNetFlush(TEXT("net.ForceNetFlush"), 0,
TEXT("Immediately flush send buffer when written to (helps trace packet writes - WARNING: May be unstable)."));
#endif
#Associated Variable and Callsites
This variable is associated with another variable named CVarMaxChannelSize
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/NetConnection.cpp:73
Scope: file
Source code excerpt:
TEXT("Randomize initial packet sequence, can provide some obfuscation"));
static TAutoConsoleVariable<int32> CVarMaxChannelSize(TEXT("net.MaxChannelSize"), 0,
TEXT("The maximum number of network channels allowed across the entire server, if <= 0 the connection DefaultMaxChannelSize will be used."));
#if !UE_BUILD_SHIPPING
static TAutoConsoleVariable<int32> CVarForceNetFlush(TEXT("net.ForceNetFlush"), 0,
TEXT("Immediately flush send buffer when written to (helps trace packet writes - WARNING: May be unstable)."));
#endif
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/NetConnection.cpp:407
Scope (from outer to inner):
file
function void UNetConnection::InitChannelData
Source code excerpt:
check(!HasAnyFlags(EObjectFlags::RF_ClassDefaultObject | EObjectFlags::RF_ArchetypeObject));
int32 ChannelSize = CVarMaxChannelSize.GetValueOnAnyThread();
if (ChannelSize <= 0)
{
// set from the connection default
ChannelSize = DefaultMaxChannelSize;
// allow the driver to override