10#include "ns3/core-module.h"
11#include "ns3/lte-module.h"
12#include "ns3/mobility-module.h"
13#include "ns3/network-module.h"
14#include <ns3/buildings-helper.h>
16#include <ns3/spectrum-module.h>
25 std::ofstream outFile;
26 outFile.open(filename, std::ios_base::out | std::ios_base::trunc);
27 if (!outFile.is_open())
35 int nDevs = node->GetNDevices();
36 for (
int j = 0; j < nDevs; j++)
42 outFile <<
"set label \"" << uedev->GetImsi() <<
"\" at " << pos.x <<
"," << pos.y
43 <<
" left font \"Helvetica,4\" textcolor rgb \"grey\" front point pt 1 ps "
44 "0.3 lc rgb \"grey\" offset 0,0"
54 std::ofstream outFile;
55 outFile.open(filename, std::ios_base::out | std::ios_base::trunc);
56 if (!outFile.is_open())
64 int nDevs = node->GetNDevices();
65 for (
int j = 0; j < nDevs; j++)
71 outFile <<
"set label \"" << enbdev->GetCellId() <<
"\" at " << pos.x <<
","
73 <<
" left font \"Helvetica,4\" textcolor rgb \"white\" front point pt 2 "
74 "ps 0.3 lc rgb \"white\" offset 0,0"
82main(
int argc,
char* argv[])
95 uint16_t numberOfRandomUes = 0;
96 double simTime = 2.500;
97 bool generateSpectrumTrace =
false;
98 bool generateRem =
false;
100 uint16_t bandwidth = 25;
101 double distance = 1000;
103 Box(-distance * 0.5, distance * 1.5, -distance * 0.5, distance * 1.5, 1.5, 1.5);
107 cmd.AddValue(
"numberOfUes",
"Number of random UEs", numberOfRandomUes);
108 cmd.AddValue(
"simTime",
"Total duration of the simulation (in seconds)", simTime);
109 cmd.AddValue(
"generateSpectrumTrace",
110 "if true, will generate a Spectrum Analyzer trace",
111 generateSpectrumTrace);
112 cmd.AddValue(
"generateRem",
113 "if true, will generate a REM and then abort the simulation",
115 cmd.AddValue(
"remRbId",
116 "Resource Block Id, for which REM will be generated,"
117 "default value is -1, what means REM will be averaged from all RBs",
119 cmd.AddValue(
"runId",
"runId", runId);
120 cmd.Parse(argc, argv);
135 randomUeNodes.
Create(numberOfRandomUes);
155 enbPositionAlloc->Add(Vector(0.0, 0.0, 0.0));
156 enbPositionAlloc->Add(Vector(distance, 0.0, 0.0));
157 enbPositionAlloc->Add(Vector(distance * 0.5, distance * 0.866, 0.0));
159 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
160 mobility.SetPositionAllocator(enbPositionAlloc);
164 edgeUePositionAlloc->Add(Vector(distance * 0.5, distance * 0.28867, 0.0));
165 edgeUePositionAlloc->Add(Vector(distance * 0.5, distance * 0.28867, 0.0));
166 edgeUePositionAlloc->Add(Vector(distance * 0.5, distance * 0.28867, 0.0));
167 mobility.SetPositionAllocator(edgeUePositionAlloc);
171 centerUePositionAlloc->Add(Vector(0.0, 0.0, 0.0));
172 centerUePositionAlloc->Add(Vector(distance, 0.0, 0.0));
173 centerUePositionAlloc->Add(Vector(distance * 0.5, distance * 0.866, 0.0));
174 mobility.SetPositionAllocator(centerUePositionAlloc);
182 randomUePositionAlloc->SetAttribute(
"X",
PointerValue(xVal));
186 randomUePositionAlloc->SetAttribute(
"Y",
PointerValue(yVal));
190 randomUePositionAlloc->SetAttribute(
"Z",
PointerValue(zVal));
191 mobility.SetPositionAllocator(randomUePositionAlloc);
199 lteHelper->SetSchedulerType(
"ns3::PfFfMacScheduler");
201 lteHelper->SetEnbDeviceAttribute(
"DlBandwidth",
UintegerValue(bandwidth));
202 lteHelper->SetEnbDeviceAttribute(
"UlBandwidth",
UintegerValue(bandwidth));
204 std::string frAlgorithmType = lteHelper->GetFfrAlgorithmType();
207 if (frAlgorithmType ==
"ns3::LteFrHardAlgorithm")
211 else if (frAlgorithmType ==
"ns3::LteFrStrictAlgorithm")
213 lteHelper->SetFfrAlgorithmAttribute(
"RsrqThreshold",
UintegerValue(32));
214 lteHelper->SetFfrAlgorithmAttribute(
"CenterPowerOffset",
216 lteHelper->SetFfrAlgorithmAttribute(
"EdgePowerOffset",
218 lteHelper->SetFfrAlgorithmAttribute(
"CenterAreaTpc",
UintegerValue(0));
219 lteHelper->SetFfrAlgorithmAttribute(
"EdgeAreaTpc",
UintegerValue(3));
224 else if (frAlgorithmType ==
"ns3::LteFrSoftAlgorithm")
226 lteHelper->SetFfrAlgorithmAttribute(
"AllowCenterUeUseEdgeSubBand",
BooleanValue(
true));
227 lteHelper->SetFfrAlgorithmAttribute(
"RsrqThreshold",
UintegerValue(25));
228 lteHelper->SetFfrAlgorithmAttribute(
"CenterPowerOffset",
230 lteHelper->SetFfrAlgorithmAttribute(
"EdgePowerOffset",
232 lteHelper->SetFfrAlgorithmAttribute(
"CenterAreaTpc",
UintegerValue(0));
233 lteHelper->SetFfrAlgorithmAttribute(
"EdgeAreaTpc",
UintegerValue(3));
238 else if (frAlgorithmType ==
"ns3::LteFfrSoftAlgorithm")
240 lteHelper->SetFfrAlgorithmAttribute(
"CenterRsrqThreshold",
UintegerValue(30));
241 lteHelper->SetFfrAlgorithmAttribute(
"EdgeRsrqThreshold",
UintegerValue(25));
242 lteHelper->SetFfrAlgorithmAttribute(
"CenterAreaPowerOffset",
244 lteHelper->SetFfrAlgorithmAttribute(
245 "MediumAreaPowerOffset",
247 lteHelper->SetFfrAlgorithmAttribute(
"EdgeAreaPowerOffset",
249 lteHelper->SetFfrAlgorithmAttribute(
"CenterAreaTpc",
UintegerValue(1));
250 lteHelper->SetFfrAlgorithmAttribute(
"MediumAreaTpc",
UintegerValue(2));
251 lteHelper->SetFfrAlgorithmAttribute(
"EdgeAreaTpc",
UintegerValue(3));
256 else if (frAlgorithmType ==
"ns3::LteFfrEnhancedAlgorithm")
258 lteHelper->SetFfrAlgorithmAttribute(
"RsrqThreshold",
UintegerValue(25));
259 lteHelper->SetFfrAlgorithmAttribute(
"DlCqiThreshold",
UintegerValue(10));
260 lteHelper->SetFfrAlgorithmAttribute(
"UlCqiThreshold",
UintegerValue(10));
261 lteHelper->SetFfrAlgorithmAttribute(
"CenterAreaPowerOffset",
263 lteHelper->SetFfrAlgorithmAttribute(
"EdgeAreaPowerOffset",
265 lteHelper->SetFfrAlgorithmAttribute(
"CenterAreaTpc",
UintegerValue(0));
266 lteHelper->SetFfrAlgorithmAttribute(
"EdgeAreaTpc",
UintegerValue(3));
271 else if (frAlgorithmType ==
"ns3::LteFfrDistributedAlgorithm")
273 NS_FATAL_ERROR(
"ns3::LteFfrDistributedAlgorithm not supported in this example. Please run "
274 "lena-distributed-ffr");
278 lteHelper->SetFfrAlgorithmType(
"ns3::LteFrNoOpAlgorithm");
281 lteHelper->SetFfrAlgorithmAttribute(
"FrCellTypeId",
UintegerValue(1));
282 enbDevs.
Add(lteHelper->InstallEnbDevice(enbNodes.
Get(0)));
284 lteHelper->SetFfrAlgorithmAttribute(
"FrCellTypeId",
UintegerValue(2));
285 enbDevs.
Add(lteHelper->InstallEnbDevice(enbNodes.
Get(1)));
287 lteHelper->SetFfrAlgorithmAttribute(
"FrCellTypeId",
UintegerValue(3));
288 enbDevs.
Add(lteHelper->InstallEnbDevice(enbNodes.
Get(2)));
292 enbDevs.
Get(0)->GetAttribute(
"LteFfrAlgorithm", tmp);
294 ffrAlgorithm->SetAttribute(
"FrCellTypeId",
UintegerValue(1));
297 edgeUeDevs = lteHelper->InstallUeDevice(edgeUeNodes);
298 centerUeDevs = lteHelper->InstallUeDevice(centerUeNodes);
299 randomUeDevs = lteHelper->InstallUeDevice(randomUeNodes);
304 lteHelper->Attach(edgeUeDevs.
Get(i), enbDevs.
Get(i));
309 lteHelper->Attach(centerUeDevs.
Get(i), enbDevs.
Get(i));
313 lteHelper->AttachToClosestEnb(randomUeDevs, enbDevs);
318 lteHelper->ActivateDataRadioBearer(edgeUeDevs, bearer);
319 lteHelper->ActivateDataRadioBearer(centerUeDevs, bearer);
320 lteHelper->ActivateDataRadioBearer(randomUeDevs, bearer);
324 spectrumAnalyzerNodes.
Create(1);
327 if (generateSpectrumTrace)
333 positionAlloc->Add(Vector(distance * 0.5, distance * 0.866, 0.0));
336 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
337 mobility.SetPositionAllocator(positionAlloc);
338 mobility.Install(spectrumAnalyzerNodes);
343 ->GetDownlinkSpectrumPhy()
353 spectrumAnalyzerHelper.
EnableAsciiAll(
"spectrum-analyzer-output");
354 spectrumAnalyzerHelper.
Install(spectrumAnalyzerNodes);
364 remHelper->SetAttribute(
"ChannelPath",
StringValue(
"/ChannelList/0"));
365 remHelper->SetAttribute(
"OutputFile",
StringValue(
"lena-frequency-reuse.rem"));
375 remHelper->SetAttribute(
"UseDataChannel",
BooleanValue(
true));
379 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.
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.
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
AttributeValue implementation for Pointer.
Ptr< Object > GetObject() const
Get the Object referenced by the PointerValue.
Smart pointer class similar to boost::intrusive_ptr.
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.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
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.
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.