21 #include "ns3/config-store.h"
22 #include "ns3/core-module.h"
23 #include "ns3/lte-module.h"
24 #include "ns3/mobility-module.h"
25 #include "ns3/network-module.h"
26 #include <ns3/buildings-helper.h>
28 #include <ns3/spectrum-module.h>
37 std::ofstream outFile;
38 outFile.open(filename, std::ios_base::out | std::ios_base::trunc);
39 if (!outFile.is_open())
48 for (
int j = 0; j < nDevs; j++)
54 outFile <<
"set label \"" << uedev->GetImsi() <<
"\" at " << pos.x <<
"," << pos.y
55 <<
" left font \"Helvetica,4\" textcolor rgb \"grey\" front point pt 1 ps "
56 "0.3 lc rgb \"grey\" offset 0,0"
66 std::ofstream outFile;
67 outFile.open(filename, std::ios_base::out | std::ios_base::trunc);
68 if (!outFile.is_open())
77 for (
int j = 0; j < nDevs; j++)
83 outFile <<
"set label \"" << enbdev->
GetCellId() <<
"\" at " << pos.x <<
","
85 <<
" left font \"Helvetica,4\" textcolor rgb \"white\" front point pt 2 "
86 "ps 0.3 lc rgb \"white\" offset 0,0"
94 main(
int argc,
char* argv[])
107 uint16_t numberOfRandomUes = 0;
108 double simTime = 2.500;
109 bool generateSpectrumTrace =
false;
110 bool generateRem =
false;
111 int32_t remRbId = -1;
112 uint16_t bandwidth = 25;
113 double distance = 1000;
115 Box(-distance * 0.5, distance * 1.5, -distance * 0.5, distance * 1.5, 1.5, 1.5);
119 cmd.AddValue(
"numberOfUes",
"Number of random UEs", numberOfRandomUes);
120 cmd.AddValue(
"simTime",
"Total duration of the simulation (in seconds)", simTime);
121 cmd.AddValue(
"generateSpectrumTrace",
122 "if true, will generate a Spectrum Analyzer trace",
123 generateSpectrumTrace);
124 cmd.AddValue(
"generateRem",
125 "if true, will generate a REM and then abort the simulation",
127 cmd.AddValue(
"remRbId",
128 "Resource Block Id, for which REM will be generated,"
129 "default value is -1, what means REM will be averaged from all RBs",
131 cmd.AddValue(
"runId",
"runId", runId);
132 cmd.Parse(argc, argv);
147 randomUeNodes.
Create(numberOfRandomUes);
167 enbPositionAlloc->Add(Vector(0.0, 0.0, 0.0));
168 enbPositionAlloc->Add(Vector(distance, 0.0, 0.0));
169 enbPositionAlloc->Add(Vector(distance * 0.5, distance * 0.866, 0.0));
171 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
172 mobility.SetPositionAllocator(enbPositionAlloc);
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 edgeUePositionAlloc->Add(Vector(distance * 0.5, distance * 0.28867, 0.0));
179 mobility.SetPositionAllocator(edgeUePositionAlloc);
183 centerUePositionAlloc->Add(Vector(0.0, 0.0, 0.0));
184 centerUePositionAlloc->Add(Vector(distance, 0.0, 0.0));
185 centerUePositionAlloc->Add(Vector(distance * 0.5, distance * 0.866, 0.0));
186 mobility.SetPositionAllocator(centerUePositionAlloc);
190 CreateObject<RandomBoxPositionAllocator>();
194 randomUePositionAlloc->SetAttribute(
"X",
PointerValue(xVal));
198 randomUePositionAlloc->SetAttribute(
"Y",
PointerValue(yVal));
202 randomUePositionAlloc->SetAttribute(
"Z",
PointerValue(zVal));
203 mobility.SetPositionAllocator(randomUePositionAlloc);
219 if (frAlgorithmType ==
"ns3::LteFrHardAlgorithm")
223 else if (frAlgorithmType ==
"ns3::LteFrStrictAlgorithm")
236 else if (frAlgorithmType ==
"ns3::LteFrSoftAlgorithm")
250 else if (frAlgorithmType ==
"ns3::LteFfrSoftAlgorithm")
257 "MediumAreaPowerOffset",
268 else if (frAlgorithmType ==
"ns3::LteFfrEnhancedAlgorithm")
283 else if (frAlgorithmType ==
"ns3::LteFfrDistributedAlgorithm")
285 NS_FATAL_ERROR(
"ns3::LteFfrDistributedAlgorithm not supported in this example. Please run "
286 "lena-distributed-ffr");
304 enbDevs.
Get(0)->GetAttribute(
"LteFfrAlgorithm", tmp);
306 ffrAlgorithm->SetAttribute(
"FrCellTypeId",
UintegerValue(1));
314 for (uint32_t i = 0; i < edgeUeDevs.
GetN(); i++)
319 for (uint32_t i = 0; i < centerUeDevs.
GetN(); i++)
336 spectrumAnalyzerNodes.
Create(1);
339 if (generateSpectrumTrace)
345 positionAlloc->Add(Vector(distance * 0.5, distance * 0.866, 0.0));
348 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
349 mobility.SetPositionAllocator(positionAlloc);
350 mobility.Install(spectrumAnalyzerNodes);
355 ->GetDownlinkSpectrumPhy()
365 spectrumAnalyzerHelper.
EnableAsciiAll(
"spectrum-analyzer-output");
366 spectrumAnalyzerHelper.
Install(spectrumAnalyzerNodes);
375 remHelper = CreateObject<RadioEnvironmentMapHelper>();
376 remHelper->SetAttribute(
"ChannelPath",
StringValue(
"/ChannelList/0"));
377 remHelper->SetAttribute(
"OutputFile",
StringValue(
"lena-frequency-reuse.rem"));
387 remHelper->SetAttribute(
"UseDataChannel",
BooleanValue(
true));
391 remHelper->Install();
AttributeValue implementation for Boolean.
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.
std::vector< Ptr< Node > >::const_iterator Iterator
Node container iterator.
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.
AttributeValue implementation for Time.
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.