--- a/src/buildings/helper/buildings-helper.cc Wed Feb 08 11:33:26 2012 +0100
+++ b/src/buildings/helper/buildings-helper.cc Wed Feb 08 13:42:00 2012 +0100
@@ -41,27 +41,35 @@
{
Ptr<BuildingsMobilityModel> bmm = (*nit)->GetObject<BuildingsMobilityModel> ();
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<BuildingsMobilityModel> 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
--- a/src/buildings/helper/buildings-helper.h Wed Feb 08 11:33:26 2012 +0100
+++ b/src/buildings/helper/buildings-helper.h Wed Feb 08 13:42:00 2012 +0100
@@ -25,15 +25,18 @@
#include <ns3/attribute.h>
#include <ns3/object-factory.h>
#include <ns3/node-container.h>
+#include <ns3/ptr.h>
namespace ns3 {
+class BuildingsMobilityModel;
class BuildingsHelper
{
public:
static void MakeMobilityModelConsistent ();
+ static void MakeConsistent (Ptr<BuildingsMobilityModel> bmm);
};
--- a/src/lte/doc/source/lte-user.rst Wed Feb 08 11:33:26 2012 +0100
+++ b/src/lte/doc/source/lte-user.rst Wed Feb 08 13:42:00 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
--- a/src/lte/examples/lena-rem-sector-antenna.cc Wed Feb 08 11:33:26 2012 +0100
+++ b/src/lte/examples/lena-rem-sector-antenna.cc Wed Feb 08 13:42:00 2012 +0100
@@ -174,8 +174,6 @@
}
mobility.Install (ueNodes.at(i));
}
- BuildingsHelper::MakeMobilityModelConsistent ();
-
// Create Devices and install them in the Nodes (eNB and UE)
NetDeviceContainer enbDevs;
@@ -218,6 +216,9 @@
lteHelper->ActivateEpsBearer (ueDev, bearer, EpcTft::Default ());
}
+
+ BuildingsHelper::MakeMobilityModelConsistent ();
+
// by default, simulation will anyway stop right after the REM has been generated
Simulator::Stop (Seconds (0.0069));
@@ -231,9 +232,6 @@
remHelper->SetAttribute ("Z", DoubleValue (1.5));
remHelper->Install ();
-
-
- BuildingsHelper::MakeMobilityModelConsistent ();
Simulator::Run ();
// GtkConfigStore config;
--- a/src/lte/helper/radio-environment-map-helper.cc Wed Feb 08 11:33:26 2012 +0100
+++ b/src/lte/helper/radio-environment-map-helper.cc Wed Feb 08 13:42:00 2012 +0100
@@ -33,9 +33,10 @@
#include <ns3/buildings-mobility-model.h>
#include <ns3/simulator.h>
#include <ns3/node.h>
+#include <ns3/buildings-helper.h>
#include <fstream>
-
+#include <limits>
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<uint32_t> ())
+ MakeUintegerChecker<uint32_t> (2,std::numeric_limits<uint16_t>::max ()))
.AddAttribute ("YRes", "The resolution (number of points) of the map along the y axis.",
UintegerValue (100),
MakeUintegerAccessor (&RadioEnvironmentMapHelper::m_yRes),
- MakeUintegerChecker<uint32_t> ())
+ MakeUintegerChecker<uint32_t> (2,std::numeric_limits<uint16_t>::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<double> ())
- .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<double> ())
;
return tid;
}
@@ -133,22 +138,21 @@
m_channel = match.Get (0)->GetObject<SpectrumChannel> ();
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<RemPoint> ());
- 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<RemSpectrumPhy> ();
p.bmm = CreateObject<BuildingsMobilityModel> ();
- p.node = CreateObject<Node> ();
- 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<std::list<RemPoint> >::iterator it1 = m_rem.begin ();
- it1 != m_rem.end ();
- ++it1)
+ for (std::list<RemPoint>::iterator it = m_rem.begin ();
+ it != m_rem.end ();
+ ++it)
{
- for (std::list<RemPoint>::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,25 +185,20 @@
return;
}
- for (std::list<std::list<RemPoint> >::iterator it1 = m_rem.begin ();
- it1 != m_rem.end ();
- ++it1)
+ for (std::list<RemPoint>::iterator it = m_rem.begin ();
+ it != m_rem.end ();
+ ++it)
{
- for (std::list<RemPoint>::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 ();
}
--- a/src/lte/helper/radio-environment-map-helper.h Wed Feb 08 11:33:26 2012 +0100
+++ b/src/lte/helper/radio-environment-map-helper.h Wed Feb 08 13:42:00 2012 +0100
@@ -62,29 +62,29 @@
struct RemPoint
{
Ptr<RemSpectrumPhy> phy;
- Ptr<Node> node;
- Ptr<NetDevice> dev;
Ptr<BuildingsMobilityModel> bmm;
};
- std::list<std::list<RemPoint> > m_rem;
+ std::list<RemPoint> 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<SpectrumChannel> m_channel;
+
+ double m_noisePower;
};
--- a/src/lte/model/rem-spectrum-phy.cc Wed Feb 08 11:33:26 2012 +0100
+++ b/src/lte/model/rem-spectrum-phy.cc Wed Feb 08 13:42:00 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<SpectrumPhy> ()
.AddConstructor<RemSpectrumPhy> ()
- .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<double> ())
;
return tid;
}
-Ptr<NetDevice>
-RemSpectrumPhy::GetDevice ()
+void
+RemSpectrumPhy::SetChannel (Ptr<SpectrumChannel> c)
{
- return m_netDevice;
-}
-
-
-Ptr<MobilityModel>
-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<const SpectrumModel>
-RemSpectrumPhy::GetRxSpectrumModel () const
-{
- return m_spectrumModel;
-}
-
-void
-RemSpectrumPhy::SetDevice (Ptr<NetDevice> d)
-{
- NS_LOG_FUNCTION (this << d);
- m_netDevice = d;
-}
-
-
void
RemSpectrumPhy::SetMobility (Ptr<MobilityModel> m)
{
@@ -114,19 +83,30 @@
m_mobility = m;
}
-
void
-RemSpectrumPhy::SetChannel (Ptr<SpectrumChannel> c)
+RemSpectrumPhy::SetDevice (Ptr<NetDevice> 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<SpectrumModel> m)
+Ptr<MobilityModel>
+RemSpectrumPhy::GetMobility ()
+{
+ return m_mobility;
+}
+
+Ptr<NetDevice>
+RemSpectrumPhy::GetDevice ()
{
- NS_LOG_FUNCTION (this << m);
- m_spectrumModel = m;
+ return 0;
+}
+
+Ptr<const SpectrumModel>
+RemSpectrumPhy::GetRxSpectrumModel () const
+{
+ // supports any SpectrumModel
+ return 0;
}
Ptr<AntennaModel>
@@ -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
--- a/src/lte/model/rem-spectrum-phy.h Wed Feb 08 11:33:26 2012 +0100
+++ b/src/lte/model/rem-spectrum-phy.h Wed Feb 08 13:42:00 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<SpectrumChannel> c);
void SetMobility (Ptr<MobilityModel> m);
void SetDevice (Ptr<NetDevice> d);
@@ -67,19 +69,12 @@
Ptr<AntennaModel> GetRxAntenna ();
void StartRx (Ptr<SpectrumSignalParameters> params);
-
- /**
- * set the SpectrumModel to be used for reception
- *
- */
- void SetRxSpectrumModel (Ptr<SpectrumModel>);
-
/**
*
*
* \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<MobilityModel> m_mobility;
- Ptr<NetDevice> m_netDevice;
- Ptr<SpectrumChannel> m_channel;
- Ptr<SpectrumModel> m_spectrumModel;
double m_referenceSignalPower;
double m_sumPower;
- double m_noisePower;
bool m_active;