@@ -61,14 +61,6 @@ using namespace chip::System::Clock::Literals;
61
61
62
62
const char PAYLOAD[] = " Hello!" ;
63
63
64
- // The CHIP_CONFIG_MRP_RETRY_INTERVAL_SENDER_BOOST can be set to non-zero value
65
- // to boost the retransmission timeout for a high latency network like Thread to
66
- // avoid spurious retransmits.
67
- //
68
- // This adds extra I/O time to account for this. See the documentation for
69
- // CHIP_CONFIG_MRP_RETRY_INTERVAL_SENDER_BOOST for more details.
70
- constexpr auto retryBoosterTimeout = CHIP_CONFIG_RMP_DEFAULT_MAX_RETRANS * CHIP_CONFIG_MRP_RETRY_INTERVAL_SENDER_BOOST;
71
-
72
64
class TestContext : public chip ::Test::LoopbackMessagingContext
73
65
{
74
66
public:
@@ -312,6 +304,34 @@ struct BackoffComplianceTestVector theBackoffComplianceTestVector[] = {
312
304
},
313
305
};
314
306
307
+ void CheckGetBackoffImpl (nlTestSuite * inSuite, System::Clock::Timeout additionalMRPBackoffTime)
308
+ {
309
+ ReliableMessageMgr::SetAdditionalMRPBackoffTime (MakeOptional (additionalMRPBackoffTime));
310
+
311
+ // Run 3x iterations to thoroughly test random jitter always results in backoff within bounds.
312
+ for (uint32_t j = 0 ; j < 3 ; j++)
313
+ {
314
+ for (const auto & test : theBackoffComplianceTestVector)
315
+ {
316
+ System::Clock::Timeout backoff = ReliableMessageMgr::GetBackoff (test.backoffBase , test.sendCount );
317
+ System::Clock::Timeout extraBackoff = additionalMRPBackoffTime;
318
+
319
+ #if CHIP_CONFIG_ENABLE_ICD_SERVER
320
+ // If running as an ICD, increase maxBackoff to account for the polling interval
321
+ extraBackoff += ICDConfigurationData::GetInstance ().GetFastPollingInterval ();
322
+ #endif
323
+
324
+ ChipLogProgress (Test, " Backoff base %" PRIu32 " extra %" PRIu32 " # %d: %" PRIu32, test.backoffBase .count (),
325
+ extraBackoff.count (), test.sendCount , backoff.count ());
326
+
327
+ NL_TEST_ASSERT (inSuite, backoff >= test.backoffMin + extraBackoff);
328
+ NL_TEST_ASSERT (inSuite, backoff <= test.backoffMax + extraBackoff);
329
+ }
330
+ }
331
+
332
+ ReliableMessageMgr::SetAdditionalMRPBackoffTime (NullOptional);
333
+ }
334
+
315
335
} // namespace
316
336
317
337
class TestReliableMessageProtocol
@@ -336,6 +356,7 @@ class TestReliableMessageProtocol
336
356
static void CheckLostStandaloneAck (nlTestSuite * inSuite, void * inContext);
337
357
static void CheckIsPeerActiveNotInitiator (nlTestSuite * inSuite, void * inContext);
338
358
static void CheckGetBackoff (nlTestSuite * inSuite, void * inContext);
359
+ static void CheckGetBackoffAdditionalTime (nlTestSuite * inSuite, void * inContext);
339
360
static void CheckApplicationResponseDelayed (nlTestSuite * inSuite, void * inContext);
340
361
static void CheckApplicationResponseNeverComes (nlTestSuite * inSuite, void * inContext);
341
362
};
@@ -437,7 +458,7 @@ void TestReliableMessageProtocol::CheckResendApplicationMessage(nlTestSuite * in
437
458
NL_TEST_ASSERT (inSuite, rm->TestGetCountRetransTable () == 1 );
438
459
439
460
// Wait for the initial message to fail (should take 330-413ms)
440
- ctx.GetIOContext ().DriveIOUntil (1000_ms32 + retryBoosterTimeout , [&] { return loopback.mSentMessageCount >= 2 ; });
461
+ ctx.GetIOContext ().DriveIOUntil (1000_ms32, [&] { return loopback.mSentMessageCount >= 2 ; });
441
462
now = System::SystemClock ().GetMonotonicTimestamp ();
442
463
timeoutTime = now - startTime;
443
464
ChipLogProgress (Test, " Attempt #1 Timeout : %" PRIu32 " ms" , timeoutTime.count ());
@@ -454,7 +475,7 @@ void TestReliableMessageProtocol::CheckResendApplicationMessage(nlTestSuite * in
454
475
NL_TEST_ASSERT (inSuite, rm->TestGetCountRetransTable () == 1 );
455
476
456
477
// Wait for the 1st retry to fail (should take 330-413ms)
457
- ctx.GetIOContext ().DriveIOUntil (1000_ms32 + retryBoosterTimeout , [&] { return loopback.mSentMessageCount >= 3 ; });
478
+ ctx.GetIOContext ().DriveIOUntil (1000_ms32, [&] { return loopback.mSentMessageCount >= 3 ; });
458
479
now = System::SystemClock ().GetMonotonicTimestamp ();
459
480
timeoutTime = now - startTime;
460
481
ChipLogProgress (Test, " Attempt #2 Timeout : %" PRIu32 " ms" , timeoutTime.count ());
@@ -471,7 +492,7 @@ void TestReliableMessageProtocol::CheckResendApplicationMessage(nlTestSuite * in
471
492
NL_TEST_ASSERT (inSuite, rm->TestGetCountRetransTable () == 1 );
472
493
473
494
// Wait for the 2nd retry to fail (should take 528-660ms)
474
- ctx.GetIOContext ().DriveIOUntil (1000_ms32 + retryBoosterTimeout , [&] { return loopback.mSentMessageCount >= 4 ; });
495
+ ctx.GetIOContext ().DriveIOUntil (1000_ms32, [&] { return loopback.mSentMessageCount >= 4 ; });
475
496
now = System::SystemClock ().GetMonotonicTimestamp ();
476
497
timeoutTime = now - startTime;
477
498
ChipLogProgress (Test, " Attempt #3 Timeout : %" PRIu32 " ms" , timeoutTime.count ());
@@ -488,7 +509,7 @@ void TestReliableMessageProtocol::CheckResendApplicationMessage(nlTestSuite * in
488
509
NL_TEST_ASSERT (inSuite, rm->TestGetCountRetransTable () == 1 );
489
510
490
511
// Wait for the 3rd retry to fail (should take 845-1056ms)
491
- ctx.GetIOContext ().DriveIOUntil (1500_ms32 + retryBoosterTimeout , [&] { return loopback.mSentMessageCount >= 5 ; });
512
+ ctx.GetIOContext ().DriveIOUntil (1500_ms32, [&] { return loopback.mSentMessageCount >= 5 ; });
492
513
now = System::SystemClock ().GetMonotonicTimestamp ();
493
514
timeoutTime = now - startTime;
494
515
ChipLogProgress (Test, " Attempt #4 Timeout : %" PRIu32 " ms" , timeoutTime.count ());
@@ -1833,25 +1854,12 @@ void TestReliableMessageProtocol::CheckLostStandaloneAck(nlTestSuite * inSuite,
1833
1854
1834
1855
void TestReliableMessageProtocol::CheckGetBackoff (nlTestSuite * inSuite, void * inContext)
1835
1856
{
1836
- // Run 3x iterations to thoroughly test random jitter always results in backoff within bounds.
1837
- for (uint32_t j = 0 ; j < 3 ; j++)
1838
- {
1839
- for (const auto & test : theBackoffComplianceTestVector)
1840
- {
1841
- System::Clock::Timeout backoff = ReliableMessageMgr::GetBackoff (test.backoffBase , test.sendCount );
1842
- ChipLogProgress (Test, " Backoff base %" PRIu32 " # %d: %" PRIu32, test.backoffBase .count (), test.sendCount ,
1843
- backoff.count ());
1844
-
1845
- NL_TEST_ASSERT (inSuite, backoff >= test.backoffMin );
1857
+ CheckGetBackoffImpl (inSuite, System::Clock::kZero );
1858
+ }
1846
1859
1847
- auto maxBackoff = test.backoffMax + retryBoosterTimeout;
1848
- #if CHIP_CONFIG_ENABLE_ICD_SERVER == 1
1849
- // If running as an ICD, increase maxBackoff to account for the polling interval
1850
- maxBackoff += ICDConfigurationData::GetInstance ().GetSlowPollingInterval ();
1851
- #endif
1852
- NL_TEST_ASSERT (inSuite, backoff <= maxBackoff);
1853
- }
1854
- }
1860
+ void TestReliableMessageProtocol::CheckGetBackoffAdditionalTime (nlTestSuite * inSuite, void * inContext)
1861
+ {
1862
+ CheckGetBackoffImpl (inSuite, System::Clock::Seconds32 (1 ));
1855
1863
}
1856
1864
1857
1865
void TestReliableMessageProtocol::CheckApplicationResponseDelayed (nlTestSuite * inSuite, void * inContext)
@@ -2195,6 +2203,7 @@ const nlTest sTests[] = {
2195
2203
TestReliableMessageProtocol::CheckLostStandaloneAck),
2196
2204
NL_TEST_DEF (" Test Is Peer Active Retry logic" , TestReliableMessageProtocol::CheckIsPeerActiveNotInitiator),
2197
2205
NL_TEST_DEF (" Test MRP backoff algorithm" , TestReliableMessageProtocol::CheckGetBackoff),
2206
+ NL_TEST_DEF (" Test MRP backoff algorithm with additional time" , TestReliableMessageProtocol::CheckGetBackoffAdditionalTime),
2198
2207
// TODO: Re-enable this test, after changing test to use Mock clock / DriveIO rather than DriveIOUntil.
2199
2208
// Issue: https://github.com/project-chip/connectedhomeip/issues/32440
2200
2209
// NL_TEST_DEF("Test an application response that comes after MRP retransmits run out",
0 commit comments