Browse Source

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
ndnSIM-v1
jnin 15 years ago
parent
commit
59ef420520
  1. 11
      src/lte/model/lte-enb-net-device.cc
  2. 134
      src/lte/model/lte-enb-rrc.cc
  3. 9
      src/lte/model/lte-enb-rrc.h
  4. 87
      src/lte/model/lte-rlc-tag.cc
  5. 82
      src/lte/model/lte-rlc-tag.h
  6. 40
      src/lte/model/lte-rlc.cc
  7. 20
      src/lte/model/lte-rlc.h
  8. 2
      src/lte/wscript

11
src/lte/model/lte-enb-net-device.cc

@ -52,7 +52,14 @@ TypeId LteEnbNetDevice::GetTypeId (void)
static TypeId
tid =
TypeId ("ns3::LteEnbNetDevice")
.SetParent<LteNetDevice> ();
.SetParent<LteNetDevice> ()
.AddConstructor<LteEnbNetDevice> ()
.AddAttribute ("LteEnbRrc",
"The RRC associated to this EnbNetDevice.",
PointerValue (),
MakePointerAccessor (&LteEnbNetDevice::m_rrc),
MakePointerChecker <LteEnbRrc> ())
;
return tid;
}
@ -110,7 +117,7 @@ LteEnbNetDevice::InitLteEnbNetDevice (void)
{
NS_LOG_DEBUG (this << "PHY ! NULL");
}
m_rrc = Create<LteEnbRrc> ();
m_rrc = CreateObject<LteEnbRrc> ();
m_rrc->SetLteEnbCmacSapProvider (m_mac->GetLteEnbCmacSapProvider ());
m_mac->SetLteEnbCmacSapUser (m_rrc->GetLteEnbCmacSapUser ());
m_rrc->SetLteMacSapProvider (m_mac->GetLteMacSapProvider ());

134
src/lte/model/lte-enb-rrc.cc

@ -20,9 +20,12 @@
#include <ns3/fatal-error.h>
#include <ns3/log.h>
#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<LteRlc> rlc;
public:
EnbRadioBearerInfo(void);
virtual ~EnbRadioBearerInfo (void);
static TypeId GetTypeId (void);
void SetRlc(Ptr<LteRlc> rlc);
private:
Ptr<LteRlc> 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<Object> ()
.AddConstructor<EnbRadioBearerInfo> ()
.AddAttribute ("RLC", "RLC.",
PointerValue (),
MakePointerAccessor (&EnbRadioBearerInfo::m_rlc),
MakePointerChecker<LteRlc> ())
;
return tid;
}
void EnbRadioBearerInfo::SetRlc(Ptr<LteRlc> rlc)
{
m_rlc = rlc;
}
/**
* Manages all the radio bearer information possessed by the ENB RRC for a single UE
*
*/
class UeInfo : public SimpleRefCount<UeInfo>
class UeInfo : public Object //public SimpleRefCount<UeInfo>
{
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> enbRadioBearerInfo);
/**
*
@ -93,7 +138,7 @@ public:
*
* \return the EnbRadioBearerInfo of the selected radio bearer
*/
EnbRadioBearerInfo GetRadioBerer (uint8_t lcid);
Ptr<EnbRadioBearerInfo> 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 <uint8_t, EnbRadioBearerInfo> m_rbMap;
std::map <uint8_t, Ptr<EnbRadioBearerInfo> > 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<Object> ()
.AddConstructor<UeInfo> ()
.AddAttribute ("RadioBearerMap", "List of UE RadioBearerInfo by LCID.",
ObjectMapValue (),
MakeObjectMapAccessor (&UeInfo::m_rbMap),
MakeObjectMapChecker<EnbRadioBearerInfo> ())
;
return tid;
}
uint8_t
UeInfo::AddRadioBearer (EnbRadioBearerInfo rbi)
UeInfo::AddRadioBearer (Ptr<EnbRadioBearerInfo> 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<uint8_t, EnbRadioBearerInfo> (lcid, rbi));
m_rbMap.insert (std::pair<uint8_t, Ptr<EnbRadioBearerInfo> >(lcid, rbi));
m_lastAllocatedId = lcid;
return lcid;
}
@ -130,7 +202,7 @@ UeInfo::AddRadioBearer (EnbRadioBearerInfo rbi)
return 0;
}
EnbRadioBearerInfo
Ptr<EnbRadioBearerInfo>
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 <uint8_t, EnbRadioBearerInfo>::iterator it = m_rbMap.find (lcid);
std::map <uint8_t, Ptr<EnbRadioBearerInfo> >::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<Object> ()
.AddConstructor<LteEnbRrc> ();
.AddConstructor<LteEnbRrc> ()
.AddAttribute ("UeMap", "List of UE Info by C-RNTI.",
ObjectMapValue (),
MakeObjectMapAccessor (&LteEnbRrc::m_ueMap),
MakeObjectMapChecker<UeInfo> ())
;
return tid;
}
uint16_t
LteEnbRrc::GetLastAllocatedRnti() const
{
NS_LOG_FUNCTION (this);
return m_lastAllocatedRnti;
}
std::map<uint16_t,Ptr<UeInfo> > LteEnbRrc::GetUeMap(void) const
{
return m_ueMap;
}
void LteEnbRrc::SetUeMap(std::map<uint16_t,Ptr<UeInfo> > 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<LteRlc> rlc = Create<LteRlcSm> ();
Ptr<LteRlcSm> rlc = CreateObject<LteRlcSm> ();
rlc->SetLteMacSapProvider (m_macSapProvider);
rlc->SetRnti (rnti);
EnbRadioBearerInfo rbInfo;
rbInfo.rlc = rlc;
Ptr<EnbRadioBearerInfo> rbInfo = CreateObject<EnbRadioBearerInfo> ();
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<uint16_t, Ptr<UeInfo> > (rnti, Create<UeInfo> ()));
m_ueMap.insert (std::pair<uint16_t, Ptr<UeInfo> > (rnti, CreateObject<UeInfo> ()));
return rnti;
}
}

9
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<uint16_t,Ptr<UeInfo> > ueMap);
std::map<uint16_t,Ptr<UeInfo> > GetUeMap(void) const;
/**
* Setup a new radio bearer for the given user

87
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 <jaume.nin@cttc.es>
*/
#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<Tag> ()
.AddConstructor<RlcTag> ();
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

82
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 <jaume.nin@cttc.es>
*/
#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 */

40
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 <ns3/log.h>
#include <ns3/simulator.h>
@ -88,6 +89,20 @@ LteRlc::LteRlc ()
m_macSapUser = new LteRlcSpecificLteMacSapUser (this);
}
TypeId LteRlc::GetTypeId (void)
{
static TypeId tid = TypeId ("LteRlc")
.SetParent<Object> ()
.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<LteRlc> ()
.AddConstructor<LteRlcSm> ()
;
return tid;
}
void
LteRlcSm::DoReceivePdu (Ptr<Packet> 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<Packet> (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);
}

20
src/lte/model/lte-rlc.h

@ -23,6 +23,13 @@
#include <ns3/simple-ref-count.h>
#include <ns3/packet.h>
#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<LteRlc>
class LteRlc : public Object // SimpleRefCount<LteRlc>
{
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<uint16_t, uint8_t, uint32_t> m_txPdu;
/**
* Used to inform of a PDU reception from the MAC SAP user
*/
TracedCallback<uint16_t, uint8_t, uint32_t, uint64_t> 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 ();

2
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',

Loading…
Cancel
Save