24 #include <ns3/abort.h>
26 #include <ns3/double.h>
27 #include <ns3/uinteger.h>
28 #include <ns3/string.h>
29 #include <ns3/boolean.h>
30 #include <ns3/spectrum-channel.h>
31 #include <ns3/config.h>
32 #include <ns3/rem-spectrum-phy.h>
33 #include <ns3/mobility-building-info.h>
34 #include <ns3/constant-position-mobility-model.h>
35 #include <ns3/simulator.h>
37 #include <ns3/buildings-helper.h>
38 #include <ns3/lte-spectrum-value-helper.h>
73 static TypeId tid =
TypeId (
"ns3::RadioEnvironmentMapHelper")
75 .AddConstructor<RadioEnvironmentMapHelper> ()
76 .AddAttribute (
"ChannelPath",
"The path to the channel for which the Radio Environment Map is to be generated",
80 .AddAttribute (
"OutputFile",
"the filename to which the Radio Environment Map is saved",
84 .AddAttribute (
"XMin",
"The min x coordinate of the map.",
87 MakeDoubleChecker<double> ())
88 .AddAttribute (
"YMin",
"The min y coordinate of the map.",
91 MakeDoubleChecker<double> ())
92 .AddAttribute (
"XMax",
"The max x coordinate of the map.",
95 MakeDoubleChecker<double> ())
96 .AddAttribute (
"YMax",
"The max y coordinate of the map.",
99 MakeDoubleChecker<double> ())
100 .AddAttribute (
"XRes",
"The resolution (number of points) of the map along the x axis.",
103 MakeUintegerChecker<uint32_t> (2,std::numeric_limits<uint16_t>::max ()))
104 .AddAttribute (
"YRes",
"The resolution (number of points) of the map along the y axis.",
107 MakeUintegerChecker<uint16_t> (2,std::numeric_limits<uint16_t>::max ()))
108 .AddAttribute (
"Z",
"The value of the z coordinate for which the map is to be generated",
111 MakeDoubleChecker<double> ())
112 .AddAttribute (
"StopWhenDone",
"If true, Simulator::Stop () will be called as soon as the REM has been generated",
115 MakeBooleanChecker ())
116 .AddAttribute (
"NoisePower",
117 "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",
120 MakeDoubleChecker<double> ())
121 .AddAttribute (
"MaxPointsPerIteration",
"Maximum number of REM points to be calculated per iteration. Every point consumes approximately 5KB of memory.",
124 MakeUintegerChecker<uint32_t> (1,std::numeric_limits<uint32_t>::max ()))
125 .AddAttribute (
"Earfcn",
126 "E-UTRA Absolute Radio Frequency Channel Number (EARFCN) "
127 "as per 3GPP 36.101 Section 5.7.3. ",
130 MakeUintegerChecker<uint16_t> ())
131 .AddAttribute (
"Bandwidth",
132 "Transmission Bandwidth Configuration (in number of RBs) over which the SINR will be calculated",
136 MakeUintegerChecker<uint16_t> ())
176 NS_FATAL_ERROR (
"only one REM supported per instance of RadioEnvironmentMapHelper");
179 if (match.
GetN () != 1)
214 p.
phy = CreateObject<RemSpectrumPhy> ();
215 p.
bmm = CreateObject<ConstantPositionMobilityModel> ();
219 p.
phy->SetMobility (p.
bmm);
224 double remIterationStartTime = 0.0001;
227 uint32_t numPointsCurrentIteration = 0;
228 bool justScheduled =
false;
237 justScheduled =
false;
240 ++numPointsCurrentIteration;
241 if ((numPointsCurrentIteration == m_maxPointsPerIteration)
246 this, xMinNext,
x, yMinNext, y);
247 remIterationStartTime += 0.001;
248 justScheduled =
true;
249 numPointsCurrentIteration = 0;
263 std::list<RemPoint>::iterator remIt =
m_rem.begin ();
268 for (y = (x == xMin) ? yMin :
m_yMin;
273 remIt->bmm->SetPosition (
Vector (x, y,
m_z));
279 if (remIt !=
m_rem.end ())
282 NS_LOG_LOGIC (
"deactivating RemSpectrumPhys that are unneeded in the last iteration");
283 while (remIt !=
m_rem.end ())
285 remIt->phy->Deactivate ();
298 for (std::list<RemPoint>::iterator it =
m_rem.begin ();
302 if (!(it->phy->IsActive ()))
308 Vector pos = it->bmm->GetPosition ();
double x
x coordinate of vector
smart pointer class similar to boost::intrusive_ptr
#define NS_LOG_FUNCTION(parameters)
hold variables of type string
uint32_t m_maxPointsPerIteration
#define NS_ASSERT(condition)
static TypeId GetTypeId(void)
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
static Ptr< SpectrumModel > GetSpectrumModel(uint16_t earfcn, uint8_t bandwidth)
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
Schedule an event to expire at the relative time "time" is reached.
Ptr< RemSpectrumPhy > phy
#define NS_FATAL_ERROR(msg)
fatal error handling
static void MakeConsistent(Ptr< MobilityModel > bmm)
Make the given mobility model consistent, by determining whether its position falls inside any of the...
Config::MatchContainer LookupMatches(std::string path)
void RunOneIteration(double xMin, double xMax, double yMin, double yMax)
Hold an unsigned integer type.
uint8_t GetBandwidth() const
std::list< RemPoint > m_rem
void AggregateObject(Ptr< Object > other)
#define NS_LOG_LOGIC(msg)
uint32_t GetN(void) const
void Install()
Deploy the RemSpectrumPhy objects that generate the map according to the specified settings...
void SetBandwidth(uint8_t bw)
Ptr< Object > Get(uint32_t i) const
double y
y coordinate of vector
std::string m_channelPath
hold a set of objects which match a specific search string.
NS_LOG_COMPONENT_DEFINE("RadioEnvironmentMapHelper")
virtual ~RadioEnvironmentMapHelper()
Ptr< SpectrumChannel > m_channel
static void Stop(void)
If an event invokes this method, it will be the last event scheduled by the Simulator::run method bef...
Defines the interface for spectrum-aware channel implementations.
RadioEnvironmentMapHelper()
a base class which provides memory management and object aggregation
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if cond is true.
Hold a floating point type.
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
Ptr< T > GetObject(void) const
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
double z
z coordinate of vector