net.PacketHandlerCRCDump

net.PacketHandlerCRCDump

#Overview

name: net.PacketHandlerCRCDump

This variable is created as a Console Variable (cvar).

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:

  1. This variable is only available in non-shipping builds (#if !UE_BUILD_SHIPPING).
  2. Enabling this feature may impact performance due to the additional CRC calculations and logging.
  3. It’s primarily intended for debugging and should not be enabled in production environments.

Best practices when using this variable include:

  1. Only enable it when actively debugging network-related issues.
  2. Be prepared to handle and analyze the additional output generated when this feature is enabled.
  3. Remember to disable it after debugging to avoid unnecessary performance overhead.

Regarding the associated variable GPacketHandlerCRCDump:

#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];