net.Reliable.Debug

net.Reliable.Debug

#Overview

name: net.Reliable.Debug

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

It is referenced in 5 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of net.Reliable.Debug is to enable debugging and logging of reliable network bunches in Unreal Engine’s networking system. This console variable is used for diagnostic purposes, allowing developers to track and analyze the transmission of reliable network data.

This setting variable is primarily used by the networking subsystem of Unreal Engine, specifically within the data channel and net driver modules. It’s referenced in the Engine module, particularly in the DataChannel.cpp and NetDriver.cpp files.

The value of this variable is set through the console or configuration files. It’s defined as a TAutoConsoleVariable, which means it can be changed at runtime through console commands.

The associated variable CVarNetReliableDebug interacts directly with net.Reliable.Debug. They share the same value and are used interchangeably in the code.

Developers must be aware that this variable has three possible values: 0: No debug output (default) 1: Print bunches as they are sent 2: Print reliable bunch buffer each net update

When using this variable, developers should consider the following best practices:

  1. Use it only for debugging purposes, not in production builds.
  2. Be cautious when enabling it in performance-sensitive scenarios, as it can generate a lot of log output.
  3. Remember to disable it after debugging to avoid unnecessary performance overhead.
  4. Use in conjunction with other networking debug tools for a comprehensive view of network behavior.

Regarding the associated variable CVarNetReliableDebug:

The purpose of CVarNetReliableDebug is to provide a programmatic way to access the net.Reliable.Debug setting within the C++ code. It’s used to check the current debug level and conditionally execute logging code.

This variable is used in the same subsystems as net.Reliable.Debug, primarily in the networking components of the Engine module.

The value of CVarNetReliableDebug is set automatically based on the net.Reliable.Debug console variable. Developers don’t need to set it separately.

CVarNetReliableDebug interacts directly with net.Reliable.Debug, essentially serving as its C++ representation.

When using CVarNetReliableDebug, developers should be aware that it’s often checked in performance-sensitive areas of the networking code. Therefore, any conditional code based on this variable should be lightweight.

Best practices for using CVarNetReliableDebug include:

  1. Use GetValueOnAnyThread() for thread-safe access to the variable’s value.
  2. Consider the performance impact of frequent checks in tight loops.
  3. Use preprocessor directives to exclude debug code in shipping builds, as seen in the provided code examples.

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/DataChannel.cpp:65

Scope: file

Source code excerpt:


TAutoConsoleVariable<int32> CVarNetReliableDebug(
	TEXT("net.Reliable.Debug"),
	0,
	TEXT("Print all reliable bunches sent over the network\n")
	TEXT(" 0: no print.\n")
	TEXT(" 1: Print bunches as they are sent.\n")
	TEXT(" 2: Print reliable bunch buffer each net update"),
	ECVF_Default);

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/DataChannel.cpp:64

Scope: file

Source code excerpt:

extern bool GbNetReuseReplicatorsForDormantObjects;

TAutoConsoleVariable<int32> CVarNetReliableDebug(
	TEXT("net.Reliable.Debug"),
	0,
	TEXT("Print all reliable bunches sent over the network\n")
	TEXT(" 0: no print.\n")
	TEXT(" 1: Print bunches as they are sent.\n")
	TEXT(" 2: Print reliable bunch buffer each net update"),

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/DataChannel.cpp:1479

Scope (from outer to inner):

file
function     FOutBunch* UChannel::PrepBunch

Source code excerpt:


#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
		if (CVarNetReliableDebug.GetValueOnAnyThread() == 1)
		{
			UE_LOG(LogNetTraffic, Warning, TEXT("%s. Reliable: %s"), *Describe(), *Bunch->DebugString);
		}
		if (CVarNetReliableDebug.GetValueOnAnyThread() == 2)
		{
			UE_LOG(LogNetTraffic, Warning, TEXT("%s. Reliable: %s"), *Describe(), *Bunch->DebugString);
			PRAGMA_DISABLE_DEPRECATION_WARNINGS
			PrintReliableBunchBuffer();
			PRAGMA_ENABLE_DEPRECATION_WARNINGS
			UE_LOG(LogNetTraffic, Warning, TEXT(""));

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/DataChannel.cpp:3540

Scope (from outer to inner):

file
function     int64 UActorChannel::ReplicateActor

Source code excerpt:


#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
	if (CVarNetReliableDebug.GetValueOnAnyThread() > 0)
	{
		Bunch.DebugString = FString::Printf(TEXT("%.2f ActorBunch: %s"), Connection->Driver->GetElapsedTime(), *Actor->GetName() );
	}
#endif

#if UE_NET_REPACTOR_NAME_DEBUG

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/NetDriver.cpp:2699

Scope (from outer to inner):

file
function     void UNetDriver::ProcessRemoteFunctionForChannelPrivate

Source code excerpt:


#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
	extern TAutoConsoleVariable<int32> CVarNetReliableDebug;

	if (CVarNetReliableDebug.GetValueOnAnyThread() > 0)
	{
		Bunch.DebugString = FString::Printf(TEXT("%.2f RPC: %s - %s"), Connection->Driver->GetElapsedTime(), *GetFullNameSafe(TargetObj), *GetNameSafe(Function));
	}
#endif

	// Init bunch for rpc