From ed411fa9c033bcbcf8b2a44e75c01982848f0df1 Mon Sep 17 00:00:00 2001 From: Manuel Requena Date: Fri, 10 May 2019 11:10:29 +0200 Subject: [PATCH] lte: Update RadioBearerStats connector and eNB/UE RRC see merge request nsnam/ns-3-dev!64 and issue nsnam/ns-3-dev!54 --- .../helper/radio-bearer-stats-connector.cc | 416 ++++++++---------- src/lte/helper/radio-bearer-stats-connector.h | 250 ++++------- src/lte/model/lte-enb-rrc.cc | 6 + src/lte/model/lte-enb-rrc.h | 7 + src/lte/model/lte-ue-rrc.cc | 15 +- src/lte/model/lte-ue-rrc.h | 12 + 6 files changed, 305 insertions(+), 401 deletions(-) diff --git a/src/lte/helper/radio-bearer-stats-connector.cc b/src/lte/helper/radio-bearer-stats-connector.cc index db2f2d3f0..34ae067c5 100644 --- a/src/lte/helper/radio-bearer-stats-connector.cc +++ b/src/lte/helper/radio-bearer-stats-connector.cc @@ -1,6 +1,6 @@ /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* - * Copyright (c) 2012 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC) + * Copyright (c) 2012-2018 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as @@ -15,19 +15,13 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * Author: Nicola Baldo + * Authors: Nicola Baldo + * Manuel Requena */ - -#include - - -#include "radio-bearer-stats-connector.h" +#include "ns3/log.h" #include "radio-bearer-stats-calculator.h" -#include -#include -#include -#include +#include "radio-bearer-stats-connector.h" namespace ns3 { @@ -102,7 +96,6 @@ UlTxPduCallback (Ptr arg, std::string path, uint16_t rnti, uint8_t lcid, uint32_t packetSize) { NS_LOG_FUNCTION (path << rnti << (uint16_t)lcid << packetSize); - arg->stats->UlTxPdu (arg->cellId, arg->imsi, rnti, lcid, packetSize); } @@ -120,155 +113,121 @@ UlRxPduCallback (Ptr arg, std::string path, uint16_t rnti, uint8_t lcid, uint32_t packetSize, uint64_t delay) { NS_LOG_FUNCTION (path << rnti << (uint16_t)lcid << packetSize << delay); - arg->stats->UlRxPdu (arg->cellId, arg->imsi, rnti, lcid, packetSize, delay); } - RadioBearerStatsConnector::RadioBearerStatsConnector () : m_connected (false) { } -void +void RadioBearerStatsConnector::EnableRlcStats (Ptr rlcStats) { m_rlcStats = rlcStats; EnsureConnected (); } -void +void RadioBearerStatsConnector::EnablePdcpStats (Ptr pdcpStats) { m_pdcpStats = pdcpStats; EnsureConnected (); } -void +void RadioBearerStatsConnector::EnsureConnected () { NS_LOG_FUNCTION (this); if (!m_connected) { Config::Connect ("/NodeList/*/DeviceList/*/LteEnbRrc/NewUeContext", - MakeBoundCallback (&RadioBearerStatsConnector::NotifyNewUeContextEnb, this)); + MakeBoundCallback (&RadioBearerStatsConnector::NotifyNewUeContextEnb, this)); + Config::Connect ("/NodeList/*/DeviceList/*/LteUeRrc/RandomAccessSuccessful", - MakeBoundCallback (&RadioBearerStatsConnector::NotifyRandomAccessSuccessfulUe, this)); - Config::Connect ("/NodeList/*/DeviceList/*/LteEnbRrc/ConnectionReconfiguration", - MakeBoundCallback (&RadioBearerStatsConnector::NotifyConnectionReconfigurationEnb, this)); - Config::Connect ("/NodeList/*/DeviceList/*/LteUeRrc/ConnectionReconfiguration", - MakeBoundCallback (&RadioBearerStatsConnector::NotifyConnectionReconfigurationUe, this)); - Config::Connect ("/NodeList/*/DeviceList/*/LteEnbRrc/HandoverStart", - MakeBoundCallback (&RadioBearerStatsConnector::NotifyHandoverStartEnb, this)); - Config::Connect ("/NodeList/*/DeviceList/*/LteUeRrc/HandoverStart", - MakeBoundCallback (&RadioBearerStatsConnector::NotifyHandoverStartUe, this)); - Config::Connect ("/NodeList/*/DeviceList/*/LteEnbRrc/HandoverEndOk", - MakeBoundCallback (&RadioBearerStatsConnector::NotifyHandoverEndOkEnb, this)); - Config::Connect ("/NodeList/*/DeviceList/*/LteUeRrc/HandoverEndOk", - MakeBoundCallback (&RadioBearerStatsConnector::NotifyHandoverEndOkUe, this)); + MakeBoundCallback (&RadioBearerStatsConnector::NotifyRandomAccessSuccessfulUe, this)); + + Config::Connect ("/NodeList/*/DeviceList/*/LteUeRrc/Srb1Created", + MakeBoundCallback (&RadioBearerStatsConnector::CreatedSrb1Ue, this)); + + Config::Connect ("/NodeList/*/DeviceList/*/LteUeRrc/DrbCreated", + MakeBoundCallback (&RadioBearerStatsConnector::CreatedDrbUe, this)); + m_connected = true; } } -void -RadioBearerStatsConnector::NotifyRandomAccessSuccessfulUe (RadioBearerStatsConnector* c, std::string context, uint64_t imsi, uint16_t cellId, uint16_t rnti) -{ - c->ConnectSrb0Traces (context, imsi, cellId, rnti); -} - -void -RadioBearerStatsConnector::NotifyConnectionSetupUe (RadioBearerStatsConnector* c, std::string context, uint64_t imsi, uint16_t cellId, uint16_t rnti) -{ - c->ConnectSrb1TracesUe (context, imsi, cellId, rnti); -} - -void -RadioBearerStatsConnector::NotifyConnectionReconfigurationUe (RadioBearerStatsConnector* c, std::string context, uint64_t imsi, uint16_t cellId, uint16_t rnti) -{ - c->ConnectTracesUeIfFirstTime (context, imsi, cellId, rnti); -} - -void -RadioBearerStatsConnector::NotifyHandoverStartUe (RadioBearerStatsConnector* c, std::string context, uint64_t imsi, uint16_t cellId, uint16_t rnti, uint16_t targetCellId) -{ - c->DisconnectTracesUe (context, imsi, cellId, rnti); -} - -void -RadioBearerStatsConnector::NotifyHandoverEndOkUe (RadioBearerStatsConnector* c, std::string context, uint64_t imsi, uint16_t cellId, uint16_t rnti) -{ - c->ConnectTracesUe (context, imsi, cellId, rnti); -} - -void -RadioBearerStatsConnector::NotifyNewUeContextEnb (RadioBearerStatsConnector* c, std::string context, uint16_t cellId, uint16_t rnti) -{ - c->StoreUeManagerPath (context, cellId, rnti); -} - -void -RadioBearerStatsConnector::NotifyConnectionReconfigurationEnb (RadioBearerStatsConnector* c, std::string context, uint64_t imsi, uint16_t cellId, uint16_t rnti) -{ - c->ConnectTracesEnbIfFirstTime (context, imsi, cellId, rnti); -} - -void -RadioBearerStatsConnector::NotifyHandoverStartEnb (RadioBearerStatsConnector* c, std::string context, uint64_t imsi, uint16_t cellId, uint16_t rnti, uint16_t targetCellId) -{ - c->DisconnectTracesEnb (context, imsi, cellId, rnti); -} - -void -RadioBearerStatsConnector::NotifyHandoverEndOkEnb (RadioBearerStatsConnector* c, std::string context, uint64_t imsi, uint16_t cellId, uint16_t rnti) -{ - c->ConnectTracesEnb (context, imsi, cellId, rnti); -} - -void +void RadioBearerStatsConnector::StoreUeManagerPath (std::string context, uint16_t cellId, uint16_t rnti) { NS_LOG_FUNCTION (this << context << cellId << rnti); - std::ostringstream ueManagerPath; - ueManagerPath << context.substr (0, context.rfind ("/")) << "/UeMap/" << (uint32_t) rnti; + std::string ueManagerPath; + ueManagerPath = context.substr (0, context.rfind ("/")) + "/UeMap/" + std::to_string (rnti); + NS_LOG_DEBUG ("ueManagerPath = " << ueManagerPath); CellIdRnti key; key.cellId = cellId; key.rnti = rnti; - m_ueManagerPathByCellIdRnti[key] = ueManagerPath.str (); + m_ueManagerPathByCellIdRnti[key] = ueManagerPath; + + Config::Connect (ueManagerPath + "/DrbCreated", + MakeBoundCallback (&RadioBearerStatsConnector::CreatedDrbEnb, this)); } -void -RadioBearerStatsConnector::ConnectSrb0Traces (std::string context, uint64_t imsi, uint16_t cellId, uint16_t rnti) +void +RadioBearerStatsConnector::NotifyNewUeContextEnb (RadioBearerStatsConnector* c, std::string context, uint16_t cellId, uint16_t rnti) { - NS_LOG_FUNCTION (this << imsi << cellId << rnti); - std::string ueRrcPath = context.substr (0, context.rfind ("/")); + NS_LOG_FUNCTION (c << context << cellId << rnti); + c->StoreUeManagerPath (context, cellId, rnti); +} + +void +RadioBearerStatsConnector::NotifyRandomAccessSuccessfulUe (RadioBearerStatsConnector* c, std::string context, uint64_t imsi, uint16_t cellId, uint16_t rnti) +{ + NS_LOG_FUNCTION (c << context << imsi << cellId << rnti); + c->ConnectTracesSrb0 (context, imsi, cellId, rnti); +} + +void +RadioBearerStatsConnector::CreatedDrbEnb (RadioBearerStatsConnector* c, std::string context, uint64_t imsi, uint16_t cellId, uint16_t rnti, uint8_t lcid) +{ + NS_LOG_FUNCTION (c << context << imsi << cellId << rnti << (uint16_t)lcid); + c->ConnectTracesDrbEnb (context, imsi, cellId, rnti, lcid); +} + +void +RadioBearerStatsConnector::CreatedSrb1Ue (RadioBearerStatsConnector* c, std::string context, uint64_t imsi, uint16_t cellId, uint16_t rnti) +{ + NS_LOG_FUNCTION (c << context << imsi << cellId << rnti); + c->ConnectTracesSrb1 (context, imsi, cellId, rnti); +} + +void +RadioBearerStatsConnector::CreatedDrbUe (RadioBearerStatsConnector* c, std::string context, uint64_t imsi, uint16_t cellId, uint16_t rnti, uint8_t lcid) +{ + NS_LOG_FUNCTION (c << context << imsi << cellId << rnti << (uint16_t)lcid); + c->ConnectTracesDrbUe (context, imsi, cellId, rnti, lcid); +} + +void +RadioBearerStatsConnector::ConnectTracesSrb0 (std::string context, uint64_t imsi, uint16_t cellId, uint16_t rnti) +{ + NS_LOG_FUNCTION (this << context << imsi << cellId << rnti); + std::string ueRrcPath = context.substr (0, context.rfind ("/")); + NS_LOG_LOGIC ("ueRrcPath = " << ueRrcPath); CellIdRnti key; key.cellId = cellId; key.rnti = rnti; std::map::iterator it = m_ueManagerPathByCellIdRnti.find (key); NS_ASSERT (it != m_ueManagerPathByCellIdRnti.end ()); - std::string ueManagerPath = it->second; - NS_LOG_LOGIC (this << " ueManagerPath: " << ueManagerPath); - m_ueManagerPathByCellIdRnti.erase (it); - + std::string ueManagerPath = it->second; + NS_LOG_LOGIC ("ueManagerPath = " << ueManagerPath); if (m_rlcStats) { Ptr arg = Create (); arg->imsi = imsi; - arg->cellId = cellId; + arg->cellId = cellId; arg->stats = m_rlcStats; - - // diconnect eventually previously connected SRB0 both at UE and eNB - Config::Disconnect (ueRrcPath + "/Srb0/LteRlc/TxPDU", - MakeBoundCallback (&UlTxPduCallback, arg)); - Config::Disconnect (ueRrcPath + "/Srb0/LteRlc/RxPDU", - MakeBoundCallback (&DlRxPduCallback, arg)); - Config::Disconnect (ueManagerPath + "/Srb0/LteRlc/TxPDU", - MakeBoundCallback (&DlTxPduCallback, arg)); - Config::Disconnect (ueManagerPath + "/Srb0/LteRlc/RxPDU", - MakeBoundCallback (&UlRxPduCallback, arg)); - - // connect SRB0 both at UE and eNB Config::Connect (ueRrcPath + "/Srb0/LteRlc/TxPDU", MakeBoundCallback (&UlTxPduCallback, arg)); Config::Connect (ueRrcPath + "/Srb0/LteRlc/RxPDU", @@ -277,8 +236,32 @@ RadioBearerStatsConnector::ConnectSrb0Traces (std::string context, uint64_t imsi MakeBoundCallback (&DlTxPduCallback, arg)); Config::Connect (ueManagerPath + "/Srb0/LteRlc/RxPDU", MakeBoundCallback (&UlRxPduCallback, arg)); + } +} - // connect SRB1 at eNB only (at UE SRB1 will be setup later) +void +RadioBearerStatsConnector::ConnectTracesSrb1 (std::string context, uint64_t imsi, uint16_t cellId, uint16_t rnti) +{ + NS_LOG_FUNCTION (this << context << imsi << cellId << rnti); + std::string ueRrcPath = context.substr (0, context.rfind ("/")); + NS_LOG_LOGIC ("ueRrcPath = " << ueRrcPath); + CellIdRnti key; + key.cellId = cellId; + key.rnti = rnti; + std::map::iterator it = m_ueManagerPathByCellIdRnti.find (key); + NS_ASSERT (it != m_ueManagerPathByCellIdRnti.end ()); + std::string ueManagerPath = it->second; + NS_LOG_LOGIC ("ueManagerPath = " << ueManagerPath); + if (m_rlcStats) + { + Ptr arg = Create (); + arg->imsi = imsi; + arg->cellId = cellId; + arg->stats = m_rlcStats; + Config::Connect (ueRrcPath + "/Srb1/LteRlc/TxPDU", + MakeBoundCallback (&UlTxPduCallback, arg)); + Config::Connect (ueRrcPath + "/Srb1/LteRlc/RxPDU", + MakeBoundCallback (&DlRxPduCallback, arg)); Config::Connect (ueManagerPath + "/Srb1/LteRlc/TxPDU", MakeBoundCallback (&DlTxPduCallback, arg)); Config::Connect (ueManagerPath + "/Srb1/LteRlc/RxPDU", @@ -288,162 +271,111 @@ RadioBearerStatsConnector::ConnectSrb0Traces (std::string context, uint64_t imsi { Ptr arg = Create (); arg->imsi = imsi; - arg->cellId = cellId; + arg->cellId = cellId; arg->stats = m_pdcpStats; - - // connect SRB1 at eNB only (at UE SRB1 will be setup later) - Config::Connect (ueManagerPath + "/Srb1/LtePdcp/RxPDU", - MakeBoundCallback (&UlRxPduCallback, arg)); + Config::Connect (ueRrcPath + "/Srb1/LtePdcp/TxPDU", + MakeBoundCallback (&UlTxPduCallback, arg)); + Config::Connect (ueRrcPath + "/Srb1/LtePdcp/RxPDU", + MakeBoundCallback (&DlRxPduCallback, arg)); Config::Connect (ueManagerPath + "/Srb1/LtePdcp/TxPDU", - MakeBoundCallback (&DlTxPduCallback, arg)); + MakeBoundCallback (&DlTxPduCallback, arg)); + Config::Connect (ueManagerPath + "/Srb1/LtePdcp/RxPDU", + MakeBoundCallback (&UlRxPduCallback, arg)); } } -void -RadioBearerStatsConnector::ConnectSrb1TracesUe (std::string ueRrcPath, uint64_t imsi, uint16_t cellId, uint16_t rnti) +void +RadioBearerStatsConnector::ConnectTracesDrbEnb (std::string context, uint64_t imsi, uint16_t cellId, uint16_t rnti, uint8_t lcid) { - NS_LOG_FUNCTION (this << imsi << cellId << rnti); - if (m_rlcStats) + NS_LOG_FUNCTION (this << context << imsi << cellId << rnti << (uint16_t)lcid); + NS_LOG_LOGIC ("expected context should match /NodeList/*/DeviceList/*/LteEnbRrc/"); + std::string basePath; + basePath = context.substr (0, context.rfind ("/")) + "/DataRadioBearerMap/" + std::to_string (lcid - 2); + NS_LOG_LOGIC ("basePath = " << basePath); + if (m_rlcStats) { Ptr arg = Create (); arg->imsi = imsi; - arg->cellId = cellId; + arg->cellId = cellId; arg->stats = m_rlcStats; - Config::Connect (ueRrcPath + "/Srb1/LteRlc/TxPDU", + Config::Connect (basePath + "/LteRlc/TxPDU", + MakeBoundCallback (&DlTxPduCallback, arg)); + Config::Connect (basePath + "/LteRlc/RxPDU", + MakeBoundCallback (&UlRxPduCallback, arg)); + } + if (m_pdcpStats) + { + Ptr arg = Create (); + arg->imsi = imsi; + arg->cellId = cellId; + arg->stats = m_pdcpStats; + Config::Connect (basePath + "/LtePdcp/TxPDU", + MakeBoundCallback (&DlTxPduCallback, arg)); + Config::Connect (basePath + "/LtePdcp/RxPDU", + MakeBoundCallback (&UlRxPduCallback, arg)); + } +} + +void +RadioBearerStatsConnector::ConnectTracesDrbUe (std::string context, uint64_t imsi, uint16_t cellId, uint16_t rnti, uint8_t lcid) +{ + NS_LOG_FUNCTION (this << context << imsi << cellId << rnti << (uint16_t)lcid); + NS_LOG_LOGIC ("expected context should match /NodeList/*/DeviceList/*/LteUeRrc/"); + std::string basePath; + basePath = context.substr (0, context.rfind ("/")) + "/DataRadioBearerMap/" + std::to_string (lcid); + NS_LOG_LOGIC ("basePath = " << basePath); + if (m_rlcStats) + { + Ptr arg = Create (); + arg->imsi = imsi; + arg->cellId = cellId; + arg->stats = m_rlcStats; + Config::Connect (basePath + "/LteRlc/TxPDU", MakeBoundCallback (&UlTxPduCallback, arg)); - Config::Connect (ueRrcPath + "/Srb1/LteRlc/RxPDU", + Config::Connect (basePath + "/LteRlc/RxPDU", MakeBoundCallback (&DlRxPduCallback, arg)); } if (m_pdcpStats) { Ptr arg = Create (); arg->imsi = imsi; - arg->cellId = cellId; + arg->cellId = cellId; arg->stats = m_pdcpStats; - Config::Connect (ueRrcPath + "/Srb1/LtePdcp/RxPDU", - MakeBoundCallback (&DlRxPduCallback, arg)); - Config::Connect (ueRrcPath + "/Srb1/LtePdcp/TxPDU", - MakeBoundCallback (&UlTxPduCallback, arg)); - } -} - -void -RadioBearerStatsConnector::ConnectTracesUeIfFirstTime (std::string context, uint64_t imsi, uint16_t cellId, uint16_t rnti) -{ - NS_LOG_FUNCTION (this << context); - if (m_imsiSeenUe.find (imsi) == m_imsiSeenUe.end ()) - { - m_imsiSeenUe.insert (imsi); - ConnectTracesUe (context, imsi, cellId, rnti); - } -} - -void -RadioBearerStatsConnector::ConnectTracesEnbIfFirstTime (std::string context, uint64_t imsi, uint16_t cellId, uint16_t rnti) -{ - NS_LOG_FUNCTION (this << context); - if (m_imsiSeenEnb.find (imsi) == m_imsiSeenEnb.end ()) - { - m_imsiSeenEnb.insert (imsi); - ConnectTracesEnb (context, imsi, cellId, rnti); + Config::Connect (basePath + "/LtePdcp/TxPDU", + MakeBoundCallback (&UlTxPduCallback, arg)); + Config::Connect (basePath + "/LtePdcp/RxPDU", + MakeBoundCallback (&DlRxPduCallback, arg)); } } -void -RadioBearerStatsConnector::ConnectTracesUe (std::string context, uint64_t imsi, uint16_t cellId, uint16_t rnti) -{ - NS_LOG_FUNCTION (this << context); - NS_LOG_LOGIC (this << "expected context should match /NodeList/*/DeviceList/*/LteUeRrc/"); - std::string basePath = context.substr (0, context.rfind ("/")); - if (m_rlcStats) - { - Ptr arg = Create (); - arg->imsi = imsi; - arg->cellId = cellId; - arg->stats = m_rlcStats; - Config::Connect (basePath + "/DataRadioBearerMap/*/LteRlc/TxPDU", - MakeBoundCallback (&UlTxPduCallback, arg)); - Config::Connect (basePath + "/DataRadioBearerMap/*/LteRlc/RxPDU", - MakeBoundCallback (&DlRxPduCallback, arg)); - Config::Connect (basePath + "/Srb1/LteRlc/TxPDU", - MakeBoundCallback (&UlTxPduCallback, arg)); - Config::Connect (basePath + "/Srb1/LteRlc/RxPDU", - MakeBoundCallback (&DlRxPduCallback, arg)); - - } - if (m_pdcpStats) - { - Ptr arg = Create (); - arg->imsi = imsi; - arg->cellId = cellId; - arg->stats = m_pdcpStats; - Config::Connect (basePath + "/DataRadioBearerMap/*/LtePdcp/RxPDU", - MakeBoundCallback (&DlRxPduCallback, arg)); - Config::Connect (basePath + "/DataRadioBearerMap/*/LtePdcp/TxPDU", - MakeBoundCallback (&UlTxPduCallback, arg)); - Config::Connect (basePath + "/Srb1/LtePdcp/RxPDU", - MakeBoundCallback (&DlRxPduCallback, arg)); - Config::Connect (basePath + "/Srb1/LtePdcp/TxPDU", - MakeBoundCallback (&UlTxPduCallback, arg)); - } -} - -void -RadioBearerStatsConnector::ConnectTracesEnb (std::string context, uint64_t imsi, uint16_t cellId, uint16_t rnti) -{ - NS_LOG_FUNCTION (this << context); - NS_LOG_LOGIC (this << "expected context should match /NodeList/*/DeviceList/*/LteEnbRrc/"); - std::ostringstream basePath; - basePath << context.substr (0, context.rfind ("/")) << "/UeMap/" << (uint32_t) rnti; - if (m_rlcStats) - { - Ptr arg = Create (); - arg->imsi = imsi; - arg->cellId = cellId; - arg->stats = m_rlcStats; - Config::Connect (basePath.str () + "/DataRadioBearerMap/*/LteRlc/RxPDU", - MakeBoundCallback (&UlRxPduCallback, arg)); - Config::Connect (basePath.str () + "/DataRadioBearerMap/*/LteRlc/TxPDU", - MakeBoundCallback (&DlTxPduCallback, arg)); - Config::Connect (basePath.str () + "/Srb0/LteRlc/RxPDU", - MakeBoundCallback (&UlRxPduCallback, arg)); - Config::Connect (basePath.str () + "/Srb0/LteRlc/TxPDU", - MakeBoundCallback (&DlTxPduCallback, arg)); - Config::Connect (basePath.str () + "/Srb1/LteRlc/RxPDU", - MakeBoundCallback (&UlRxPduCallback, arg)); - Config::Connect (basePath.str () + "/Srb1/LteRlc/TxPDU", - MakeBoundCallback (&DlTxPduCallback, arg)); - } - if (m_pdcpStats) - { - Ptr arg = Create (); - arg->imsi = imsi; - arg->cellId = cellId; - arg->stats = m_pdcpStats; - Config::Connect (basePath.str () + "/DataRadioBearerMap/*/LtePdcp/TxPDU", - MakeBoundCallback (&DlTxPduCallback, arg)); - Config::Connect (basePath.str () + "/DataRadioBearerMap/*/LtePdcp/RxPDU", - MakeBoundCallback (&UlRxPduCallback, arg)); - Config::Connect (basePath.str () + "/Srb1/LtePdcp/TxPDU", - MakeBoundCallback (&DlTxPduCallback, arg)); - Config::Connect (basePath.str () + "/Srb1/LtePdcp/RxPDU", - MakeBoundCallback (&UlRxPduCallback, arg)); - } -} - -void -RadioBearerStatsConnector::DisconnectTracesUe (std::string context, uint64_t imsi, uint16_t cellId, uint16_t rnti) -{ - NS_LOG_FUNCTION (this); -} - - -void +void RadioBearerStatsConnector::DisconnectTracesEnb (std::string context, uint64_t imsi, uint16_t cellId, uint16_t rnti) { NS_LOG_FUNCTION (this); + /** + * This method is left empty to be extended in future. + * Note: Be aware, that each of the connect method uses + * its own BoundCallbackArgument struct as an argument + * of the callback. And, if the code to disconnect the + * traces would also use their own struct, the traces + * will not disconnect, since it changes the parameter + * of the callback. + */ } - +void +RadioBearerStatsConnector::DisconnectTracesUe (std::string context, uint64_t imsi, uint16_t cellId, uint16_t rnti) +{ + NS_LOG_FUNCTION (this); + /** + * This method is left empty to be extended in future. + * Note: Be aware, that each of the connect method uses + * its own BoundCallbackArgument struct as an argument + * of the callback. And, if the code to disconnect the + * traces would also use their own struct, the traces + * will not disconnect, since it changes the parameter + * of the callback. + */ +} } // namespace ns3 diff --git a/src/lte/helper/radio-bearer-stats-connector.h b/src/lte/helper/radio-bearer-stats-connector.h index e90cb8af1..2a639f755 100644 --- a/src/lte/helper/radio-bearer-stats-connector.h +++ b/src/lte/helper/radio-bearer-stats-connector.h @@ -1,6 +1,6 @@ /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* - * Copyright (c) 2012 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC) + * Copyright (c) 2012-2018 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as @@ -15,21 +15,18 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * Author: Nicola Baldo + * Authors: Nicola Baldo + * Manuel Requena */ - - #ifndef RADIO_BEARER_STATS_CONNECTOR_H #define RADIO_BEARER_STATS_CONNECTOR_H +#include "ns3/ptr.h" +#include "ns3/simple-ref-count.h" +#include "ns3/config.h" +#include "ns3/traced-callback.h" -#include -#include -#include -#include - -#include #include namespace ns3 { @@ -74,9 +71,22 @@ public: // trace sinks, to be used with MakeBoundCallback + /** + * Function hooked to NewUeContext trace source at eNB RRC, + * which is fired upon creation of a new UE context. + * It stores the UE manager path and connects the callback that will be called + * when the DRB is created in the eNB. + * \param c + * \param context + * \param cellid + * \param rnti + */ + static void NotifyNewUeContextEnb (RadioBearerStatsConnector* c, std::string context, uint16_t cellid, uint16_t rnti); + /** * Function hooked to RandomAccessSuccessful trace source at UE RRC, - * which is fired upon successful completion of the random access procedure + * which is fired upon successful completion of the random access procedure. + * It connects the callbacks for the SRB0 at the eNB and the UE. * \param c * \param context * \param imsi @@ -86,168 +96,42 @@ public: static void NotifyRandomAccessSuccessfulUe (RadioBearerStatsConnector* c, std::string context, uint64_t imsi, uint16_t cellid, uint16_t rnti); /** - * Sink connected source of UE Connection Setup trace. Not used. + * Function hooked to Srb1Created trace source at UE RRC, + * which is fired when SRB1 is created, i.e. RLC and PDCP are created for one LC = 1. + * It connects the callbacks for the DRB at the eNB. * \param c * \param context * \param imsi * \param cellid * \param rnti */ - static void NotifyConnectionSetupUe (RadioBearerStatsConnector* c, std::string context, uint64_t imsi, uint16_t cellid, uint16_t rnti); + static void CreatedSrb1Ue (RadioBearerStatsConnector* c, std::string context, uint64_t imsi, uint16_t cellid, uint16_t rnti); /** - * Function hooked to ConnectionReconfiguration trace source at UE RRC, - * which is fired upon RRC connection reconfiguration + * Function hooked to DrbCreated trace source at UE manager in eNB RRC, + * which is fired when DRB is created, i.e. RLC and PDCP are created for LC = lcid. + * It connects the callbacks for the DRB at the eNB. * \param c * \param context * \param imsi * \param cellid * \param rnti + * \param lcid */ - static void NotifyConnectionReconfigurationUe (RadioBearerStatsConnector* c, std::string context, uint64_t imsi, uint16_t cellid, uint16_t rnti); + static void CreatedDrbEnb (RadioBearerStatsConnector* c, std::string context, uint64_t imsi, uint16_t cellid, uint16_t rnti, uint8_t lcid); /** - * Function hooked to HandoverStart trace source at UE RRC, - * which is fired upon start of a handover procedure + * Function hooked to DrbCreated trace source at UE RRC, + * which is fired when DRB is created, i.e. RLC and PDCP are created for LC = lcid. + * It connects the callbacks for the DRB at the UE. * \param c * \param context * \param imsi * \param cellid * \param rnti - * \param targetCellId + * \param lcid */ - static void NotifyHandoverStartUe (RadioBearerStatsConnector* c, std::string context, uint64_t imsi, uint16_t cellid, uint16_t rnti, uint16_t targetCellId); - - /** - * Function hooked to HandoverStart trace source at UE RRC, - * which is fired upon successful termination of a handover procedure - * \param c - * \param context - * \param imsi - * \param cellid - * \param rnti - */ - static void NotifyHandoverEndOkUe (RadioBearerStatsConnector* c, std::string context, uint64_t imsi, uint16_t cellid, uint16_t rnti); - - /** - * Function hooked to NewUeContext trace source at eNB RRC, - * which is fired upon creation of a new UE context - * \param c - * \param context - * \param cellid - * \param rnti - */ - static void NotifyNewUeContextEnb (RadioBearerStatsConnector* c, std::string context, uint16_t cellid, uint16_t rnti); - - /** - * Function hooked to ConnectionReconfiguration trace source at eNB RRC, - * which is fired upon RRC connection reconfiguration - * \param c - * \param context - * \param imsi - * \param cellid - * \param rnti - */ - static void NotifyConnectionReconfigurationEnb (RadioBearerStatsConnector* c, std::string context, uint64_t imsi, uint16_t cellid, uint16_t rnti); - - /** - * Function hooked to HandoverStart trace source at eNB RRC, - * which is fired upon start of a handover procedure - * \param c - * \param context - * \param imsi - * \param cellid - * \param rnti - * \param targetCellId - */ - static void NotifyHandoverStartEnb (RadioBearerStatsConnector* c, std::string context, uint64_t imsi, uint16_t cellid, uint16_t rnti, uint16_t targetCellId); - - /** - * Function hooked to HandoverEndOk trace source at eNB RRC, - * which is fired upon successful termination of a handover procedure - * \param c - * \param context - * \param imsi - * \param cellid - * \param rnti - */ - static void NotifyHandoverEndOkEnb (RadioBearerStatsConnector* c, std::string context, uint64_t imsi, uint16_t cellid, uint16_t rnti); - -private: - /** - * Creates UE Manager path and stores it in m_ueManagerPathByCellIdRnti - * \param ueManagerPath - * \param cellId - * \param rnti - */ - void StoreUeManagerPath (std::string ueManagerPath, uint16_t cellId, uint16_t rnti); - - /** - * Connects Srb0 trace sources at UE and eNB to RLC and PDCP calculators, - * and Srb1 trace sources at eNB to RLC and PDCP calculators, - * \param ueRrcPath - * \param imsi - * \param cellId - * \param rnti - */ - void ConnectSrb0Traces (std::string ueRrcPath, uint64_t imsi, uint16_t cellId, uint16_t rnti); - - /** - * Connects Srb1 trace sources at UE to RLC and PDCP calculators - * \param ueRrcPath - * \param imsi - * \param cellId - * \param rnti - */ - void ConnectSrb1TracesUe (std::string ueRrcPath, uint64_t imsi, uint16_t cellId, uint16_t rnti); - - /** - * Connects all trace sources at UE to RLC and PDCP calculators. - * This function can connect traces only once for UE. - * \param context - * \param imsi - * \param cellid - * \param rnti - */ - void ConnectTracesUeIfFirstTime (std::string context, uint64_t imsi, uint16_t cellid, uint16_t rnti); - - /** - * Connects all trace sources at eNB to RLC and PDCP calculators. - * This function can connect traces only once for eNB. - * \param context - * \param imsi - * \param cellid - * \param rnti - */ - void ConnectTracesEnbIfFirstTime (std::string context, uint64_t imsi, uint16_t cellid, uint16_t rnti); - - /** - * Connects all trace sources at UE to RLC and PDCP calculators. - * \param context - * \param imsi - * \param cellid - * \param rnti - */ - void ConnectTracesUe (std::string context, uint64_t imsi, uint16_t cellid, uint16_t rnti); - - /** - * Disconnects all trace sources at UE to RLC and PDCP calculators. - * Function is not implemented. - * \param context - * \param imsi - * \param cellid - * \param rnti - */ - void DisconnectTracesUe (std::string context, uint64_t imsi, uint16_t cellid, uint16_t rnti); - - /** - * Connects all trace sources at eNB to RLC and PDCP calculators - * \param context - * \param imsi - * \param cellid - * \param rnti - */ - void ConnectTracesEnb (std::string context, uint64_t imsi, uint16_t cellid, uint16_t rnti); + static void CreatedDrbUe (RadioBearerStatsConnector* c, std::string context, uint64_t imsi, uint16_t cellid, uint16_t rnti, uint8_t lcid); /** * Disconnects all trace sources at eNB to RLC and PDCP calculators. @@ -259,14 +143,69 @@ private: */ void DisconnectTracesEnb (std::string context, uint64_t imsi, uint16_t cellid, uint16_t rnti); + /** + * Disconnects all trace sources at UE to RLC and PDCP calculators. + * Function is not implemented. + * \param context + * \param imsi + * \param cellid + * \param rnti + */ + void DisconnectTracesUe (std::string context, uint64_t imsi, uint16_t cellid, uint16_t rnti); + + +private: + /** + * Creates UE Manager path and stores it in m_ueManagerPathByCellIdRnti + * \param ueManagerPath + * \param cellId + * \param rnti + */ + void StoreUeManagerPath (std::string ueManagerPath, uint16_t cellId, uint16_t rnti); + + /** + * Connects SRB0 trace sources at UE and eNB to RLC and PDCP calculators + * \param context + * \param imsi + * \param cellId + * \param rnti + */ + void ConnectTracesSrb0 (std::string context, uint64_t imsi, uint16_t cellId, uint16_t rnti); + + /** + * Connects SRB1 trace sources at UE and eNB to RLC and PDCP calculators + * \param context + * \param imsi + * \param cellId + * \param rnti + */ + void ConnectTracesSrb1 (std::string context, uint64_t imsi, uint16_t cellId, uint16_t rnti); + + /** + * Connects DRB trace sources at eNB to RLC and PDCP calculators + * \param context + * \param imsi + * \param cellId + * \param rnti + * \param lcid + */ + void ConnectTracesDrbEnb (std::string context, uint64_t imsi, uint16_t cellId, uint16_t rnti, uint8_t lcid); + + /** + * Connects DRB trace sources at UE to RLC and PDCP calculators + * \param context + * \param imsi + * \param cellId + * \param rnti + * \param lcid + */ + void ConnectTracesDrbUe (std::string context, uint64_t imsi, uint16_t cellId, uint16_t rnti, uint8_t lcid); Ptr m_rlcStats; //!< Calculator for RLC Statistics Ptr m_pdcpStats; //!< Calculator for PDCP Statistics bool m_connected; //!< true if traces are connected to sinks, initially set to false - std::set m_imsiSeenUe; //!< stores all UEs for which RLC and PDCP traces were connected - std::set m_imsiSeenEnb; //!< stores all eNBs for which RLC and PDCP traces were connected - + /** * Struct used as key in m_ueManagerPathByCellIdRnti map */ @@ -292,9 +231,6 @@ private: }; - - } // namespace ns3 - #endif // RADIO_BEARER_STATS_CONNECTOR_H diff --git a/src/lte/model/lte-enb-rrc.cc b/src/lte/model/lte-enb-rrc.cc index 8129f36e0..7dd0c5c05 100644 --- a/src/lte/model/lte-enb-rrc.cc +++ b/src/lte/model/lte-enb-rrc.cc @@ -346,6 +346,10 @@ TypeId UeManager::GetTypeId (void) "UeManager at the eNB RRC", MakeTraceSourceAccessor (&UeManager::m_stateTransitionTrace), "ns3::UeManager::StateTracedCallback") + .AddTraceSource ("DrbCreated", + "trace fired after DRB is created", + MakeTraceSourceAccessor (&UeManager::m_drbCreatedTrace), + "ns3::UeManager::ImsiCidRntiLcIdTracedCallback") ; return tid; } @@ -431,6 +435,8 @@ UeManager::SetupDataRadioBearer (EpsBearer bearer, uint8_t bearerId, uint32_t gt drbInfo->m_pdcp = pdcp; } + m_drbCreatedTrace (m_imsi, m_rrc->ComponentCarrierToCellId (m_componentCarrierId), m_rnti, lcid); + std::vector lcOnCcMapping = m_rrc->m_ccmRrcSapProvider->SetupDataRadioBearer (bearer, bearerId, m_rnti, lcid, m_rrc->GetLogicalChannelGroup (bearer), rlc->GetLteMacSapUser ()); // LteEnbCmacSapProvider::LcInfo lcinfo; // lcinfo.rnti = m_rnti; diff --git a/src/lte/model/lte-enb-rrc.h b/src/lte/model/lte-enb-rrc.h index a5d935f4f..569a73a85 100644 --- a/src/lte/model/lte-enb-rrc.h +++ b/src/lte/model/lte-enb-rrc.h @@ -542,6 +542,13 @@ private: */ TracedCallback m_stateTransitionTrace; + /** + * The `DrbCreated` trace source. Fired when DRB is created, i.e. + * the RLC and PDCP entities are created for one logical channel. + * Exporting IMSI, cell ID, RNTI, and LCID + */ + TracedCallback m_drbCreatedTrace; + uint16_t m_sourceX2apId; ///< source X2 ap ID uint16_t m_sourceCellId; ///< source cell ID uint16_t m_targetCellId; ///< target cell ID diff --git a/src/lte/model/lte-ue-rrc.cc b/src/lte/model/lte-ue-rrc.cc index f6734e0c8..d26342e0a 100644 --- a/src/lte/model/lte-ue-rrc.cc +++ b/src/lte/model/lte-ue-rrc.cc @@ -281,6 +281,14 @@ LteUeRrc::GetTypeId (void) "trace fired after configuring secondary carriers", MakeTraceSourceAccessor (&LteUeRrc::m_sCarrierConfiguredTrace), "ns3::LteUeRrc::SCarrierConfiguredTracedCallback") + .AddTraceSource ("Srb1Created", + "trace fired after SRB1 is created", + MakeTraceSourceAccessor (&LteUeRrc::m_srb1CreatedTrace), + "ns3::LteUeRrc::ImsiCidRntiTracedCallback") + .AddTraceSource ("DrbCreated", + "trace fired after DRB is created", + MakeTraceSourceAccessor (&LteUeRrc::m_drbCreatedTrace), + "ns3::LteUeRrc::ImsiCidRntiLcIdTracedCallback") ; return tid; } @@ -1339,7 +1347,8 @@ LteUeRrc::ApplyRadioResourceConfigDedicated (LteRrcSap::RadioResourceConfigDedic m_srb1->m_rlc = rlc; m_srb1->m_pdcp = pdcp; m_srb1->m_srbIdentity = 1; - + m_srb1CreatedTrace (m_imsi, m_cellId, m_rnti); + m_srb1->m_logicalChannelConfig.priority = stamIt->logicalChannelConfig.priority; m_srb1->m_logicalChannelConfig.prioritizedBitRateKbps = stamIt->logicalChannelConfig.prioritizedBitRateKbps; m_srb1->m_logicalChannelConfig.bucketSizeDurationMs = stamIt->logicalChannelConfig.bucketSizeDurationMs; @@ -1433,7 +1442,9 @@ LteUeRrc::ApplyRadioResourceConfigDedicated (LteRrcSap::RadioResourceConfigDedic m_bid2DrbidMap[dtamIt->epsBearerIdentity] = dtamIt->drbIdentity; m_drbMap.insert (std::pair > (dtamIt->drbIdentity, drbInfo)); - + + m_drbCreatedTrace (m_imsi, m_cellId, m_rnti, dtamIt->drbIdentity); + struct LteUeCmacSapProvider::LogicalChannelConfig lcConfig; lcConfig.priority = dtamIt->logicalChannelConfig.priority; diff --git a/src/lte/model/lte-ue-rrc.h b/src/lte/model/lte-ue-rrc.h index 1af929fa1..8fe8c544a 100644 --- a/src/lte/model/lte-ue-rrc.h +++ b/src/lte/model/lte-ue-rrc.h @@ -858,6 +858,18 @@ private: * message. */ TracedCallback, std::list > m_sCarrierConfiguredTrace; + /** + * The `Srb1Created` trace source. Fired when SRB1 is created, i.e. + * the RLC and PDCP entities are created for logical channel = 1. + * Exporting IMSI, cell ID, and RNTI + */ + TracedCallback m_srb1CreatedTrace; + /** + * The `DrbCreated` trace source. Fired when DRB is created, i.e. + * the RLC and PDCP entities are created for one logical channel. + * Exporting IMSI, cell ID, RNTI, and LCID + */ + TracedCallback m_drbCreatedTrace; /// True if a connection request by upper layers is pending. bool m_connectionPending;