MessageBus.UDP.SegmenterTimeout
MessageBus.UDP.SegmenterTimeout
#Overview
name: MessageBus.UDP.SegmenterTimeout
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
The number of milliseconds to wait for a segment to be acknowledge before attempting to resend. Values are clamped between 10 and 1000
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of MessageBus.UDP.SegmenterTimeout is to control the timeout duration for UDP message segmentation in Unreal Engine’s messaging system. Specifically, it determines how long the system waits for a segment to be acknowledged before attempting to resend it.
This setting variable is primarily used within the UDP Messaging plugin, which is part of Unreal Engine’s networking and communication subsystem. Based on the callsites, it’s clear that this variable is utilized in the UdpMessageSegmenter class, which handles the segmentation of large UDP messages.
The value of this variable is set using a console variable (CVar) system. It’s initialized with a default value of 100 milliseconds but can be changed at runtime through console commands or configuration files.
The associated variable CVarSegmenterTimeout interacts directly with MessageBus.UDP.SegmenterTimeout. They essentially represent the same setting, with CVarSegmenterTimeout being the C++ implementation of the console variable.
Developers must be aware of the following when using this variable:
- The value is clamped between 10 and 1000 milliseconds (as per the description), although the actual implementation clamps it between 10 and 5000 milliseconds.
- Changing this value affects the reliability and performance of UDP message transmission in the engine.
- The timeout value is used in the NeedSending function to determine when to resend unacknowledged segments.
Best practices when using this variable include:
- Adjust the value based on network conditions and requirements of your specific game or application.
- Monitor network performance and adjust accordingly. A lower value might improve responsiveness but could increase network traffic, while a higher value might reduce unnecessary retransmissions but could introduce more latency.
- Consider the interaction with other networking settings, such as CVarSegmenterMaxResends, to optimize overall network performance.
Regarding the associated variable CVarSegmenterTimeout:
- Its purpose is to provide a programmatic interface to the MessageBus.UDP.SegmenterTimeout setting.
- It’s used within the UdpMessageSegmenter class to retrieve the current timeout value.
- The value is accessed using the GetValueOnAnyThread() method, which suggests it’s designed for thread-safe access.
- Developers should use this variable when they need to programmatically read or modify the segmenter timeout within C++ code.
- Best practices include using the provided FMath::Clamp function when applying the value to ensure it stays within the intended range.
#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:232
Scope: file
Source code excerpt:
TAutoConsoleVariable<int32> CVarSegmenterTimeout(
TEXT("MessageBus.UDP.SegmenterTimeout"),
100,
TEXT("The number of milliseconds to wait for a segment to be acknowledge before attempting to resend. Values are clamped between 10 and 1000"),
ECVF_Default
);
TAutoConsoleVariable<int32> CVarSegmenterMaxResends(
TEXT("MessageBus.UDP.SegmenterMaxResends"),
#Associated Variable and Callsites
This variable is associated with another variable named CVarSegmenterTimeout
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Plugins/Messaging/UdpMessaging/Source/UdpMessaging/Private/Transport/UdpMessageSegmenter.cpp:231
Scope: file
Source code excerpt:
}
TAutoConsoleVariable<int32> CVarSegmenterTimeout(
TEXT("MessageBus.UDP.SegmenterTimeout"),
100,
TEXT("The number of milliseconds to wait for a segment to be acknowledge before attempting to resend. Values are clamped between 10 and 1000"),
ECVF_Default
);
TAutoConsoleVariable<int32> CVarSegmenterMaxResends(
#Loc: <Workspace>/Engine/Plugins/Messaging/UdpMessaging/Source/UdpMessaging/Private/Transport/UdpMessageSegmenter.cpp:260
Scope (from outer to inner):
file
function bool FUdpMessageSegmenter::NeedSending
Source code excerpt:
}
const int32 NumMs = FMath::Clamp(CVarSegmenterTimeout.GetValueOnAnyThread(), 10, 5000);
const FTimespan SendInterval = FTimespan::FromMilliseconds(NumMs);
if (AreAcknowledgementsComplete() == false
&& LastSentTime + SendInterval <= CurrentTime)
{
// We have gone through a period of time where packets or acks may have been lost,
// so resend any segments that have yet to be acknowledged