diff --git a/src/lte/examples/inter-cell-interference.cc b/src/lte/examples/inter-cell-interference.cc index dc87f173a..ffb21376a 100644 --- a/src/lte/examples/inter-cell-interference.cc +++ b/src/lte/examples/inter-cell-interference.cc @@ -90,9 +90,8 @@ int main (int argc, char *argv[]) << "_numUes" << std::setw(3) << std::setfill('0') << numUes << "_rngRun" << std::setw(3) << std::setfill('0') << runValue.Get () ; - - LenaHelper lena; - + Ptr lena = CreateObject (); + // Create Nodes: eNodeB and UE NodeContainer enbNodes; NodeContainer ueNodes1, ueNodes2; @@ -133,19 +132,19 @@ int main (int argc, char *argv[]) NetDeviceContainer enbDevs; NetDeviceContainer ueDevs1; NetDeviceContainer ueDevs2; - enbDevs = lena.InstallEnbDevice (enbNodes); - ueDevs1 = lena.InstallUeDevice (ueNodes1); - ueDevs2 = lena.InstallUeDevice (ueNodes2); + enbDevs = lena->InstallEnbDevice (enbNodes); + ueDevs1 = lena->InstallUeDevice (ueNodes1); + ueDevs2 = lena->InstallUeDevice (ueNodes2); // Attach UEs to a eNB - lena.Attach (ueDevs1, enbDevs.Get (0)); - lena.Attach (ueDevs2, enbDevs.Get (1)); + lena->Attach (ueDevs1, enbDevs.Get (0)); + lena->Attach (ueDevs2, enbDevs.Get (1)); // Activate an EPS bearer on all UEs enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; EpsBearer bearer (q); - lena.ActivateEpsBearer (ueDevs1, bearer); - lena.ActivateEpsBearer (ueDevs2, bearer); + lena->ActivateEpsBearer (ueDevs1, bearer); + lena->ActivateEpsBearer (ueDevs2, bearer); Simulator::Stop (Seconds (10)); diff --git a/src/lte/examples/lena-first-sim.cc b/src/lte/examples/lena-first-sim.cc index 97b213b83..926b5ffc5 100644 --- a/src/lte/examples/lena-first-sim.cc +++ b/src/lte/examples/lena-first-sim.cc @@ -44,9 +44,9 @@ int main (int argc, char *argv[]) // parse again so you can override default values from the command line cmd.Parse (argc, argv); - LenaHelper lena; + Ptr lena = CreateObject (); - lena.EnableLogComponents (); + //lena->EnableLogComponents (); // Create Nodes: eNodeB and UE NodeContainer enbNodes; @@ -64,18 +64,18 @@ int main (int argc, char *argv[]) // Create Devices and install them in the Nodes (eNB and UE) NetDeviceContainer enbDevs; NetDeviceContainer ueDevs; - //lena.SetScheduler ("RrFfMacScheduler"); - lena.SetScheduler ("PfFfMacScheduler"); - enbDevs = lena.InstallEnbDevice (enbNodes); - ueDevs = lena.InstallUeDevice (ueNodes); + //lena->SetSchedulerType ("ns3::RrFfMacScheduler"); + lena->SetSchedulerType ("ns3::PfFfMacScheduler"); + enbDevs = lena->InstallEnbDevice (enbNodes); + ueDevs = lena->InstallUeDevice (ueNodes); // Attach a UE to a eNB - lena.Attach (ueDevs, enbDevs.Get (0)); + lena->Attach (ueDevs, enbDevs.Get (0)); // Activate an EPS bearer enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; EpsBearer bearer (q); - lena.ActivateEpsBearer (ueDevs, bearer); + lena->ActivateEpsBearer (ueDevs, bearer); Simulator::Stop (Seconds (0.005)); diff --git a/src/lte/examples/lena-rlc-calculator.cc b/src/lte/examples/lena-rlc-calculator.cc index ecf29d9a0..8a0c89b42 100644 --- a/src/lte/examples/lena-rlc-calculator.cc +++ b/src/lte/examples/lena-rlc-calculator.cc @@ -55,8 +55,6 @@ void DlRxPduCallback(Ptr rlcStats, std::string path, int main (int argc, char *argv[]) { - LenaHelper lena; - // Command line arguments CommandLine cmd; cmd.Parse (argc, argv); @@ -67,8 +65,10 @@ int main (int argc, char *argv[]) // parse again so you can override default values from the command line cmd.Parse (argc, argv); + Ptr lena = CreateObject (); + // Enable LTE log components - //lena.EnableLogComponents (); + //lena->EnableLogComponents (); // Create Nodes: eNodeB and UE NodeContainer enbNodes; @@ -86,16 +86,16 @@ int main (int argc, char *argv[]) // Create Devices and install them in the Nodes (eNB and UE) NetDeviceContainer enbDevs; NetDeviceContainer ueDevs; - enbDevs = lena.InstallEnbDevice (enbNodes); - ueDevs = lena.InstallUeDevice (ueNodes); + enbDevs = lena->InstallEnbDevice (enbNodes); + ueDevs = lena->InstallUeDevice (ueNodes); // Attach a UE to a eNB - lena.Attach (ueDevs, enbDevs.Get (0)); + lena->Attach (ueDevs, enbDevs.Get (0)); // Activate an EPS bearer enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; EpsBearer bearer (q); - lena.ActivateEpsBearer (ueDevs, bearer); + lena->ActivateEpsBearer (ueDevs, bearer); Simulator::Stop (Seconds (4)); diff --git a/src/lte/helper/lena-helper.cc b/src/lte/helper/lena-helper.cc index 36dca1dd7..26d42f4c2 100644 --- a/src/lte/helper/lena-helper.cc +++ b/src/lte/helper/lena-helper.cc @@ -22,6 +22,9 @@ #include "lena-helper.h" +#include +#include + #include #include #include @@ -37,66 +40,105 @@ #include #include -#include -#include -#include -#include -#include -#include +#include +NS_LOG_COMPONENT_DEFINE ("LenaHelper"); namespace ns3 { +NS_OBJECT_ENSURE_REGISTERED (LenaHelper); LenaHelper::LenaHelper (void) { + NS_LOG_FUNCTION (this); +} + +void +LenaHelper::DoStart (void) +{ + NS_LOG_FUNCTION (this); m_downlinkChannel = CreateObject (); m_uplinkChannel = CreateObject (); - Ptr dlPropagationModel = CreateObject (); - Ptr ulPropagationModel = CreateObject (); + Ptr dlPropagationModel = m_propagationModelFactory.Create (); + Ptr ulPropagationModel = m_propagationModelFactory.Create (); m_downlinkChannel->AddSpectrumPropagationLossModel (dlPropagationModel); - m_uplinkChannel->AddSpectrumPropagationLossModel (ulPropagationModel); - - SetScheduler ("RrFfMacScheduler"); // default scheduler + m_uplinkChannel->AddSpectrumPropagationLossModel (ulPropagationModel); + Object::DoStart (); } LenaHelper::~LenaHelper (void) { - m_downlinkChannel = 0; - m_uplinkChannel = 0; + NS_LOG_FUNCTION (this); } +void +LenaHelper::DoDispose () +{ + NS_LOG_FUNCTION (this); + m_downlinkChannel = 0; + m_uplinkChannel = 0; + Object::DoDispose (); +} + +TypeId LenaHelper::GetTypeId (void) +{ + static TypeId + tid = + TypeId ("ns3::LenaHelper") + .SetParent () + .AddConstructor () + .AddAttribute ("Scheduler", + "The type of scheduler to be used for eNBs", + StringValue ("ns3::RrFfMacScheduler"), + MakeStringAccessor (&LenaHelper::SetSchedulerType), + MakeStringChecker ()) + .AddAttribute ("PropagationModel", + "The type of propagation model to be used", + StringValue ("ns3::FriisSpectrumPropagationLossModel"), + MakeStringAccessor (&LenaHelper::SetPropagationModelType), + MakeStringChecker ()) + ; + return tid; +} + +void +LenaHelper::SetSchedulerType (std::string type) +{ + NS_LOG_FUNCTION (this << type); + m_schedulerFactory = ObjectFactory (); + m_schedulerFactory.SetTypeId (type); +} + +void +LenaHelper::SetSchedulerAttribute (std::string n, const AttributeValue &v) +{ + NS_LOG_FUNCTION (this << n); + m_schedulerFactory.Set (n, v); +} 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) +LenaHelper::SetPropagationModelType (std::string type) { - 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); + NS_LOG_FUNCTION (this << type); + m_propagationModelFactory = ObjectFactory (); + m_propagationModelFactory.SetTypeId (type); } +void +LenaHelper::SetPropagationModelAttribute (std::string n, const AttributeValue &v) +{ + NS_LOG_FUNCTION (this << n); + m_propagationModelFactory.Set (n, v); +} NetDeviceContainer LenaHelper::InstallEnbDevice (NodeContainer c) { + NS_LOG_FUNCTION (this); + Start (); // will run DoStart () if necessary NetDeviceContainer devices; for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i) { @@ -110,6 +152,7 @@ LenaHelper::InstallEnbDevice (NodeContainer c) NetDeviceContainer LenaHelper::InstallUeDevice (NodeContainer c) { + NS_LOG_FUNCTION (this); NetDeviceContainer devices; for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i) { @@ -124,13 +167,15 @@ LenaHelper::InstallUeDevice (NodeContainer c) void LenaHelper::SetEnbDeviceAttribute (std::string name, const AttributeValue &value) { - + NS_LOG_FUNCTION (this); + NS_FATAL_ERROR ("not implemented yet"); } void LenaHelper::SetUeDeviceAttribute (std::string name, const AttributeValue &value) { - + NS_LOG_FUNCTION (this); + NS_FATAL_ERROR ("not implemented yet"); } @@ -156,7 +201,7 @@ LenaHelper::InstallSingleEnbDevice (Ptr n) m_uplinkChannel->AddRx (ulPhy); Ptr mac = CreateObject (); - Ptr sched = m_scheduler.Create (); + Ptr sched = m_schedulerFactory.Create (); Ptr rrc = CreateObject (); diff --git a/src/lte/helper/lena-helper.h b/src/lte/helper/lena-helper.h index b5f15511b..4ef7debc7 100644 --- a/src/lte/helper/lena-helper.h +++ b/src/lte/helper/lena-helper.h @@ -43,12 +43,14 @@ class SpectrumChannel; * Creation and configuration of LTE entities * */ -class LenaHelper +class LenaHelper : public Object { public: LenaHelper (void); - ~LenaHelper (void); + virtual ~LenaHelper (void); + static TypeId GetTypeId (void); + virtual void DoDispose (void); /** * \todo to be implemented @@ -117,41 +119,30 @@ public: */ void ActivateEpsBearer (Ptr ueDevice, EpsBearer bearer); + /** + * + * + * \param type the type of scheduler to be used for the eNBs + */ + void SetSchedulerType (std::string type); /** - * \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 ()); - - + * set an attribute for the scheduler to be created + */ + void SetSchedulerAttribute (std::string n, const AttributeValue &v); + + /** + * + * + * \param type the type of propagation model to be used for the eNBs + */ + void SetPropagationModelType (std::string type); + /** + * set an attribute for the propagation model to be created + */ + void SetPropagationModelAttribute (std::string n, const AttributeValue &v); + /** * Enables logging for all components of the LENA architecture @@ -159,14 +150,22 @@ public: */ void EnableLogComponents (void); + +protected: + + // inherited from Object + virtual void DoStart (void); + private: + Ptr InstallSingleEnbDevice (Ptr n); Ptr InstallSingleUeDevice (Ptr n); Ptr m_downlinkChannel; Ptr m_uplinkChannel; - ObjectFactory m_scheduler; + ObjectFactory m_schedulerFactory; + ObjectFactory m_propagationModelFactory; }; diff --git a/src/lte/model/pf-ff-mac-scheduler.cc b/src/lte/model/pf-ff-mac-scheduler.cc index 53d922dd6..7fefa209e 100644 --- a/src/lte/model/pf-ff-mac-scheduler.cc +++ b/src/lte/model/pf-ff-mac-scheduler.cc @@ -233,7 +233,7 @@ PfFfMacScheduler::DoDispose () TypeId PfFfMacScheduler::GetTypeId (void) { - static TypeId tid = TypeId ("PfFfMacScheduler") + static TypeId tid = TypeId ("ns3::PfFfMacScheduler") .SetParent () .AddConstructor (); return tid; diff --git a/src/lte/model/rr-ff-mac-scheduler.cc b/src/lte/model/rr-ff-mac-scheduler.cc index 7337421e0..415b192d7 100644 --- a/src/lte/model/rr-ff-mac-scheduler.cc +++ b/src/lte/model/rr-ff-mac-scheduler.cc @@ -230,7 +230,7 @@ RrFfMacScheduler::DoDispose () TypeId RrFfMacScheduler::GetTypeId (void) { - static TypeId tid = TypeId ("RrFfMacScheduler") + static TypeId tid = TypeId ("ns3::RrFfMacScheduler") .SetParent () .AddConstructor (); return tid;