[Messaging] Force idle timeout for first message of exchange#72756
[Messaging] Force idle timeout for first message of exchange#72756andy31415 wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors the CalculateNextRetransTime method in ReliableMessageMgr.cpp to determine the base retransmission timeout using an immediately invoked lambda expression (IIFE). However, the lambda expression as written will fail to compile because its return statements yield mismatched types (System::Clock::Milliseconds32 and System::Clock::Timeout). It is recommended to replace the IIFE with a standard if-else block, which resolves the compilation error and simplifies the code by leveraging implicit type conversion.
According to Matter Core Specification §4.12.2.1, the first message of a new exchange SHALL use the idle retransmission timeout (SII) of the peer, as we cannot assume the peer is active yet. Subsequent messages SHOULD use the active state of the peer (dynamic based on PeerActiveMode, i.e. using GetMRPBaseTimeout()), unless the sender has other means to determine if the device is active. We implement these "other means" via GetMRPBaseTimeout(), which tracks peer activity against the Session Active Threshold (SAT). This fixes a spec violation introduced in PR project-chip#72230, where the first message could use active timeout if the session was considered active (e.g. fresh session).
for more information, see https://pre-commit.ci
592905b to
0e8d0a5
Compare
|
PR #72756: Size comparison from 51d1d76 to 0e8d0a5 Full report (33 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, efr32, esp32, nrfconnect, psoc6, qpg, realtek, stm32, telink)
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #72756 +/- ##
==========================================
- Coverage 56.79% 56.60% -0.19%
==========================================
Files 1642 1642
Lines 112757 113141 +384
Branches 13139 13245 +106
==========================================
+ Hits 64041 64049 +8
- Misses 48716 49092 +376 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| // We use the idle retransmission timeout (SII) from the session. | ||
| return sessionHandle->GetRemoteMRPConfig().mIdleRetransTimeout; |
There was a problem hiding this comment.
Why? The "idle state of the peer" is "is the peer idle or active?" and you're supposed to ask the session that.
There was a problem hiding this comment.
Are you refering to
bool IsPeerActive() const
{
return ((System::SystemClock().GetMonotonicTimestamp() - GetLastPeerActivityTime()) <
GetRemoteMRPConfig().mActiveThresholdTime);
}
This is used to determine sessionHandle->GetMRPBaseTimeout() like below. It could be used here yes.
The problem with only this check tho is that GetRemoteMRPConfig().mActiveThresholdTime could be set to 0 and then IsPeerActive is always false.
But in reality the ICD device should not go to Idle while a Exchange Context is open.
(Yes we did discus that the spec isn't enforcing this, but this is a real issue we should look into clearing that up too)
|
Closing for now ... this behavior needs settling in ICD TT ... |
Summary
Re-work of #72230 - that change made
GetMRPBaseTimeoutto be used for all messages, including the first message of an exchange. For a newly created session, the peer is considered active (due to fresh session activity time being within SAT), soGetMRPBaseTimeout()returns SAI.According to Matter Core Specification §4.12.2.1:
Using SAI for the first message on a fresh session is a spec violation.
Change
This PR reworks the logic in
ReliableMessageMgr::CalculateNextRetransTimeto satisfy both requirements:mIdleRetransTimeout), complying with the spec.GetMRPBaseTimeout()to dynamically switch between SAI and SII based on peer activity and SAT, preserving the fix from [Messaging] Honor peer SAT in MRP retransmit backoff for ICDs #72230.Testing
Verified that all unit tests in
TestReliableMessageProtocolpass, including:CheckPeerRetxUsesIdleBackoffWhenNoMessagesReceived(which verifies that the first message uses idle backoff).