RPCRepeatLimitMSPerPeriod

RPCRepeatLimitMSPerPeriod

#Overview

name: RPCRepeatLimitMSPerPeriod

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 5 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of RPCRepeatLimitMSPerPeriod is to set a limit on the number of milliseconds a single Remote Procedure Call (RPC) can spend executing over a specified time period. This variable is part of Unreal Engine’s network security system, specifically for Denial of Service (DoS) protection.

This setting variable is primarily used by the networking subsystem of Unreal Engine, particularly in the RPC DoS detection module. It’s referenced in the Engine/Source/Runtime/Engine/Private/Net/RPCDoSDetection.cpp and Engine/Source/Runtime/Engine/Public/Net/RPCDoSDetection.h files.

The value of this variable is set in the engine configuration files and can be modified through project settings. It’s defined as a UPROPERTY with the ‘config’ specifier, allowing it to be easily configured without changing the source code.

RPCRepeatLimitMSPerPeriod interacts closely with other DoS protection variables, particularly RPCRepeatLimitTimePeriod. Together, these variables define the time window and execution time limit for repeated RPCs.

Developers must be aware that this variable is part of a larger DoS protection system. Setting it too low might cause legitimate RPCs to be flagged as potential DoS attacks, while setting it too high could leave the system vulnerable to actual attacks.

Best practices when using this variable include:

  1. Carefully considering the typical execution time of your RPCs when setting this value.
  2. Testing thoroughly with realistic network conditions to ensure the setting doesn’t interfere with normal gameplay.
  3. Using it in conjunction with other DoS protection settings for a comprehensive security approach.
  4. Monitoring logs and adjusting the value if legitimate RPCs are being incorrectly flagged.
  5. Keeping in mind that a value of -1 disables this particular check.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/BaseEngine.ini:1773, section: [RPCDoSDetection.DoS]

Location: <Workspace>/Engine/Config/BaseEngine.ini:1789, section: [RPCDoSDetection.ExpensiveDoS]

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Net/RPCDoSDetection.cpp:125

Scope (from outer to inner):

file
function     void FRPCDoSState::ApplyImpliedValues

Source code excerpt:

{
	EscalateQuotaTimePeriod = (EscalateQuotaRPCsPerPeriod != -1 || EscalateTimeQuotaMSPerPeriod != -1) ? EscalateQuotaTimePeriod : -1;
	RPCRepeatLimitTimePeriod = (RPCRepeatLimitPerPeriod != -1 || RPCRepeatLimitMSPerPeriod != -1) ? RPCRepeatLimitTimePeriod : -1;

	bTrackRecentRPCs = bTrackRecentRPCs || (RPCRepeatLimitPerPeriod != -1 && RPCRepeatLimitTimePeriod != -1);
	EscalateTimeQuotaSecsPerFrame = (EscalateTimeQuotaMSPerFrame != -1 ? (EscalateTimeQuotaMSPerFrame / 1000.0) : 0.0);
	EscalateTimeQuotaSecsPerPeriod = (EscalateTimeQuotaMSPerPeriod != -1 ? (EscalateTimeQuotaMSPerPeriod / 1000.0) : 0.0);
	RPCRepeatLimitSecsPerPeriod = (RPCRepeatLimitMSPerPeriod != -1 ? (RPCRepeatLimitMSPerPeriod / 1000.0) : 0.0);
	EscalationTimeToleranceSeconds = (EscalationTimeToleranceMS != -1 ? (EscalationTimeToleranceMS / 1000.0) : 0.0);
}

bool FRPCDoSState::HasHitQuota_Count(const FRPCDoSCounters(&PerPeriodHistory)[16], FRPCDoSCounters& InFrameCounter) const
{
	bool bReturnVal = EscalateQuotaRPCsPerFrame > 0 && InFrameCounter.RPCCounter >= EscalateQuotaRPCsPerFrame;

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Net/RPCDoSDetection.cpp:289

Scope (from outer to inner):

file
function     void FRPCDoSStateConfig::ValidateConfig

Source code excerpt:


	ValidateTimePeriod(RPCRepeatLimitTimePeriod, TEXT("RPCRepeatLimitTimePeriod"),
						(RPCRepeatLimitPerPeriod > 0 || RPCRepeatLimitMSPerPeriod > 0));

	if (AutoEscalateTime > 0 && AutoEscalateTime < CooloffTime)
	{
		UE_LOG(LogNet, Warning, TEXT("FRPCDoSStateConfig: AutoEscalateTime must be larger than CooloffTime."));
	}
}

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Net/RPCDoSDetection.cpp:319

Scope (from outer to inner):

file
function     void FRPCDoSStateConfig::ApplyState

Source code excerpt:

	Target.EscalateQuotaTimePeriod			= EscalateQuotaTimePeriod;
	Target.RPCRepeatLimitPerPeriod			= RPCRepeatLimitPerPeriod;
	Target.RPCRepeatLimitMSPerPeriod		= RPCRepeatLimitMSPerPeriod;
	Target.RPCRepeatLimitTimePeriod			= RPCRepeatLimitTimePeriod;
	Target.CooloffTime						= CooloffTime;
	Target.AutoEscalateTime					= AutoEscalateTime;

	Target.ApplyImpliedValues();
}

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Public/Net/RPCDoSDetection.h:230

Scope: file

Source code excerpt:

	/** The limit for the number of milliseconds a single RPC can spend executing, over the time period specified by RPCRepeatTimeLimitPeriod */
	UPROPERTY(config)
	int16 RPCRepeatLimitMSPerPeriod		= -1;

	/** The time period to use for measuring excessive execution time for a single RPC (Max: 16) */
	UPROPERTY(config)
	int8 RPCRepeatLimitTimePeriod		= -1;

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Public/Net/RPCDoSDetection.h:254

Scope: file

Source code excerpt:

	double EscalateTimeQuotaSecsPerPeriod	= 0.0;

	/** RPCRepeatLimitMSPerPeriod converted to seconds */
	double RPCRepeatLimitSecsPerPeriod		= 0.0;

	/** EscalationTimeToleranceMS converted to seconds */
	double EscalationTimeToleranceSeconds	= 0.0;