UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
NetConnection.cpp File Reference
#include "Engine/NetConnection.h"
#include "Engine/ReplicationDriver.h"
#include "Engine/GameInstance.h"
#include "EngineStats.h"
#include "Net/Core/Trace/Private/NetTraceInternal.h"
#include "UObject/Package.h"
#include "GameFramework/PlayerController.h"
#include "Engine/LevelStreaming.h"
#include "PacketHandlers/StatelessConnectHandlerComponent.h"
#include "Engine/LocalPlayer.h"
#include "Stats/StatsTrace.h"
#include "UnrealEngine.h"
#include "EngineUtils.h"
#include "Net/UnrealNetwork.h"
#include "Net/NetworkProfiler.h"
#include "Net/DataReplication.h"
#include "Engine/ActorChannel.h"
#include "Engine/ChildConnection.h"
#include "Engine/VoiceChannel.h"
#include "Misc/App.h"
#include "Net/DataChannel.h"
#include "Engine/PackageMapClient.h"
#include "Engine/NetworkObjectList.h"
#include "EncryptionComponent.h"
#include "Net/PerfCountersHelpers.h"
#include "GameDelegates.h"
#include "Misc/PackageName.h"
#include "Templates/Greater.h"
#include "UObject/LinkerLoad.h"
#include "UObject/UObjectIterator.h"
#include "Net/Core/Trace/NetTrace.h"
#include "Net/NetworkGranularMemoryLogging.h"
#include "SocketSubsystem.h"
#include "HAL/LowLevelMemStats.h"
#include "Net/NetPing.h"
#include "LevelUtils.h"
#include "Net/RPCDoSDetection.h"
#include "Net/NetConnectionFaultRecovery.h"
#include "Net/NetSubObjectRegistryGetter.h"
#include "Net/RepLayout.h"
#include "Net/Subsystems/NetworkSubsystem.h"
#include "Iris/IrisConfig.h"
#include "Iris/ReplicationSystem/ReplicationSystem.h"
#include "Iris/ReplicationSystem/Filtering/NetObjectFilter.h"
#include "Net/Iris/ReplicationSystem/EngineReplicationBridge.h"
#include "Iris/ReplicationSystem/NetTokenStore.h"

Classes

struct  UE::Net::Connection::Private::FValidateLevelVisibilityResult
 

Namespaces

namespace  NetConnectionHelper
 
namespace  UE
 
namespace  UE::Net
 
namespace  UE::Net::Connection
 
namespace  UE::Net::Connection::Private
 
namespace  FChannelRecordImpl
 
namespace  UE::Net::Private
 

Functions

 DECLARE_LLM_MEMORY_STAT (TEXT("NetConnection"), STAT_NetConnectionLLM, STATGROUP_LLMFULL)
 
 LLM_DEFINE_TAG (NetConnection, NAME_None, TEXT("Networking"), GET_STATFNAME(STAT_NetConnectionLLM), GET_STATFNAME(STAT_NetworkingSummaryLLM))
 
 DECLARE_CYCLE_STAT (TEXT("NetConnection SendAcks"), Stat_NetConnectionSendAck, STATGROUP_Net)
 
 DECLARE_CYCLE_STAT (TEXT("NetConnection Tick"), Stat_NetConnectionTick, STATGROUP_Net)
 
 DECLARE_CYCLE_STAT (TEXT("NetConnection ReceivedNak"), Stat_NetConnectionReceivedNak, STATGROUP_Net)
 
 DECLARE_CYCLE_STAT (TEXT("NetConnection NetConnectionReceivedAcks"), Stat_NetConnectionReceivedAcks, STATGROUP_Net)
 
ENGINE_API bool NetConnectionHelper::HasDisabledBandwidthThrottling ()
 
const FValidateLevelVisibilityResult UE::Net::Connection::Private::ValidateLevelVisibility (UWorld *World, const FUpdateLevelVisibilityLevelInfo &LevelVisibility)
 
