NetClientTicksPerSecond

NetClientTicksPerSecond

#Overview

name: NetClientTicksPerSecond

The value of this variable can be defined or overridden in .ini config files. 1 .ini config file referencing this setting variable.

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of NetClientTicksPerSecond is to control the frequency at which the server updates client connections in Unreal Engine’s networking system. This setting is used to manage network performance and bandwidth usage.

This setting variable is primarily relied upon by Unreal Engine’s networking subsystem, specifically within the UNetDriver class, which is responsible for managing network connections and replication.

The value of this variable is set in the Engine configuration files, as indicated by the UPROPERTY(globalconfig) decorator in the UEngine class definition.

NetClientTicksPerSecond interacts with other variables such as DeltaSeconds (the time elapsed since the last frame) and DeltaTimeOverflow (accumulated time when no clients were ticked in a frame). It’s used to calculate ClientUpdatesThisFrame, which determines how many clients should be updated in the current frame.

Developers must be aware that this variable directly impacts network performance and server load. Setting it too high may lead to increased bandwidth usage and potential server performance issues, while setting it too low may result in less responsive gameplay for clients.

Best practices when using this variable include:

  1. Carefully balancing it with other network settings to optimize performance and responsiveness.
  2. Testing thoroughly with various network conditions to ensure smooth gameplay.
  3. Considering different values for LAN and internet play, as the code suggests a higher update rate for LAN play.
  4. Monitoring server performance and bandwidth usage to fine-tune this setting.
  5. Being cautious when modifying this value, as it can significantly impact the game’s networking behavior.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/BaseEngine.ini:299, section: [/Script/Engine.Engine]

#References in C++ code

#Callsites

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

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

Scope (from outer to inner):

file
class        class UEngine : public UObject , public FExec

Source code excerpt:

	/** Number of times to tick each client per second */
	UPROPERTY(globalconfig)
	float NetClientTicksPerSecond;

	/** Current display gamma setting */
	UPROPERTY(config)
	float DisplayGamma;

	/** Minimum desired framerate setting, below this frame rate visual detail may be lowered */

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

Scope: file

Source code excerpt:

	 * and then attempting to replicate each actor for each connection that it is relevant to until the connection becomes saturated.
	 *
	 * NetClientTicksPerSecond is used to throttle how many clients are updated each frame, hoping to avoid saturating the server's upstream bandwidth, although
	 * the current solution is far from optimal.  Ideally the throttling could be based upon the server connection becoming saturated, at which point each
	 * connection is reduced to priority only updates, and spread out amongst several ticks.  Also might want to investigate eliminating the redundant consider/relevancy
	 * checks for Actors that were successfully replicated for some channels but not all, since that would make a decent CPU optimization.
	 *
	 * @param DeltaSeconds elapsed time since last call
	 *
	 * @return the number of actors that were replicated
	 */
	ENGINE_API virtual int32 ServerReplicateActors(float DeltaSeconds);

	/**
	 * Process a remote function call on some actor destined for a remote location
	 *
	 * @param Actor actor making the function call
	 * @param Function function definition called
	 * @param Params parameters in a UObject memory layout
	 * @param Stack stack frame the UFunction is called in
	 * @param SubObject optional: sub object to actually call function on
	 */
	ENGINE_API virtual void ProcessRemoteFunction(class AActor* Actor, class UFunction* Function, void* Parameters, struct FOutParmRec* OutParms, struct FFrame* Stack, class UObject* SubObject = nullptr );

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

Scope (from outer to inner):

file
function     int32 UNetDriver::ServerReplicateActors_PrepConnections

Source code excerpt:

		//@todo - ideally we wouldn't want to tick more clients with a higher deltatime as that's not going to be good for performance and probably saturate bandwidth in hitchy situations, maybe 
		// come up with a solution that is greedier with higher framerates, but still won't risk saturating server upstream bandwidth
		float ClientUpdatesThisFrame = GEngine->NetClientTicksPerSecond * ( DeltaSeconds + DeltaTimeOverflow ) * ( LanPlay ? 2.f : 1.f );
		NumClientsToTick = FMath::Min<int32>( NumClientsToTick, FMath::TruncToInt( ClientUpdatesThisFrame ) );
		//UE_LOG(LogNet, Log, TEXT("%2.3f: Ticking %d clients this frame, %2.3f/%2.4f"),GetWorld()->GetTimeSeconds(),NumClientsToTick,DeltaSeconds,ClientUpdatesThisFrame);
		if ( NumClientsToTick == 0 )
		{
			// if no clients are ticked this frame accumulate the time elapsed for the next frame
			DeltaTimeOverflow += DeltaSeconds;