MessageBus.UDP.SegmenterMaxResends
MessageBus.UDP.SegmenterMaxResends
#Overview
name: MessageBus.UDP.SegmenterMaxResends
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
The number of attempts to resend data to an endpoint. Values are clamped between 1 and 100.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of MessageBus.UDP.SegmenterMaxResends is to control the number of attempts to resend data to an endpoint in the UDP messaging system of Unreal Engine 5. This setting is crucial for managing network communication reliability in the engine’s messaging infrastructure.
The Unreal Engine subsystem that relies on this setting variable is the UDP Messaging plugin, specifically within the message segmentation component. This can be seen from the file path where the variable is defined and used: Engine/Plugins/Messaging/UdpMessaging/Source/UdpMessaging/Private/Transport/UdpMessageSegmenter.cpp.
The value of this variable is set using a console variable (CVar) system. It’s initialized with a default value of 16 and can be changed at runtime through console commands or configuration files.
This variable interacts directly with its associated variable CVarSegmenterMaxResends, which is a TAutoConsoleVariable
Developers must be aware that:
- The value is clamped between 1 and 100, as seen in the FMath::Clamp() function call.
- This variable affects the reliability of UDP message transmission, which is inherently unreliable.
- Setting this value too low might result in message loss, while setting it too high could lead to unnecessary network traffic and delays.
Best practices when using this variable include:
- Adjust the value based on your specific network conditions and reliability requirements.
- Monitor network performance and adjust as needed.
- Consider the trade-off between reliability and performance when setting this value.
- Use logging and telemetry to track when messages are not successfully sent after the maximum number of resends.
Regarding the associated variable CVarSegmenterMaxResends:
- It’s a console variable that directly represents MessageBus.UDP.SegmenterMaxResends in the code.
- It’s used to retrieve the current value of the setting using GetValueOnAnyThread().
- The variable is defined with a default value, description, and flags for the console variable system.
- It’s important to note that changes to this variable will immediately affect the behavior of the UDP message segmenter.
When working with CVarSegmenterMaxResends, developers should:
- Use the GetValueOnAnyThread() method to retrieve the current value in a thread-safe manner.
- Be aware that the value can change at runtime, so always fetch the latest value when needed.
- Consider performance implications of frequently accessing this value in performance-critical code paths.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Plugins/Messaging/UdpMessaging/Source/UdpMessaging/Private/Transport/UdpMessageSegmenter.cpp:238
Scope: file
Source code excerpt:
);
TAutoConsoleVariable<int32> CVarSegmenterMaxResends(
TEXT("MessageBus.UDP.SegmenterMaxResends"),
16,
TEXT("The number of attempts to resend data to an endpoint. Values are clamped between 1 and 100."),
ECVF_Default
);
bool FUdpMessageSegmenter::NeedSending(const FDateTime& CurrentTime)
#Associated Variable and Callsites
This variable is associated with another variable named CVarSegmenterMaxResends
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Plugins/Messaging/UdpMessaging/Source/UdpMessaging/Private/Transport/UdpMessageSegmenter.cpp:237
Scope: file
Source code excerpt:
ECVF_Default
);
TAutoConsoleVariable<int32> CVarSegmenterMaxResends(
TEXT("MessageBus.UDP.SegmenterMaxResends"),
16,
TEXT("The number of attempts to resend data to an endpoint. Values are clamped between 1 and 100."),
ECVF_Default
);
#Loc: <Workspace>/Engine/Plugins/Messaging/UdpMessaging/Source/UdpMessaging/Private/Transport/UdpMessageSegmenter.cpp:252
Scope (from outer to inner):
file
function bool FUdpMessageSegmenter::NeedSending
Source code excerpt:
}
const uint16 MaxNumResends = FMath::Clamp(CVarSegmenterMaxResends.GetValueOnAnyThread(), 1, 100);
if (AreAcknowledgementsComplete() == false && SentNumber > MaxNumResends)
{
UE_LOG(LogUdpMessaging, Warning, TEXT("Gave up sending with %d outstanding acks."), AcknowledgeSegments.Num() - AcknowledgeSegmentsCount);
SerializedMessage->UpdateState(EUdpSerializedMessageState::Invalid);
return false;
}