HitchFrameTolerance

HitchFrameTolerance

#Overview

name: HitchFrameTolerance

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

It is referenced in 4 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of HitchFrameTolerance is to control the DDoS detection system’s sensitivity to frame hitches in Unreal Engine 5. It is used to determine when to consider packet buildup as a potential DDoS attack rather than a result of normal frame hitching.

This setting variable is primarily used in the DDoS detection subsystem of Unreal Engine’s networking module. It is part of the Net/Core component, specifically within the DDoSDetection class.

The value of HitchFrameTolerance is set in the InitConfig() function of the FDDoSDetection class. It is read from the engine’s configuration file (GEngineIni) using the GConfig system, under the DDoS section with the key “HitchFrameTolerance”.

HitchFrameTolerance interacts with the HitchFrameCount variable. In the PreFrameReceive function, these two variables are compared to determine whether to adjust the DDoS detection based on the current frame’s delta time or to use a fixed value due to excessive hitching.

Developers must be aware that this variable is crucial for balancing the DDoS detection system’s sensitivity. Setting it too low might result in false positives during normal gameplay hitches, while setting it too high could delay the detection of actual DDoS attacks.

Best practices when using this variable include:

  1. Carefully tuning its value based on the game’s performance characteristics and expected network behavior.
  2. Monitoring and adjusting it in different network conditions and gameplay scenarios.
  3. Considering it in conjunction with other DDoS detection parameters for a comprehensive protection strategy.
  4. Documenting any changes made to this variable and their impacts on the game’s network security.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/BaseEngine.ini:1651, section: [DDoSDetection]

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Net/Core/Private/Net/Core/Misc/DDoSDetection.cpp:76

Scope (from outer to inner):

file
function     FDDoSDetection::FDDoSDetection

Source code excerpt:

	, LogHitCounter(0)
	, HitchTimeQuotaMS(-1)
	, HitchFrameTolerance(-1)
	, HitchFrameCount(0)
	, LastPerSecQuotaBegin(0.0)
	, CounterPerSecHistory()
	, LastCounterPerSecHistoryIdx(0)
	, StartFrameRecvTimestamp(0.0)
	, EndFrameRecvTimestamp(0.0)

#Loc: <Workspace>/Engine/Source/Runtime/Net/Core/Private/Net/Core/Misc/DDoSDetection.cpp:106

Scope (from outer to inner):

file
function     void FDDoSDetection::InitConfig

Source code excerpt:

	GConfig->GetInt(DDoSSection, TEXT("DDoSLogSpamLimit"), DDoSLogSpamLimit, GEngineIni);
	GConfig->GetInt(DDoSSection, TEXT("HitchTimeQuotaMS"), HitchTimeQuotaMS, GEngineIni);
	GConfig->GetInt(DDoSSection, TEXT("HitchFrameTolerance"), HitchFrameTolerance32, GEngineIni);

	HitchFrameTolerance = IntCastChecked<int8>(HitchFrameTolerance32);
	DDoSLogSpamLimit = DDoSLogSpamLimit > 0 ? DDoSLogSpamLimit : 64;

	DetectionSeverity.Empty();

	UE_LOG(LogNetCore, Log, TEXT("DDoS detection status: detection enabled: %d analytics enabled: %d"), bDDoSDetection, bDDoSAnalytics);

#Loc: <Workspace>/Engine/Source/Runtime/Net/Core/Private/Net/Core/Misc/DDoSDetection.cpp:284

Scope (from outer to inner):

file
function     void FDDoSDetection::PreFrameReceive

Source code excerpt:


		// At the start of every frame, adjust the DDoS detection based upon DeltaTime - unless there is excessive hitching
		FrameAdjustment = static_cast<float>((HitchFrameCount > 0 && HitchFrameCount > HitchFrameTolerance) ? 1.0 : (double)DeltaTime / ExpectedFrameTime);

		if (ActiveState > 0 && CooloffTime > 0 && (float)(StartFrameRecvTimestamp - LastMetEscalationConditions) > (float)CooloffTime)
		{
			UpdateSeverity(false);
		}

#Loc: <Workspace>/Engine/Source/Runtime/Net/Core/Public/Net/Core/Misc/DDoSDetection.h:333

Scope (from outer to inner):

file
class        class FDDoSDetection : protected FDDoSPacketCounters, protected FDDoSState

Source code excerpt:


	/** The number of frames spent hitching, before disabling false positive detection, and treating packet buildup as potential DDoS */
	int8 HitchFrameTolerance;

	/** The number of consecutive frames spent hitching */
	int32 HitchFrameCount;


	/** Timestamp for the last time per-second quota counting began */