int32 UE::Net::Connection::Private::GetClockTimeMilliseconds (double ClockTimeInSeconds)
 
bool UE::Net::Connection::Private::Add_DetectOverflow_Clamp (int64 Original, int64 Change, int32 &Result)
 
void UE::Net::Connection::Private::TrackFlushedSubObject (FDormantObjectMap &InOutFlushedGuids, UObject *FlushedObject, const TSharedPtr< FNetGUIDCache > &GuidCache)
 
void UE::Net::Connection::Private::FlushDormancyForSubObjects (UNetConnection *Connection, AActor *Actor, const UE::Net::FSubObjectRegistry &SubObjects, FDormantObjectMap &InOutFlushedGuids, const TStaticBitArray< COND_Max > &ConditionMap, const FNetConditionGroupManager *NetConditionGroupManager)
 
PRAGMA_ENABLE_DEPRECATION_WARNINGS const TCHARLexToString (const EConnectionState Value)
 
template<class Functor >
void FChannelRecordImpl::ConsumeChannelRecordsForPacket (FWrittenChannelsRecord &WrittenChannelsRecord, int32 PacketId, Functor &&Func)
 
template<class Functor >
void FChannelRecordImpl::ConsumeAllChannelRecords (FWrittenChannelsRecord &WrittenChannelsRecord, Functor &&Func)
 

Variables

TAutoConsoleVariable< int32CVarNetEnableCongestionControl (TEXT("net.EnableCongestionControl"), 0, TEXT("Enables congestion control module."))
 
int32 BufferBloatCooldownTimeInMS = 1000
 
int32 GNetDormancyValidate
 
bool GbNetReuseReplicatorsForDormantObjects
 
constexpr uint32 UE::Net::Connection::Private::MaxJitterClockTimeValue = (1 << NetConnectionHelper::NumBitsForJitterClockTimeInHeader) - 1
 
constexpr int32 UE::Net::Connection::Private::MaxJitterPrecisionInMS = 1000
 
constexpr double UE::Net::Connection::Private::JitterNoiseReduction = 16.0
 
bool UE::Net::Connection::Private::bGracefulCloseEnabled = true
 
FAutoConsoleVariableRef UE::Net::Connection::Private::CVarNetGracefulCloseEnabled (TEXT("net.GracefulCloseEnabled"), bGracefulCloseEnabled, TEXT("If enabled, connections will wait for reliable bunches to be acked before cleaning up."))
 
int32 UE::Net::Connection::Private::bTrackFlushedDormantObjects = true
 
FAutoConsoleVariableRef UE::Net::Connection::Private::CVarNetTrackFlushedDormantObjects (TEXT("net.TrackFlushedDormantObjects"), bTrackFlushedDormantObjects, TEXT("If enabled, track dormant subobjects when dormancy is flushed, so they can be properly deleted if destroyed prior to the next ReplicateActor."))
 
int32 UE::Net::Connection::Private::bEnableFlushDormantSubObjects = true
 
FAutoConsoleVariableRef UE::Net::Connection::Private::CVarNetFlushDormantSubObjects (TEXT("net.EnableFlushDormantSubObjects"), bEnableFlushDormantSubObjects, TEXT("If enabled, FlushNetDormancy will flush replicated subobjects in addition to replicated components. Only applies to objects using the replicated subobject list."))
 
int32 UE::Net::Connection::Private::bEnableFlushDormantSubObjectsCheckConditions = true
 
FAutoConsoleVariableRef UE::Net::Connection::Private::CVarNetFlushDormantSubObjectsCheckConditions (TEXT("net.EnableFlushDormantSubObjectsCheckConditions"), bEnableFlushDormantSubObjectsCheckConditions, TEXT("If enabled, when net.EnableFlushDormantSubObjects is also true a dormancy flush will also check replicated subobject conditions"))
 
int32 UE::Net::Connection::Private::bFlushDormancyUseDefaultStateForUnloadedLevels = true
 
