Skip to content

Commit 21cc234

Browse files
update mrp calculation
-- 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()
1 parent dca6ad9 commit 21cc234

File tree

3 files changed

+27
-6
lines changed

3 files changed

+27
-6
lines changed

src/messaging/ReliableMessageProtocolConfig.cpp

+7-2
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,15 @@ System::Clock::Timeout GetRetransmissionTimeout(System::Clock::Timeout activeInt
133133
// Calculate the retransmission timeout and take into account that an active/idle state change can happen
134134
// in the middle.
135135
System::Clock::Timestamp timeout(0);
136+
System::Clock::Milliseconds32 sitIcdSlowPollMaximum = System::Clock::Milliseconds32(15000);
136137
for (uint8_t i = 0; i < CHIP_CONFIG_RMP_DEFAULT_MAX_RETRANS + 1; i++)
137138
{
138-
auto baseInterval =
139-
((timeSinceLastActivity + timeout) < activityThreshold) ? activeInterval : min(activeInterval, idleInterval);
139+
auto baseInterval = activeInterval;
140+
if ((timeSinceLastActivity + timeout) >= activityThreshold) &&
141+
(idleInterval.count() <= sitIcdSlowPollMaximum.count()))
142+
{
143+
baseInterval = idleInterval;
144+
}
140145
timeout += Messaging::ReliableMessageMgr::GetBackoff(baseInterval, i, /* computeMaxPossible */ true);
141146
}
142147

src/transport/SecureSession.h

+10-2
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,16 @@ class SecureSession : public Session, public ReferenceCounted<SecureSession, Sec
265265

266266
System::Clock::Timestamp GetMRPBaseTimeout() const override
267267
{
268-
return IsPeerActive() ? GetRemoteMRPConfig().mActiveRetransTimeout
269-
: min(GetRemoteMRPConfig().mActiveRetransTimeout, GetRemoteMRPConfig().mIdleRetransTimeout);
268+
System::Clock::Milliseconds32 sitIcdSlowPollMaximum = System::Clock::Milliseconds32(15000);
269+
if (IsPeerActive())
270+
{
271+
return GetRemoteMRPConfig().mActiveRetransTimeout;
272+
}
273+
if (GetRemoteMRPConfig().mIdleRetransTimeout.count() <= sitIcdSlowPollMaximum.count())
274+
{
275+
return GetRemoteMRPConfig().mIdleRetransTimeout;
276+
}
277+
return GetRemoteMRPConfig().mActiveRetransTimeout;
270278
}
271279

272280
CryptoContext & GetCryptoContext() { return mCryptoContext; }

src/transport/UnauthenticatedSessionTable.h

+10-2
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,16 @@ class UnauthenticatedSession : public Session, public ReferenceCounted<Unauthent
155155

156156
System::Clock::Timestamp GetMRPBaseTimeout() const override
157157
{
158-
return IsPeerActive() ? GetRemoteMRPConfig().mActiveRetransTimeout
159-
: min(GetRemoteMRPConfig().mActiveRetransTimeout, GetRemoteMRPConfig().mIdleRetransTimeout);
158+
System::Clock::Milliseconds32 sitIcdSlowPollMaximum = System::Clock::Milliseconds32(15000);
159+
if (IsPeerActive())
160+
{
161+
return GetRemoteMRPConfig().mActiveRetransTimeout;
162+
}
163+
if (GetRemoteMRPConfig().mIdleRetransTimeout.count() <= sitIcdSlowPollMaximum.count())
164+
{
165+
return GetRemoteMRPConfig().mIdleRetransTimeout;
166+
}
167+
return GetRemoteMRPConfig().mActiveRetransTimeout;
160168
}
161169

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

0 commit comments

Comments
 (0)