# HG changeset patch # User Manuel Requena # Date 1328717698 -3600 # Node ID 859fa94888fc33d22f822c89967c713ea896a893 # Parent b86b82c7669392685fa6b2e236b2a4388ee4b0d6# Parent db24d2db55d43aad2cd646a8e9cb3dae12ec92cb Merge new tests of RLC entities diff -r b86b82c76693 -r 859fa94888fc src/buildings/helper/buildings-helper.cc --- a/src/buildings/helper/buildings-helper.cc Wed Feb 08 17:14:17 2012 +0100 +++ b/src/buildings/helper/buildings-helper.cc Wed Feb 08 17:14:58 2012 +0100 @@ -41,27 +41,35 @@ { Ptr bmm = (*nit)->GetObject (); NS_ABORT_MSG_UNLESS (0 != bmm, "node " << (*nit)->GetId () << " does not have a BuildingsMobilityModel"); - bool found = false; - for (BuildingList::Iterator bit = BuildingList::Begin (); bit != BuildingList::End (); ++bit) - { - Vector pos = bmm->GetPosition (); - if ((*bit)->IsInside (pos)) - { - NS_LOG_LOGIC ("node " << (*nit)->GetId () << " falls inside building " << (*bit)->GetId ()); - NS_ABORT_MSG_UNLESS (found == false, "node already inside another building!"); - found = true; - uint16_t floor = (*bit)->GetFloor (pos); - uint16_t roomX = (*bit)->GetRoomX (pos); - uint16_t roomY = (*bit)->GetRoomY (pos); - bmm->SetIndoor (*bit, floor, roomX, roomY); - } - } - if (!found) - { - NS_LOG_LOGIC ("node " << (*nit)->GetId () << " is outdoor"); - bmm->SetOutdoor (); - } + MakeConsistent (bmm); } } + +void +BuildingsHelper::MakeConsistent (Ptr bmm) +{ + bool found = false; + for (BuildingList::Iterator bit = BuildingList::Begin (); bit != BuildingList::End (); ++bit) + { + Vector pos = bmm->GetPosition (); + if ((*bit)->IsInside (pos)) + { + NS_LOG_LOGIC ("BuildingsMobilityModel " << bmm << " falls inside building " << (*bit)->GetId ()); + NS_ABORT_MSG_UNLESS (found == false, " BuildingsMobilityModel already inside another building!"); + found = true; + uint16_t floor = (*bit)->GetFloor (pos); + uint16_t roomX = (*bit)->GetRoomX (pos); + uint16_t roomY = (*bit)->GetRoomY (pos); + bmm->SetIndoor (*bit, floor, roomX, roomY); + } + } + if (!found) + { + NS_LOG_LOGIC ("BuildingsMobilityModel " << bmm << " is outdoor"); + bmm->SetOutdoor (); + } + +} + } // namespace ns3 diff -r b86b82c76693 -r 859fa94888fc src/buildings/helper/buildings-helper.h --- a/src/buildings/helper/buildings-helper.h Wed Feb 08 17:14:17 2012 +0100 +++ b/src/buildings/helper/buildings-helper.h Wed Feb 08 17:14:58 2012 +0100 @@ -25,15 +25,18 @@ #include #include #include +#include namespace ns3 { +class BuildingsMobilityModel; class BuildingsHelper { public: static void MakeMobilityModelConsistent (); + static void MakeConsistent (Ptr bmm); }; diff -r b86b82c76693 -r 859fa94888fc src/lte/doc/source/lte-user.rst --- a/src/lte/doc/source/lte-user.rst Wed Feb 08 17:14:17 2012 +0100 +++ b/src/lte/doc/source/lte-user.rst Wed Feb 08 17:14:58 2012 +0100 @@ -498,6 +498,21 @@ generate only one REM; if you want to generate more REMs, you need to create one separate instance for each REM. +Note that the REM generation is very demanding, in particular: + + * the run-time memory consumption is approximately 5KB per pixel. For example, + a REM with a resolution of 500x500 needs about 1.25 GB of memory, and + a resolution of 1000x1000 needs about 5 GB (too much for a + regular PC at the time of this writing). + * if you generate a REM at the beginning of a simulation, it will + slow down the execution of the rest of the simulation. If you want + to generate a REM for a program and also use the same program to + get simulation result, it is recommended to add a command-line + switch that allows to either generate the REM or run the complete + simulation. For this purpose, note that there is an attribute + ``RadioEnvironmentMapHelper::StopWhenDone`` (default: true) that + will force the simulation to stop right after the REM has been generated. + The REM is stored in an ASCII file in the following format: * column 1 is the x coordinate @@ -512,6 +527,7 @@ set xlabel "X" set ylabel "Y" set cblabel "SINR (dB)" + unset key plot "rem.out" using ($1):($2):(10*log10($4)) with image diff -r b86b82c76693 -r 859fa94888fc src/lte/examples/lena-rem-sector-antenna.cc --- a/src/lte/examples/lena-rem-sector-antenna.cc Wed Feb 08 17:14:17 2012 +0100 +++ b/src/lte/examples/lena-rem-sector-antenna.cc Wed Feb 08 17:14:58 2012 +0100 @@ -37,8 +37,6 @@ int main (int argc, char *argv[]) { - double simTime = 0.03; - CommandLine cmd; cmd.Parse (argc, argv); @@ -176,31 +174,35 @@ } mobility.Install (ueNodes.at(i)); } - BuildingsHelper::MakeMobilityModelConsistent (); - // Create Devices and install them in the Nodes (eNB and UE) NetDeviceContainer enbDevs; vector < NetDeviceContainer > ueDevs; + // power setting in dBm for small cells + Config::SetDefault ("ns3::LteEnbPhy::TxPower", DoubleValue (10.0)); enbDevs = lteHelper->InstallEnbDevice (oneSectorNodes); + + // power setting for three-sector macrocell + Config::SetDefault ("ns3::LteEnbPhy::TxPower", DoubleValue (30.0)); + // Beam width is made quite narrow so sectors can be noticed in the REM lteHelper->SetEnbAntennaModelType ("ns3::CosineAntennaModel"); lteHelper->SetEnbAntennaModelAttribute ("Orientation", DoubleValue (0)); - lteHelper->SetEnbAntennaModelAttribute ("Beamwidth", DoubleValue (20)); + lteHelper->SetEnbAntennaModelAttribute ("Beamwidth", DoubleValue (100)); lteHelper->SetEnbAntennaModelAttribute ("MaxGain", DoubleValue (0.0)); enbDevs.Add ( lteHelper->InstallEnbDevice (threeSectorNodes.Get (0))); lteHelper->SetEnbAntennaModelType ("ns3::CosineAntennaModel"); lteHelper->SetEnbAntennaModelAttribute ("Orientation", DoubleValue (360/3)); - lteHelper->SetEnbAntennaModelAttribute ("Beamwidth", DoubleValue (20)); + lteHelper->SetEnbAntennaModelAttribute ("Beamwidth", DoubleValue (100)); lteHelper->SetEnbAntennaModelAttribute ("MaxGain", DoubleValue (0.0)); enbDevs.Add ( lteHelper->InstallEnbDevice (threeSectorNodes.Get (1))); lteHelper->SetEnbAntennaModelType ("ns3::CosineAntennaModel"); lteHelper->SetEnbAntennaModelAttribute ("Orientation", DoubleValue (2*360/3)); - lteHelper->SetEnbAntennaModelAttribute ("Beamwidth", DoubleValue (20)); + lteHelper->SetEnbAntennaModelAttribute ("Beamwidth", DoubleValue (100)); lteHelper->SetEnbAntennaModelAttribute ("MaxGain", DoubleValue (0.0)); enbDevs.Add ( lteHelper->InstallEnbDevice (threeSectorNodes.Get (2))); @@ -214,27 +216,28 @@ lteHelper->ActivateEpsBearer (ueDev, bearer, EpcTft::Default ()); } - Simulator::Stop (Seconds (simTime)); - lteHelper->EnableTraces (); + + BuildingsHelper::MakeMobilityModelConsistent (); + + // by default, simulation will anyway stop right after the REM has been generated + Simulator::Stop (Seconds (0.0069)); Ptr remHelper = CreateObject (); remHelper->SetAttribute ("ChannelPath", StringValue ("/ChannelList/0")); remHelper->SetAttribute ("OutputFile", StringValue ("rem.out")); remHelper->SetAttribute ("XMin", DoubleValue (-2000.0)); remHelper->SetAttribute ("XMax", DoubleValue (+2000.0)); - remHelper->SetAttribute ("XRes", UintegerValue (100)); remHelper->SetAttribute ("YMin", DoubleValue (-500.0)); remHelper->SetAttribute ("YMax", DoubleValue (+3500.0)); - remHelper->SetAttribute ("YRes", UintegerValue (100)); remHelper->SetAttribute ("Z", DoubleValue (1.5)); remHelper->Install (); - // Recall the buildings helper to place the REM nodes in its position - BuildingsHelper::MakeMobilityModelConsistent (); + Simulator::Run (); // GtkConfigStore config; // config.ConfigureAttributes (); + lteHelper = 0; Simulator::Destroy (); return 0; } diff -r b86b82c76693 -r 859fa94888fc src/lte/examples/lena-rem.cc --- a/src/lte/examples/lena-rem.cc Wed Feb 08 17:14:17 2012 +0100 +++ b/src/lte/examples/lena-rem.cc Wed Feb 08 17:14:58 2012 +0100 @@ -26,6 +26,7 @@ #include "ns3/lte-module.h" #include "ns3/config-store.h" #include "ns3/spectrum-module.h" +#include //#include "ns3/gtk-config-store.h" using namespace ns3; @@ -90,10 +91,8 @@ remHelper->SetAttribute ("OutputFile", StringValue ("rem.out")); remHelper->SetAttribute ("XMin", DoubleValue (-400.0)); remHelper->SetAttribute ("XMax", DoubleValue (400.0)); - remHelper->SetAttribute ("XRes", UintegerValue (40)); remHelper->SetAttribute ("YMin", DoubleValue (-300.0)); remHelper->SetAttribute ("YMax", DoubleValue (300.0)); - remHelper->SetAttribute ("YRes", UintegerValue (30)); remHelper->SetAttribute ("Z", DoubleValue (0.0)); remHelper->Install (); @@ -107,9 +106,10 @@ // plot "rem.out" using ($1):($2):(10*log10($4)) with image - + BuildingsHelper::MakeMobilityModelConsistent (); - Simulator::Stop (Seconds (0.020)); + // by default, simulation will anyway stop right after the REM has been generated + Simulator::Stop (Seconds (0.0069)); Simulator::Run (); diff -r b86b82c76693 -r 859fa94888fc src/lte/helper/lte-stats-calculator.cc --- a/src/lte/helper/lte-stats-calculator.cc Wed Feb 08 17:14:17 2012 +0100 +++ b/src/lte/helper/lte-stats-calculator.cc Wed Feb 08 17:14:58 2012 +0100 @@ -1,8 +1,21 @@ +/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* - * lte-stats-calculator.cpp + * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (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; * - * Created on: Nov 4, 2011 - * Author: jnin + * 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-stats-calculator.h" diff -r b86b82c76693 -r 859fa94888fc src/lte/helper/lte-stats-calculator.h --- a/src/lte/helper/lte-stats-calculator.h Wed Feb 08 17:14:17 2012 +0100 +++ b/src/lte/helper/lte-stats-calculator.h Wed Feb 08 17:14:58 2012 +0100 @@ -1,8 +1,21 @@ +/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* - * lte-stats-calculator.h + * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (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; * - * Created on: Nov 4, 2011 - * Author: jnin + * 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 LTE_STATS_CALCULATOR_H_ diff -r b86b82c76693 -r 859fa94888fc src/lte/helper/radio-environment-map-helper.cc --- a/src/lte/helper/radio-environment-map-helper.cc Wed Feb 08 17:14:17 2012 +0100 +++ b/src/lte/helper/radio-environment-map-helper.cc Wed Feb 08 17:14:58 2012 +0100 @@ -33,9 +33,10 @@ #include #include #include +#include #include - +#include NS_LOG_COMPONENT_DEFINE ("RadioEnvironmentMapHelper"); @@ -96,20 +97,24 @@ .AddAttribute ("XRes", "The resolution (number of points) of the map along the x axis.", UintegerValue (100), MakeUintegerAccessor (&RadioEnvironmentMapHelper::m_xRes), - MakeUintegerChecker ()) + MakeUintegerChecker (2,std::numeric_limits::max ())) .AddAttribute ("YRes", "The resolution (number of points) of the map along the y axis.", UintegerValue (100), MakeUintegerAccessor (&RadioEnvironmentMapHelper::m_yRes), - MakeUintegerChecker ()) + MakeUintegerChecker (2,std::numeric_limits::max ())) .AddAttribute ("Z", "The value of the z coordinate for which the map is to be generated", DoubleValue (0.0), MakeDoubleAccessor (&RadioEnvironmentMapHelper::m_z), MakeDoubleChecker ()) - .AddAttribute ("ExitWhenDone", "If true, Simulator::Stop () will be called as soon as the REM has been generated", + .AddAttribute ("StopWhenDone", "If true, Simulator::Stop () will be called as soon as the REM has been generated", BooleanValue (true), - MakeBooleanAccessor (&RadioEnvironmentMapHelper::m_exitWhenDone), + MakeBooleanAccessor (&RadioEnvironmentMapHelper::m_stopWhenDone), MakeBooleanChecker ()) - + .AddAttribute ("NoisePower", + "the power of the measuring instrument noise, in Watts. Default to a kT of -174 dBm with a noise figure of 9 dB and a bandwidth of 25 LTE Resource Blocks", + DoubleValue (1.4230e-10), + MakeDoubleAccessor (&RadioEnvironmentMapHelper::m_noisePower), + MakeDoubleChecker ()) ; return tid; } @@ -133,22 +138,21 @@ m_channel = match.Get (0)->GetObject (); NS_ABORT_MSG_IF (m_channel == 0, "object at " << m_channelPath << "is not of type SpectrumChannel"); - double xStep = (m_xMax - m_xMin)/m_xRes; - double yStep = (m_yMax - m_yMin)/m_yRes; + double xStep = (m_xMax - m_xMin)/(m_xRes-1); + double yStep = (m_yMax - m_yMin)/(m_yRes-1); + - for (double x = m_xMin; x <= m_xMax ; x += xStep) + for (double x = m_xMin; x < m_xMax + 0.5*xStep; x += xStep) { - m_rem.push_back (std::list ()); - for (double y = m_yMin; y <= m_yMax ; y += yStep) + for (double y = m_yMin; y < m_yMax + 0.5*yStep ; y += yStep) { RemPoint p; p.phy = CreateObject (); p.bmm = CreateObject (); - p.node = CreateObject (); - p.node->AggregateObject (p.bmm); p.phy->SetMobility (p.bmm); p.bmm->SetPosition (Vector (x, y, m_z)); - m_rem.back ().push_back (p); + BuildingsHelper::MakeConsistent (p.bmm); + m_rem.push_back (p); } } Simulator::Schedule (Seconds (0.0055), &RadioEnvironmentMapHelper::Connect, this); @@ -160,18 +164,13 @@ RadioEnvironmentMapHelper::Connect () { NS_LOG_FUNCTION (this); - for (std::list >::iterator it1 = m_rem.begin (); - it1 != m_rem.end (); - ++it1) + for (std::list::iterator it = m_rem.begin (); + it != m_rem.end (); + ++it) { - for (std::list::iterator it2 = it1->begin (); - it2 != it1->end (); - ++it2) - { - NS_LOG_LOGIC ("adding phy " << it2->phy); - m_channel->AddRx (it2->phy); - } - } + NS_LOG_LOGIC ("adding phy " << it->phy); + m_channel->AddRx (it->phy); + } } void @@ -186,29 +185,22 @@ return; } - for (std::list >::iterator it1 = m_rem.begin (); - it1 != m_rem.end (); - ++it1) + for (std::list::iterator it = m_rem.begin (); + it != m_rem.end (); + ++it) { - for (std::list::iterator it2 = it1->begin (); - it2 != it1->end (); - ++it2) - { - Vector pos = it2->bmm->GetPosition (); - outFile << pos.x << "\t" - << pos.y << "\t" - << pos.z << "\t" - << it2->phy->GetSinr () - << std::endl; - it2->phy->Deactivate (); - } + Vector pos = it->bmm->GetPosition (); + outFile << pos.x << "\t" + << pos.y << "\t" + << pos.z << "\t" + << it->phy->GetSinr (m_noisePower) + << std::endl; + it->phy->Deactivate (); } outFile.close (); - if (m_exitWhenDone) + if (m_stopWhenDone) { Simulator::Stop (); - Simulator::Destroy (); - exit (0); } } diff -r b86b82c76693 -r 859fa94888fc src/lte/helper/radio-environment-map-helper.h --- a/src/lte/helper/radio-environment-map-helper.h Wed Feb 08 17:14:17 2012 +0100 +++ b/src/lte/helper/radio-environment-map-helper.h Wed Feb 08 17:14:58 2012 +0100 @@ -62,29 +62,29 @@ struct RemPoint { Ptr phy; - Ptr node; - Ptr dev; Ptr bmm; }; - std::list > m_rem; + std::list m_rem; double m_xMin; double m_xMax; - uint32_t m_xRes; + uint16_t m_xRes; double m_yMin; double m_yMax; - uint32_t m_yRes; + uint16_t m_yRes; double m_z; std::string m_channelPath; std::string m_outputFile; - bool m_exitWhenDone; + bool m_stopWhenDone; Ptr m_channel; + + double m_noisePower; }; diff -r b86b82c76693 -r 859fa94888fc src/lte/model/rem-spectrum-phy.cc --- a/src/lte/model/rem-spectrum-phy.cc Wed Feb 08 17:14:17 2012 +0100 +++ b/src/lte/model/rem-spectrum-phy.cc Wed Feb 08 17:14:58 2012 +0100 @@ -35,9 +35,7 @@ NS_OBJECT_ENSURE_REGISTERED (RemSpectrumPhy); RemSpectrumPhy::RemSpectrumPhy () - : m_mobility (0), - m_netDevice (0), - m_channel (0), + : m_mobility (0), m_referenceSignalPower (0), m_sumPower (0), m_active (true) @@ -57,8 +55,6 @@ { NS_LOG_FUNCTION (this); m_mobility = 0; - m_netDevice = 0; - m_channel = 0; SpectrumPhy::DoDispose (); } @@ -68,45 +64,18 @@ static TypeId tid = TypeId ("ns3::RemSpectrumPhy") .SetParent () .AddConstructor () - .AddAttribute ("NoisePower", - "the power of the measuring instrument noise, in Watts. Default to a kT of -174 dBm with a noise figure of 9 dB and a bandwidth of 25 LTE Resource Blocks", - DoubleValue (1.4230e-10), - MakeDoubleAccessor (&RemSpectrumPhy::m_noisePower), - MakeDoubleChecker ()) ; return tid; } -Ptr -RemSpectrumPhy::GetDevice () +void +RemSpectrumPhy::SetChannel (Ptr c) { - return m_netDevice; -} - - -Ptr -RemSpectrumPhy::GetMobility () -{ - return m_mobility; + // this is a no-op, RemSpectrumPhy does not transmit hence it does not need a reference to the channel } - -Ptr -RemSpectrumPhy::GetRxSpectrumModel () const -{ - return m_spectrumModel; -} - -void -RemSpectrumPhy::SetDevice (Ptr d) -{ - NS_LOG_FUNCTION (this << d); - m_netDevice = d; -} - - void RemSpectrumPhy::SetMobility (Ptr m) { @@ -114,19 +83,30 @@ m_mobility = m; } - void -RemSpectrumPhy::SetChannel (Ptr c) +RemSpectrumPhy::SetDevice (Ptr d) { - NS_LOG_FUNCTION (this << c); - m_channel = c; + NS_LOG_FUNCTION (this << d); + // this is a no-op, RemSpectrumPhy does not handle any data hence it does not support the use of a NetDevice } -void -RemSpectrumPhy::SetRxSpectrumModel (Ptr m) +Ptr +RemSpectrumPhy::GetMobility () +{ + return m_mobility; +} + +Ptr +RemSpectrumPhy::GetDevice () { - NS_LOG_FUNCTION (this << m); - m_spectrumModel = m; + return 0; +} + +Ptr +RemSpectrumPhy::GetRxSpectrumModel () const +{ + // supports any SpectrumModel + return 0; } Ptr @@ -154,9 +134,9 @@ } double -RemSpectrumPhy::GetSinr () +RemSpectrumPhy::GetSinr (double noisePower) { - return m_referenceSignalPower / (m_sumPower + m_noisePower); + return m_referenceSignalPower / (m_sumPower + noisePower); } void diff -r b86b82c76693 -r 859fa94888fc src/lte/model/rem-spectrum-phy.h --- a/src/lte/model/rem-spectrum-phy.h Wed Feb 08 17:14:17 2012 +0100 +++ b/src/lte/model/rem-spectrum-phy.h Wed Feb 08 17:14:58 2012 +0100 @@ -55,9 +55,11 @@ RemSpectrumPhy (); virtual ~RemSpectrumPhy (); + // inherited from Object + void DoDispose (); static TypeId GetTypeId (void); -// inherited from SpectrumPhy + // inherited from SpectrumPhy void SetChannel (Ptr c); void SetMobility (Ptr m); void SetDevice (Ptr d); @@ -67,19 +69,12 @@ Ptr GetRxAntenna (); void StartRx (Ptr params); - - /** - * set the SpectrumModel to be used for reception - * - */ - void SetRxSpectrumModel (Ptr); - /** * * * \return the Signal to Noise Ratio calculated */ - double GetSinr (); + double GetSinr (double noisePower); /** * make StartRx a no-op from now on @@ -87,18 +82,12 @@ */ void Deactivate (); -protected: - void DoDispose (); private: Ptr m_mobility; - Ptr m_netDevice; - Ptr m_channel; - Ptr m_spectrumModel; double m_referenceSignalPower; double m_sumPower; - double m_noisePower; bool m_active; diff -r b86b82c76693 -r 859fa94888fc src/network/model/packet-metadata.h --- a/src/network/model/packet-metadata.h Wed Feb 08 17:14:17 2012 +0100 +++ b/src/network/model/packet-metadata.h Wed Feb 08 17:14:58 2012 +0100 @@ -22,6 +22,7 @@ #include #include +#include #include "ns3/callback.h" #include "ns3/assert.h" #include "ns3/type-id.h" @@ -210,7 +211,7 @@ uint32_t maxSize); struct Data { /* number of references to this struct Data instance. */ - uint16_t m_count; + uint32_t m_count; /* size (in bytes) of m_data buffer below */ uint16_t m_size; /* max of the m_used field over all objects which @@ -376,6 +377,7 @@ m_packetUid (o.m_packetUid) { NS_ASSERT (m_data != 0); + NS_ASSERT (m_data->m_count < std::numeric_limits::max()); m_data->m_count++; } PacketMetadata &