RecentlyDisconnectedTrackingTime

RecentlyDisconnectedTrackingTime

#Overview

name: RecentlyDisconnectedTrackingTime

The value of this variable can be defined or overridden in .ini config files. 2 .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 RecentlyDisconnectedTrackingTime is to manage the duration for which recently disconnected clients are tracked in the networking system of Unreal Engine 5. It is primarily used in the network driver subsystem to handle and monitor disconnected clients for a specified period after they have disconnected.

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

The value of this variable is set through configuration (UPROPERTY(Config)), allowing it to be adjusted in the project settings or configuration files.

RecentlyDisconnectedTrackingTime interacts with other variables and data structures in the UNetDriver class, such as RecentlyDisconnectedClients and MappedClientConnections. These are used together to keep track of disconnected clients and manage their removal from the tracking system.

Developers must be aware that:

  1. This variable is measured in seconds.
  2. Setting it to 0 effectively disables the tracking of recently disconnected clients.
  3. It directly affects how long disconnected clients’ information is kept in memory.

Best practices when using this variable include:

  1. Set an appropriate value based on your game’s needs. A longer tracking time can help with reconnection handling but may consume more memory.
  2. Consider the implications on server performance and memory usage when setting this value, especially for games with high player counts.
  3. Use this in conjunction with other networking settings to create a robust connection management system.
  4. Regularly review and adjust this value based on your game’s performance metrics and player behavior patterns.

#Setting Variables

#References In INI files

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

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

#References in C++ code

#Callsites

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

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

Scope (from outer to inner):

file
class        class UNetDriver : public UObject, public FExec

Source code excerpt:

	/** The amount of time, in seconds, that recently disconnected clients should be tracked */
	UPROPERTY(Config)
	int32 RecentlyDisconnectedTrackingTime;


	/** Serverside PacketHandler for managing connectionless packets */
	TUniquePtr<PacketHandler> ConnectionlessHandler;

	/** Reference to the PacketHandler component, for managing stateless connection handshakes */

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

Scope (from outer to inner):

file
function     UNetDriver::UNetDriver

Source code excerpt:

,	MappedClientConnections()
,	RecentlyDisconnectedClients()
,	RecentlyDisconnectedTrackingTime(0)
,	ConnectionlessHandler()
,	StatelessConnectComponent()
,	AnalyticsProvider()
,	AnalyticsAggregator()
,   World(nullptr)
,	NetDriverDefinition(NAME_None)

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

Scope (from outer to inner):

file
function     void UNetDriver::TickDispatch

Source code excerpt:

			for (const FDisconnectedClient& CurElement : RecentlyDisconnectedClients)
			{
				if ((CurrentRealtime - CurElement.DisconnectTime) >= RecentlyDisconnectedTrackingTime)
				{
					verify(MappedClientConnections.Remove(CurElement.Address) == 1);

					NumToRemove++;
				}
				else

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

Scope (from outer to inner):

file
function     void UNetDriver::RemoveClientConnection

Source code excerpt:

		TSharedRef<const FInternetAddr> ConstAddrRef = AddrToRemove.ToSharedRef();

		if (RecentlyDisconnectedTrackingTime > 0)
		{
			auto* FoundVal = MappedClientConnections.Find(ConstAddrRef);

			// Mark recently disconnected clients as nullptr (don't wait for GC), and keep the MappedClientConections entry for a while.
			// Required for identifying/ignoring packets from recently disconnected clients, with the same performance as for NetConnection's (important for DDoS detection)
			if (ensure(FoundVal != nullptr))