Skip to content

Commit

Permalink
[MRP] Update GetAckTimeout to take into account the PeerActive status…
Browse files Browse the repository at this point in the history
… and use GetRestransmissionTimeout to be more accurate
  • Loading branch information
vivien-apple committed Oct 25, 2022
1 parent 7066ac5 commit 68c6f86
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ async def test_wifi(self, endpointId):
logger.info(f"Connect to a network")
req = Clusters.NetworkCommissioning.Commands.ConnectNetwork(
networkID=TEST_WIFI_SSID.encode(), breadcrumb=self.with_breadcrumb())
res = await self._devCtrl.SendCommand(nodeid=self._nodeid, endpoint=endpointId, payload=req)
res = await self._devCtrl.SendCommand(nodeid=self._nodeid, endpoint=endpointId, payload=req, interactionTimeoutMs=60000)
logger.info(f"Got response: {res}")
if res.networkingStatus != Clusters.NetworkCommissioning.Enums.NetworkCommissioningStatus.kSuccess:
raise AssertionError(f"Unexpected result: {res.networkingStatus}")
Expand Down
6 changes: 4 additions & 2 deletions src/transport/SecureSession.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ class SecureSession : public Session, public ReferenceCounted<SecureSession, Sec
switch (mPeerAddress.GetTransportType())
{
case Transport::Type::kUdp:
return GetRemoteMRPConfig().mIdleRetransTimeout * (CHIP_CONFIG_RMP_DEFAULT_MAX_RETRANS + 1);
return GetRetransmissionTimeout(mRemoteMRPConfig.mActiveRetransTimeout, mRemoteMRPConfig.mIdleRetransTimeout,
GetLastPeerActivityTime());
case Transport::Type::kTcp:
return System::Clock::Seconds16(30);
case Transport::Type::kBle:
Expand Down Expand Up @@ -222,7 +223,8 @@ class SecureSession : public Session, public ReferenceCounted<SecureSession, Sec

bool IsPeerActive() const
{
return ((System::SystemClock().GetMonotonicTimestamp() - GetLastPeerActivityTime()) < kMinActiveTime);
return ((System::SystemClock().GetMonotonicTimestamp() - GetLastPeerActivityTime()) <
GetRetransmissionTimeout(mRemoteMRPConfig.mActiveRetransTimeout));
}

System::Clock::Timestamp GetMRPBaseTimeout() const override
Expand Down
2 changes: 0 additions & 2 deletions src/transport/Session.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,6 @@ class UnauthenticatedSession;
class IncomingGroupSession;
class OutgoingGroupSession;

constexpr System::Clock::Milliseconds32 kMinActiveTime = System::Clock::Milliseconds32(4000);

class Session
{
public:
Expand Down
6 changes: 4 additions & 2 deletions src/transport/UnauthenticatedSessionTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ class UnauthenticatedSession : public Session,
switch (mPeerAddress.GetTransportType())
{
case Transport::Type::kUdp:
return GetRemoteMRPConfig().mIdleRetransTimeout * (CHIP_CONFIG_RMP_DEFAULT_MAX_RETRANS + 1);
return GetRetransmissionTimeout(mRemoteMRPConfig.mActiveRetransTimeout, mRemoteMRPConfig.mIdleRetransTimeout,
GetLastPeerActivityTime());
case Transport::Type::kTcp:
return System::Clock::Seconds16(30);
default:
Expand All @@ -113,7 +114,8 @@ class UnauthenticatedSession : public Session,

bool IsPeerActive() const
{
return ((System::SystemClock().GetMonotonicTimestamp() - GetLastPeerActivityTime()) < kMinActiveTime);
return ((System::SystemClock().GetMonotonicTimestamp() - GetLastPeerActivityTime()) <
GetRetransmissionTimeout(mRemoteMRPConfig.mActiveRetransTimeout));
}

System::Clock::Timestamp GetMRPBaseTimeout() const override
Expand Down

0 comments on commit 68c6f86

Please sign in to comment.