Skip to content

Commit

Permalink
update mrp calculation
Browse files Browse the repository at this point in the history
-- Use 15 seconds to determine whether device is in LIT mode, then if
yes, set the timeout base as SAI if GetRemoteMRPConfig().mIdleRetransTimeout.count() > sitIcdSlowPollMaximum.count()
  • Loading branch information
yunhanw-google committed Feb 22, 2025
1 parent dca6ad9 commit 21cc234
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
9 changes: 7 additions & 2 deletions src/messaging/ReliableMessageProtocolConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,15 @@ System::Clock::Timeout GetRetransmissionTimeout(System::Clock::Timeout activeInt
// Calculate the retransmission timeout and take into account that an active/idle state change can happen
// in the middle.
System::Clock::Timestamp timeout(0);
System::Clock::Milliseconds32 sitIcdSlowPollMaximum = System::Clock::Milliseconds32(15000);
for (uint8_t i = 0; i < CHIP_CONFIG_RMP_DEFAULT_MAX_RETRANS + 1; i++)
{
auto baseInterval =
((timeSinceLastActivity + timeout) < activityThreshold) ? activeInterval : min(activeInterval, idleInterval);
auto baseInterval = activeInterval;
if ((timeSinceLastActivity + timeout) >= activityThreshold) &&
(idleInterval.count() <= sitIcdSlowPollMaximum.count()))
{
baseInterval = idleInterval;
}
timeout += Messaging::ReliableMessageMgr::GetBackoff(baseInterval, i, /* computeMaxPossible */ true);
}

Expand Down
12 changes: 10 additions & 2 deletions src/transport/SecureSession.h
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,16 @@ class SecureSession : public Session, public ReferenceCounted<SecureSession, Sec

System::Clock::Timestamp GetMRPBaseTimeout() const override
{
return IsPeerActive() ? GetRemoteMRPConfig().mActiveRetransTimeout
: min(GetRemoteMRPConfig().mActiveRetransTimeout, GetRemoteMRPConfig().mIdleRetransTimeout);
System::Clock::Milliseconds32 sitIcdSlowPollMaximum = System::Clock::Milliseconds32(15000);
if (IsPeerActive())
{
return GetRemoteMRPConfig().mActiveRetransTimeout;
}
if (GetRemoteMRPConfig().mIdleRetransTimeout.count() <= sitIcdSlowPollMaximum.count())
{
return GetRemoteMRPConfig().mIdleRetransTimeout;
}
return GetRemoteMRPConfig().mActiveRetransTimeout;
}

CryptoContext & GetCryptoContext() { return mCryptoContext; }
Expand Down
12 changes: 10 additions & 2 deletions src/transport/UnauthenticatedSessionTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,16 @@ class UnauthenticatedSession : public Session, public ReferenceCounted<Unauthent

System::Clock::Timestamp GetMRPBaseTimeout() const override
{
return IsPeerActive() ? GetRemoteMRPConfig().mActiveRetransTimeout
: min(GetRemoteMRPConfig().mActiveRetransTimeout, GetRemoteMRPConfig().mIdleRetransTimeout);
System::Clock::Milliseconds32 sitIcdSlowPollMaximum = System::Clock::Milliseconds32(15000);
if (IsPeerActive())
{
return GetRemoteMRPConfig().mActiveRetransTimeout;
}
if (GetRemoteMRPConfig().mIdleRetransTimeout.count() <= sitIcdSlowPollMaximum.count())
{
return GetRemoteMRPConfig().mIdleRetransTimeout;
}
return GetRemoteMRPConfig().mActiveRetransTimeout;
}

void SetRemoteSessionParameters(const SessionParameters & sessionParams) { mRemoteSessionParams = sessionParams; }
Expand Down

0 comments on commit 21cc234

Please sign in to comment.