From db2c435f42c96086631cf4cc7bc80c9ad59a0d45 Mon Sep 17 00:00:00 2001 From: Nicola Baldo Date: Tue, 21 Dec 2010 13:55:25 +0100 Subject: [PATCH] lte examples now passing valgrind tests --- src/devices/lte/examples/lte-device.cc | 17 ++++--- .../lte/examples/lte-multiple-flows.cc | 4 ++ src/devices/lte/examples/lte-phy-downlink.cc | 2 +- src/devices/lte/examples/lte-phy-uplink.cc | 2 +- src/devices/lte/model/enb-mac-entity.cc | 9 +++- src/devices/lte/model/enb-mac-entity.h | 5 +- src/devices/lte/model/enb-net-device.cc | 32 +++++-------- src/devices/lte/model/enb-net-device.h | 3 +- src/devices/lte/model/enb-phy.cc | 6 +-- src/devices/lte/model/enb-phy.h | 4 +- .../lte/model/ideal-control-messages.cc | 40 ++-------------- .../lte/model/ideal-control-messages.h | 7 +-- src/devices/lte/model/lte-mac-queue.h | 4 +- src/devices/lte/model/lte-net-device.cc | 5 +- src/devices/lte/model/lte-phy.cc | 20 ++++---- src/devices/lte/model/lte-phy.h | 4 +- src/devices/lte/model/multipath-loss-model.cc | 23 ++++----- src/devices/lte/model/multipath-loss-model.h | 7 +-- src/devices/lte/model/packet-scheduler.cc | 12 +++-- src/devices/lte/model/packet-scheduler.h | 3 +- .../lte/model/radio-bearer-instance.cc | 22 ++++++--- src/devices/lte/model/rlc-entity.cc | 7 +++ src/devices/lte/model/rlc-entity.h | 1 + src/devices/lte/model/rrc-entity.cc | 48 ++++++++++++++----- src/devices/lte/model/rrc-entity.h | 9 ++-- src/devices/lte/model/shadowing-loss-model.cc | 11 ++--- src/devices/lte/model/shadowing-loss-model.h | 2 +- .../lte/model/simple-packet-scheduler.cc | 7 +-- src/devices/lte/model/ue-mac-entity.cc | 4 +- src/devices/lte/model/ue-mac-entity.h | 2 +- src/devices/lte/model/ue-manager.cc | 2 +- src/devices/lte/model/ue-net-device.cc | 16 +++---- src/devices/lte/model/ue-net-device.h | 3 +- src/devices/lte/model/ue-phy.cc | 9 ++-- src/devices/lte/model/ue-phy.h | 4 +- src/devices/lte/model/ue-record.cc | 10 ++-- 36 files changed, 184 insertions(+), 182 deletions(-) diff --git a/src/devices/lte/examples/lte-device.cc b/src/devices/lte/examples/lte-device.cc index 8d5b118ef..7fa6ee339 100644 --- a/src/devices/lte/examples/lte-device.cc +++ b/src/devices/lte/examples/lte-device.cc @@ -66,11 +66,11 @@ int main (int argc, char *argv[]) Ptr enb; enb = enbDevs.Get (0)->GetObject (); - Ptr ue[nbUE]; + std::vector > ue (nbUE); for (int i = 0; i < nbUE; i++) { - ue[i] = ueDevs.Get (i)->GetObject (); - lte.RegisterUeToTheEnb (ue[i], enb); + ue.at (i) = ueDevs.Get (i)->GetObject (); + lte.RegisterUeToTheEnb (ue. at (i), enb); } @@ -94,8 +94,8 @@ int main (int argc, char *argv[]) for (int i = 0; i < nbUE; i++) { - ue[i]->GetPhy ()->SetDownlinkSubChannels (dlSubChannels); - ue[i]->GetPhy ()->SetUplinkSubChannels (ulSubChannels); + ue.at (i)->GetPhy ()->SetDownlinkSubChannels (dlSubChannels); + ue.at (i)->GetPhy ()->SetUplinkSubChannels (ulSubChannels); } @@ -110,9 +110,9 @@ int main (int argc, char *argv[]) ueMobility->SetPosition (Vector (30.0, 0.0, 0.0)); ueMobility->SetVelocity (Vector (30.0, 0.0, 0.0)); - lte.AddMobility (ue[i]->GetPhy (), ueMobility); + lte.AddMobility (ue.at (i)->GetPhy (), ueMobility); - lte.AddDownlinkChannelRealization (enbMobility, ueMobility, ue[i]->GetPhy ()); + lte.AddDownlinkChannelRealization (enbMobility, ueMobility, ue.at (i)->GetPhy ()); } @@ -156,6 +156,7 @@ int main (int argc, char *argv[]) enb->GetRrcEntity ()->AddDownlinkNgbrBearer (bearer); + bearer = 0; @@ -173,6 +174,8 @@ int main (int argc, char *argv[]) Simulator::Destroy (); + delete ipcs; + std::cout << "Done." << std::endl; return 0; diff --git a/src/devices/lte/examples/lte-multiple-flows.cc b/src/devices/lte/examples/lte-multiple-flows.cc index 7ca44d38a..e58f12c50 100644 --- a/src/devices/lte/examples/lte-multiple-flows.cc +++ b/src/devices/lte/examples/lte-multiple-flows.cc @@ -231,6 +231,10 @@ int main (int argc, char *argv[]) Simulator::Destroy (); + delete ipcs_1; + delete ipcs_2; + delete ipcs_3; + std::cout << "Done." << std::endl; return 0; diff --git a/src/devices/lte/examples/lte-phy-downlink.cc b/src/devices/lte/examples/lte-phy-downlink.cc index 0515c06e5..bec60d61d 100644 --- a/src/devices/lte/examples/lte-phy-downlink.cc +++ b/src/devices/lte/examples/lte-phy-downlink.cc @@ -154,7 +154,7 @@ int main (int argc, char** argv) // ****** simulate a packet transmission in the downlink ****** - Ptr pb = Create (); + Ptr pb = CreateObject (); Ptr p1 = Create (500); Ptr p2 = Create (500); pb->AddPacket (p1); diff --git a/src/devices/lte/examples/lte-phy-uplink.cc b/src/devices/lte/examples/lte-phy-uplink.cc index df78be15f..42dc15fa3 100644 --- a/src/devices/lte/examples/lte-phy-uplink.cc +++ b/src/devices/lte/examples/lte-phy-uplink.cc @@ -151,7 +151,7 @@ int main (int argc, char** argv) // ****** simulate a packet transmission in the downlink ****** - Ptr pb = Create (); + Ptr pb = CreateObject (); Ptr p1 = Create (500); Ptr p2 = Create (500); pb->AddPacket (p1); diff --git a/src/devices/lte/model/enb-mac-entity.cc b/src/devices/lte/model/enb-mac-entity.cc index 734a1788b..b87e49329 100644 --- a/src/devices/lte/model/enb-mac-entity.cc +++ b/src/devices/lte/model/enb-mac-entity.cc @@ -57,6 +57,11 @@ EnbMacEntity::EnbMacEntity () EnbMacEntity::~EnbMacEntity () +{ +} + +void +EnbMacEntity::DoDispose () { m_downlinkScheduler = 0; m_uplinkScheduler = 0; @@ -97,7 +102,7 @@ EnbMacEntity::GetDownlinkPacketScheduler (void) void -EnbMacEntity::ReceiveCqiIdealControlMessage (CqiIdealControlMessage* msg) +EnbMacEntity::ReceiveCqiIdealControlMessage (Ptr msg) { NS_LOG_FUNCTION (this << msg); NS_LOG_FUNCTION (this << msg->GetSourceDevice () << msg->GetDestinationDevice ()); @@ -124,7 +129,7 @@ EnbMacEntity::ReceiveCqiIdealControlMessage (CqiIdealControlMessage* msg) void -EnbMacEntity::SendPdcchMapIdealControlMessage (PdcchMapIdealControlMessage* msg) +EnbMacEntity::SendPdcchMapIdealControlMessage (Ptr msg) { NS_LOG_FUNCTION (this << msg); diff --git a/src/devices/lte/model/enb-mac-entity.h b/src/devices/lte/model/enb-mac-entity.h index 012d99452..d33606c20 100644 --- a/src/devices/lte/model/enb-mac-entity.h +++ b/src/devices/lte/model/enb-mac-entity.h @@ -41,6 +41,7 @@ public: EnbMacEntity (void); virtual ~EnbMacEntity (void); + virtual void DoDispose (void); /** * \brief Set the uplink packet scheduler @@ -67,13 +68,13 @@ public: * \brief Receive a CQI ideal control message * \param msg the message */ - void ReceiveCqiIdealControlMessage (CqiIdealControlMessage* msg); + void ReceiveCqiIdealControlMessage (Ptr msg); /** * \brief Send the PDCCH control message * \param msg the message */ - void SendPdcchMapIdealControlMessage (PdcchMapIdealControlMessage* msg); + void SendPdcchMapIdealControlMessage (Ptr msg); private: Ptr m_uplinkScheduler; diff --git a/src/devices/lte/model/enb-net-device.cc b/src/devices/lte/model/enb-net-device.cc index 27026c9d2..76e0a16f4 100644 --- a/src/devices/lte/model/enb-net-device.cc +++ b/src/devices/lte/model/enb-net-device.cc @@ -53,15 +53,7 @@ TypeId EnbNetDevice::GetTypeId (void) static TypeId tid = TypeId ("ns3::EnbNetDevice") - .SetParent () - -/* - .AddAttribute ("UeManager", - "The UE manager attached to this device.", - PointerValue (), - MakePointerAccessor (&EnbNetDevice::GetUeManager, - &EnbNetDevice::SetUeManager), - MakePointerChecker ())*/; + .SetParent (); return tid; } @@ -82,11 +74,22 @@ EnbNetDevice::EnbNetDevice (Ptr node, Ptr phy) EnbNetDevice::~EnbNetDevice (void) { NS_LOG_FUNCTION (this); +} + +void +EnbNetDevice::DoDispose () +{ + NS_LOG_FUNCTION (this); + m_ueManager->Dispose (); m_ueManager = 0; + + m_macEntity->Dispose (); m_macEntity = 0; + LteNetDevice::DoDispose (); } + void EnbNetDevice::InitEnbNetDevice (void) { @@ -99,17 +102,6 @@ EnbNetDevice::InitEnbNetDevice (void) SetPhy (0); } - -void -EnbNetDevice::DoDispose (void) -{ - NS_LOG_FUNCTION (this); - LteNetDevice::DoDispose (); - m_ueManager = 0; - m_macEntity = 0; -} - - void EnbNetDevice::Start (void) { diff --git a/src/devices/lte/model/enb-net-device.h b/src/devices/lte/model/enb-net-device.h index 7ae72adcc..f82b0f96f 100644 --- a/src/devices/lte/model/enb-net-device.h +++ b/src/devices/lte/model/enb-net-device.h @@ -58,8 +58,7 @@ public: EnbNetDevice (Ptr node, Ptr phy); virtual ~EnbNetDevice (void); - - void DoDispose (void); + virtual void DoDispose (void); /** * \brief Initialize all parameters of this device diff --git a/src/devices/lte/model/enb-phy.cc b/src/devices/lte/model/enb-phy.cc index b746ba566..9000aba84 100644 --- a/src/devices/lte/model/enb-phy.cc +++ b/src/devices/lte/model/enb-phy.cc @@ -115,19 +115,19 @@ EnbLtePhy::CalcChannelQualityForUe (std::vector sinr, Ptr msg) { NS_LOG_FUNCTION (this << msg); } void -EnbLtePhy::ReceiveIdealControlMessage (IdealControlMessage* msg) +EnbLtePhy::ReceiveIdealControlMessage (Ptr msg) { NS_LOG_FUNCTION (this << msg); if (msg->GetMessageType () == IdealControlMessage::CQI_FEEDBACKS) { - CqiIdealControlMessage* msg2 = dynamic_cast (msg); + Ptr msg2 = DynamicCast (msg); Ptr macEntity = GetDevice ()->GetObject ()->GetMacEntity (); macEntity->ReceiveCqiIdealControlMessage (msg2); } diff --git a/src/devices/lte/model/enb-phy.h b/src/devices/lte/model/enb-phy.h index dd194660b..6d25c94f6 100644 --- a/src/devices/lte/model/enb-phy.h +++ b/src/devices/lte/model/enb-phy.h @@ -70,12 +70,12 @@ public: * \brief Send the control message * \param msg the message to send */ - virtual void SendIdealControlMessage (IdealControlMessage* msg); + virtual void SendIdealControlMessage (Ptr msg); /** * \brief Receive the control message * \param msg the received message */ - virtual void ReceiveIdealControlMessage (IdealControlMessage* msg); + virtual void ReceiveIdealControlMessage (Ptr msg); /** diff --git a/src/devices/lte/model/ideal-control-messages.cc b/src/devices/lte/model/ideal-control-messages.cc index b341b8f99..821809711 100644 --- a/src/devices/lte/model/ideal-control-messages.cc +++ b/src/devices/lte/model/ideal-control-messages.cc @@ -30,8 +30,6 @@ NS_LOG_COMPONENT_DEFINE ("IdealControlMessage"); namespace ns3 { -NS_OBJECT_ENSURE_REGISTERED ( IdealControlMessage); - IdealControlMessage::IdealControlMessage (void) : m_source (0), m_destination (0) @@ -41,15 +39,8 @@ IdealControlMessage::IdealControlMessage (void) IdealControlMessage::~IdealControlMessage (void) { -} - -TypeId -IdealControlMessage::GetTypeId (void) -{ - static TypeId tid = TypeId ("ns3::IdealControlMessage") - .SetParent () - ; - return tid; + m_source = 0; + m_destination = 0; } @@ -98,8 +89,6 @@ IdealControlMessage::GetMessageType (void) // ---------------------------------------------------------------------------------------------------------- -NS_OBJECT_ENSURE_REGISTERED ( PdcchMapIdealControlMessage); - PdcchMapIdealControlMessage::PdcchMapIdealControlMessage (void) { m_idealPdcchMessage = new IdealPdcchMessage (); @@ -109,20 +98,9 @@ PdcchMapIdealControlMessage::PdcchMapIdealControlMessage (void) PdcchMapIdealControlMessage::~PdcchMapIdealControlMessage (void) { - delete m_idealPdcchMessage; + delete m_idealPdcchMessage; } - -TypeId -PdcchMapIdealControlMessage::GetTypeId (void) -{ - static TypeId tid = TypeId ("ns3::PdcchMapIdealControlMessage") - .SetParent () - ; - return tid; -} - - void PdcchMapIdealControlMessage::AddNewRecord (Direction direction, int subChannel, Ptr ue, double mcs) @@ -141,7 +119,6 @@ PdcchMapIdealControlMessage::GetMessage (void) // ---------------------------------------------------------------------------------------------------------- -NS_OBJECT_ENSURE_REGISTERED ( CqiIdealControlMessage); CqiIdealControlMessage::CqiIdealControlMessage (void) { @@ -155,17 +132,6 @@ CqiIdealControlMessage::~CqiIdealControlMessage (void) delete m_cqiFeedbacks; } - -TypeId -CqiIdealControlMessage::GetTypeId (void) -{ - static TypeId tid = TypeId ("ns3::CqiIdealControlMessage") - .SetParent () - ; - return tid; -} - - void CqiIdealControlMessage::AddNewRecord (int subChannel, double cqi) { diff --git a/src/devices/lte/model/ideal-control-messages.h b/src/devices/lte/model/ideal-control-messages.h index 959be279e..3211da163 100644 --- a/src/devices/lte/model/ideal-control-messages.h +++ b/src/devices/lte/model/ideal-control-messages.h @@ -21,7 +21,7 @@ #ifndef IDEAL_CONTROL_MESSAGES_H #define IDEAL_CONTROL_MESSAGES_H -#include "ns3/object.h" +#include "ns3/ptr.h" #include "ns3/simple-ref-count.h" #include @@ -38,8 +38,7 @@ class LteNetDevice; class IdealControlMessage : public SimpleRefCount { public: - static TypeId GetTypeId (void); - + /** * The type of the message */ @@ -125,7 +124,6 @@ class LteNetDevice; class PdcchMapIdealControlMessage : public IdealControlMessage { public: - static TypeId GetTypeId (void); PdcchMapIdealControlMessage (void); virtual ~PdcchMapIdealControlMessage (void); @@ -205,7 +203,6 @@ class LteNetDevice; class CqiIdealControlMessage : public IdealControlMessage { public: - static TypeId GetTypeId (void); CqiIdealControlMessage (void); virtual ~CqiIdealControlMessage (void); diff --git a/src/devices/lte/model/lte-mac-queue.h b/src/devices/lte/model/lte-mac-queue.h index ef25ad1ab..2114a999f 100644 --- a/src/devices/lte/model/lte-mac-queue.h +++ b/src/devices/lte/model/lte-mac-queue.h @@ -101,8 +101,8 @@ public: */ uint32_t GetNBytes (void) const; /** - * \brief Get the length of the queue with MAC + RLC + CRC overheads - * \return the length of the queue with MAC + RLC + CRC overheads + * \brief Get the length of the queue with MAC + RLC + CRC overhead + * \return the length of the queue with MAC + RLC + CRC overhead */ uint32_t GetQueueLengthWithMACOverhead (void); diff --git a/src/devices/lte/model/lte-net-device.cc b/src/devices/lte/model/lte-net-device.cc index ab1ff63fe..3bb5d10c6 100644 --- a/src/devices/lte/model/lte-net-device.cc +++ b/src/devices/lte/model/lte-net-device.cc @@ -69,14 +69,12 @@ TypeId LteNetDevice::GetTypeId (void) LteNetDevice::LteNetDevice (void) { NS_LOG_FUNCTION (this); - m_rrcEntity = CreateObject (); } LteNetDevice::~LteNetDevice (void) { NS_LOG_FUNCTION (this); - m_rrcEntity = 0; } @@ -85,9 +83,10 @@ LteNetDevice::DoDispose (void) { NS_LOG_FUNCTION (this); - m_phy->DoDispose (); + m_phy->Dispose (); m_phy = 0; m_node = 0; + m_rrcEntity->Dispose (); m_rrcEntity = 0; m_phyMacTxStartCallback = MakeNullCallback< bool, Ptr > (); NetDevice::DoDispose (); diff --git a/src/devices/lte/model/lte-phy.cc b/src/devices/lte/model/lte-phy.cc index 9afc42d0d..8ee1c07fe 100644 --- a/src/devices/lte/model/lte-phy.cc +++ b/src/devices/lte/model/lte-phy.cc @@ -51,7 +51,6 @@ LtePhy::GetTypeId (void) { static TypeId tid = TypeId ("ns3::LtePhy") .SetParent () - // .AddConstructor () ; return tid; } @@ -61,6 +60,15 @@ LtePhy::~LtePhy () { } +void +LtePhy::DoDispose () +{ + NS_LOG_FUNCTION (this); + m_downlinkSpectrumPhy = 0; + m_uplinkSpectrumPhy = 0; + m_netDevice = 0; +} + void LtePhy::SetDevice (Ptr d) { @@ -204,16 +212,6 @@ LtePhy::GetTxPower (void) return m_txPower; } - -void -LtePhy::DoDispose () -{ - NS_LOG_FUNCTION (this); - m_downlinkSpectrumPhy = 0; - m_uplinkSpectrumPhy = 0; -} - - void LtePhy::SetTti (double tti) { diff --git a/src/devices/lte/model/lte-phy.h b/src/devices/lte/model/lte-phy.h index 836365e23..5d4732246 100644 --- a/src/devices/lte/model/lte-phy.h +++ b/src/devices/lte/model/lte-phy.h @@ -178,12 +178,12 @@ public: * \brief Send SendIdealControlMessage (PDCCH map, CQI feedbacks) using the ideal control channel * \param msg the Ideal Control Message to send */ - virtual void SendIdealControlMessage (IdealControlMessage* msg) = 0; + virtual void SendIdealControlMessage (Ptr msg) = 0; /** * \brief Receive SendIdealControlMessage (PDCCH map, CQI feedbacks) using the ideal control channel * \param msg the Ideal Control Message to receive */ - virtual void ReceiveIdealControlMessage (IdealControlMessage* msg) = 0; + virtual void ReceiveIdealControlMessage (Ptr msg) = 0; /** diff --git a/src/devices/lte/model/multipath-loss-model.cc b/src/devices/lte/model/multipath-loss-model.cc index 063d658e3..c02d61be0 100644 --- a/src/devices/lte/model/multipath-loss-model.cc +++ b/src/devices/lte/model/multipath-loss-model.cc @@ -56,13 +56,12 @@ namespace ns3 { NS_OBJECT_ENSURE_REGISTERED (JakesFadingLossModel); JakesFadingLossModel::JakesFadingLossModel () + : m_nbOfPaths (1, 4), + m_startJakes (1, 2000), + m_phy (0) { NS_LOG_FUNCTION (this); SetSamplingPeriod (0.5); // default value - m_multipath = new MultipathForFrequencyDomain (); - m_nbOfPaths = new UniformVariable (1, 4); - m_startJakes = new UniformVariable (1, 2000); - m_phy = 0; } @@ -79,9 +78,7 @@ JakesFadingLossModel::GetTypeId (void) JakesFadingLossModel::~JakesFadingLossModel () { - delete m_multipath; - delete m_nbOfPaths; - delete m_startJakes; + m_phy = 0; } @@ -108,7 +105,7 @@ JakesFadingLossModel::SetValue (void) { NS_LOG_FUNCTION (this); - m_multipath->clear (); + m_multipath.clear (); int downlinkSubChannels = GetPhy ()->GetDownlinkSubChannels ().size (); @@ -156,12 +153,12 @@ JakesFadingLossModel::SetValue (void) // number of path = M // x = 1 -> M=6, x = 2 -> M=8, x = 3 -> M=10, x = 4 -> M=12 - int x = m_nbOfPaths->GetValue (); + int x = m_nbOfPaths.GetValue (); for (int i = 0; i < downlinkSubChannels; i++) { // StartJakes allow us to select a window of 0.5ms into the Jakes realization lasting 3s. - int startJakes = m_startJakes->GetValue (); + int startJakes = m_startJakes.GetValue (); MultipathForTimeDomain multipathForTimeDomain; @@ -302,7 +299,7 @@ JakesFadingLossModel::SetValue (void) } - m_multipath->push_back (multipathForTimeDomain); + m_multipath.push_back (multipathForTimeDomain); } SetLastUpdate (); @@ -323,9 +320,9 @@ JakesFadingLossModel::GetValue (int subChannel) int index = now_ms - lastUpdate_ms; NS_LOG_FUNCTION (this << subChannel << now_ms - << lastUpdate_ms << index << m_multipath->at (subChannel).at (index)); + << lastUpdate_ms << index << m_multipath.at (subChannel).at (index)); - return m_multipath->at (subChannel).at (index); + return m_multipath.at (subChannel).at (index); } diff --git a/src/devices/lte/model/multipath-loss-model.h b/src/devices/lte/model/multipath-loss-model.h index ac0938647..a4932baa3 100644 --- a/src/devices/lte/model/multipath-loss-model.h +++ b/src/devices/lte/model/multipath-loss-model.h @@ -87,10 +87,11 @@ public: typedef std::vector MultipathForFrequencyDomain; private: - MultipathForFrequencyDomain *m_multipath; - UniformVariable *m_nbOfPaths; - UniformVariable *m_startJakes; + MultipathForFrequencyDomain m_multipath; + + UniformVariable m_nbOfPaths; + UniformVariable m_startJakes; Ptr m_phy; }; diff --git a/src/devices/lte/model/packet-scheduler.cc b/src/devices/lte/model/packet-scheduler.cc index e50d4c274..8baa1ec6a 100644 --- a/src/devices/lte/model/packet-scheduler.cc +++ b/src/devices/lte/model/packet-scheduler.cc @@ -49,17 +49,15 @@ PacketScheduler::PacketScheduler (Ptr enb) } -/* + TypeId PacketScheduler::GetTypeId (void) { static TypeId tid = TypeId ("ns3::PacketScheduler") .SetParent () - .AddConstructor () ; return tid; } -*/ PacketScheduler::~PacketScheduler () @@ -67,6 +65,14 @@ PacketScheduler::~PacketScheduler () NS_LOG_FUNCTION (this); } +void +PacketScheduler::DoDispose () +{ + NS_LOG_FUNCTION (this); + m_enb = 0; + m_macEntity = 0; + Object::DoDispose (); +} void PacketScheduler::SetDevice (Ptr enb) diff --git a/src/devices/lte/model/packet-scheduler.h b/src/devices/lte/model/packet-scheduler.h index 17d75f724..1028ff3e2 100644 --- a/src/devices/lte/model/packet-scheduler.h +++ b/src/devices/lte/model/packet-scheduler.h @@ -49,8 +49,9 @@ public: */ PacketScheduler (Ptr enb); virtual ~PacketScheduler (); + virtual void DoDispose (void); - // static TypeId GetTypeId (void); + static TypeId GetTypeId (void); /** * \brief Set the device where the scheduler works diff --git a/src/devices/lte/model/radio-bearer-instance.cc b/src/devices/lte/model/radio-bearer-instance.cc index 2af3cab7f..20fd7d323 100644 --- a/src/devices/lte/model/radio-bearer-instance.cc +++ b/src/devices/lte/model/radio-bearer-instance.cc @@ -52,17 +52,31 @@ RadioBearerInstance::RadioBearerInstance () m_rlcEntity (CreateObject ()), m_ipcsClassifierRecord (0) { + NS_LOG_FUNCTION (this); m_rlcEntity->SetRadioBearer (this); } RadioBearerInstance::~RadioBearerInstance () { + NS_LOG_FUNCTION (this); m_rlcEntity = 0; m_queue = 0; m_ipcsClassifierRecord = 0; } + +void +RadioBearerInstance::DoDispose (void) +{ + NS_LOG_FUNCTION (this); + m_queue = 0; + m_qosParameters = 0; + m_rlcEntity->Dispose (); + m_rlcEntity = 0; +} + + void RadioBearerInstance::SetBearerDirection (BearerDirection direction) { @@ -105,13 +119,6 @@ RadioBearerInstance::GetQosParameters (void) } -void -RadioBearerInstance::DoDispose (void) -{ - NS_LOG_FUNCTION (this); - m_queue = 0; -} - Ptr RadioBearerInstance::GetQueue (void) const @@ -178,6 +185,7 @@ void RadioBearerInstance::SetIpcsClassifierRecord (IpcsClassifierRecord* c) { NS_LOG_FUNCTION (this << c); + NS_ASSERT (m_ipcsClassifierRecord == 0); m_ipcsClassifierRecord = c; } diff --git a/src/devices/lte/model/rlc-entity.cc b/src/devices/lte/model/rlc-entity.cc index a00a2050a..9ca304792 100644 --- a/src/devices/lte/model/rlc-entity.cc +++ b/src/devices/lte/model/rlc-entity.cc @@ -63,6 +63,13 @@ RlcEntity::~RlcEntity () NS_LOG_FUNCTION (this); } +void +RlcEntity::DoDispose () +{ + NS_LOG_FUNCTION (this); + m_device = 0; + m_bearer = 0; +} void RlcEntity::SetDevice (Ptr d) diff --git a/src/devices/lte/model/rlc-entity.h b/src/devices/lte/model/rlc-entity.h index ddd267706..a436855cc 100644 --- a/src/devices/lte/model/rlc-entity.h +++ b/src/devices/lte/model/rlc-entity.h @@ -47,6 +47,7 @@ public: */ RlcEntity (Ptr d); virtual ~RlcEntity (void); + virtual void DoDispose (void); /** diff --git a/src/devices/lte/model/rrc-entity.cc b/src/devices/lte/model/rrc-entity.cc index e50923383..938da4c8e 100644 --- a/src/devices/lte/model/rrc-entity.cc +++ b/src/devices/lte/model/rrc-entity.cc @@ -52,33 +52,55 @@ TypeId RrcEntity::GetTypeId (void) RrcEntity::RrcEntity () { - NS_LOG_FUNCTION (this); - CreateBearersContainer (); + NS_LOG_FUNCTION (this); + m_downlinkGbrBearersContainer = new BearersContainer (); + m_downlinkNgbrBearersContainer = new BearersContainer (); + m_uplinkGbrBearersContainer = new BearersContainer (); + m_uplinkNgbrBearersContainer = new BearersContainer (); + + m_defaultBearer = CreateObject (); } RrcEntity::~RrcEntity () { NS_LOG_FUNCTION (this); - delete m_downlinkGbrBearersContainer; - delete m_downlinkNgbrBearersContainer; - delete m_uplinkGbrBearersContainer; - delete m_uplinkNgbrBearersContainer; - m_defaultBearer = 0; } void -RrcEntity::CreateBearersContainer () +RrcEntity::DoDispose () { NS_LOG_FUNCTION (this); - m_downlinkGbrBearersContainer = new BearersContainer (); - m_downlinkNgbrBearersContainer = new BearersContainer (); - m_uplinkGbrBearersContainer = new BearersContainer (); - m_uplinkNgbrBearersContainer = new BearersContainer (); - m_defaultBearer = CreateObject (); + // RadioBearerInstance has a ref to RlcEntity + // which has a ref to RrcEntity + // which has a ref to RadioBearerInstance + // so we have to break this ref cycle by manually Disposing all RadioBearerInstances + + DisposeAllElements (m_downlinkGbrBearersContainer); + DisposeAllElements (m_downlinkNgbrBearersContainer); + DisposeAllElements (m_uplinkGbrBearersContainer); + DisposeAllElements (m_uplinkNgbrBearersContainer); + + delete m_downlinkGbrBearersContainer; + delete m_downlinkNgbrBearersContainer; + delete m_uplinkGbrBearersContainer; + delete m_uplinkNgbrBearersContainer; + + m_defaultBearer->Dispose (); + m_defaultBearer = 0; + Object::DoDispose (); } +void +RrcEntity::DisposeAllElements (BearersContainer *c) +{ + for (BearersContainer::iterator it = c->begin (); it != c->end (); ++it) + { + (*it)->Dispose (); + } +} + RrcEntity::BearersContainer* RrcEntity::GetDownlinkGbrBearers (void) const diff --git a/src/devices/lte/model/rrc-entity.h b/src/devices/lte/model/rrc-entity.h index 66973942d..9f41ef31a 100644 --- a/src/devices/lte/model/rrc-entity.h +++ b/src/devices/lte/model/rrc-entity.h @@ -42,17 +42,13 @@ public: RrcEntity (void); virtual ~RrcEntity (void); + virtual void DoDispose (void); /** * \brief A cointainer of bearer with the same QoS requirements */ typedef std::vector< Ptr > BearersContainer; - /** - * \brief Creates all bearer containers for this node - */ - void CreateBearersContainer (void); - /** * \brief Get all GBR downlink bearers of this node * \return a pointer to the BearersContainer of downlink GBR bearers @@ -117,6 +113,9 @@ public: Ptr GetDefaultBearer (void); private: + + void DisposeAllElements (BearersContainer *c); + BearersContainer* m_downlinkGbrBearersContainer; BearersContainer* m_downlinkNgbrBearersContainer; diff --git a/src/devices/lte/model/shadowing-loss-model.cc b/src/devices/lte/model/shadowing-loss-model.cc index 374ca9044..8d9a492a6 100644 --- a/src/devices/lte/model/shadowing-loss-model.cc +++ b/src/devices/lte/model/shadowing-loss-model.cc @@ -30,18 +30,18 @@ namespace ns3 { NS_OBJECT_ENSURE_REGISTERED (ShadowingLossModel); ShadowingLossModel::ShadowingLossModel () + : m_randVariable (.0, 8.) { - m_randVariable = new LogNormalVariable (.0, 8.); - SetValue (m_randVariable->GetValue ()); + SetValue (m_randVariable.GetValue ()); SetLastUpdate (); SetSamplingPeriod (0.5); // defauld value } ShadowingLossModel::ShadowingLossModel (double mu, double sigma, double samplingPeriod) + : m_randVariable (mu, sigma) { - m_randVariable = new LogNormalVariable (mu, sigma); - SetValue (m_randVariable->GetValue ()); + SetValue (m_randVariable.GetValue ()); SetLastUpdate (); SetSamplingPeriod (samplingPeriod); // defauld value } @@ -60,7 +60,6 @@ ShadowingLossModel::GetTypeId (void) ShadowingLossModel::~ShadowingLossModel () { - delete m_randVariable; } @@ -78,7 +77,7 @@ ShadowingLossModel::GetValue (void) NS_LOG_FUNCTION (this); if (NeedForUpdate ()) { - double sh = m_randVariable->GetValue (); + double sh = m_randVariable.GetValue (); SetValue (sh); SetLastUpdate (); } diff --git a/src/devices/lte/model/shadowing-loss-model.h b/src/devices/lte/model/shadowing-loss-model.h index 2aa3a49a1..c4ecbc2f5 100644 --- a/src/devices/lte/model/shadowing-loss-model.h +++ b/src/devices/lte/model/shadowing-loss-model.h @@ -62,7 +62,7 @@ public: double GetValue (void); private: - LogNormalVariable* m_randVariable; + LogNormalVariable m_randVariable; double m_shadowingValue; }; diff --git a/src/devices/lte/model/simple-packet-scheduler.cc b/src/devices/lte/model/simple-packet-scheduler.cc index 0f77744b2..762a0e453 100644 --- a/src/devices/lte/model/simple-packet-scheduler.cc +++ b/src/devices/lte/model/simple-packet-scheduler.cc @@ -44,14 +44,13 @@ NS_OBJECT_ENSURE_REGISTERED (SimplePacketScheduler); SimplePacketScheduler::SimplePacketScheduler () { NS_LOG_FUNCTION (this); - SetDevice (0); } SimplePacketScheduler::SimplePacketScheduler (Ptr enb) + : PacketScheduler (enb) { NS_LOG_FUNCTION (this << enb); - SetDevice (enb); } @@ -80,7 +79,7 @@ SimplePacketScheduler::DoRunPacketScheduler (void) Ptr pb = CreateObject (); - PdcchMapIdealControlMessage* msg = new PdcchMapIdealControlMessage (); + Ptr msg = Create (); //This scheduler takes one packet from each bearer @@ -141,8 +140,6 @@ SimplePacketScheduler::DoRunPacketScheduler (void) GetMacEntity ()->GetObject ()->SendPdcchMapIdealControlMessage (msg); - delete msg; - enb->StartTransmission (); } diff --git a/src/devices/lte/model/ue-mac-entity.cc b/src/devices/lte/model/ue-mac-entity.cc index 097a8cb24..170cb3c82 100644 --- a/src/devices/lte/model/ue-mac-entity.cc +++ b/src/devices/lte/model/ue-mac-entity.cc @@ -56,7 +56,7 @@ UeMacEntity::~UeMacEntity () { } -CqiIdealControlMessage* +Ptr UeMacEntity::CreateCqiFeedbacks (std::vector sinr) { NS_LOG_FUNCTION (this); @@ -70,7 +70,7 @@ UeMacEntity::CreateCqiFeedbacks (std::vector sinr) // CREATE CqiIdealControlMessage - CqiIdealControlMessage* msg = new CqiIdealControlMessage (); + Ptr msg = Create (); msg->SetSourceDevice (thisDevice); msg->SetDestinationDevice (remoteDevice); diff --git a/src/devices/lte/model/ue-mac-entity.h b/src/devices/lte/model/ue-mac-entity.h index 8aaaffee2..affdf1581 100644 --- a/src/devices/lte/model/ue-mac-entity.h +++ b/src/devices/lte/model/ue-mac-entity.h @@ -47,7 +47,7 @@ public: * computed at the physical layer when is received a signal from the eNB * \param sinr list of SINR values */ - CqiIdealControlMessage* CreateCqiFeedbacks (std::vector sinr); + Ptr CreateCqiFeedbacks (std::vector sinr); private: }; diff --git a/src/devices/lte/model/ue-manager.cc b/src/devices/lte/model/ue-manager.cc index faa1c90ee..716f130df 100644 --- a/src/devices/lte/model/ue-manager.cc +++ b/src/devices/lte/model/ue-manager.cc @@ -38,7 +38,7 @@ UeManager::UeManager (void) UeManager::~UeManager (void) { - delete m_ueRecords; + delete m_ueRecords; } diff --git a/src/devices/lte/model/ue-net-device.cc b/src/devices/lte/model/ue-net-device.cc index e29aa5b46..a31de7e9d 100644 --- a/src/devices/lte/model/ue-net-device.cc +++ b/src/devices/lte/model/ue-net-device.cc @@ -88,6 +88,14 @@ UeNetDevice::UeNetDevice (Ptr node, Ptr phy, Ptr tar UeNetDevice::~UeNetDevice (void) { NS_LOG_FUNCTION (this); +} + +void +UeNetDevice::DoDispose (void) +{ + NS_LOG_FUNCTION (this); + m_targetEnb = 0; + m_macEntity->Dispose (); m_macEntity = 0; LteNetDevice::DoDispose (); } @@ -120,14 +128,6 @@ UeNetDevice::GetMacEntity (void) return m_macEntity; } -void -UeNetDevice::DoDispose (void) -{ - NS_LOG_FUNCTION (this); - LteNetDevice::DoDispose (); -} - - void UeNetDevice::Start (void) { diff --git a/src/devices/lte/model/ue-net-device.h b/src/devices/lte/model/ue-net-device.h index f1acca0bd..fedff33d6 100644 --- a/src/devices/lte/model/ue-net-device.h +++ b/src/devices/lte/model/ue-net-device.h @@ -64,6 +64,7 @@ public: */ UeNetDevice (Ptr node, Ptr phy, Ptr targetEnb); virtual ~UeNetDevice (void); + virtual void DoDispose (); /** * \brief Set the MAC entity @@ -77,8 +78,6 @@ public: Ptr GetMacEntity (void); - void DoDispose (void); - /** * \brief Initialize the UE */ diff --git a/src/devices/lte/model/ue-phy.cc b/src/devices/lte/model/ue-phy.cc index 214197fad..3f06ab6aa 100644 --- a/src/devices/lte/model/ue-phy.cc +++ b/src/devices/lte/model/ue-phy.cc @@ -153,13 +153,12 @@ UeLtePhy::CreateCqiFeedbacks (std::vector sinr) NS_LOG_FUNCTION (this); Ptr thisDevice = GetDevice ()->GetObject (); Ptr mac = thisDevice->GetMacEntity ()->GetObject (); - CqiIdealControlMessage* msg = mac->CreateCqiFeedbacks (sinr); + Ptr msg = mac->CreateCqiFeedbacks (sinr); SendIdealControlMessage (msg); - delete msg; } void -UeLtePhy::SendIdealControlMessage (IdealControlMessage* msg) +UeLtePhy::SendIdealControlMessage (Ptr msg) { NS_LOG_FUNCTION (this << msg); Ptr phy = msg->GetDestinationDevice ()->GetPhy (); @@ -168,13 +167,13 @@ UeLtePhy::SendIdealControlMessage (IdealControlMessage* msg) void -UeLtePhy::ReceiveIdealControlMessage (IdealControlMessage* msg) +UeLtePhy::ReceiveIdealControlMessage (Ptr msg) { NS_LOG_FUNCTION (this << msg); if (msg->GetMessageType () == IdealControlMessage::ALLOCATION_MAP) { - PdcchMapIdealControlMessage* msg2 = dynamic_cast (msg); + Ptr msg2 = DynamicCast (msg); std::vector ulSubChennels; std::vector dlSubChennels; diff --git a/src/devices/lte/model/ue-phy.h b/src/devices/lte/model/ue-phy.h index 61d72389f..2cbea8d9b 100644 --- a/src/devices/lte/model/ue-phy.h +++ b/src/devices/lte/model/ue-phy.h @@ -95,8 +95,8 @@ public: */ void CreateCqiFeedbacks (std::vector sinr); - virtual void SendIdealControlMessage (IdealControlMessage* msg); - virtual void ReceiveIdealControlMessage (IdealControlMessage* msg); + virtual void SendIdealControlMessage (Ptr msg); + virtual void ReceiveIdealControlMessage (Ptr msg); private: std::vector m_subChannelsForTransmission; diff --git a/src/devices/lte/model/ue-record.cc b/src/devices/lte/model/ue-record.cc index 08d316c01..ad3f6a0ed 100644 --- a/src/devices/lte/model/ue-record.cc +++ b/src/devices/lte/model/ue-record.cc @@ -31,10 +31,6 @@ UeRecord::UeRecord (void) NS_LOG_FUNCTION (this); } -UeRecord::~UeRecord (void) -{ -} - UeRecord::UeRecord (Ptr ue, Ptr enb) : m_ue (ue), m_enb (enb) @@ -42,6 +38,12 @@ UeRecord::UeRecord (Ptr ue, Ptr enb) NS_LOG_FUNCTION (this << ue << enb); } +UeRecord::~UeRecord (void) +{ + NS_LOG_FUNCTION (this); + m_ue = 0; + m_enb = 0; +} void UeRecord::SetUe (Ptr ue)