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:
- The core networking module (NetDriver)
- The Online Subsystem Utils plugin (OnlineBeaconHost)
- The player management system (PlayerController)
- 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:
- CurrentNetSpeed: The actual network speed used for a client connection, which is clamped between a minimum value (usually 1800) and MaxClientRate.
- MaxInternetClientRate: Used to potentially lower MaxClientRate for internet play as opposed to LAN play.
Developers should be aware that:
- This variable affects the maximum amount of data that can be sent to clients per second.
- It’s used in various network-related operations to ensure clients don’t exceed the set limit.
- The value can be different for LAN and Internet play.
Best practices when using this variable include:
- Carefully consider the balance between network performance and data transmission when setting this value.
- Test thoroughly with different network conditions to ensure optimal performance.
- Allow for configuration options to adjust this value based on the game’s needs and the target platform’s capabilities.
- 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]
- INI Section:
/Script/OnlineSubsystemUtils.IpNetDriver
- Raw value:
100000
- Is Array:
False
Location: <Workspace>/Engine/Config/BaseEngine.ini:2262, section: [/Script/SteamSockets.SteamSocketsNetDriver]
- INI Section:
/Script/SteamSockets.SteamSocketsNetDriver
- Raw value:
100000
- Is Array:
False
Location: <Workspace>/Engine/Plugins/Experimental/WebSocketNetworking/Config/BaseWebSocketNetDriver.ini:15, section: [/Script/WebSocketNetworking.WebSocketNetDriver]
- INI Section:
/Script/WebSocketNetworking.WebSocketNetDriver
- Raw value:
15000
- Is Array:
False
Location: <Workspace>/Projects/Lyra/Config/DefaultEngine.ini:90, section: [/Script/OnlineSubsystemUtils.IpNetDriver]
- INI Section:
/Script/OnlineSubsystemUtils.IpNetDriver
- Raw value:
200000
- Is Array:
False
#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;