@@ -101,6 +101,35 @@ void ReliableMessageMgr::TicklessDebugDumpRetransTable(const char * log)
101
101
#endif
102
102
}
103
103
104
+ #if CHIP_CONFIG_MRP_ANALYTICS_ENABLED
105
+ void ReliableMessageMgr::NotifyMessageSendAnalytics (const RetransTableEntry & entry, const SessionHandle & sessionHandle,
106
+ const ReliableMessageAnalyticsDelegate::EventType & eventType)
107
+ {
108
+ // For now we only support sending analytics for messages being sent over an established CASE session.
109
+ if (!mAnalyticsDelegate || !sessionHandle->IsSecureSession ())
110
+ {
111
+ return ;
112
+ }
113
+
114
+ auto secureSession = sessionHandle->AsSecureSession ();
115
+ if (!secureSession->IsCASESession ())
116
+ {
117
+ return ;
118
+ }
119
+
120
+ uint32_t messageCounter = entry.retainedBuf .GetMessageCounter ();
121
+ auto fabricIndex = sessionHandle->GetFabricIndex ();
122
+ auto destination = secureSession->GetPeerNodeId ();
123
+ ReliableMessageAnalyticsDelegate::TransmitEvent event = { .nodeId = destination,
124
+ .fabricIndex = fabricIndex,
125
+ .sessionType =
126
+ ReliableMessageAnalyticsDelegate::SessionType::kEstablishedCase ,
127
+ .eventType = eventType,
128
+ .messageCounter = messageCounter };
129
+ mAnalyticsDelegate ->OnTransmitEvent (event);
130
+ }
131
+ #endif // CHIP_CONFIG_MRP_ANALYTICS_ENABLED
132
+
104
133
void ReliableMessageMgr::ExecuteActions ()
105
134
{
106
135
System::Clock::Timestamp now = System::SystemClock ().GetMonotonicTimestamp ();
@@ -155,6 +184,10 @@ void ReliableMessageMgr::ExecuteActions()
155
184
Transport::GetSessionTypeString (session), fabricIndex, ChipLogValueX64 (destination),
156
185
CHIP_CONFIG_RMP_DEFAULT_MAX_RETRANS);
157
186
187
+ #if CHIP_CONFIG_MRP_ANALYTICS_ENABLED
188
+ NotifyMessageSendAnalytics (*entry, session, ReliableMessageAnalyticsDelegate::EventType::kFailed );
189
+ #endif // CHIP_CONFIG_MRP_ANALYTICS_ENABLED
190
+
158
191
// If the exchange is expecting a response, it will handle sending
159
192
// this notification once it detects that it has not gotten a
160
193
// response. Otherwise, we need to do it.
@@ -286,6 +319,9 @@ System::Clock::Timeout ReliableMessageMgr::GetBackoff(System::Clock::Timeout bas
286
319
void ReliableMessageMgr::StartRetransmision (RetransTableEntry * entry)
287
320
{
288
321
CalculateNextRetransTime (*entry);
322
+ #if CHIP_CONFIG_MRP_ANALYTICS_ENABLED
323
+ NotifyMessageSendAnalytics (*entry, entry->ec ->GetSessionHandle (), ReliableMessageAnalyticsDelegate::EventType::kInitialSend );
324
+ #endif // CHIP_CONFIG_MRP_ANALYTICS_ENABLED
289
325
StartTimer ();
290
326
}
291
327
@@ -295,6 +331,11 @@ bool ReliableMessageMgr::CheckAndRemRetransTable(ReliableMessageContext * rc, ui
295
331
mRetransTable .ForEachActiveObject ([&](auto * entry) {
296
332
if (entry->ec ->GetReliableMessageContext () == rc && entry->retainedBuf .GetMessageCounter () == ackMessageCounter)
297
333
{
334
+ #if CHIP_CONFIG_MRP_ANALYTICS_ENABLED
335
+ auto session = entry->ec ->GetSessionHandle ();
336
+ NotifyMessageSendAnalytics (*entry, session, ReliableMessageAnalyticsDelegate::EventType::kAcknowledged );
337
+ #endif // CHIP_CONFIG_MRP_ANALYTICS_ENABLED
338
+
298
339
// Clear the entry from the retransmision table.
299
340
ClearRetransTable (*entry);
300
341
@@ -334,6 +375,10 @@ CHIP_ERROR ReliableMessageMgr::SendFromRetransTable(RetransTableEntry * entry)
334
375
#if CHIP_CONFIG_ENABLE_ICD_SERVER
335
376
app::ICDNotifier::GetInstance ().NotifyNetworkActivityNotification ();
336
377
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER
378
+ #if CHIP_CONFIG_MRP_ANALYTICS_ENABLED
379
+ NotifyMessageSendAnalytics (*entry, entry->ec ->GetSessionHandle (),
380
+ ReliableMessageAnalyticsDelegate::EventType::kRetransmission );
381
+ #endif // CHIP_CONFIG_MRP_ANALYTICS_ENABLED
337
382
#if CHIP_CONFIG_RESOLVE_PEER_ON_FIRST_TRANSMIT_FAILURE
338
383
const ExchangeManager * exchangeMgr = entry->ec ->GetExchangeMgr ();
339
384
// TODO: investigate why in ReliableMessageMgr::CheckResendApplicationMessageWithPeerExchange unit test released exchange
@@ -440,6 +485,13 @@ void ReliableMessageMgr::RegisterSessionUpdateDelegate(SessionUpdateDelegate * s
440
485
mSessionUpdateDelegate = sessionUpdateDelegate;
441
486
}
442
487
488
+ #if CHIP_CONFIG_MRP_ANALYTICS_ENABLED
489
+ void ReliableMessageMgr::RegisterAnalyticsDelegate (ReliableMessageAnalyticsDelegate * analyticsDelegate)
490
+ {
491
+ mAnalyticsDelegate = analyticsDelegate;
492
+ }
493
+ #endif // CHIP_CONFIG_MRP_ANALYTICS_ENABLED
494
+
443
495
CHIP_ERROR ReliableMessageMgr::MapSendError (CHIP_ERROR error, uint16_t exchangeId, bool isInitiator)
444
496
{
445
497
if (
0 commit comments