6#include "nr-bearer-stats-connector.h"
8#include "nr-bearer-stats-calculator.h"
10#include <ns3/config.h>
16NS_LOG_COMPONENT_DEFINE(
"NrBearerStatsConnector");
22operator<(
const NrBearerStatsConnector::CellIdRnti& a,
const NrBearerStatsConnector::CellIdRnti& b)
24 return ((a.cellId < b.cellId) || ((a.cellId == b.cellId) && (a.rnti < b.rnti)));
33struct NrBoundCallbackArgument :
public SimpleRefCount<NrBoundCallbackArgument>
36 Ptr<NrBearerStatsBase> stats;
50DlTxPduCallback(Ptr<NrBoundCallbackArgument> arg,
56 NS_LOG_FUNCTION(path << rnti << (uint16_t)lcid << packetSize);
57 arg->stats->DlTxPdu(arg->cellId, arg->imsi, rnti, lcid, packetSize);
70DlRxPduCallback(Ptr<NrBoundCallbackArgument> arg,
77 NS_LOG_FUNCTION(path << rnti << (uint16_t)lcid << packetSize << delay);
78 arg->stats->DlRxPdu(arg->cellId, arg->imsi, rnti, lcid, packetSize, delay);
90UlTxPduCallback(Ptr<NrBoundCallbackArgument> arg,
96 NS_LOG_FUNCTION(path << rnti << (uint16_t)lcid << packetSize);
98 arg->stats->UlTxPdu(arg->cellId, arg->imsi, rnti, lcid, packetSize);
111UlRxPduCallback(Ptr<NrBoundCallbackArgument> arg,
118 NS_LOG_FUNCTION(path << rnti << (uint16_t)lcid << packetSize << delay);
120 arg->stats->UlRxPdu(arg->cellId, arg->imsi, rnti, lcid, packetSize, delay);
131 m_rlcStats = rlcStats;
138 m_pdcpStats = pdcpStats;
145 NS_LOG_FUNCTION(
this);
148 Config::Connect(
"/NodeList/*/DeviceList/*/LteEnbRrc/NewUeContext",
151 "/NodeList/*/DeviceList/*/LteUeRrc/RandomAccessSuccessful",
154 "/NodeList/*/DeviceList/*/LteEnbRrc/ConnectionReconfiguration",
157 "/NodeList/*/DeviceList/*/LteUeRrc/ConnectionReconfiguration",
159 Config::Connect(
"/NodeList/*/DeviceList/*/LteEnbRrc/HandoverStart",
161 Config::Connect(
"/NodeList/*/DeviceList/*/LteUeRrc/HandoverStart",
163 Config::Connect(
"/NodeList/*/DeviceList/*/LteEnbRrc/HandoverEndOk",
165 Config::Connect(
"/NodeList/*/DeviceList/*/LteUeRrc/HandoverEndOk",
178 c->ConnectSrb0Traces(context, imsi, cellId, rnti);
188 c->ConnectSrb1TracesUe(context, imsi, cellId, rnti);
198 c->ConnectTracesUeIfFirstTime(context, imsi, cellId, rnti);
207 uint16_t targetCellId)
209 c->DisconnectTracesUe(context, imsi, cellId, rnti);
219 c->ConnectTracesUe(context, imsi, cellId, rnti);
228 c->StoreUeManagerPath(context, cellId, rnti);
238 c->ConnectTracesEnbIfFirstTime(context, imsi, cellId, rnti);
247 uint16_t targetCellId)
249 c->DisconnectTracesEnb(context, imsi, cellId, rnti);
259 c->ConnectTracesEnb(context, imsi, cellId, rnti);
263NrBearerStatsConnector::StoreUeManagerPath(std::string context, uint16_t cellId, uint16_t rnti)
265 NS_LOG_FUNCTION(
this << context << cellId << rnti);
266 std::ostringstream ueManagerPath;
267 ueManagerPath << context.substr(0, context.rfind(
'/')) <<
"/UeMap/" << (uint32_t)rnti;
271 m_ueManagerPathByCellIdRnti[key] = ueManagerPath.str();
275NrBearerStatsConnector::ConnectSrb0Traces(std::string context,
280 NS_LOG_FUNCTION(
this << imsi << cellId << rnti);
281 std::string ueRrcPath = context.substr(0, context.rfind(
'/'));
285 std::map<CellIdRnti, std::string>::iterator it = m_ueManagerPathByCellIdRnti.find(key);
286 NS_ASSERT(it != m_ueManagerPathByCellIdRnti.end());
287 std::string ueManagerPath = it->second;
288 NS_LOG_LOGIC(
this <<
" ueManagerPath: " << ueManagerPath);
289 m_ueManagerPathByCellIdRnti.erase(it);
293 Ptr<NrBoundCallbackArgument> arg = Create<NrBoundCallbackArgument>();
295 arg->cellId = cellId;
296 arg->stats = m_rlcStats;
299 Config::Disconnect(ueRrcPath +
"/Srb0/LteRlc/TxPDU",
300 MakeBoundCallback(&UlTxPduCallback, arg));
301 Config::Disconnect(ueRrcPath +
"/Srb0/LteRlc/RxPDU",
302 MakeBoundCallback(&DlRxPduCallback, arg));
303 Config::Disconnect(ueManagerPath +
"/Srb0/LteRlc/TxPDU",
304 MakeBoundCallback(&DlTxPduCallback, arg));
305 Config::Disconnect(ueManagerPath +
"/Srb0/LteRlc/RxPDU",
306 MakeBoundCallback(&UlRxPduCallback, arg));
309 Config::Connect(ueRrcPath +
"/Srb0/LteRlc/TxPDU", MakeBoundCallback(&UlTxPduCallback, arg));
310 Config::Connect(ueRrcPath +
"/Srb0/LteRlc/RxPDU", MakeBoundCallback(&DlRxPduCallback, arg));
311 Config::Connect(ueManagerPath +
"/Srb0/LteRlc/TxPDU",
312 MakeBoundCallback(&DlTxPduCallback, arg));
313 Config::Connect(ueManagerPath +
"/Srb0/LteRlc/RxPDU",
314 MakeBoundCallback(&UlRxPduCallback, arg));
317 Config::Connect(ueManagerPath +
"/Srb1/LteRlc/TxPDU",
318 MakeBoundCallback(&DlTxPduCallback, arg));
319 Config::Connect(ueManagerPath +
"/Srb1/LteRlc/RxPDU",
320 MakeBoundCallback(&UlRxPduCallback, arg));
324 Ptr<NrBoundCallbackArgument> arg = Create<NrBoundCallbackArgument>();
326 arg->cellId = cellId;
327 arg->stats = m_pdcpStats;
330 Config::Connect(ueManagerPath +
"/Srb1/LtePdcp/RxPDU",
331 MakeBoundCallback(&UlRxPduCallback, arg));
332 Config::Connect(ueManagerPath +
"/Srb1/LtePdcp/TxPDU",
333 MakeBoundCallback(&DlTxPduCallback, arg));
338NrBearerStatsConnector::ConnectSrb1TracesUe(std::string ueRrcPath,
343 NS_LOG_FUNCTION(
this << imsi << cellId << rnti);
346 Ptr<NrBoundCallbackArgument> arg = Create<NrBoundCallbackArgument>();
348 arg->cellId = cellId;
349 arg->stats = m_rlcStats;
350 Config::Connect(ueRrcPath +
"/Srb1/LteRlc/TxPDU", MakeBoundCallback(&UlTxPduCallback, arg));
351 Config::Connect(ueRrcPath +
"/Srb1/LteRlc/RxPDU", MakeBoundCallback(&DlRxPduCallback, arg));
355 Ptr<NrBoundCallbackArgument> arg = Create<NrBoundCallbackArgument>();
357 arg->cellId = cellId;
358 arg->stats = m_pdcpStats;
359 Config::Connect(ueRrcPath +
"/Srb1/LtePdcp/RxPDU",
360 MakeBoundCallback(&DlRxPduCallback, arg));
361 Config::Connect(ueRrcPath +
"/Srb1/LtePdcp/TxPDU",
362 MakeBoundCallback(&UlTxPduCallback, arg));
367NrBearerStatsConnector::ConnectTracesUeIfFirstTime(std::string context,
372 NS_LOG_FUNCTION(
this << context);
373 if (m_imsiSeenUe.find(imsi) == m_imsiSeenUe.end())
375 m_imsiSeenUe.insert(imsi);
376 ConnectTracesUe(context, imsi, cellId, rnti);
381NrBearerStatsConnector::ConnectTracesEnbIfFirstTime(std::string context,
386 NS_LOG_FUNCTION(
this << context);
387 if (m_imsiSeenEnb.find(imsi) == m_imsiSeenEnb.end())
389 m_imsiSeenEnb.insert(imsi);
390 ConnectTracesEnb(context, imsi, cellId, rnti);
395NrBearerStatsConnector::ConnectTracesUe(std::string context,
400 NS_LOG_FUNCTION(
this << context);
401 NS_LOG_LOGIC(
this <<
"expected context should match /NodeList/*/DeviceList/*/LteUeRrc/");
402 std::string basePath = context.substr(0, context.rfind(
'/'));
405 Ptr<NrBoundCallbackArgument> arg = Create<NrBoundCallbackArgument>();
407 arg->cellId = cellId;
408 arg->stats = m_rlcStats;
409 Config::Connect(basePath +
"/DataRadioBearerMap/*/LteRlc/TxPDU",
410 MakeBoundCallback(&UlTxPduCallback, arg));
411 Config::Connect(basePath +
"/DataRadioBearerMap/*/LteRlc/RxPDU",
412 MakeBoundCallback(&DlRxPduCallback, arg));
413 Config::Connect(basePath +
"/Srb1/LteRlc/TxPDU", MakeBoundCallback(&UlTxPduCallback, arg));
414 Config::Connect(basePath +
"/Srb1/LteRlc/RxPDU", MakeBoundCallback(&DlRxPduCallback, arg));
418 Ptr<NrBoundCallbackArgument> arg = Create<NrBoundCallbackArgument>();
420 arg->cellId = cellId;
421 arg->stats = m_pdcpStats;
422 Config::Connect(basePath +
"/DataRadioBearerMap/*/LtePdcp/RxPDU",
423 MakeBoundCallback(&DlRxPduCallback, arg));
424 Config::Connect(basePath +
"/DataRadioBearerMap/*/LtePdcp/TxPDU",
425 MakeBoundCallback(&UlTxPduCallback, arg));
426 Config::Connect(basePath +
"/Srb1/LtePdcp/RxPDU", MakeBoundCallback(&DlRxPduCallback, arg));
427 Config::Connect(basePath +
"/Srb1/LtePdcp/TxPDU", MakeBoundCallback(&UlTxPduCallback, arg));
432NrBearerStatsConnector::ConnectTracesEnb(std::string context,
437 NS_LOG_FUNCTION(
this << context);
438 NS_LOG_LOGIC(
this <<
"expected context should match /NodeList/*/DeviceList/*/LteEnbRrc/");
439 std::ostringstream basePath;
440 basePath << context.substr(0, context.rfind(
'/')) <<
"/UeMap/" << (uint32_t)rnti;
443 Ptr<NrBoundCallbackArgument> arg = Create<NrBoundCallbackArgument>();
445 arg->cellId = cellId;
446 arg->stats = m_rlcStats;
447 Config::Connect(basePath.str() +
"/DataRadioBearerMap/*/LteRlc/RxPDU",
448 MakeBoundCallback(&UlRxPduCallback, arg));
449 Config::Connect(basePath.str() +
"/DataRadioBearerMap/*/LteRlc/TxPDU",
450 MakeBoundCallback(&DlTxPduCallback, arg));
451 Config::Connect(basePath.str() +
"/Srb0/LteRlc/RxPDU",
452 MakeBoundCallback(&UlRxPduCallback, arg));
453 Config::Connect(basePath.str() +
"/Srb0/LteRlc/TxPDU",
454 MakeBoundCallback(&DlTxPduCallback, arg));
455 Config::Connect(basePath.str() +
"/Srb1/LteRlc/RxPDU",
456 MakeBoundCallback(&UlRxPduCallback, arg));
457 Config::Connect(basePath.str() +
"/Srb1/LteRlc/TxPDU",
458 MakeBoundCallback(&DlTxPduCallback, arg));
462 Ptr<NrBoundCallbackArgument> arg = Create<NrBoundCallbackArgument>();
464 arg->cellId = cellId;
465 arg->stats = m_pdcpStats;
466 Config::Connect(basePath.str() +
"/DataRadioBearerMap/*/LtePdcp/TxPDU",
467 MakeBoundCallback(&DlTxPduCallback, arg));
468 Config::Connect(basePath.str() +
"/DataRadioBearerMap/*/LtePdcp/RxPDU",
469 MakeBoundCallback(&UlRxPduCallback, arg));
470 Config::Connect(basePath.str() +
"/Srb1/LtePdcp/TxPDU",
471 MakeBoundCallback(&DlTxPduCallback, arg));
472 Config::Connect(basePath.str() +
"/Srb1/LtePdcp/RxPDU",
473 MakeBoundCallback(&UlRxPduCallback, arg));
478NrBearerStatsConnector::DisconnectTracesUe(std::string context,
483 NS_LOG_FUNCTION(
this);
487NrBearerStatsConnector::DisconnectTracesEnb(std::string context,
492 NS_LOG_FUNCTION(
this);
495Ptr<NrBearerStatsBase>
501Ptr<NrBearerStatsBase>
static void NotifyHandoverStartEnb(NrBearerStatsConnector *c, std::string context, uint64_t imsi, uint16_t cellid, uint16_t rnti, uint16_t targetCellId)
static void NotifyConnectionSetupUe(NrBearerStatsConnector *c, std::string context, uint64_t imsi, uint16_t cellid, uint16_t rnti)
static void NotifyRandomAccessSuccessfulUe(NrBearerStatsConnector *c, std::string context, uint64_t imsi, uint16_t cellid, uint16_t rnti)
static void NotifyConnectionReconfigurationEnb(NrBearerStatsConnector *c, std::string context, uint64_t imsi, uint16_t cellid, uint16_t rnti)
NrBearerStatsConnector()
Constructor.
Ptr< NrBearerStatsBase > GetPdcpStats()
static void NotifyHandoverEndOkUe(NrBearerStatsConnector *c, std::string context, uint64_t imsi, uint16_t cellid, uint16_t rnti)
void EnablePdcpStats(Ptr< NrBearerStatsBase > pdcpStats)
static void NotifyHandoverStartUe(NrBearerStatsConnector *c, std::string context, uint64_t imsi, uint16_t cellid, uint16_t rnti, uint16_t targetCellId)
void EnableRlcStats(Ptr< NrBearerStatsBase > rlcStats)
Ptr< NrBearerStatsBase > GetRlcStats()
static void NotifyHandoverEndOkEnb(NrBearerStatsConnector *c, std::string context, uint64_t imsi, uint16_t cellid, uint16_t rnti)
static void NotifyConnectionReconfigurationUe(NrBearerStatsConnector *c, std::string context, uint64_t imsi, uint16_t cellid, uint16_t rnti)
static void NotifyNewUeContextEnb(NrBearerStatsConnector *c, std::string context, uint16_t cellid, uint16_t rnti)