net.UseRecvTimestamps
net.UseRecvTimestamps
#Overview
name: net.UseRecvTimestamps
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
If true and if net.UseRecvMulti is also true, on a Unix/Linux platform, the kernel timestamp will be retrieved for each packet received, providing more accurate ping calculations.
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of net.UseRecvTimestamps is to enable more accurate ping calculations by retrieving kernel timestamps for received packets on Unix/Linux platforms. This setting is specifically designed for network-related functionality within the Unreal Engine.
This setting variable is primarily used in the OnlineSubsystemUtils plugin, specifically within the IpNetDriver module. It’s part of the networking subsystem of Unreal Engine 5.
The value of this variable is set through a console variable (CVarNetUseRecvTimestamps) with a default value of 0 (disabled). It can be changed at runtime through console commands or programmatically.
This variable interacts closely with another setting, net.UseRecvMulti. Both need to be true for the timestamp retrieval to be active. Additionally, it’s associated with the CVarNetUseRecvTimestamps variable, which is used to access its value in the code.
Developers must be aware that:
- This feature is platform-specific (Unix/Linux only).
- It requires net.UseRecvMulti to be true as well.
- Enabling this feature may have performance implications, as it involves additional system calls to retrieve timestamps.
Best practices when using this variable include:
- Only enable it when more accurate ping calculations are necessary.
- Monitor performance impact when enabled, especially in high-traffic network scenarios.
- Ensure that net.UseRecvMulti is also set to true when enabling this feature.
Regarding the associated variable CVarNetUseRecvTimestamps:
The purpose of CVarNetUseRecvTimestamps is to provide programmatic access to the net.UseRecvTimestamps setting within the C++ code.
This variable is used in the IpNetDriver to check if timestamp retrieval should be enabled and to configure the network resolver accordingly.
The value of CVarNetUseRecvTimestamps is set automatically based on the net.UseRecvTimestamps console variable.
It interacts directly with the Resolver object, setting whether to retrieve timestamps or not.
Developers should be aware that this variable is accessed using the GetValueOnAnyThread() method, which suggests it’s designed for multi-threaded access.
Best practices for using CVarNetUseRecvTimestamps include:
- Use GetValueOnAnyThread() for thread-safe access to its value.
- Consider caching the value if it’s accessed frequently in performance-critical code sections.
- Be aware that changes to this variable at runtime will affect the behavior of the network subsystem.
#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:83
Scope: file
Source code excerpt:
TAutoConsoleVariable<int32> CVarNetUseRecvTimestamps(
TEXT("net.UseRecvTimestamps"),
0,
TEXT("If true and if net.UseRecvMulti is also true, on a Unix/Linux platform, ")
TEXT("the kernel timestamp will be retrieved for each packet received, providing more accurate ping calculations."));
TAutoConsoleVariable<float> CVarRcvThreadSleepTimeForWaitableErrorsInSeconds(
TEXT("net.RcvThreadSleepTimeForWaitableErrorsInSeconds"),
#Associated Variable and Callsites
This variable is associated with another variable named CVarNetUseRecvTimestamps
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Plugins/Online/OnlineSubsystemUtils/Source/OnlineSubsystemUtils/Private/IpNetDriver.cpp:82
Scope: file
Source code excerpt:
TEXT("bigger is better (especially under a DDoS), but keep an eye on memory cost."));
TAutoConsoleVariable<int32> CVarNetUseRecvTimestamps(
TEXT("net.UseRecvTimestamps"),
0,
TEXT("If true and if net.UseRecvMulti is also true, on a Unix/Linux platform, ")
TEXT("the kernel timestamp will be retrieved for each packet received, providing more accurate ping calculations."));
TAutoConsoleVariable<float> CVarRcvThreadSleepTimeForWaitableErrorsInSeconds(
#Loc: <Workspace>/Engine/Plugins/Online/OnlineSubsystemUtils/Source/OnlineSubsystemUtils/Private/IpNetDriver.cpp:949
Scope (from outer to inner):
file
function bool UIpNetDriver::InitBase
Source code excerpt:
if (bSupportsRecvMulti)
{
bool bRetrieveTimestamps = CVarNetUseRecvTimestamps.GetValueOnAnyThread() != 0;
if (bRetrieveTimestamps)
{
Resolver->SetRetrieveTimestamp(true);
}
#Loc: <Workspace>/Engine/Plugins/Online/OnlineSubsystemUtils/Source/OnlineSubsystemUtils/Private/IpNetDriver.cpp:1074
Scope (from outer to inner):
file
function void UIpNetDriver::TickDispatch
Source code excerpt:
ISocketSubsystem* SocketSubsystem = GetSocketSubsystem();
bool bRetrieveTimestamps = CVarNetUseRecvTimestamps.GetValueOnAnyThread() != 0;
// Process all incoming packets
for (FPacketIterator It(this); It; ++It)
{
FReceivedPacketView ReceivedPacket;
FInPacketTraits& ReceivedTraits = ReceivedPacket.Traits;