diff --git a/src/transport/SecureSession.h b/src/transport/SecureSession.h index 8146884cf15373..494dbf3f280a54 100644 --- a/src/transport/SecureSession.h +++ b/src/transport/SecureSession.h @@ -67,7 +67,9 @@ class SecureSession : public Session FabricIndex fabric, const ReliableMessageProtocolConfig & config) : mSecureSessionType(secureSessionType), mPeerNodeId(peerNodeId), mPeerCATs(peerCATs), mLocalSessionId(localSessionId), mPeerSessionId(peerSessionId), - mLastActivityTime(System::SystemClock().GetMonotonicTimestamp()), mMRPConfig(config) + mLastActivityTime(System::SystemClock().GetMonotonicTimestamp()), + mLastPeerActivityTime(System::SystemClock().GetMonotonicTimestamp()), + mMRPConfig(config) { SetFabricIndex(fabric); } @@ -134,7 +136,12 @@ class SecureSession : public Session } System::Clock::Timestamp GetLastActivityTime() const { return mLastActivityTime; } + System::Clock::Timestamp GetLastPeerActivityTime() const { return mLastPeerActivityTime; } void MarkActive() { mLastActivityTime = System::SystemClock().GetMonotonicTimestamp(); } + void MarkActiveRx() { + mLastPeerActivityTime = System::SystemClock().GetMonotonicTimestamp(); + MarkActive(); + } CryptoContext & GetCryptoContext() { return mCryptoContext; } @@ -148,7 +155,8 @@ class SecureSession : public Session const uint16_t mPeerSessionId; PeerAddress mPeerAddress; - System::Clock::Timestamp mLastActivityTime; + System::Clock::Timestamp mLastActivityTime; ///< Timestamp of last tx or rx + System::Clock::Timestamp mLastPeerActivityTime; ///< Timestamp of last rx ReliableMessageProtocolConfig mMRPConfig; CryptoContext mCryptoContext; SessionMessageCounter mSessionMessageCounter; diff --git a/src/transport/SessionManager.cpp b/src/transport/SessionManager.cpp index 652193a7d93fc1..74ea4932a8f16a 100644 --- a/src/transport/SessionManager.cpp +++ b/src/transport/SessionManager.cpp @@ -528,7 +528,7 @@ void SessionManager::UnauthenticatedMessageDispatch(const PacketHeader & packetH unsecuredSession->SetPeerAddress(peerAddress); SessionMessageDelegate::DuplicateMessage isDuplicate = SessionMessageDelegate::DuplicateMessage::No; - unsecuredSession->MarkActive(); + unsecuredSession->MarkActiveRx(); PayloadHeader payloadHeader; ReturnOnFailure(payloadHeader.DecodeAndConsume(msg)); @@ -612,7 +612,7 @@ void SessionManager::SecureUnicastMessageDispatch(const PacketHeader & packetHea return; } - secureSession->MarkActive(); + secureSession->MarkActiveRx(); if (isDuplicate == SessionMessageDelegate::DuplicateMessage::Yes && !payloadHeader.NeedsAck()) { diff --git a/src/transport/UnauthenticatedSessionTable.h b/src/transport/UnauthenticatedSessionTable.h index 5ac2211fd06d05..59dc581d47f795 100644 --- a/src/transport/UnauthenticatedSessionTable.h +++ b/src/transport/UnauthenticatedSessionTable.h @@ -54,7 +54,9 @@ class UnauthenticatedSession : public Session, public ReferenceCounted