From 59ef4205204b7457838740e2063425e4eec77a68 Mon Sep 17 00:00:00 2001 From: jnin Date: Fri, 18 Mar 2011 12:01:39 +0100 Subject: [PATCH] Added attributes to enable access to RLC instances in Enb Added trace sources in RLC to enable KPI calculation Added tag to measure RLC delay --- src/lte/model/lte-enb-net-device.cc | 11 ++- src/lte/model/lte-enb-rrc.cc | 134 ++++++++++++++++++++++++---- src/lte/model/lte-enb-rrc.h | 9 +- src/lte/model/lte-rlc-tag.cc | 87 ++++++++++++++++++ src/lte/model/lte-rlc-tag.h | 82 +++++++++++++++++ src/lte/model/lte-rlc.cc | 40 +++++++++ src/lte/model/lte-rlc.h | 20 ++++- src/lte/wscript | 2 + 8 files changed, 363 insertions(+), 22 deletions(-) create mode 100644 src/lte/model/lte-rlc-tag.cc create mode 100644 src/lte/model/lte-rlc-tag.h diff --git a/src/lte/model/lte-enb-net-device.cc b/src/lte/model/lte-enb-net-device.cc index 21cbe0446..85f608437 100644 --- a/src/lte/model/lte-enb-net-device.cc +++ b/src/lte/model/lte-enb-net-device.cc @@ -52,7 +52,14 @@ TypeId LteEnbNetDevice::GetTypeId (void) static TypeId tid = TypeId ("ns3::LteEnbNetDevice") - .SetParent (); + .SetParent () + .AddConstructor () + .AddAttribute ("LteEnbRrc", + "The RRC associated to this EnbNetDevice.", + PointerValue (), + MakePointerAccessor (&LteEnbNetDevice::m_rrc), + MakePointerChecker ()) + ; return tid; } @@ -110,7 +117,7 @@ LteEnbNetDevice::InitLteEnbNetDevice (void) { NS_LOG_DEBUG (this << "PHY ! NULL"); } - m_rrc = Create (); + m_rrc = CreateObject (); m_rrc->SetLteEnbCmacSapProvider (m_mac->GetLteEnbCmacSapProvider ()); m_mac->SetLteEnbCmacSapUser (m_rrc->GetLteEnbCmacSapUser ()); m_rrc->SetLteMacSapProvider (m_mac->GetLteMacSapProvider ()); diff --git a/src/lte/model/lte-enb-rrc.cc b/src/lte/model/lte-enb-rrc.cc index 008ccc586..5e8ffb2fc 100644 --- a/src/lte/model/lte-enb-rrc.cc +++ b/src/lte/model/lte-enb-rrc.cc @@ -20,9 +20,12 @@ #include #include +#include "ns3/pointer.h" #include "lte-enb-rrc.h" #include "lte-rlc.h" +#include "ns3/object-map.h" +#include "ns3/object-vector.h" NS_LOG_COMPONENT_DEFINE ("LteEnbRrc"); @@ -63,18 +66,60 @@ EnbRrcMemberLteEnbCmacSapUser::NotifyLcConfigResult (uint16_t rnti, uint8_t lcid // per-UE radio bearer info management // ///////////////////////////////////////// - -struct EnbRadioBearerInfo +class EnbRadioBearerInfo : public Object { - Ptr rlc; + +public: + + EnbRadioBearerInfo(void); + virtual ~EnbRadioBearerInfo (void); + static TypeId GetTypeId (void); + + void SetRlc(Ptr rlc); + +private: + + Ptr m_rlc; + }; +EnbRadioBearerInfo::EnbRadioBearerInfo (void) +{ + // Nothing to do here +} + +EnbRadioBearerInfo::~EnbRadioBearerInfo (void) +{ + // Nothing to do here +} + +TypeId EnbRadioBearerInfo::GetTypeId (void) +{ + static TypeId + tid = + TypeId ("ns3::EnbRadioBearerInfo") + .SetParent () + .AddConstructor () + .AddAttribute ("RLC", "RLC.", + PointerValue (), + MakePointerAccessor (&EnbRadioBearerInfo::m_rlc), + MakePointerChecker ()) + ; + return tid; +} + +void EnbRadioBearerInfo::SetRlc(Ptr rlc) +{ + m_rlc = rlc; +} + + /** * Manages all the radio bearer information possessed by the ENB RRC for a single UE * */ -class UeInfo : public SimpleRefCount +class UeInfo : public Object //public SimpleRefCount { public: /** @@ -84,7 +129,7 @@ public: * * \return the allocated logical channel id; 0 is returned if it is not possible to allocate a channel id (e.g., id space exausted). */ - uint8_t AddRadioBearer (EnbRadioBearerInfo); + uint8_t AddRadioBearer (Ptr enbRadioBearerInfo); /** * @@ -93,7 +138,7 @@ public: * * \return the EnbRadioBearerInfo of the selected radio bearer */ - EnbRadioBearerInfo GetRadioBerer (uint8_t lcid); + Ptr GetRadioBerer (uint8_t lcid); /** @@ -103,15 +148,42 @@ public: */ void RemoveRadioBearer (uint8_t lcid); + UeInfo(void); + virtual ~UeInfo (void); + + static TypeId GetTypeId (void); + private: - std::map m_rbMap; + std::map > m_rbMap; uint8_t m_lastAllocatedId; }; +UeInfo::UeInfo (void) : + m_lastAllocatedId (0) +{ + // Nothing to do here +} +UeInfo::~UeInfo (void) +{ + // Nothing to do here +} + +TypeId UeInfo::GetTypeId (void) +{ + static TypeId tid = TypeId ("ns3::UeInfo") + .SetParent () + .AddConstructor () + .AddAttribute ("RadioBearerMap", "List of UE RadioBearerInfo by LCID.", + ObjectMapValue (), + MakeObjectMapAccessor (&UeInfo::m_rbMap), + MakeObjectMapChecker ()) + ; + return tid; +} uint8_t -UeInfo::AddRadioBearer (EnbRadioBearerInfo rbi) +UeInfo::AddRadioBearer (Ptr rbi) { NS_LOG_FUNCTION (this); for (uint8_t lcid = m_lastAllocatedId; lcid != m_lastAllocatedId - 1; ++lcid) @@ -120,7 +192,7 @@ UeInfo::AddRadioBearer (EnbRadioBearerInfo rbi) { if (m_rbMap.find (lcid) == m_rbMap.end ()) { - m_rbMap.insert (std::pair (lcid, rbi)); + m_rbMap.insert (std::pair >(lcid, rbi)); m_lastAllocatedId = lcid; return lcid; } @@ -130,7 +202,7 @@ UeInfo::AddRadioBearer (EnbRadioBearerInfo rbi) return 0; } -EnbRadioBearerInfo +Ptr UeInfo::GetRadioBerer (uint8_t lcid) { NS_LOG_FUNCTION (this << (uint32_t) lcid); @@ -143,7 +215,7 @@ void UeInfo::RemoveRadioBearer (uint8_t lcid) { NS_LOG_FUNCTION (this << (uint32_t) lcid); - std::map ::iterator it = m_rbMap.find (lcid); + std::map >::iterator it = m_rbMap.find (lcid); NS_ASSERT_MSG (it != m_rbMap.end (), "request to remove radio bearer with unknown lcid " << lcid); m_rbMap.erase (it); } @@ -185,12 +257,42 @@ LteEnbRrc::DoDispose () TypeId LteEnbRrc::GetTypeId (void) { + NS_LOG_FUNCTION ("LteEnbRrc::GetTypeId"); static TypeId tid = TypeId ("ns3::LteEnbRrc") .SetParent () - .AddConstructor (); + .AddConstructor () + .AddAttribute ("UeMap", "List of UE Info by C-RNTI.", + ObjectMapValue (), + MakeObjectMapAccessor (&LteEnbRrc::m_ueMap), + MakeObjectMapChecker ()) + ; return tid; } +uint16_t +LteEnbRrc::GetLastAllocatedRnti() const +{ + NS_LOG_FUNCTION (this); + return m_lastAllocatedRnti; +} +std::map > LteEnbRrc::GetUeMap(void) const +{ + return m_ueMap; +} + +void LteEnbRrc::SetUeMap(std::map > ueMap) +{ + this->m_ueMap = ueMap; +} + + +void +LteEnbRrc::SetLastAllocatedRnti(uint16_t lastAllocatedRnti) +{ + NS_LOG_FUNCTION (this << lastAllocatedRnti); + m_lastAllocatedRnti = lastAllocatedRnti; +} + void @@ -260,12 +362,12 @@ LteEnbRrc::SetupRadioBearer (uint16_t rnti, EpsBearer bearer) // create RLC instance // for now we support RLC SM only - Ptr rlc = Create (); + Ptr rlc = CreateObject (); rlc->SetLteMacSapProvider (m_macSapProvider); rlc->SetRnti (rnti); - EnbRadioBearerInfo rbInfo; - rbInfo.rlc = rlc; + Ptr rbInfo = CreateObject (); + rbInfo->SetRlc (rlc); uint8_t lcid = ueInfo->AddRadioBearer (rbInfo); rlc->SetLcId (lcid); @@ -317,7 +419,7 @@ LteEnbRrc::CreateUeInfo () if (m_ueMap.find (rnti) == m_ueMap.end ()) { m_lastAllocatedRnti = rnti; - m_ueMap.insert (std::pair > (rnti, Create ())); + m_ueMap.insert (std::pair > (rnti, CreateObject ())); return rnti; } } diff --git a/src/lte/model/lte-enb-rrc.h b/src/lte/model/lte-enb-rrc.h index 82d738576..e0284d04f 100644 --- a/src/lte/model/lte-enb-rrc.h +++ b/src/lte/model/lte-enb-rrc.h @@ -68,9 +68,8 @@ public: */ void SetLteEnbCmacSapProvider (LteEnbCmacSapProvider * s); - /** - * - * + /** + * Get the CMAC SAP this RRC should interact with * \return s the CMAC SAP User interface offered to the MAC by this RRC */ LteEnbCmacSapUser* GetLteEnbCmacSapUser (); @@ -120,6 +119,10 @@ public: */ void RemoveUe (uint16_t rnti); + uint16_t GetLastAllocatedRnti() const; + void SetLastAllocatedRnti(uint16_t lastAllocatedRnti); + void SetUeMap(std::map > ueMap); + std::map > GetUeMap(void) const; /** * Setup a new radio bearer for the given user diff --git a/src/lte/model/lte-rlc-tag.cc b/src/lte/model/lte-rlc-tag.cc new file mode 100644 index 000000000..5e2ed58a2 --- /dev/null +++ b/src/lte/model/lte-rlc-tag.cc @@ -0,0 +1,87 @@ +/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2011 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 + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Jaume Nin + */ + +#include "lte-rlc-tag.h" +#include "ns3/tag.h" +#include "ns3/uinteger.h" + +namespace ns3 { + +NS_OBJECT_ENSURE_REGISTERED (RlcTag); + +RlcTag::RlcTag (): + m_senderTimestamp (Seconds (0)) +{ + // Nothing to do here +} + + +RlcTag::RlcTag(Time senderTimestamp): + m_senderTimestamp (senderTimestamp) + +{ + // Nothing to do here +} + +TypeId +RlcTag::GetTypeId (void) +{ + static TypeId tid = TypeId ("ns3::RlcTag") + .SetParent () + .AddConstructor (); + return tid; +} + +TypeId +RlcTag::GetInstanceTypeId (void) const +{ + return GetTypeId (); +} + +uint32_t +RlcTag::GetSerializedSize (void) const +{ + return sizeof(Time); +} + +void +RlcTag::Serialize (TagBuffer i) const +{ + int64_t senderTimestamp = m_senderTimestamp.GetNanoSeconds(); + i.Write ((const uint8_t *)&senderTimestamp, sizeof(int64_t)); +} + +void +RlcTag::Deserialize (TagBuffer i) +{ + int64_t senderTimestamp; + i.Read((uint8_t *)&senderTimestamp, 8); + m_senderTimestamp = NanoSeconds (senderTimestamp); + +} + +void +RlcTag::Print (std::ostream &os) const +{ + os << m_senderTimestamp; +} + +} // namespace ns3 + diff --git a/src/lte/model/lte-rlc-tag.h b/src/lte/model/lte-rlc-tag.h new file mode 100644 index 000000000..ef0a1b630 --- /dev/null +++ b/src/lte/model/lte-rlc-tag.h @@ -0,0 +1,82 @@ +/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2011 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 + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Jaume Nin + */ + +#ifndef RLC_TAG_H +#define RLC_TAG_H + +#include "ns3/packet.h" +#include "ns3/nstime.h" + + +namespace ns3 +{ + +class Tag; + +/** + * Tag to calculate the per-PDU delay from eNb RLC to UE RLC + */ + +class RlcTag : public Tag +{ +public: + static TypeId GetTypeId(void); + virtual TypeId GetInstanceTypeId(void) const; + + /** + * Create an empty RLC tag + */ + RlcTag (); + /** + * Create an RLC tag with the given senderTimestamp + */ + RlcTag (Time senderTimestamp); + + virtual void Serialize(TagBuffer i) const; + virtual void Deserialize(TagBuffer i); + virtual uint32_t GetSerializedSize() const; + virtual void Print (std::ostream &os) const; + + /** + * Get the instant when the RLC delivers the PDU to the MAC SAP provider + */ + Time getSenderTimestamp(void) const + { + return m_senderTimestamp; + } + + /** + * Set the sender timestamp + * @param senderTimestamp time stamp of the instant when the RLC delivers the PDU to the MAC SAP provider + */ + void setSenderTimestamp(Time senderTimestamp) + { + this->m_senderTimestamp = senderTimestamp; + } + +private: + + Time m_senderTimestamp; + +}; + +} //namespace ns3 + +#endif /* RLC_TAG_H */ diff --git a/src/lte/model/lte-rlc.cc b/src/lte/model/lte-rlc.cc index 58264431d..15a414770 100644 --- a/src/lte/model/lte-rlc.cc +++ b/src/lte/model/lte-rlc.cc @@ -22,6 +22,7 @@ #include "lte-rlc.h" #include "lte-mac-sap.h" #include "ff-mac-sched-sap.h" +#include "lte-rlc-tag.h" #include #include @@ -88,6 +89,20 @@ LteRlc::LteRlc () m_macSapUser = new LteRlcSpecificLteMacSapUser (this); } +TypeId LteRlc::GetTypeId (void) +{ + static TypeId tid = TypeId ("LteRlc") + .SetParent () + .AddTraceSource ("TxPDU", + "PDU transmission notified to the MAC.", + MakeTraceSourceAccessor (&LteRlc::m_txPdu)) + .AddTraceSource ("RxPDU", + "PDU received.", + MakeTraceSourceAccessor (&LteRlc::m_rxPdu)) + ; + return tid; +} + void LteRlc::SetRnti (uint8_t rnti) { @@ -139,10 +154,29 @@ LteRlcSm::~LteRlcSm () NS_LOG_FUNCTION (this); } +TypeId LteRlcSm::GetTypeId (void) +{ + static TypeId tid = TypeId ("LteRlcSm") + .SetParent () + .AddConstructor () + ; + return tid; +} + void LteRlcSm::DoReceivePdu (Ptr p) { NS_LOG_FUNCTION (this << p); + + // RLC Performance evaluation + RlcTag rlcTag; + Time t; + if (p->FindFirstMatchingByteTag(rlcTag)) + { + t = Simulator::Now() - rlcTag.getSenderTimestamp (); + } + + m_rxPdu(m_rnti, m_lcid, p->GetSize (), t.GetNanoSeconds () ); } void @@ -153,6 +187,12 @@ LteRlcSm::DoNotifyTxOpportunity (uint32_t bytes) params.pdu = Create (bytes); params.rnti = m_rnti; params.lcid = m_lcid; + + // RLC Performance evaluation + RlcTag tag (Simulator::Now()); + params.pdu->AddByteTag (tag); + m_txPdu(m_rnti, m_lcid, bytes); + m_macSapProvider->TransmitPdu (params); } diff --git a/src/lte/model/lte-rlc.h b/src/lte/model/lte-rlc.h index 04fd2fd3f..c63b509cf 100644 --- a/src/lte/model/lte-rlc.h +++ b/src/lte/model/lte-rlc.h @@ -23,6 +23,13 @@ #include #include +#include "ns3/uinteger.h" +#include "ns3/traced-value.h" +#include "ns3/trace-source-accessor.h" +#include "ns3/nstime.h" + +#include "ns3/object.h" + namespace ns3 { @@ -35,12 +42,13 @@ class LteMacSapUser; * (LTE_RLC) in LTE, see 3GPP TS 36.322 * */ -class LteRlc : public SimpleRefCount +class LteRlc : public Object // SimpleRefCount { friend class LteRlcSpecificLteMacSapUser; public: LteRlc (); virtual ~LteRlc (); + static TypeId GetTypeId (void); /** * @@ -85,6 +93,15 @@ protected: uint16_t m_rnti; uint8_t m_lcid; + /** + * Used to inform of a PDU delivery to the MAC SAP provider + */ + TracedCallback m_txPdu; + /** + * Used to inform of a PDU reception from the MAC SAP user + */ + TracedCallback m_rxPdu; + }; @@ -102,6 +119,7 @@ class LteRlcSm : public LteRlc public: LteRlcSm (); virtual ~LteRlcSm (); + static TypeId GetTypeId (void); virtual void DoNotifyTxOpportunity (uint32_t bytes); virtual void DoNotifyHarqDeliveryFailure (); diff --git a/src/lte/wscript b/src/lte/wscript index 22883eb1f..56dda6b3c 100644 --- a/src/lte/wscript +++ b/src/lte/wscript @@ -20,6 +20,7 @@ def build(bld): 'model/lte-enb-rrc.cc', 'model/lte-ue-rrc.cc', 'model/lte-rlc.cc', + 'model/lte-rlc-tag.cc', 'model/eps-bearer.cc', 'model/lte-net-device.cc', 'model/lte-enb-net-device.cc', @@ -60,6 +61,7 @@ def build(bld): 'model/lte-enb-rrc.h', 'model/lte-ue-rrc.h', 'model/lte-rlc.h', + 'model/lte-rlc-tag.h', 'model/eps-bearer.h', 'model/lte-net-device.h', 'model/lte-enb-net-device.h',