net.IpNetDriverReceiveThreadQueueMaxPackets
net.IpNetDriverReceiveThreadQueueMaxPackets
#Overview
name: net.IpNetDriverReceiveThreadQueueMaxPackets
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
If net.IpNetDriverUseReceiveThread is true, the maximum number of packets that can be waiting in the queue. Additional packets received will be dropped.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of net.IpNetDriverReceiveThreadQueueMaxPackets is to set the maximum number of packets that can be waiting in the queue when the IpNetDriver is using a separate receive thread.
This setting variable is primarily used by the networking system in Unreal Engine, specifically within the OnlineSubsystemUtils plugin. It’s part of the IpNetDriver implementation, which handles network communications.
The value of this variable is set as a console variable (CVar) with a default value of 1024. It can be adjusted at runtime through the console or configuration files.
The associated variable CVarNetIpNetDriverReceiveThreadQueueMaxPackets directly interacts with this setting. It’s used to initialize the ReceiveQueue in the UIpNetDriver::FReceiveThreadRunnable constructor.
Developers must be aware that this variable only takes effect when net.IpNetDriverUseReceiveThread is set to true. If the queue size exceeds the value set by this variable, additional incoming packets will be dropped, potentially causing loss of network data.
Best practices when using this variable include:
- Monitoring network performance and adjusting the value based on the specific needs of the game.
- Considering the trade-off between memory usage and potential packet loss when setting this value.
- Ensuring that net.IpNetDriverUseReceiveThread is set to true for this setting to have any effect.
Regarding the associated variable CVarNetIpNetDriverReceiveThreadQueueMaxPackets:
The purpose of CVarNetIpNetDriverReceiveThreadQueueMaxPackets is to provide a programmatic way to access and modify the net.IpNetDriverReceiveThreadQueueMaxPackets setting within the C++ code.
This variable is used within the OnlineSubsystemUtils plugin, specifically in the IpNetDriver implementation.
The value of this variable is set when the console variable net.IpNetDriverReceiveThreadQueueMaxPackets is initialized, and it can be accessed or modified at runtime using the GetValueOnAnyThread() method.
It directly interacts with the net.IpNetDriverReceiveThreadQueueMaxPackets setting, essentially serving as its C++ representation.
Developers should be aware that changes to this variable will affect the maximum size of the receive queue in the IpNetDriver’s receive thread.
Best practices for using this variable include:
- Using GetValueOnAnyThread() when accessing the value to ensure thread-safe operations.
- Considering the impact on memory usage and network performance when modifying this value.
- Coordinating any changes with the net.IpNetDriverReceiveThreadQueueMaxPackets console variable to maintain consistency.
#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:61
Scope: file
Source code excerpt:
TAutoConsoleVariable<int32> CVarNetIpNetDriverReceiveThreadQueueMaxPackets(
TEXT("net.IpNetDriverReceiveThreadQueueMaxPackets"),
1024,
TEXT("If net.IpNetDriverUseReceiveThread is true, the maximum number of packets that can be waiting in the queue. Additional packets received will be dropped."));
TAutoConsoleVariable<int32> CVarNetIpNetDriverReceiveThreadPollTimeMS(
TEXT("net.IpNetDriverReceiveThreadPollTimeMS"),
250,
#Associated Variable and Callsites
This variable is associated with another variable named CVarNetIpNetDriverReceiveThreadQueueMaxPackets
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Plugins/Online/OnlineSubsystemUtils/Source/OnlineSubsystemUtils/Private/IpNetDriver.cpp:60
Scope: file
Source code excerpt:
TEXT("If true, the IpNetDriver will call the socket's RecvFrom function on a separate thread (not the game thread)"));
TAutoConsoleVariable<int32> CVarNetIpNetDriverReceiveThreadQueueMaxPackets(
TEXT("net.IpNetDriverReceiveThreadQueueMaxPackets"),
1024,
TEXT("If net.IpNetDriverUseReceiveThread is true, the maximum number of packets that can be waiting in the queue. Additional packets received will be dropped."));
TAutoConsoleVariable<int32> CVarNetIpNetDriverReceiveThreadPollTimeMS(
TEXT("net.IpNetDriverReceiveThreadPollTimeMS"),
#Loc: <Workspace>/Engine/Plugins/Online/OnlineSubsystemUtils/Source/OnlineSubsystemUtils/Private/IpNetDriver.cpp:2005
Scope (from outer to inner):
file
function UIpNetDriver::FReceiveThreadRunnable::FReceiveThreadRunnable
Source code excerpt:
UIpNetDriver::FReceiveThreadRunnable::FReceiveThreadRunnable(UIpNetDriver* InOwningNetDriver)
: ReceiveQueue(CVarNetIpNetDriverReceiveThreadQueueMaxPackets.GetValueOnAnyThread())
, bIsRunning(true)
, OwningNetDriver(InOwningNetDriver)
{
SocketSubsystem = OwningNetDriver->GetSocketSubsystem();
}