-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding MRP analytics delegate #37439
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright (c) 2025 Project CHIP Authors | ||
* All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/** | ||
* @file | ||
* This file defines interface for objects interested in MRP events for analytics | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <lib/core/DataModelTypes.h> | ||
#include <lib/core/NodeId.h> | ||
|
||
namespace chip { | ||
namespace Messaging { | ||
|
||
class ReliableMessageAnalyticsDelegate | ||
{ | ||
public: | ||
virtual ~ReliableMessageAnalyticsDelegate() = default; | ||
enum class EventType | ||
{ | ||
kInitialSend, | ||
kRetransmission, | ||
kAcknowledged, | ||
kFailed, | ||
kUndefined, /* Should be last element in enum */ | ||
}; | ||
|
||
struct TransmitEvent | ||
{ | ||
NodeId nodeId = kUndefinedNodeId; | ||
FabricIndex fabricIndex = kUndefinedFabricIndex; | ||
EventType eventType = EventType::kUndefined; | ||
uint32_t messageCounter = 0; | ||
}; | ||
|
||
virtual void OnTransmitEvent(const TransmitEvent & event) = 0; | ||
}; | ||
|
||
} // namespace Messaging | ||
} // namespace chip |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -155,6 +155,17 @@ void ReliableMessageMgr::ExecuteActions() | |
Transport::GetSessionTypeString(session), fabricIndex, ChipLogValueX64(destination), | ||
CHIP_CONFIG_RMP_DEFAULT_MAX_RETRANS); | ||
|
||
if (mAnalyticsDelegate) | ||
{ | ||
ReliableMessageAnalyticsDelegate::TransmitEvent event = { .nodeId = destination, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TODO needs to move outside of |
||
.fabricIndex = fabricIndex, | ||
.eventType = | ||
ReliableMessageAnalyticsDelegate::EventType::kFailed, | ||
.messageCounter = messageCounter }; | ||
|
||
mAnalyticsDelegate->OnTransmitEvent(event); | ||
} | ||
|
||
// If the exchange is expecting a response, it will handle sending | ||
// this notification once it detects that it has not gotten a | ||
// response. Otherwise, we need to do it. | ||
|
@@ -295,6 +306,25 @@ bool ReliableMessageMgr::CheckAndRemRetransTable(ReliableMessageContext * rc, ui | |
mRetransTable.ForEachActiveObject([&](auto * entry) { | ||
if (entry->ec->GetReliableMessageContext() == rc && entry->retainedBuf.GetMessageCounter() == ackMessageCounter) | ||
{ | ||
if (mAnalyticsDelegate) | ||
{ | ||
auto session = entry->ec->GetSessionHandle(); | ||
auto fabricIndex = session->GetFabricIndex(); | ||
auto destination = kUndefinedNodeId; | ||
if (session->IsSecureSession()) | ||
{ | ||
destination = session->AsSecureSession()->GetPeerNodeId(); | ||
} | ||
ReliableMessageAnalyticsDelegate::TransmitEvent event = { | ||
.nodeId = destination, | ||
.fabricIndex = fabricIndex, | ||
.eventType = ReliableMessageAnalyticsDelegate::EventType::kAcknowledged, | ||
.messageCounter = ackMessageCounter | ||
}; | ||
|
||
mAnalyticsDelegate->OnTransmitEvent(event); | ||
} | ||
|
||
// Clear the entry from the retransmision table. | ||
ClearRetransTable(*entry); | ||
|
||
|
@@ -440,6 +470,11 @@ void ReliableMessageMgr::RegisterSessionUpdateDelegate(SessionUpdateDelegate * s | |
mSessionUpdateDelegate = sessionUpdateDelegate; | ||
} | ||
|
||
void ReliableMessageMgr::RegisterAnalyticsDelegate(ReliableMessageAnalyticsDelegate * analyticsDelegate) | ||
{ | ||
mAnalyticsDelegate = analyticsDelegate; | ||
} | ||
|
||
CHIP_ERROR ReliableMessageMgr::MapSendError(CHIP_ERROR error, uint16_t exchangeId, bool isInitiator) | ||
{ | ||
if ( | ||
|
@@ -511,6 +546,22 @@ void ReliableMessageMgr::CalculateNextRetransTime(RetransTableEntry & entry) | |
peerIsActive = sessionHandle->AsUnauthenticatedSession()->IsPeerActive(); | ||
} | ||
|
||
// For initial send the packet has already been submitted to transport layer successfully. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How do people feel about the location of this and how re-transmission has technically not taken place yet |
||
// On re-transmits we do not know if transport layer is unable to retransmit for some | ||
// reason, so saying we have sent re-transmit here is a little presumptuous. | ||
if (mAnalyticsDelegate) | ||
{ | ||
ReliableMessageAnalyticsDelegate::TransmitEvent event = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TODO needs to move outside of |
||
.nodeId = destination, | ||
.fabricIndex = fabricIndex, | ||
.eventType = entry.sendCount == 0 ? ReliableMessageAnalyticsDelegate::EventType::kInitialSend | ||
: ReliableMessageAnalyticsDelegate::EventType::kRetransmission, | ||
.messageCounter = messageCounter | ||
}; | ||
|
||
mAnalyticsDelegate->OnTransmitEvent(event); | ||
} | ||
|
||
ChipLogProgress(ExchangeManager, | ||
"??%d [E:" ChipLogFormatExchange " S:%u M:" ChipLogFormatMessageCounter | ||
"] (%s) Msg Retransmission to %u:" ChipLogFormatX64 " in %" PRIu32 "ms [State:%s II:%" PRIu32 " AI:%" PRIu32 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this should be the first element 🤷