FAutoConsoleVariableRef UE::Net::Connection::Private::CVarFlushDormancyUseDefaultStateForUnloadedLevels (TEXT("net.FlushDormancyUseDefaultStateForUnloadedLevels"), bFlushDormancyUseDefaultStateForUnloadedLevels, TEXT("If enabled, dormancy flushing will init replicators with default object state if the client doesn't have the actor's level loaded."))
 
bool UE::Net::Private::bTrackDormantObjectsByLevel = false
 
uint32 GNetOutBytes = 0
 
FAutoConsoleCommandWithWorldAndArgs AddimulatedConnectionsCmd (TEXT("net.SimulateConnections"), TEXT("Starts a Simulated Net Driver"), FConsoleCommandWithWorldAndArgsDelegate::CreateStatic(AddSimulatedNetConnections))
 
FAutoConsoleCommandWithWorldAndArgs RemoveSimulatedConnectionsCmd (TEXT("net.DisconnectSimulatedConnections"), TEXT("Disconnects some simulated connections (0 = all)"), FConsoleCommandWithWorldAndArgsDelegate::CreateStatic(RemoveSimulatedNetConnections))
 
FAutoConsoleCommandWithWorldAndArgs ForceOnePacketPerBunch (TEXT("net.ForceOnePacketPerBunch"), TEXT("When set to true it will enable AutoFlush on all connections and force a packet to be sent for every bunch we create. This forces one packet per replicated actor and can help find rare ordering bugs"), FConsoleCommandWithWorldAndArgsDelegate::CreateLambda([](const TArray< FString > &Args, UWorld *World) { bool bEnable=true;if(Args.Num() > 0) { LexTryParseString< bool >(bEnable, *Args[0]);} UE_LOG(LogNet, Display, TEXT("ForceOnePacketPerBunch set to %s"), bEnable?TEXT("true"):TEXT("false"));for(TObjectIterator< UNetConnection > It;It;++It) { if(It->Driver==World->NetDriver) { It->SetAutoFlush(bEnable);} } }))
 
FAutoConsoleCommandWithWorldAndArgs PrintActorReportCmd (TEXT("net.ActorReport"), TEXT(""), FConsoleCommandWithWorldAndArgsDelegate::CreateStatic(PrintActorReportFunc))
 

Function Documentation

◆ DECLARE_CYCLE_STAT() [1/4]

