NetServerMaxTickRate

NetServerMaxTickRate

#Overview

name: NetServerMaxTickRate

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

It is referenced in 4 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of NetServerMaxTickRate is to control the maximum tick rate for network servers in Unreal Engine. This setting variable is crucial for managing the frequency at which the server processes and sends updates to connected clients.

NetServerMaxTickRate is primarily used in the Engine module, specifically within the UNetDriver class, which is responsible for managing network communications. It’s also referenced in the ReplicationGraph plugin, indicating its importance in network replication.

The value of this variable is typically set in configuration files, as indicated by the UPROPERTY(Config) attribute. However, it can also be modified at runtime using the SetNetServerMaxTickRate function in the UNetDriver class.

This variable interacts with other network-related settings, such as MaxNetTickRate and MaxInternetClientRate. It’s also used in calculations for replication frequency in the ReplicationGraph plugin.

Developers must be aware that:

  1. This variable is deprecated as of Unreal Engine 5.3 and will be made private in future versions.
  2. Changes to this value can significantly impact network performance and game experience.
  3. It affects the DDoS protection system, as seen in the SetNetServerMaxTickRate function.

Best practices when using this variable include:

  1. Use the getter (GetNetServerMaxTickRate) and setter (SetNetServerMaxTickRate) functions instead of accessing the variable directly.
  2. Consider the implications on network bandwidth and client-side performance when adjusting this value.
  3. Monitor the OnNetServerMaxTickRateChanged delegate to react to changes in the tick rate.
  4. Ensure that the tick rate is appropriate for your game’s networking requirements and target platforms.
  5. Be cautious when increasing this value, as it can lead to increased server load and bandwidth usage.

#Setting Variables

#References In INI files

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

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

Location: <Workspace>/Engine/Plugins/Experimental/WebSocketNetworking/Config/BaseWebSocketNetDriver.ini:20, section: [/Script/WebSocketNetworking.WebSocketNetDriver]

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Plugins/Runtime/ReplicationGraph/Source/Private/ReplicationGraph.cpp:3973

Scope: file

Source code excerpt:

/*
 *	Notes on Default Zone Values
 *		-Below values assume 30hz tick rate (the default UNetDriver::NetServerMaxTickRate value).
 *		-If you have a different tick rate, you should reinitialize this data structure yourself. See ReInitDynamicSpatializationSettingsCmd as an example of how to do this from a game project.
 *		-(Alternatively, you can make your own subclass of UReplicationGraphNode_DynamicSpatialFrequency or set UReplicationGraphNode_DynamicSpatialFrequency::Settings*.
 *		
 *	Overview of algorithm:
 *		1. Determine which zone you are in based on DOT product
 *		2. Calculate % of distance/NetCullDistance
 *		3. Map+clamp calculated % to MinPCT/MaxPCT.
 *		4. Take calculated % (between 0-1) and map to MinDistHz - MaxDistHz.
 *
 */

namespace RepGraphDynamicSpatialFrequency
{
	constexpr float AssumedTickRate = 30.f; // UNetDriver::NetServerMaxTickRate
	constexpr float TargetKBytesSec = 10.f; // 10K/sec
	constexpr int64 BitsPerFrame = (int64)((TargetKBytesSec * 1024.f * 8.f) / AssumedTickRate);
};

static TArray<UReplicationGraphNode_DynamicSpatialFrequency::FSpatializationZone>& DefaultSpatializationZones()
{

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

Scope (from outer to inner):

file
class        class UNetDriver : public UObject, public FExec

Source code excerpt:

	UE_DEPRECATED(5.3, "Variable will be made private. Use GetNetServerMaxTickRate and SetNetServerMaxTickRate instead.")
	UPROPERTY(Config)
	int32 NetServerMaxTickRate;

	/** The current max tick rate of the engine when running in dedicated server mode. */
	int32 GetNetServerMaxTickRate() const 
	{ 
		PRAGMA_DISABLE_DEPRECATION_WARNINGS
		return NetServerMaxTickRate;
		PRAGMA_ENABLE_DEPRECATION_WARNINGS
	}

	/** Override the configured server tick rate. Value is in ticks per second. */
	ENGINE_API void SetNetServerMaxTickRate(int32 InServerMaxTickRate);

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

Scope: file

Source code excerpt:

	* Delegate triggered when SetNetServerMaxTickRate is called and causes a change to the current max tick rate.
	* @param UNetDriver The netdriver that changed max tick rate.
	* @param int32 The new value of NetServerMaxTickRate
	* @param int32 The old value of NetServerMaxTickRate 
	*/
	DECLARE_MULTICAST_DELEGATE_ThreeParams(FOnNetServerMaxTickRateChanged, UNetDriver*, int32, int32);
	FOnNetServerMaxTickRateChanged OnNetServerMaxTickRateChanged;

	/** Limit tick rate of replication to allow very high frame rates to still replicate data. A value less or equal to zero means use the engine tick rate. A value greater than zero will clamp the net tick rate to this value.  */
	UPROPERTY(Config)
	int32 MaxNetTickRate;

	/** @todo document */
	UPROPERTY(Config)
	int32 MaxInternetClientRate;

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

Scope (from outer to inner):

file
function     void UNetDriver::SetNetServerMaxTickRate

Source code excerpt:

void UNetDriver::SetNetServerMaxTickRate(int32 InServerMaxTickRate)
{
	if (NetServerMaxTickRate != InServerMaxTickRate)
	{
		const int32 OldTickRate = NetServerMaxTickRate;
		NetServerMaxTickRate = InServerMaxTickRate;

		DDoS.SetMaxTickRate(NetServerMaxTickRate);

		OnNetServerMaxTickRateChanged.Broadcast(this, NetServerMaxTickRate, OldTickRate);
	}
}
PRAGMA_ENABLE_DEPRECATION_WARNINGS

ECreateReplicationChangelistMgrFlags UNetDriver::GetCreateReplicationChangelistMgrFlags() const
{