n.IpNetDriverMaxFrameTimeBeforeLogging

n.IpNetDriverMaxFrameTimeBeforeLogging

#Overview

name: n.IpNetDriverMaxFrameTimeBeforeLogging

This variable is created as a Console Variable (cvar).

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of n.IpNetDriverMaxFrameTimeBeforeLogging is to set a threshold for logging warnings when the processing time for networking data in a single frame exceeds a specified duration. This setting is primarily used for monitoring and debugging network performance in Unreal Engine.

This setting variable is used in the Online Subsystem Utils plugin, specifically within the IpNetDriver module. The IpNetDriver is responsible for handling network communications in Unreal Engine.

The value of this variable is set through a console variable (CVar) using FAutoConsoleVariableRef. It’s initialized with a default value of 10 seconds, but can be modified at runtime through the console or configuration files.

The variable n.IpNetDriverMaxFrameTimeBeforeLogging is directly associated with GIpNetDriverLongFramePrintoutThresholdSecs. They share the same value, with GIpNetDriverLongFramePrintoutThresholdSecs being the actual float variable used in the code.

Developers should be aware that this variable affects logging behavior and not the actual network performance. It’s a diagnostic tool to help identify potential network processing bottlenecks.

Best practices when using this variable include:

  1. Adjusting the value based on the specific needs of the project and expected network conditions.
  2. Using it in conjunction with other network profiling tools to get a comprehensive view of network performance.
  3. Monitoring logs during development and testing to catch any unexpected network processing delays.

Regarding the associated variable GIpNetDriverLongFramePrintoutThresholdSecs:

Its purpose is to store the actual threshold value used in the code for comparing against network processing time.

It’s used directly in the IpNetDriver module, specifically in the FPacketIterator destructor to check if the packet receiving time exceeds the threshold.

The value is set through the n.IpNetDriverMaxFrameTimeBeforeLogging console variable.

It interacts primarily with the network packet receiving process, triggering a warning log when exceeded.

Developers should be aware that modifying this variable directly in code is not recommended, as it’s intended to be controlled via the console variable.

Best practices include using the console variable for adjustments rather than modifying the GIpNetDriverLongFramePrintoutThresholdSecs variable directly in code, and considering the impact on log verbosity when setting very low values.

#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:50

Scope: file

Source code excerpt:


FAutoConsoleVariableRef GIpNetDriverLongFramePrintoutThresholdSecsCVar(
	TEXT("n.IpNetDriverMaxFrameTimeBeforeLogging"),
	GIpNetDriverLongFramePrintoutThresholdSecs,
	TEXT("Time to spend processing networking data in a single frame before an output log warning is printed (in seconds)\n")
	TEXT(" default: 10 s"));

TAutoConsoleVariable<int32> CVarNetIpNetDriverUseReceiveThread(
	TEXT("net.IpNetDriverUseReceiveThread"),

#Associated Variable and Callsites

This variable is associated with another variable named GIpNetDriverLongFramePrintoutThresholdSecs. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Plugins/Online/OnlineSubsystemUtils/Source/OnlineSubsystemUtils/Private/IpNetDriver.cpp:47

Scope: file

Source code excerpt:


// Time before the time taken in a single frame is printed out (in seconds)
float GIpNetDriverLongFramePrintoutThresholdSecs = 10.0f;

FAutoConsoleVariableRef GIpNetDriverLongFramePrintoutThresholdSecsCVar(
	TEXT("n.IpNetDriverMaxFrameTimeBeforeLogging"),
	GIpNetDriverLongFramePrintoutThresholdSecs,
	TEXT("Time to spend processing networking data in a single frame before an output log warning is printed (in seconds)\n")
	TEXT(" default: 10 s"));

TAutoConsoleVariable<int32> CVarNetIpNetDriverUseReceiveThread(
	TEXT("net.IpNetDriverUseReceiveThread"),
	0,

#Loc: <Workspace>/Engine/Plugins/Online/OnlineSubsystemUtils/Source/OnlineSubsystemUtils/Private/IpNetDriver.cpp:268

Scope (from outer to inner):

file
class        class FPacketIterator
function     ~FPacketIterator

Source code excerpt:

		const float DeltaReceiveTime = float(FPlatformTime::Seconds() - StartReceiveTime);

		if (DeltaReceiveTime > GIpNetDriverLongFramePrintoutThresholdSecs)
		{
			UE_LOG(LogNet, Warning, TEXT("Took too long to receive packets. Time: %2.2f %s"), DeltaReceiveTime, *Driver->GetName());
		}
	}

	FORCEINLINE FPacketIterator& operator++()