21 #include "ns3/core-module.h"
22 #include "ns3/lte-module.h"
23 #include "ns3/mobility-module.h"
24 #include "ns3/network-module.h"
25 #include <ns3/buildings-helper.h>
27 #include <ns3/spectrum-module.h>
36 std::ofstream outFile;
37 outFile.open(filename, std::ios_base::out | std::ios_base::trunc);
38 if (!outFile.is_open())
47 for (
int j = 0; j < nDevs; j++)
53 outFile <<
"set label \"" << uedev->GetImsi() <<
"\" at " << pos.x <<
"," << pos.y
54 <<
" left font \"Helvetica,4\" textcolor rgb \"grey\" front point pt 1 ps "
55 "0.3 lc rgb \"grey\" offset 0,0"
65 std::ofstream outFile;
66 outFile.open(filename, std::ios_base::out | std::ios_base::trunc);
67 if (!outFile.is_open())
76 for (
int j = 0; j < nDevs; j++)
82 outFile <<
"set label \"" << enbdev->
GetCellId() <<
"\" at " << pos.x <<
","
84 <<
" left font \"Helvetica,4\" textcolor rgb \"white\" front point pt 2 "
85 "ps 0.3 lc rgb \"white\" offset 0,0"
93 main(
int argc,
char* argv[])
106 uint16_t numberOfRandomUes = 0;
107 double simTime = 2.500;
108 bool generateSpectrumTrace =
false;
109 bool generateRem =
false;
110 int32_t remRbId = -1;
111 uint16_t bandwidth = 25;
112 double distance = 1000;
114 Box(-distance * 0.5, distance * 1.5, -distance * 0.5, distance * 1.5, 1.5, 1.5);
118 cmd.AddValue(
"numberOfUes",
"Number of random UEs", numberOfRandomUes);
119 cmd.AddValue(
"simTime",
"Total duration of the simulation (in seconds)", simTime);
120 cmd.AddValue(
"generateSpectrumTrace",
121 "if true, will generate a Spectrum Analyzer trace",
122 generateSpectrumTrace);
123 cmd.AddValue(
"generateRem",
124 "if true, will generate a REM and then abort the simulation",
126 cmd.AddValue(
"remRbId",
127 "Resource Block Id, for which REM will be generated,"
128 "default value is -1, what means REM will be averaged from all RBs",
130 cmd.AddValue(
"runId",
"runId", runId);
131 cmd.Parse(argc, argv);
146 randomUeNodes.
Create(numberOfRandomUes);
166 enbPositionAlloc->Add(Vector(0.0, 0.0, 0.0));
167 enbPositionAlloc->Add(Vector(distance, 0.0, 0.0));
168 enbPositionAlloc->Add(Vector(distance * 0.5, distance * 0.866, 0.0));
170 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
171 mobility.SetPositionAllocator(enbPositionAlloc);
175 edgeUePositionAlloc->Add(Vector(distance * 0.5, distance * 0.28867, 0.0));
176 edgeUePositionAlloc->Add(Vector(distance * 0.5, distance * 0.28867, 0.0));
177 edgeUePositionAlloc->Add(Vector(distance * 0.5, distance * 0.28867, 0.0));
178 mobility.SetPositionAllocator(edgeUePositionAlloc);
182 centerUePositionAlloc->Add(Vector(0.0, 0.0, 0.0));
183 centerUePositionAlloc->Add(Vector(distance, 0.0, 0.0));
184 centerUePositionAlloc->Add(Vector(distance * 0.5, distance * 0.866, 0.0));
185 mobility.SetPositionAllocator(centerUePositionAlloc);
189 CreateObject<RandomBoxPositionAllocator>();
193 randomUePositionAlloc->SetAttribute(
"X",
PointerValue(xVal));
197 randomUePositionAlloc->SetAttribute(
"Y",
PointerValue(yVal));
201 randomUePositionAlloc->SetAttribute(
"Z",
PointerValue(zVal));
202 mobility.SetPositionAllocator(randomUePositionAlloc);
218 if (frAlgorithmType ==
"ns3::LteFrHardAlgorithm")
222 else if (frAlgorithmType ==
"ns3::LteFrStrictAlgorithm")
235 else if (frAlgorithmType ==
"ns3::LteFrSoftAlgorithm")
249 else if (frAlgorithmType ==
"ns3::LteFfrSoftAlgorithm")
256 "MediumAreaPowerOffset",
267 else if (frAlgorithmType ==
"ns3::LteFfrEnhancedAlgorithm")
282 else if (frAlgorithmType ==
"ns3::LteFfrDistributedAlgorithm")
284 NS_FATAL_ERROR(
"ns3::LteFfrDistributedAlgorithm not supported in this example. Please run "
285 "lena-distributed-ffr");
303 enbDevs.
Get(0)->GetAttribute(
"LteFfrAlgorithm", tmp);
305 ffrAlgorithm->SetAttribute(
"FrCellTypeId",
UintegerValue(1));
313 for (uint32_t i = 0; i < edgeUeDevs.
GetN(); i++)
318 for (uint32_t i = 0; i < centerUeDevs.
GetN(); i++)
335 spectrumAnalyzerNodes.
Create(1);
338 if (generateSpectrumTrace)
344 positionAlloc->Add(Vector(distance * 0.5, distance * 0.866, 0.0));
347 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
348 mobility.SetPositionAllocator(positionAlloc);
349 mobility.Install(spectrumAnalyzerNodes);
354 ->GetDownlinkSpectrumPhy()
364 spectrumAnalyzerHelper.
EnableAsciiAll(
"spectrum-analyzer-output");
365 spectrumAnalyzerHelper.
Install(spectrumAnalyzerNodes);
374 remHelper = CreateObject<RadioEnvironmentMapHelper>();
375 remHelper->SetAttribute(
"ChannelPath",
StringValue(
"/ChannelList/0"));
376 remHelper->SetAttribute(
"OutputFile",
StringValue(
"lena-frequency-reuse.rem"));
386 remHelper->SetAttribute(
"UseDataChannel",
BooleanValue(
true));
390 remHelper->Install();
double yMax
The y coordinate of the top bound of the box.
double xMin
The x coordinate of the left bound of the box.
double yMin
The y coordinate of the bottom bound of the box.
double xMax
The x coordinate of the right bound of the box.
double zMin
The z coordinate of the down bound of the box.
double zMax
The z coordinate of the up bound of the box.
Parse command-line arguments.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Hold variables of type enum.
This class contains the specification of EPS Bearers.
@ GBR_CONV_VOICE
GBR Conversational Voice.
Hold a signed integer type.
The eNodeB device implementation.
uint16_t GetCellId() const
void SetFfrAlgorithmType(std::string type)
Set the type of FFR algorithm to be used by eNodeB devices.
void SetSchedulerAttribute(std::string n, const AttributeValue &v)
Set an attribute for the scheduler to be created.
NetDeviceContainer InstallEnbDevice(NodeContainer c)
Create a set of eNodeB devices.
std::string GetFfrAlgorithmType() const
void SetFfrAlgorithmAttribute(std::string n, const AttributeValue &v)
Set an attribute for the FFR algorithm to be created.
void SetSchedulerType(std::string type)
Set the type of scheduler to be used by eNodeB devices.
void Attach(NetDeviceContainer ueDevices)
Enables automatic attachment of a set of UE devices to a suitable cell using Idle mode initial cell s...
void SetEnbDeviceAttribute(std::string n, const AttributeValue &v)
Set an attribute for the eNodeB devices (LteEnbNetDevice) to be created.
void ActivateDataRadioBearer(NetDeviceContainer ueDevices, EpsBearer bearer)
Activate a Data Radio Bearer on a given UE devices (for LTE-only simulation).
NetDeviceContainer InstallUeDevice(NodeContainer c)
Create a set of UE devices.
void AttachToClosestEnb(NetDeviceContainer ueDevices, NetDeviceContainer enbDevices)
Manual attachment of a set of UE devices to the network via the closest eNodeB (with respect to dista...
The LteSpectrumPhy models the physical layer of LTE.
static Ptr< SpectrumModel > GetSpectrumModel(uint32_t earfcn, uint16_t bandwidth)
The LteUeNetDevice class implements the UE net device.
Helper class used to assign positions and mobility models to nodes.
Keep track of the current position and velocity of an object.
holds a vector of ns3::NetDevice pointers
uint32_t GetN() const
Get the number of Ptr<NetDevice> stored in this container.
void Add(NetDeviceContainer other)
Append the contents of another NetDeviceContainer to the end of this container.
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
keep track of a set of node pointers.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
uint32_t GetNDevices() const
Ptr< NetDevice > GetDevice(uint32_t index) const
Retrieve the index-th NetDevice associated to this node.
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
Hold objects of type Ptr<T>.
Ptr< Object > GetObject() const
Get the Object referenced by the PointerValue.
static void SetRun(uint64_t run)
Set the run number of simulation.
static void SetSeed(uint32_t seed)
Set the seed.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
static void Run()
Run the simulation.
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Class to allow the Spectrum Analysis.
NetDeviceContainer Install(NodeContainer c) const
void SetPhyAttribute(std::string name, const AttributeValue &v)
void SetChannel(Ptr< SpectrumChannel > channel)
Set the SpectrumChannel that will be used by SpectrumPhy instances created by this helper.
void EnableAsciiAll(std::string prefix)
Enable ASCII output.
void SetRxSpectrumModel(Ptr< SpectrumModel > m)
Set the spectrum model used by the created SpectrumAnalyzer instances to represent incoming signals.
Hold variables of type string.
Hold an unsigned integer type.
void SetDefault(std::string name, const AttributeValue &value)
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Time Seconds(double value)
Construct a Time in the indicated unit.
void PrintGnuplottableEnbListToFile(std::string filename)
void PrintGnuplottableUeListToFile(std::string filename)
Every class exported by the ns3 library is enclosed in the ns3 namespace.