From b372eab5e72961a3dfb7d90d62a95632bf60f903 Mon Sep 17 00:00:00 2001 From: Marco Miozzo Date: Thu, 24 Mar 2011 10:20:18 +0100 Subject: [PATCH] MAC, RRC and Scheduler created by LenaHelper --- src/lte/examples/lena-first-sim.cc | 2 +- src/lte/helper/lena-helper.cc | 54 +++++++++++++++++++++++----- src/lte/helper/lena-helper.h | 38 ++++++++++++++++++++ src/lte/model/lte-enb-net-device.cc | 29 ++++++++------- src/lte/model/lte-enb-net-device.h | 7 ++-- src/lte/model/lte-phy.cc | 4 +-- src/lte/model/lte-ue-net-device.cc | 23 ++++++------ src/lte/model/lte-ue-net-device.h | 2 +- src/lte/model/rr-ff-mac-scheduler.cc | 4 +-- 9 files changed, 123 insertions(+), 40 deletions(-) diff --git a/src/lte/examples/lena-first-sim.cc b/src/lte/examples/lena-first-sim.cc index 8db46b984..fbc1a28ee 100644 --- a/src/lte/examples/lena-first-sim.cc +++ b/src/lte/examples/lena-first-sim.cc @@ -30,7 +30,7 @@ int main (int argc, char *argv[]) { LenaHelper lena; - //lena.EnableLogComponents (); + lena.EnableLogComponents (); // Create Nodes: eNodeB and UE NodeContainer enbNodes; diff --git a/src/lte/helper/lena-helper.cc b/src/lte/helper/lena-helper.cc index 77e911494..20be1f1e5 100644 --- a/src/lte/helper/lena-helper.cc +++ b/src/lte/helper/lena-helper.cc @@ -38,6 +38,11 @@ #include #include +#include +#include +#include +#include +#include namespace ns3 { @@ -49,6 +54,8 @@ LenaHelper::LenaHelper (void) { Ptr model = CreateObject (); m_downlinkChannel->AddSpectrumPropagationLossModel (model); + + //SetScheduler ("PfFfMacScheduler"); // default scheduler } LenaHelper::~LenaHelper (void) @@ -59,6 +66,32 @@ LenaHelper::~LenaHelper (void) +/* +void +LenaHelper::SetScheduler (std::string type, + std::string n0, const AttributeValue &v0, + std::string n1, const AttributeValue &v1, + std::string n2, const AttributeValue &v2, + std::string n3, const AttributeValue &v3, + std::string n4, const AttributeValue &v4, + std::string n5, const AttributeValue &v5, + std::string n6, const AttributeValue &v6, + std::string n7, const AttributeValue &v7) +{ + m_scheduler = ObjectFactory (); + m_scheduler.SetTypeId (type); + m_scheduler.Set (n0, v0); + m_scheduler.Set (n1, v1); + m_scheduler.Set (n2, v2); + m_scheduler.Set (n3, v3); + m_scheduler.Set (n4, v4); + m_scheduler.Set (n5, v5); + m_scheduler.Set (n6, v6); + m_scheduler.Set (n7, v7); +} +*/ + + NetDeviceContainer LenaHelper::InstallEnbDevice (NodeContainer c) { @@ -122,14 +155,17 @@ LenaHelper::InstallSingleEnbDevice (Ptr n) ulPhy->SetMobility (mm); m_uplinkChannel->AddRx (ulPhy); - - Ptr dev = CreateObject (n, phy); + Ptr mac = CreateObject (); + //Ptr sched = m_scheduler.Create (); + Ptr sched = Create (); + Ptr rrc = Create (); + Ptr dev = CreateObject (n, phy, mac, sched, rrc); phy->SetDevice (dev); dlPhy->SetDevice (dev); ulPhy->SetDevice (dev); n->AddDevice (dev); - Ptr mac = dev->GetMac (); + //Ptr mac = dev->GetMac (); ulPhy->SetPhyMacRxEndOkCallback (MakeCallback (&LteEnbPhy::PhyPduReceived, phy)); dev->Start (); @@ -162,14 +198,16 @@ LenaHelper::InstallSingleUeDevice (Ptr n) ulPhy->SetMobility (mm); m_downlinkChannel->AddRx (dlPhy); - - Ptr dev = CreateObject (n, phy); + + Ptr mac = CreateObject (); + Ptr rrc = Create (); + Ptr dev = CreateObject (n, phy, mac, rrc); phy->SetDevice (dev); dlPhy->SetDevice (dev); ulPhy->SetDevice (dev); n->AddDevice (dev); - Ptr mac = dev->GetMac (); + //Ptr mac = dev->GetMac (); dlPhy->SetPhyMacRxEndOkCallback (MakeCallback (&LteUePhy::PhyPduReceived, phy)); dev->Start (); @@ -237,8 +275,8 @@ LenaHelper::EnableLogComponents (void) LogComponentEnable ("LteEnbMac", LOG_LEVEL_ALL); LogComponentEnable ("LteUeMac", LOG_LEVEL_ALL); LogComponentEnable ("LteRlc", LOG_LEVEL_ALL); - LogComponentEnable ("RrPacketScheduler", LOG_LEVEL_ALL); - LogComponentEnable ("PfPacketScheduler", LOG_LEVEL_ALL); + LogComponentEnable ("RrFfMacScheduler", LOG_LEVEL_ALL); + LogComponentEnable ("PfFfMacScheduler", LOG_LEVEL_ALL); LogComponentEnable ("LtePhy", LOG_LEVEL_ALL); LogComponentEnable ("LteEnbPhy", LOG_LEVEL_ALL); diff --git a/src/lte/helper/lena-helper.h b/src/lte/helper/lena-helper.h index 57c434d52..2976992cc 100644 --- a/src/lte/helper/lena-helper.h +++ b/src/lte/helper/lena-helper.h @@ -116,6 +116,42 @@ public: * \param bearer the characteristics of the bearer to be activated */ void ActivateEpsBearer (Ptr ueDevice, EpsBearer bearer); + + + /** + * \param type the type of ns3::WifiRemoteStationManager to create. + * \param n0 the name of the attribute to set + * \param v0 the value of the attribute to set + * \param n1 the name of the attribute to set + * \param v1 the value of the attribute to set + * \param n2 the name of the attribute to set + * \param v2 the value of the attribute to set + * \param n3 the name of the attribute to set + * \param v3 the value of the attribute to set + * \param n4 the name of the attribute to set + * \param v4 the value of the attribute to set + * \param n5 the name of the attribute to set + * \param v5 the value of the attribute to set + * \param n6 the name of the attribute to set + * \param v6 the value of the attribute to set + * \param n7 the name of the attribute to set + * \param v7 the value of the attribute to set + * + * All the attributes specified in this method should exist + * in the requested scheduler. + */ + void SetScheduler (std::string type, + std::string n0 = "", const AttributeValue &v0 = EmptyAttributeValue (), + std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (), + std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (), + std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (), + std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (), + std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (), + std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (), + std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue ()); + + + /** * Enables logging for all components of the LENA architecture @@ -129,6 +165,8 @@ private: Ptr m_downlinkChannel; Ptr m_uplinkChannel; + + //ObjectFactory m_scheduler; }; diff --git a/src/lte/model/lte-enb-net-device.cc b/src/lte/model/lte-enb-net-device.cc index 859fcccb9..cef75fe48 100644 --- a/src/lte/model/lte-enb-net-device.cc +++ b/src/lte/model/lte-enb-net-device.cc @@ -73,10 +73,13 @@ LteEnbNetDevice::LteEnbNetDevice (void) InitLteEnbNetDevice (); } -LteEnbNetDevice::LteEnbNetDevice (Ptr node, Ptr phy) - : m_phy (phy) +LteEnbNetDevice::LteEnbNetDevice (Ptr node, Ptr phy, Ptr mac, Ptr sched, Ptr rrc) { NS_LOG_FUNCTION (this); + m_phy = phy; + m_mac = mac; + m_scheduler = sched; + m_rrc = rrc; InitLteEnbNetDevice (); SetNode (node); } @@ -91,14 +94,14 @@ LteEnbNetDevice::DoDispose () { NS_LOG_FUNCTION (this); - m_mac->Dispose (); - m_mac = 0; - - m_rrc->Dispose (); - m_rrc = 0; - - m_phy->Dispose (); - m_phy = 0; +// m_mac->Dispose (); +// m_mac = 0; +// +// m_rrc->Dispose (); +// m_rrc = 0; +// +// m_phy->Dispose (); +// m_phy = 0; LteNetDevice::DoDispose (); } @@ -109,7 +112,7 @@ LteEnbNetDevice::InitLteEnbNetDevice (void) { NS_LOG_FUNCTION (this); - m_mac = CreateObject (); + //m_mac = CreateObject (); // m_mac->SetDevice (this->GetObject ()); SetNode (0); if (GetPhy () == 0) @@ -120,13 +123,13 @@ LteEnbNetDevice::InitLteEnbNetDevice (void) { NS_LOG_DEBUG (this << "PHY ! NULL"); } - m_rrc = CreateObject (); + //m_rrc = Create (); m_rrc->SetLteEnbCmacSapProvider (m_mac->GetLteEnbCmacSapProvider ()); m_mac->SetLteEnbCmacSapUser (m_rrc->GetLteEnbCmacSapUser ()); m_rrc->SetLteMacSapProvider (m_mac->GetLteMacSapProvider ()); //m_scheduler = Create (); - m_scheduler = Create (); + //m_scheduler = Create (); m_mac->SetFfMacSchedSapProvider (m_scheduler->GetFfMacSchedSapProvider ()); m_mac->SetFfMacCschedSapProvider (m_scheduler->GetFfMacCschedSapProvider ()); diff --git a/src/lte/model/lte-enb-net-device.h b/src/lte/model/lte-enb-net-device.h index 1a5b13f19..f7fc5185f 100644 --- a/src/lte/model/lte-enb-net-device.h +++ b/src/lte/model/lte-enb-net-device.h @@ -55,9 +55,12 @@ public: /** * \brief Create eNB net device * \param node the network node - * \param phy the physical object attache dto it + * \param phy the physical object attached to it + * \param mac the mac layer object attached to it + * \param sched the scheduler object attached to it + * \param rrc the rrc entity object attached to it */ - LteEnbNetDevice (Ptr node, Ptr phy); + LteEnbNetDevice (Ptr node, Ptr phy, Ptr mac, Ptr sched, Ptr rrc); virtual ~LteEnbNetDevice (void); virtual void DoDispose (void); diff --git a/src/lte/model/lte-phy.cc b/src/lte/model/lte-phy.cc index 177f94148..f428368fe 100644 --- a/src/lte/model/lte-phy.cc +++ b/src/lte/model/lte-phy.cc @@ -84,8 +84,8 @@ LtePhy::DoDispose () m_netDevice = 0; for (int i = 0; i < m_macChTtiDelay; i++) { - m_packetBurstQueue.erase (m_packetBurstQueue.begin ()); - m_controlMessagesQueue.erase (m_controlMessagesQueue.begin ()); + m_packetBurstQueue.erase (m_packetBurstQueue.begin (), m_packetBurstQueue.end ()); + m_controlMessagesQueue.erase (m_controlMessagesQueue.begin (), m_controlMessagesQueue.end ()); } } diff --git a/src/lte/model/lte-ue-net-device.cc b/src/lte/model/lte-ue-net-device.cc index 1a4ac238b..c87b94af9 100644 --- a/src/lte/model/lte-ue-net-device.cc +++ b/src/lte/model/lte-ue-net-device.cc @@ -66,13 +66,14 @@ LteUeNetDevice::LteUeNetDevice (void) } -LteUeNetDevice::LteUeNetDevice (Ptr node, Ptr phy) - : m_phy (phy) +LteUeNetDevice::LteUeNetDevice (Ptr node, Ptr phy, Ptr mac, Ptr rrc) { NS_LOG_FUNCTION (this); + m_phy = phy; + m_mac = mac; + m_rrc = rrc; InitLteUeNetDevice (); SetNode (node); - /** * WILD HACK * to be translated to PHY-SAP primitive @@ -90,12 +91,12 @@ LteUeNetDevice::DoDispose (void) { NS_LOG_FUNCTION (this); m_targetEnb = 0; - m_mac->Dispose (); - m_mac = 0; - m_rrc->Dispose (); - m_rrc = 0; - m_phy->Dispose (); - m_phy = 0; +// m_mac->Dispose (); +// m_mac = 0; +// m_rrc->Dispose (); +// m_rrc = 0; +// m_phy->Dispose (); +// m_phy = 0; LteNetDevice::DoDispose (); } @@ -105,8 +106,8 @@ LteUeNetDevice::InitLteUeNetDevice (void) NS_LOG_FUNCTION (this); m_targetEnb = 0; SetNode (0); - m_mac = CreateObject (); - m_rrc = CreateObject (); + //m_mac = CreateObject (); + //m_rrc = Create (); m_rrc->SetLteUeCmacSapProvider (m_mac->GetLteUeCmacSapProvider ()); m_mac->SetLteUeCmacSapUser (m_rrc->GetLteUeCmacSapUser ()); m_rrc->SetLteMacSapProvider (m_mac->GetLteMacSapProvider ()); diff --git a/src/lte/model/lte-ue-net-device.h b/src/lte/model/lte-ue-net-device.h index 6b0bf46e7..4f81bce85 100644 --- a/src/lte/model/lte-ue-net-device.h +++ b/src/lte/model/lte-ue-net-device.h @@ -57,7 +57,7 @@ public: * \param node * \param phy */ - LteUeNetDevice (Ptr node, Ptr phy); + LteUeNetDevice (Ptr node, Ptr phy, Ptr mac, Ptr rrc); virtual ~LteUeNetDevice (void); virtual void DoDispose (); diff --git a/src/lte/model/rr-ff-mac-scheduler.cc b/src/lte/model/rr-ff-mac-scheduler.cc index 60822a604..e4d64456e 100644 --- a/src/lte/model/rr-ff-mac-scheduler.cc +++ b/src/lte/model/rr-ff-mac-scheduler.cc @@ -24,7 +24,7 @@ #include "lte-amc.h" #include "rr-ff-mac-scheduler.h" -NS_LOG_COMPONENT_DEFINE ("RrPacketScheduler"); +NS_LOG_COMPONENT_DEFINE ("RrFfMacScheduler"); namespace ns3 { @@ -36,7 +36,7 @@ int Type0AllocationRbg[4] = { }; // see table 7.1.6.1-1 of 36.213 -// NS_OBJECT_ENSURE_REGISTERED (RrPacketScheduler); +NS_OBJECT_ENSURE_REGISTERED (RrFfMacScheduler); class RrSchedulerMemberCschedSapProvider : public FfMacCschedSapProvider