net.PacketHandlerCRCDump
net.PacketHandlerCRCDump
#Overview
name: net.PacketHandlerCRCDump
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Enables or disables dumping of packet CRC\'s for every HandlerComponent, Incoming and Outgoing, for debugging.
It is referenced in 10
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of net.PacketHandlerCRCDump
is to enable or disable the dumping of packet CRCs (Cyclic Redundancy Checks) for every HandlerComponent, both incoming and outgoing, for debugging purposes.
This setting variable is primarily used in the networking subsystem of Unreal Engine, specifically within the PacketHandler module. It’s designed to help developers debug network-related issues by providing detailed information about packet processing.
The value of this variable is set through the Unreal Engine console variable system. It’s defined as an FAutoConsoleVariableRef
, which means it can be changed at runtime through console commands or configuration files.
The associated variable GPacketHandlerCRCDump
directly interacts with net.PacketHandlerCRCDump
. They share the same value, and GPacketHandlerCRCDump
is used throughout the code to check if CRC dumping is enabled.
Developers must be aware that:
- This variable is only available in non-shipping builds (
#if !UE_BUILD_SHIPPING
). - Enabling this feature may impact performance due to the additional CRC calculations and logging.
- It’s primarily intended for debugging and should not be enabled in production environments.
Best practices when using this variable include:
- Only enable it when actively debugging network-related issues.
- Be prepared to handle and analyze the additional output generated when this feature is enabled.
- Remember to disable it after debugging to avoid unnecessary performance overhead.
Regarding the associated variable GPacketHandlerCRCDump
:
- It’s an integer variable that acts as the actual storage for the console variable’s value.
- It’s used in conditional statements throughout the PacketHandler code to determine whether CRC dumping should occur.
- When enabled (non-zero value), it triggers CRC calculations and logging for both incoming and outgoing packets at various stages of packet processing.
- Developers should use this variable in conjunction with other networking debugging tools to get a comprehensive view of packet handling in their application.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/PacketHandlers/PacketHandler/Private/PacketHandler.cpp:34
Scope: file
Source code excerpt:
FAutoConsoleVariableRef CVarNetPacketHandlerCRCDump(
TEXT("net.PacketHandlerCRCDump"),
GPacketHandlerCRCDump,
TEXT("Enables or disables dumping of packet CRC's for every HandlerComponent, Incoming and Outgoing, for debugging."));
static int32 GPacketHandlerTimeguardLimit = 20;
static float GPacketHandlerTimeguardThresholdMS = 0.0f;
bool GPacketHandlerDiscardTimeguardMeasurement = false;
#Associated Variable and Callsites
This variable is associated with another variable named GPacketHandlerCRCDump
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/PacketHandlers/PacketHandler/Private/PacketHandler.cpp:31
Scope: file
Source code excerpt:
#if !UE_BUILD_SHIPPING
int32 GPacketHandlerCRCDump = 0;
FAutoConsoleVariableRef CVarNetPacketHandlerCRCDump(
TEXT("net.PacketHandlerCRCDump"),
GPacketHandlerCRCDump,
TEXT("Enables or disables dumping of packet CRC's for every HandlerComponent, Incoming and Outgoing, for debugging."));
static int32 GPacketHandlerTimeguardLimit = 20;
static float GPacketHandlerTimeguardThresholdMS = 0.0f;
bool GPacketHandlerDiscardTimeguardMeasurement = false;
#Loc: <Workspace>/Engine/Source/Runtime/PacketHandlers/PacketHandler/Private/PacketHandler.cpp:547
Scope (from outer to inner):
file
function EIncomingResult PacketHandler::Incoming_Internal
Source code excerpt:
uint32 SocketCRC = 0;
if (UNLIKELY(!!GPacketHandlerCRCDump))
{
SocketCRC = FCrc::MemCrc32(DataView.GetData(), DataView.NumBytes());
}
#endif
if (HandlerComponents.Num() > 0)
#Loc: <Workspace>/Engine/Source/Runtime/PacketHandlers/PacketHandler/Private/PacketHandler.cpp:610
Scope (from outer to inner):
file
function EIncomingResult PacketHandler::Incoming_Internal
Source code excerpt:
#if !UE_BUILD_SHIPPING
if (UNLIKELY(!!GPacketHandlerCRCDump))
{
if (ProcessedPacketReader.IsError())
{
HandlerCRCs.Add({0, false, true});
}
else if (ProcessedPacketReader.GetPosBits() == 0)
#Loc: <Workspace>/Engine/Source/Runtime/PacketHandlers/PacketHandler/Private/PacketHandler.cpp:635
Scope (from outer to inner):
file
function EIncomingResult PacketHandler::Incoming_Internal
Source code excerpt:
#if !UE_BUILD_SHIPPING
if (UNLIKELY(!!GPacketHandlerCRCDump))
{
FHandlerCRC& CurCRC = HandlerCRCs[HandlerCRCs.Num() - 1];
CurCRC.CRC = FCrc::MemCrc32(ProcessedPacketReader.GetData(), IntCastLog<int32, int64>(ProcessedPacketReader.GetNumBytes()));
CurCRC.bHasAlignedCRC = true;
}
#Loc: <Workspace>/Engine/Source/Runtime/PacketHandlers/PacketHandler/Private/PacketHandler.cpp:669
Scope (from outer to inner):
file
function EIncomingResult PacketHandler::Incoming_Internal
Source code excerpt:
#if !UE_BUILD_SHIPPING
if (UNLIKELY(!!GPacketHandlerCRCDump))
{
NetConnectionCRC = FCrc::MemCrc32(IncomingPacket.GetData(), IntCastLog<int32, int64>(IncomingPacket.GetBytesLeft()));
}
#endif
}
#Loc: <Workspace>/Engine/Source/Runtime/PacketHandlers/PacketHandler/Private/PacketHandler.cpp:686
Scope (from outer to inner):
file
function EIncomingResult PacketHandler::Incoming_Internal
Source code excerpt:
#if !UE_BUILD_SHIPPING
if (UNLIKELY(!!GPacketHandlerCRCDump))
{
TStringBuilder<2048> HandlerCRCStr;
for (int32 i=HandlerCRCs.Num()-1; i>=0; i--)
{
FHandlerCRC& CurCRC = HandlerCRCs[i];
#Loc: <Workspace>/Engine/Source/Runtime/PacketHandlers/PacketHandler/Private/PacketHandler.cpp:736
Scope (from outer to inner):
file
function const ProcessedPacket PacketHandler::Outgoing_Internal
Source code excerpt:
TArray<FHandlerCRC> HandlerCRCs;
if (UNLIKELY(!!GPacketHandlerCRCDump))
{
NetConnectionCRC = FCrc::MemCrc32(Packet, FMath::DivideAndRoundUp(CountBits, 8));
}
#endif
if (!bRawSend)
#Loc: <Workspace>/Engine/Source/Runtime/PacketHandlers/PacketHandler/Private/PacketHandler.cpp:791
Scope (from outer to inner):
file
function const ProcessedPacket PacketHandler::Outgoing_Internal
Source code excerpt:
#if !UE_BUILD_SHIPPING
if (UNLIKELY(!!GPacketHandlerCRCDump))
{
if (OutgoingPacket.IsError())
{
HandlerCRCs.Add({0, true});
}
else
#Loc: <Workspace>/Engine/Source/Runtime/PacketHandlers/PacketHandler/Private/PacketHandler.cpp:852
Scope (from outer to inner):
file
function const ProcessedPacket PacketHandler::Outgoing_Internal
Source code excerpt:
#if !UE_BUILD_SHIPPING
if (UNLIKELY(!!GPacketHandlerCRCDump))
{
TStringBuilder<2048> HandlerCRCStr;
for (int32 i=0; i<HandlerCRCs.Num(); i++)
{
FHandlerCRC& CurCRC = HandlerCRCs[i];