net.RecvMultiCapacity
net.RecvMultiCapacity
#Overview
name: net.RecvMultiCapacity
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
When RecvMulti is enabled, this is the number of packets it is allocated to handle per call - bigger is better (especially under a DDoS), but keep an eye on memory cost.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of net.RecvMultiCapacity is to control the capacity of the RecvMulti functionality in Unreal Engine’s networking system. It determines the number of packets that can be handled per call when RecvMulti is enabled.
This setting variable is primarily used by the networking subsystem, specifically within the OnlineSubsystemUtils plugin. It’s particularly relevant for the IpNetDriver, which is responsible for managing network connections in Unreal Engine.
The value of this variable is set through a console variable (CVarRecvMultiCapacity) with a default value of 2048. This means that by default, RecvMulti is allocated to handle 2048 packets per call.
The associated variable CVarRecvMultiCapacity interacts directly with net.RecvMultiCapacity. It’s used to retrieve the value of the console variable in the C++ code.
Developers must be aware that this variable has a significant impact on network performance and memory usage. A larger value can improve performance, especially under high network load or potential DDoS attacks, but it also increases memory consumption.
Best practices when using this variable include:
- Adjusting the value based on the specific needs of the game or application.
- Monitoring memory usage when increasing this value.
- Testing thoroughly with different values to find the optimal balance between performance and resource usage.
- Considering the target platform’s capabilities when setting this value.
Regarding the associated variable CVarRecvMultiCapacity:
The purpose of CVarRecvMultiCapacity is to provide programmatic access to the net.RecvMultiCapacity console variable within the C++ code.
It’s used in the OnlineSubsystemUtils plugin, specifically in the IpNetDriver implementation.
The value of CVarRecvMultiCapacity is set when the console variable net.RecvMultiCapacity is initialized or changed.
It interacts directly with the net.RecvMultiCapacity console variable, serving as a C++ interface to access its value.
Developers should be aware that changes to net.RecvMultiCapacity will be reflected in CVarRecvMultiCapacity.
Best practices for using CVarRecvMultiCapacity include:
- Using GetValueOnAnyThread() to retrieve the current value safely from any thread.
- Considering caching the value if it’s accessed frequently, to avoid repeated calls to GetValueOnAnyThread().
- Being aware that the value can change at runtime if the console variable is modified.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Plugins/Online/OnlineSubsystemUtils/Source/OnlineSubsystemUtils/Private/IpNetDriver.cpp:77
Scope: file
Source code excerpt:
TAutoConsoleVariable<int32> CVarRecvMultiCapacity(
TEXT("net.RecvMultiCapacity"),
2048,
TEXT("When RecvMulti is enabled, this is the number of packets it is allocated to handle per call - ")
TEXT("bigger is better (especially under a DDoS), but keep an eye on memory cost."));
TAutoConsoleVariable<int32> CVarNetUseRecvTimestamps(
TEXT("net.UseRecvTimestamps"),
#Associated Variable and Callsites
This variable is associated with another variable named CVarRecvMultiCapacity
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Plugins/Online/OnlineSubsystemUtils/Source/OnlineSubsystemUtils/Private/IpNetDriver.cpp:76
Scope: file
Source code excerpt:
TEXT("improving performance and also allowing retrieval of timestamp information."));
TAutoConsoleVariable<int32> CVarRecvMultiCapacity(
TEXT("net.RecvMultiCapacity"),
2048,
TEXT("When RecvMulti is enabled, this is the number of packets it is allocated to handle per call - ")
TEXT("bigger is better (especially under a DDoS), but keep an eye on memory cost."));
TAutoConsoleVariable<int32> CVarNetUseRecvTimestamps(
#Loc: <Workspace>/Engine/Plugins/Online/OnlineSubsystemUtils/Source/OnlineSubsystemUtils/Private/IpNetDriver.cpp:957
Scope (from outer to inner):
file
function bool UIpNetDriver::InitBase
Source code excerpt:
ERecvMultiFlags RecvMultiFlags = bRetrieveTimestamps ? ERecvMultiFlags::RetrieveTimestamps : ERecvMultiFlags::None;
int32 MaxRecvMultiPackets = FMath::Max(32, CVarRecvMultiCapacity.GetValueOnAnyThread());
RecvMultiState = SocketSubsystem->CreateRecvMulti(MaxRecvMultiPackets, MAX_PACKET_SIZE, RecvMultiFlags);
FArchiveCountMem MemArc(nullptr);
RecvMultiState->CountBytes(MemArc);