MaxClientRate

MaxClientRate

#Overview

name: MaxClientRate

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

It is referenced in 7 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of MaxClientRate is to set an upper limit on the network speed for clients connecting to a server in Unreal Engine 5. It is primarily used in the networking system to control data transmission rates between the server and clients.

This setting variable is relied upon by several Unreal Engine subsystems and modules, including:

  1. The core networking module (NetDriver)
  2. The Online Subsystem Utils plugin (OnlineBeaconHost)
  3. The player management system (PlayerController)
  4. The world management system (UWorld)

The value of MaxClientRate is typically set in the configuration files and can be accessed through the UNetDriver class. It is initialized in the UNetDriver constructor with a default value of 15000.

MaxClientRate interacts with other variables such as:

Developers should be aware that:

  1. This variable affects the maximum amount of data that can be sent to clients per second.
  2. It’s used in various network-related operations to ensure clients don’t exceed the set limit.
  3. The value can be different for LAN and Internet play.

Best practices when using this variable include:

  1. Carefully consider the balance between network performance and data transmission when setting this value.
  2. Test thoroughly with different network conditions to ensure optimal performance.
  3. Allow for configuration options to adjust this value based on the game’s needs and the target platform’s capabilities.
  4. Remember that while a higher value can allow for more data transmission, it may also increase bandwidth requirements and potentially introduce latency issues for players with slower connections.

#Setting Variables

#References In INI files

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

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

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

Location: <Workspace>/Projects/Lyra/Config/DefaultEngine.ini:90, section: [/Script/OnlineSubsystemUtils.IpNetDriver]

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Plugins/Online/OnlineSubsystemUtils/Source/OnlineSubsystemUtils/Private/OnlineBeaconHost.cpp:368

Scope (from outer to inner):

file
function     bool AOnlineBeaconHost::HandleControlMessage

Source code excerpt:

				return false;
			}
			Connection->CurrentNetSpeed = FMath::Clamp(Rate, 1800, NetDriver->MaxClientRate);
			UE_LOG(LogBeacon, Log, TEXT("%s: Client netspeed is %i"), *GetDebugName(Connection), Connection->CurrentNetSpeed);
		}
		break;
	case NMT_BeaconJoin:
		{
			if (!ConnState->bHasSetNetspeed || ConnState->bHasJoined || (bAuthRequired && !ConnState->bHasAuthenticated))

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

Scope (from outer to inner):

file
class        class UNetDriver : public UObject, public FExec

Source code excerpt:

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

	/** Amount of time a server will wait before traveling to next map, gives clients time to receive final RPCs on existing level @see NextSwitchCountdown */
	UPROPERTY(Config)
	float ServerTravelPause;

	/** @todo document */

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

Scope (from outer to inner):

file
function     UNetDriver::UNetDriver

Source code excerpt:

:	UObject(ObjectInitializer)
,	MaxInternetClientRate(10000)
, 	MaxClientRate(15000)
,   ServerConnection(nullptr)
,	ClientConnections()
,	MappedClientConnections()
,	RecentlyDisconnectedClients()
,	RecentlyDisconnectedTrackingTime(0)
,	ConnectionlessHandler()

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PlayerController.cpp:506

Scope (from outer to inner):

file
function     void APlayerController::SetNetSpeed

Source code excerpt:

	if (Player != NULL && Driver != NULL)
	{
		Player->CurrentNetSpeed = FMath::Clamp(NewSpeed, 1800, Driver->MaxClientRate);
		if (Driver->ServerConnection != NULL)
		{
			Driver->ServerConnection->CurrentNetSpeed = Player->CurrentNetSpeed;
		}
	}
}

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PlayerController.cpp:4902

Scope (from outer to inner):

file
function     void APlayerController::SetPlayer

Source code excerpt:

	if( (ClientCap>=2600) && Driver && Driver->ServerConnection )
	{
		Player->CurrentNetSpeed = Driver->ServerConnection->CurrentNetSpeed = FMath::Clamp( ClientCap, 1800, Driver->MaxClientRate );
	}

	// initializations only for local players
	ULocalPlayer *LP = Cast<ULocalPlayer>(InPlayer);
	if (LP != NULL)
	{

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/World.cpp:6440

Scope (from outer to inner):

file
function     void UWorld::NotifyControlMessage

Source code excerpt:

				if (FNetControlMessage<NMT_Netspeed>::Receive(Bunch, Rate))
				{
					Connection->CurrentNetSpeed = FMath::Clamp(Rate, 1800, NetDriver->MaxClientRate);
					UE_LOG(LogNet, Log, TEXT("Client netspeed is %i"), Connection->CurrentNetSpeed);
				}

				break;
			}
			case NMT_Abort:

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/World.cpp:6848

Scope (from outer to inner):

file
function     bool UWorld::Listen

Source code excerpt:

	static const bool bLanPlay = FParse::Param(FCommandLine::Get(),TEXT("lanplay"));
	const bool bLanSpeed = bLanPlay || InURL.HasOption(TEXT("LAN"));
	if ( !bLanSpeed && (NetDriver->MaxInternetClientRate < NetDriver->MaxClientRate) && (NetDriver->MaxInternetClientRate > 2500) )
	{
		NetDriver->MaxClientRate = NetDriver->MaxInternetClientRate;
	}

	NextSwitchCountdown = NetDriver->ServerTravelPause;
	return true;
#else
	return false;