bRPCDoSDetection

bRPCDoSDetection

#Overview

name: bRPCDoSDetection

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

#Summary

#Usage in the C++ source code

The purpose of bRPCDoSDetection is to enable or disable the RPC (Remote Procedure Call) Denial of Service (DoS) detection system in Unreal Engine 5. This setting variable is primarily used for network security and performance monitoring.

bRPCDoSDetection is mainly used in the networking subsystem of Unreal Engine, specifically in the RPC DoS detection module. It’s referenced in the FRPCDoSDetection class, which is part of the Engine’s networking infrastructure.

The value of this variable is typically set in the engine configuration files, but it can also be overridden programmatically. It’s initialized in the InitConfig function of the FRPCDoSDetection class, where it reads from a configuration object (CurConfigObj) or an override value (RPCDoSDetectionOverride).

This variable interacts closely with other RPC DoS detection-related variables, such as bRPCDoSAnalytics, HitchTimeQuotaMS, and various counters and scopes used in the detection process.

Developers must be aware that enabling this variable activates the RPC DoS detection system, which can impact performance due to the additional checks it performs. It’s crucial to balance security needs with performance requirements.

Best practices when using this variable include:

  1. Only enable it in environments where RPC DoS attacks are a concern, such as public-facing servers.
  2. Ensure proper configuration of related settings, such as DetectionSeverity, to avoid false positives.
  3. Monitor the performance impact when enabled and adjust other related settings as needed.
  4. Use in conjunction with bRPCDoSAnalytics for better insight into potential attacks.
  5. Regularly review and update the configuration based on observed network behavior and any detected anomalies.

#Setting Variables

#References In INI files

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

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

#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:341

Scope (from outer to inner):

file
function     void FRPCDoSDetection::Init

