net.UseAdaptiveNetUpdateFrequency

net.UseAdaptiveNetUpdateFrequency

#Overview

name: net.UseAdaptiveNetUpdateFrequency

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

It is referenced in 4 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of net.UseAdaptiveNetUpdateFrequency is to control the adaptive network update frequency for actors in Unreal Engine’s networking system. It allows the engine to dynamically adjust the update rate of actors based on their actual replication needs.

This setting variable is primarily used by the networking subsystem of Unreal Engine, specifically within the NetDriver module. The NetDriver is responsible for managing network communications and replication of actors across the network.

The value of this variable is set through a console variable (CVar) system. It’s defined as a TAutoConsoleVariable with a default value of 0, meaning the feature is disabled by default. Developers can enable it by setting the value to 1 through console commands or configuration files.

The associated variable CVarUseAdaptiveNetUpdateFrequency directly interacts with net.UseAdaptiveNetUpdateFrequency. They share the same value and purpose.

Developers must be aware that enabling this feature can significantly impact network performance and behavior. When enabled, the engine will dynamically adjust the NetUpdateFrequency of actors based on how often they actually need to replicate changes. This can lead to reduced network traffic for less frequently updated actors, but may also introduce latency for sudden changes in actor state.

Best practices when using this variable include:

  1. Thoroughly testing the impact on your specific game’s network performance before enabling in production.
  2. Monitoring network statistics to ensure the adaptive frequency doesn’t negatively impact gameplay.
  3. Considering the trade-offs between reduced network traffic and potential increased latency for certain actors.
  4. Using in conjunction with other network optimization techniques for best results.

Regarding the associated variable CVarUseAdaptiveNetUpdateFrequency:

The purpose of CVarUseAdaptiveNetUpdateFrequency is identical to net.UseAdaptiveNetUpdateFrequency. It’s the actual console variable implementation that controls the adaptive network update frequency feature.

This variable is used directly in the UNetDriver class to determine if the adaptive network update frequency is enabled. The IsAdaptiveNetUpdateFrequencyEnabled() function checks the value of this variable to return whether the feature is active.

The value of CVarUseAdaptiveNetUpdateFrequency is set through the console variable system, allowing runtime configuration.

Developers should be aware that this variable is the actual implementation behind the net.UseAdaptiveNetUpdateFrequency setting. Changes to this variable will directly affect the behavior of the adaptive network update frequency system.

Best practices for CVarUseAdaptiveNetUpdateFrequency align with those of net.UseAdaptiveNetUpdateFrequency, as they are essentially the same setting. Developers should use the console command system to modify this value for testing and debugging purposes, and consider exposing it as a configurable option in their game’s settings if adaptive network update frequency is a feature they want to give users control over.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarUseAdaptiveNetUpdateFrequency(
	TEXT( "net.UseAdaptiveNetUpdateFrequency" ), 
	0, 
	TEXT( "If 1, NetUpdateFrequency will be calculated based on how often actors actually send something when replicating" ) );

TAutoConsoleVariable<int32> CVarNetAllowEncryption(
	TEXT("net.AllowEncryption"),
	1,

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Classes/Engine/NetDriver.h:1835

Scope: file

Source code excerpt:

	/**
	 * Returns whether adaptive net frequency is enabled. If enabled, update frequency is allowed to ramp down to MinNetUpdateFrequency for an actor when no replicated properties have changed.
	 * This is currently controlled by the CVar "net.UseAdaptiveNetUpdateFrequency".
	 */
	ENGINE_API static bool IsAdaptiveNetUpdateFrequencyEnabled();

	/** Returns true if adaptive net update frequency is enabled and the given actor is having its update rate lowered from its standard rate. */
	ENGINE_API bool IsNetworkActorUpdateFrequencyThrottled(const AActor* InActor) const;

	/** Returns true if adaptive net update frequency is enabled and the given actor is having its update rate lowered from its standard rate. */
	UE_DEPRECATED(5.3, "Will be made private in a future release, please use version that takes an actor")
	ENGINE_API bool IsNetworkActorUpdateFrequencyThrottled(const FNetworkObjectInfo& InNetworkActor) const;

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

	ECVF_Default);

static TAutoConsoleVariable<int32> CVarUseAdaptiveNetUpdateFrequency(
	TEXT( "net.UseAdaptiveNetUpdateFrequency" ), 
	0, 
	TEXT( "If 1, NetUpdateFrequency will be calculated based on how often actors actually send something when replicating" ) );

TAutoConsoleVariable<int32> CVarNetAllowEncryption(
	TEXT("net.AllowEncryption"),

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

Scope (from outer to inner):

file
function     bool UNetDriver::IsAdaptiveNetUpdateFrequencyEnabled

Source code excerpt:

/*static*/ bool UNetDriver::IsAdaptiveNetUpdateFrequencyEnabled()
{
	const bool bUseAdapativeNetFrequency = CVarUseAdaptiveNetUpdateFrequency.GetValueOnAnyThread() > 0;
	return bUseAdapativeNetFrequency;
}

void UNetDriver::AddNetworkActor(AActor* Actor)
{
	LLM_SCOPE(ELLMTag::Networking);