24 #include <ns3/abort.h>
26 #include <ns3/double.h>
27 #include <ns3/integer.h>
28 #include <ns3/uinteger.h>
29 #include <ns3/string.h>
30 #include <ns3/boolean.h>
31 #include <ns3/spectrum-channel.h>
32 #include <ns3/config.h>
33 #include <ns3/rem-spectrum-phy.h>
34 #include <ns3/mobility-building-info.h>
35 #include <ns3/constant-position-mobility-model.h>
36 #include <ns3/simulator.h>
38 #include <ns3/buildings-helper.h>
39 #include <ns3/lte-spectrum-value-helper.h>
71 static TypeId tid =
TypeId (
"ns3::RadioEnvironmentMapHelper")
73 .AddConstructor<RadioEnvironmentMapHelper> ()
74 .AddAttribute (
"ChannelPath",
"The path to the channel for which the Radio Environment Map is to be generated",
78 .AddAttribute (
"OutputFile",
"the filename to which the Radio Environment Map is saved",
82 .AddAttribute (
"XMin",
"The min x coordinate of the map.",
85 MakeDoubleChecker<double> ())
86 .AddAttribute (
"YMin",
"The min y coordinate of the map.",
89 MakeDoubleChecker<double> ())
90 .AddAttribute (
"XMax",
"The max x coordinate of the map.",
93 MakeDoubleChecker<double> ())
94 .AddAttribute (
"YMax",
"The max y coordinate of the map.",
97 MakeDoubleChecker<double> ())
98 .AddAttribute (
"XRes",
"The resolution (number of points) of the map along the x axis.",
101 MakeUintegerChecker<uint32_t> (2,std::numeric_limits<uint16_t>::max ()))
102 .AddAttribute (
"YRes",
"The resolution (number of points) of the map along the y axis.",
105 MakeUintegerChecker<uint16_t> (2,std::numeric_limits<uint16_t>::max ()))
106 .AddAttribute (
"Z",
"The value of the z coordinate for which the map is to be generated",
109 MakeDoubleChecker<double> ())
110 .AddAttribute (
"StopWhenDone",
"If true, Simulator::Stop () will be called as soon as the REM has been generated",
114 .AddAttribute (
"NoisePower",
115 "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",
118 MakeDoubleChecker<double> ())
119 .AddAttribute (
"MaxPointsPerIteration",
"Maximum number of REM points to be calculated per iteration. Every point consumes approximately 5KB of memory.",
122 MakeUintegerChecker<uint32_t> (1,std::numeric_limits<uint32_t>::max ()))
123 .AddAttribute (
"Earfcn",
124 "E-UTRA Absolute Radio Frequency Channel Number (EARFCN) "
125 "as per 3GPP 36.101 Section 5.7.3. ",
128 MakeUintegerChecker<uint16_t> ())
129 .AddAttribute (
"Bandwidth",
130 "Transmission Bandwidth Configuration (in number of RBs) over which the SINR will be calculated",
134 MakeUintegerChecker<uint16_t> ())
135 .AddAttribute (
"UseDataChannel",
136 "If true, REM will be generated for PDSCH and for PDCCH otherwise ",
140 .AddAttribute (
"RbId",
141 "Resource block Id, for which REM will be generated,"
142 "default value is -1, what means REM will be averaged from all RBs",
145 MakeIntegerChecker<int32_t> ())
185 NS_FATAL_ERROR (
"only one REM supported per instance of RadioEnvironmentMapHelper");
188 if (match.
GetN () != 1)
202 double startDelay = 0.0026;
231 p.
phy = CreateObject<RemSpectrumPhy> ();
232 p.
bmm = CreateObject<ConstantPositionMobilityModel> ();
236 p.
phy->SetMobility (p.
bmm);
243 double remIterationStartTime = 0.0001;
246 uint32_t numPointsCurrentIteration = 0;
247 bool justScheduled =
false;
256 justScheduled =
false;
259 ++numPointsCurrentIteration;
260 if ((numPointsCurrentIteration == m_maxPointsPerIteration)
265 this, xMinNext,
x, yMinNext, y);
266 remIterationStartTime += 0.001;
267 justScheduled =
true;
268 numPointsCurrentIteration = 0;
283 std::list<RemPoint>::iterator remIt =
m_rem.begin ();
288 for (y = (x == xMin) ? yMin :
m_yMin;
293 remIt->bmm->SetPosition (Vector (x, y,
m_z));
299 if (remIt !=
m_rem.end ())
302 NS_LOG_LOGIC (
"deactivating RemSpectrumPhys that are unneeded in the last iteration");
303 while (remIt !=
m_rem.end ())
305 remIt->phy->Deactivate ();
318 for (std::list<RemPoint>::iterator it =
m_rem.begin ();
322 if (!(it->phy->IsActive ()))
328 Vector pos = it->bmm->GetPosition ();
Ptr< const AttributeChecker > MakeStringChecker(void)
Smart pointer class similar to boost::intrusive_ptr.
void PrintAndReset()
Go through every listener, write the computed SINR, and then reset it.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
AttributeValue implementation for Boolean.
uint16_t m_xRes
The XRes attribute.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
void DelayedInstall()
Scheduled by Install() to perform the actual generation of map.
Hold variables of type string.
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
std::ofstream m_outFile
Stream the output to a file.
Ptr< MobilityModel > bmm
Position of the listener in the environment.
uint32_t m_maxPointsPerIteration
The MaxPointsPerIteration attribute.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
static TypeId GetTypeId(void)
Register this type.
Hold a signed integer type.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
void Finalize()
Called when the map generation procedure has been completed.
double m_xMax
The XMax attribute.
#define NS_FATAL_ERROR(msg)
Fatal error handling.
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.
bool m_stopWhenDone
The StopWhenDone attribute.
double m_yMin
The YMin attribute.
Ptr< RemSpectrumPhy > phy
Simplified listener which compute SINR over the DL channel.
uint16_t m_bandwidth
The Bandwidth attribute.
static void MakeConsistent(Ptr< MobilityModel > bmm)
Make the given mobility model consistent, by determining whether its position falls inside any of the...
Ptr< const AttributeAccessor > MakeIntegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Config::MatchContainer LookupMatches(std::string path)
void RunOneIteration(double xMin, double xMax, double yMin, double yMax)
Mobilize all the listeners to a specified area.
Hold an unsigned integer type.
uint8_t GetBandwidth() const
std::list< RemPoint > m_rem
List of listeners in the environment.
bool m_useDataChannel
The UseDataChannel attribute.
double m_yStep
Distance along Y axis between adjacent listening points.
void AggregateObject(Ptr< Object > other)
Aggregate two Objects together.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
uint32_t GetN(void) const
Every class exported by the ns3 library is enclosed in the ns3 namespace.
double m_yMax
The YMax attribute.
Ptr< const AttributeChecker > MakeBooleanChecker(void)
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 m_z
The Z attribute.
std::string m_channelPath
The ChannelPath attribute.
hold a set of objects which match a specific search string.
A complete Radio Environment Map is composed of many of this structure.
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
virtual ~RadioEnvironmentMapHelper()
uint16_t m_earfcn
The Earfcn attribute.
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
Ptr< SpectrumChannel > m_channel
The channel object taken from the ChannelPath attribute.
static void Stop(void)
Tell the Simulator the calling event should be the last one executed.
Time Seconds(double value)
Construct a Time in the indicated unit.
Defines the interface for spectrum-aware channel implementations.
uint16_t m_yRes
The YRes attribute.
RadioEnvironmentMapHelper()
int32_t m_rbId
The RbId attribute.
A base class which provides memory management and object aggregation.
std::string m_outputFile
The OutputFile attribute.
Ptr< const AttributeAccessor > MakeStringAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
double m_xStep
Distance along X axis between adjacent listening points.
This class can be used to hold variables of floating point type such as 'double' or 'float'...
virtual void DoDispose(void)
Destructor implementation.
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
a unique identifier for an interface.
double m_noisePower
The NoisePower attribute.
TypeId SetParent(TypeId tid)
double m_xMin
The XMin attribute.