Source code excerpt:

	InitConfig(NetDriverName);

	if (bRPCDoSDetection && bRPCDoSAnalytics && AnalyticsAggregator.IsValid())
	{
		RPCDoSAnalyticsData = REGISTER_NET_ANALYTICS(AnalyticsAggregator, FRPCDoSAnalyticsData, TEXT("Core.ServerRPCDoS"));

		if (RPCDoSAnalyticsData.IsValid())
		{
			RPCDoSAnalyticsData->WorldFunc = MoveTemp(InWorldFunc);

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

Scope (from outer to inner):

file
function     void FRPCDoSDetection::InitConfig

Source code excerpt:

	if (CurConfigObj != nullptr)
	{
		bRPCDoSDetection = CurConfigObj->bRPCDoSDetection;
		bRPCDoSAnalytics = CurConfigObj->bRPCDoSAnalytics;
		HitchTimeQuotaMS = CurConfigObj->HitchTimeQuotaMS;
		HitchSuspendDetectionTimeMS = CurConfigObj->HitchSuspendDetectionTimeMS;

		if (NextTimeQuotaCheck == 0.0 && CurConfigObj->InitialConnectToleranceMS > 0)
		{

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

Scope (from outer to inner):

file
function     void FRPCDoSDetection::InitConfig

Source code excerpt:

			if (KeyVal.Num() > 1 && KeyVal[0] == NetDriverName.ToString() && !KeyVal[1].IsEmpty())
			{
				bRPCDoSDetection = (FCString::Atoi(*KeyVal[1]) == 0) ? false : true;
			}
		}
	}
	else if (!RPCDoSDetectionOverride.IsEmpty())
	{
		const bool bOverrideVal = (FCString::Atoi(*RPCDoSDetectionOverride) == 0) ? false : true;

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

Scope (from outer to inner):

file
function     void FRPCDoSDetection::InitConfig

Source code excerpt:

			if (NetDriverName == NAME_GameNetDriver)
			{
				bRPCDoSDetection = bOverrideVal;
			}
		}
		else
		{
			bRPCDoSDetection = bOverrideVal;
		}
	}


	DetectionSeverity.Empty();

	if (bRPCDoSDetection)
	{
		int32 HighestHistoryRequirment = 0;

		if (CurConfigObj != nullptr)
		{
			TArray<FString>& SeverityCategories = CurConfigObj->DetectionSeverity;

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

Scope (from outer to inner):

file
function     void FRPCDoSDetection::InitConfig

Source code excerpt:

			UE_LOG(LogNet, Warning, TEXT("RPC DoS detection enabled, but no DetectionSeverity states specified! Disabling."));

			bRPCDoSDetection = false;
		}
	}


	if (bRPCDoSDetection)
	{
		if (ActiveRPCTracking.Num() == 0)
		{
			ActiveRPCTracking.Empty(DefaultActiveRPCTrackingSize);
		}

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

Scope (from outer to inner):

file
function     void FRPCDoSDetection::PreTickDispatch

Source code excerpt:

	TickScopePrivate.SetActive(true);

	if (bRPCDoSDetection)
	{
		NextTimeQuotaCheck = FMath::Max(TimeSeconds + TimeQuotaCheckInterval, NextTimeQuotaCheck);

		if (HitchTimeQuotaMS > 0 && ReceivedPacketEndTime != 0.0)
		{
			// Timing is approximate to reduce timestamp retrieval, and packets aren't received each frame

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Net/RPCDoSDetectionConfig.h:58

Scope (from outer to inner):

file
class        class URPCDoSDetectionConfig : public UObject

Source code excerpt:

	/** Whether or not RPC DoS detection is presently enabled */
	UPROPERTY(config)
	bool bRPCDoSDetection;

	/** Whether or not analytics for RPC DoS detection is enabled */
	UPROPERTY(config)
	bool bRPCDoSAnalytics;

	/** The amount of time since the previous frame, for detecting hitches, to prevent false positives from built-up packets */

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

Scope (from outer to inner):

file
class        class FRPCDoSDetection : protected FRPCDoSState
function     ERPCNotifyResult NotifyReceivedRPC

Source code excerpt:

#endif

		if (bRPCDoSDetection && !bHitchSuspendDetection)
		{
			if (!SequentialRPCScopePrivate.IsActive())
			{
				PreSequentialRPC();
			}

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

Scope (from outer to inner):

file
class        class FRPCDoSDetection : protected FRPCDoSState
function     void LightweightReceivedRPC

Source code excerpt:

#endif

		if (bRPCDoSDetection && !bHitchSuspendDetection)
		{
			if (!SequentialRPCScopePrivate.IsActive())
			{
				PreSequentialRPC();
			}

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

Scope (from outer to inner):

file
class        class FRPCDoSDetection : protected FRPCDoSState
function     void PostReceivedRPC

Source code excerpt:

#endif

		if (bRPCDoSDetection && !bHitchSuspendDetection)
		{
			FTickScope& TickScope = GetTickScope();
			FPacketScope& PacketScope = GetPacketScope();
			FSequentialRPCScope& SequentialRPCScope = GetSequentialRPCScope();

			TickScope.FrameCounter.RPCCounter++;

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

Scope (from outer to inner):

file
class        class FRPCDoSDetection : protected FRPCDoSState
function     bool IsRPCDoSDetectionEnabled

Source code excerpt:

	bool IsRPCDoSDetectionEnabled() const
	{
		return bRPCDoSDetection;
	}

	/**
	 * Overrides the current AddressFunc
	 *
	 * @param InAddressFunc		The new AddressFunc

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

Scope (from outer to inner):

file
class        class FRPCDoSDetection : protected FRPCDoSState

Source code excerpt:

private:
	/** Whether or not RPC DoS detection is presently enabled */
	bool bRPCDoSDetection											= false;

	/** Whether or not analytics for RPC DoS detection is enabled */
	bool bRPCDoSAnalytics											= false;

	/** The amount of time since the previous frame, for detecting hitches, to prevent false positives from built-up packets */
	int32 HitchTimeQuotaMS											= 0;