@@ -65,14 +65,6 @@ using namespace chip::System::Clock::Literals;
65
65
66
66
const char PAYLOAD[] = " Hello!" ;
67
67
68
- // The CHIP_CONFIG_MRP_RETRY_INTERVAL_SENDER_BOOST can be set to non-zero value
69
- // to boost the retransmission timeout for a high latency network like Thread to
70
- // avoid spurious retransmits.
71
- //
72
- // This adds extra I/O time to account for this. See the documentation for
73
- // CHIP_CONFIG_MRP_RETRY_INTERVAL_SENDER_BOOST for more details.
74
- constexpr auto retryBoosterTimeout = CHIP_CONFIG_RMP_DEFAULT_MAX_RETRANS * CHIP_CONFIG_MRP_RETRY_INTERVAL_SENDER_BOOST;
75
-
76
68
class TestContext : public chip ::Test::LoopbackMessagingContext
77
69
{
78
70
public:
@@ -324,6 +316,34 @@ struct BackoffComplianceTestVector theBackoffComplianceTestVector[] = { {
324
316
.backoffMax = System::Clock::Timeout (20'286'001 ),
325
317
} };
326
318
319
+ void CheckGetBackoffImpl (nlTestSuite * inSuite, System::Clock::Timeout additionalMRPBackoffTime)
320
+ {
321
+ ReliableMessageMgr::SetAdditionalMRPBackoffTime (MakeOptional (additionalMRPBackoffTime));
322
+
323
+ // Run 3x iterations to thoroughly test random jitter always results in backoff within bounds.
324
+ for (uint32_t j = 0 ; j < 3 ; j++)
325
+ {
326
+ for (const auto & test : theBackoffComplianceTestVector)
327
+ {
328
+ System::Clock::Timeout backoff = ReliableMessageMgr::GetBackoff (test.backoffBase , test.sendCount );
329
+ System::Clock::Timeout extraBackoff = additionalMRPBackoffTime;
330
+
331
+ #if CHIP_CONFIG_ENABLE_ICD_SERVER
332
+ // If running as an ICD, increase maxBackoff to account for the polling interval
333
+ extraBackoff += ICDConfigurationData::GetInstance ().GetFastPollingInterval ();
334
+ #endif
335
+
336
+ ChipLogProgress (Test, " Backoff base %" PRIu32 " extra %" PRIu32 " # %d: %" PRIu32, test.backoffBase .count (),
337
+ extraBackoff.count (), test.sendCount , backoff.count ());
338
+
339
+ NL_TEST_ASSERT (inSuite, backoff >= test.backoffMin + extraBackoff);
340
+ NL_TEST_ASSERT (inSuite, backoff <= test.backoffMax + extraBackoff);
341
+ }
342
+ }
343
+
344
+ ReliableMessageMgr::SetAdditionalMRPBackoffTime (NullOptional);
345
+ }
346
+
327
347
} // namespace
328
348
329
349
class TestReliableMessageProtocol
@@ -348,6 +368,7 @@ class TestReliableMessageProtocol
348
368
static void CheckLostStandaloneAck (nlTestSuite * inSuite, void * inContext);
349
369
static void CheckIsPeerActiveNotInitiator (nlTestSuite * inSuite, void * inContext);
350
370
static void CheckGetBackoff (nlTestSuite * inSuite, void * inContext);
371
+ static void CheckGetBackoffAdditionalTime (nlTestSuite * inSuite, void * inContext);
351
372
static void CheckApplicationResponseDelayed (nlTestSuite * inSuite, void * inContext);
352
373
static void CheckApplicationResponseNeverComes (nlTestSuite * inSuite, void * inContext);
353
374
};
@@ -449,7 +470,7 @@ void TestReliableMessageProtocol::CheckResendApplicationMessage(nlTestSuite * in
449
470
NL_TEST_ASSERT (inSuite, rm->TestGetCountRetransTable () == 1 );
450
471
451
472
// Wait for the initial message to fail (should take 330-413ms)
452
- ctx.GetIOContext ().DriveIOUntil (1000_ms32 + retryBoosterTimeout , [&] { return loopback.mSentMessageCount >= 2 ; });
473
+ ctx.GetIOContext ().DriveIOUntil (1000_ms32, [&] { return loopback.mSentMessageCount >= 2 ; });
453
474
now = System::SystemClock ().GetMonotonicTimestamp ();
454
475
timeoutTime = now - startTime;
455
476
ChipLogProgress (Test, " Attempt #1 Timeout : %" PRIu32 " ms" , timeoutTime.count ());
@@ -466,7 +487,7 @@ void TestReliableMessageProtocol::CheckResendApplicationMessage(nlTestSuite * in
466
487
NL_TEST_ASSERT (inSuite, rm->TestGetCountRetransTable () == 1 );
467
488
468
489
// Wait for the 1st retry to fail (should take 330-413ms)
469
- ctx.GetIOContext ().DriveIOUntil (1000_ms32 + retryBoosterTimeout , [&] { return loopback.mSentMessageCount >= 3 ; });
490
+ ctx.GetIOContext ().DriveIOUntil (1000_ms32, [&] { return loopback.mSentMessageCount >= 3 ; });
470
491
now = System::SystemClock ().GetMonotonicTimestamp ();
471
492
timeoutTime = now - startTime;
472
493
ChipLogProgress (Test, " Attempt #2 Timeout : %" PRIu32 " ms" , timeoutTime.count ());
@@ -483,7 +504,7 @@ void TestReliableMessageProtocol::CheckResendApplicationMessage(nlTestSuite * in
483
504
NL_TEST_ASSERT (inSuite, rm->TestGetCountRetransTable () == 1 );
484
505
485
506
// Wait for the 2nd retry to fail (should take 528-660ms)
486
- ctx.GetIOContext ().DriveIOUntil (1000_ms32 + retryBoosterTimeout , [&] { return loopback.mSentMessageCount >= 4 ; });
507
+ ctx.GetIOContext ().DriveIOUntil (1000_ms32, [&] { return loopback.mSentMessageCount >= 4 ; });
487
508
now = System::SystemClock ().GetMonotonicTimestamp ();
488
509
timeoutTime = now - startTime;
489
510
ChipLogProgress (Test, " Attempt #3 Timeout : %" PRIu32 " ms" , timeoutTime.count ());
@@ -500,7 +521,7 @@ void TestReliableMessageProtocol::CheckResendApplicationMessage(nlTestSuite * in
500
521
NL_TEST_ASSERT (inSuite, rm->TestGetCountRetransTable () == 1 );
501
522
502
523
// Wait for the 3rd retry to fail (should take 845-1056ms)
503
- ctx.GetIOContext ().DriveIOUntil (1500_ms32 + retryBoosterTimeout , [&] { return loopback.mSentMessageCount >= 5 ; });
524
+ ctx.GetIOContext ().DriveIOUntil (1500_ms32, [&] { return loopback.mSentMessageCount >= 5 ; });
504
525
now = System::SystemClock ().GetMonotonicTimestamp ();
505
526
timeoutTime = now - startTime;
506
527
ChipLogProgress (Test, " Attempt #4 Timeout : %" PRIu32 " ms" , timeoutTime.count ());
@@ -1845,25 +1866,12 @@ void TestReliableMessageProtocol::CheckLostStandaloneAck(nlTestSuite * inSuite,
1845
1866
1846
1867
void TestReliableMessageProtocol::CheckGetBackoff (nlTestSuite * inSuite, void * inContext)
1847
1868
{
1848
- // Run 3x iterations to thoroughly test random jitter always results in backoff within bounds.
1849
- for (uint32_t j = 0 ; j < 3 ; j++)
1850
- {
1851
- for (const auto & test : theBackoffComplianceTestVector)
1852
- {
1853
- System::Clock::Timeout backoff = ReliableMessageMgr::GetBackoff (test.backoffBase , test.sendCount );
1854
- ChipLogProgress (Test, " Backoff base %" PRIu32 " # %d: %" PRIu32, test.backoffBase .count (), test.sendCount ,
1855
- backoff.count ());
1856
-
1857
- NL_TEST_ASSERT (inSuite, backoff >= test.backoffMin );
1869
+ CheckGetBackoffImpl (inSuite, System::Clock::kZero );
1870
+ }
1858
1871
1859
- auto maxBackoff = test.backoffMax + retryBoosterTimeout;
1860
- #if CHIP_CONFIG_ENABLE_ICD_SERVER == 1
1861
- // If running as an ICD, increase maxBackoff to account for the polling interval
1862
- maxBackoff += ICDConfigurationData::GetInstance ().GetSlowPollingInterval ();
1863
- #endif
1864
- NL_TEST_ASSERT (inSuite, backoff <= maxBackoff);
1865
- }
1866
- }
1872
+ void TestReliableMessageProtocol::CheckGetBackoffAdditionalTime (nlTestSuite * inSuite, void * inContext)
1873
+ {
1874
+ CheckGetBackoffImpl (inSuite, System::Clock::Seconds32 (1 ));
1867
1875
}
1868
1876
1869
1877
void TestReliableMessageProtocol::CheckApplicationResponseDelayed (nlTestSuite * inSuite, void * inContext)
@@ -2207,6 +2215,7 @@ const nlTest sTests[] = {
2207
2215
TestReliableMessageProtocol::CheckLostStandaloneAck),
2208
2216
NL_TEST_DEF (" Test Is Peer Active Retry logic" , TestReliableMessageProtocol::CheckIsPeerActiveNotInitiator),
2209
2217
NL_TEST_DEF (" Test MRP backoff algorithm" , TestReliableMessageProtocol::CheckGetBackoff),
2218
+ NL_TEST_DEF (" Test MRP backoff algorithm with additional time" , TestReliableMessageProtocol::CheckGetBackoffAdditionalTime),
2210
2219
// TODO: Re-enable this test, after changing test to use Mock clock / DriveIO rather than DriveIOUntil.
2211
2220
// Issue: https://github.com/project-chip/connectedhomeip/issues/32440
2212
2221
// NL_TEST_DEF("Test an application response that comes after MRP retransmits run out",
0 commit comments