DECLARE_CYCLE_STAT ( TEXT("NetConnection NetConnectionReceivedAcks" ,
Stat_NetConnectionReceivedAcks  ,
STATGROUP_Net   
)

◆ DECLARE_CYCLE_STAT() [2/4]

DECLARE_CYCLE_STAT ( TEXT("NetConnection ReceivedNak" ,
Stat_NetConnectionReceivedNak  ,
STATGROUP_Net   
)

◆ DECLARE_CYCLE_STAT() [3/4]

DECLARE_CYCLE_STAT ( TEXT("NetConnection SendAcks" ,
Stat_NetConnectionSendAck  ,
STATGROUP_Net   
)

◆ DECLARE_CYCLE_STAT() [4/4]

DECLARE_CYCLE_STAT ( TEXT("NetConnection Tick" ,
Stat_NetConnectionTick  ,
STATGROUP_Net   
)

◆ DECLARE_LLM_MEMORY_STAT()

DECLARE_LLM_MEMORY_STAT ( TEXT("NetConnection")  ,
STAT_NetConnectionLLM  ,
STATGROUP_LLMFULL   
)

◆ LexToString()

PRAGMA_ENABLE_DEPRECATION_WARNINGS const TCHAR * LexToString ( const EConnectionState  Value)

◆ LLM_DEFINE_TAG()

LLM_DEFINE_TAG ( NetConnection  ,
NAME_None  ,
TEXT("Networking")  ,
GET_STATFNAME(STAT_NetConnectionLLM ,
GET_STATFNAME(STAT_NetworkingSummaryLLM  
)

Variable Documentation

◆ AddimulatedConnectionsCmd

FAutoConsoleCommandWithWorldAndArgs AddimulatedConnectionsCmd(TEXT("net.SimulateConnections"), TEXT("Starts a Simulated Net Driver"), FConsoleCommandWithWorldAndArgsDelegate::CreateStatic(AddSimulatedNetConnections)) ( TEXT("net.SimulateConnections")  ,
TEXT("Starts a Simulated Net Driver" ,
FConsoleCommandWithWorldAndArgsDelegate::CreateStatic(AddSimulatedNetConnections)   
)

◆ BufferBloatCooldownTimeInMS

int32 BufferBloatCooldownTimeInMS = 1000

◆ CVarNetEnableCongestionControl

TAutoConsoleVariable< int32 > CVarNetEnableCongestionControl(TEXT("net.EnableCongestionControl"), 0, TEXT("Enables congestion control module.")) ( TEXT("net.EnableCongestionControl")  ,
,
TEXT("Enables congestion control module."  
)

◆ ForceOnePacketPerBunch

FAutoConsoleCommandWithWorldAndArgs ForceOnePacketPerBunch(TEXT("net.ForceOnePacketPerBunch"), TEXT("When set to true it will enable AutoFlush on all connections and force a packet to be sent for every bunch we create. This forces one packet per replicated actor and can help find rare ordering bugs"), FConsoleCommandWithWorldAndArgsDelegate::CreateLambda([](const TArray< FString > &Args, UWorld *World) { bool bEnable=true; if(Args.Num() > 0) { LexTryParseString< bool >(bEnable, *Args[0]); } UE_LOG(LogNet, Display, TEXT("ForceOnePacketPerBunch set to %s"), bEnable?TEXT("true"):TEXT("false")); for(TObjectIterator< UNetConnection > It;It;++It) { if(It->Driver==World->NetDriver) { It->SetAutoFlush(bEnable); } } })) ( TEXT("net.ForceOnePacketPerBunch")  ,
TEXT("When set to true it will enable AutoFlush on all connections and force a packet to be sent for every bunch we create. This forces one packet per replicated actor and can help find rare ordering bugs" ,
FConsoleCommandWithWorldAndArgsDelegate::CreateLambda([](const TArray< FString > &Args, UWorld *World){ bool bEnable=true;if(Args.Num() > 0) { LexTryParseString< bool >(bEnable, *Args[0]);} UE_LOG(LogNet, Display, TEXT("ForceOnePacketPerBunch set to %s"), bEnable?TEXT("true"):TEXT("false"));for(TObjectIterator< UNetConnection > It;It;++It) { if(It->Driver==World->NetDriver) { It->SetAutoFlush(bEnable); } }})   
)

◆ GbNetReuseReplicatorsForDormantObjects

bool GbNetReuseReplicatorsForDormantObjects
extern

◆ GNetDormancyValidate

int32 GNetDormancyValidate
extern

◆ GNetOutBytes

uint32 GNetOutBytes = 0

◆ PrintActorReportCmd

FAutoConsoleCommandWithWorldAndArgs PrintActorReportCmd(TEXT("net.ActorReport"), TEXT(""), FConsoleCommandWithWorldAndArgsDelegate::CreateStatic(PrintActorReportFunc)) ( TEXT("net.ActorReport")  ,
TEXT("")  ,
FConsoleCommandWithWorldAndArgsDelegate::CreateStatic(PrintActorReportFunc)   
)

◆ RemoveSimulatedConnectionsCmd

FAutoConsoleCommandWithWorldAndArgs RemoveSimulatedConnectionsCmd(TEXT("net.DisconnectSimulatedConnections"), TEXT("Disconnects some simulated connections (0 = all)"), FConsoleCommandWithWorldAndArgsDelegate::CreateStatic(RemoveSimulatedNetConnections)) ( TEXT("net.DisconnectSimulatedConnections")  ,
TEXT("Disconnects some simulated connections (0 = all)")  ,
FConsoleCommandWithWorldAndArgsDelegate::CreateStatic(RemoveSimulatedNetConnections)   
)