mirror of
https://github.com/espressif/openthread.git
synced 2026-08-13 06:07:48 +00:00
[srp-client] use proportional jitter for retry timer (#12044)
This change updates the jitter calculation for the SRP client's retry mechanism. Previously, a fixed jitter value was used. This could lead to synchronized retries from multiple clients, especially as the retry interval grows. The new implementation calculates the jitter as a fraction of the current retry interval (1/5th), ensuring that the jitter scales with the wait time. This helps to better decorrelate retries from different clients. A new constant `kRetryJitterDivisor` is introduced for this calculation. The jitter is clamped to a minimum value given by `kRetryIntervalJitter`.
This commit is contained in:
@@ -1088,8 +1088,15 @@ exit:
|
||||
}
|
||||
else
|
||||
{
|
||||
uint16_t retryJitter;
|
||||
|
||||
LogRetryWaitInterval();
|
||||
mTimer.Start(Random::NonCrypto::AddJitter(GetRetryWaitInterval(), kRetryIntervalJitter));
|
||||
|
||||
// Use a divisor of current retry interval for jitter
|
||||
retryJitter = ClampToUint16(GetRetryWaitInterval() / kRetryJitterDivisor);
|
||||
retryJitter = Max(retryJitter, kRetryIntervalJitter);
|
||||
mTimer.Start(Random::NonCrypto::AddJitter(GetRetryWaitInterval(), retryJitter));
|
||||
|
||||
GrowRetryWaitInterval();
|
||||
InvokeCallback(error);
|
||||
}
|
||||
|
||||
@@ -845,6 +845,7 @@ private:
|
||||
|
||||
static constexpr uint16_t kTxFailureRetryJitter = 10; // in ms
|
||||
static constexpr uint16_t kRetryIntervalJitter = OPENTHREAD_CONFIG_SRP_CLIENT_RETRY_WAIT_INTERVAL_JITTER; // in ms
|
||||
static constexpr uint32_t kRetryJitterDivisor = 5; // divisor for proportional jitter (1/N of retry interval)
|
||||
|
||||
static_assert(kDefaultLease <= static_cast<uint32_t>(kMaxLease), "kDefaultLease is larger than max");
|
||||
static_assert(kDefaultKeyLease <= static_cast<uint32_t>(kMaxLease), "kDefaultKeyLease is larger than max");
|
||||
|
||||
Reference in New Issue
Block a user