Skip to content

Commit

Permalink
[mrp] Default to active timeout.
Browse files Browse the repository at this point in the history
  • Loading branch information
turon committed Mar 10, 2022
1 parent a8b4057 commit b690e72
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/messaging/ReliableMessageMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ CHIP_ERROR ReliableMessageMgr::AddToRetransTable(ReliableMessageContext * rc, Re
System::Clock::Timestamp ReliableMessageMgr::GetBackoff(System::Clock::Timestamp baseInterval, uint8_t sendCount)
{
#define MRP_BACKOFF_JITTER_BASE 1000
#define MRP_BACKOFF_JITTER_MAX 250
#define MRP_BACKOFF_BASE_NUMERATOR 16
#define MRP_BACKOFF_BASE_DENOMENATOR 10

Expand All @@ -213,7 +214,7 @@ System::Clock::Timestamp ReliableMessageMgr::GetBackoff(System::Clock::Timestamp
backoff = backoff * backoffNum / backoffDenom;

// Generate jitter as random multiplier from 1.000 to 1.250:
unsigned jitter = MRP_BACKOFF_JITTER_BASE + Crypto::GetRandU8() % 250;
unsigned jitter = MRP_BACKOFF_JITTER_BASE + Crypto::GetRandU16() % MRP_BACKOFF_JITTER_MAX;
backoff = backoff * jitter / MRP_BACKOFF_JITTER_BASE;

return backoff;
Expand All @@ -223,7 +224,7 @@ void ReliableMessageMgr::StartRetransmision(RetransTableEntry * entry)
{
// TODO(#15800): Choose active/idle timeout corresponding to the ActiveState of peer in session.
System::Clock::Timestamp backoff =
GetBackoff(entry->ec->GetSessionHandle()->GetMRPConfig().mIdleRetransTimeout, entry->sendCount);
GetBackoff(entry->ec->GetSessionHandle()->GetMRPConfig().mActiveRetransTimeout, entry->sendCount);
entry->nextRetransTime = System::SystemClock().GetMonotonicTimestamp() + backoff;
StartTimer();
}
Expand Down
2 changes: 1 addition & 1 deletion src/protocols/secure_channel/tests/TestPASESession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ void SecurePairingHandshakeTestCommon(nlTestSuite * inSuite, void * inContext, P

while (gLoopback.mMessageDropped)
{
chip::test_utils::SleepMillis(65);
chip::test_utils::SleepMillis(85);
gLoopback.mMessageDropped = false;
ReliableMessageMgr::Timeout(&ctx.GetSystemLayer(), ctx.GetExchangeManager().GetReliableMessageMgr());
ctx.DrainAndServiceIO();
Expand Down

0 comments on commit b690e72

Please sign in to comment.