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())
47 int nDevs = node->GetNDevices();
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())
76 int nDevs = node->GetNDevices();
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"
94main(
int argc,
char* argv[])
107 uint16_t numberOfRandomUes = 0;
108 double simTime = 2.500;
109 bool generateSpectrumTrace =
false;
110 bool generateRem =
false;
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);
211 lteHelper->SetSchedulerType(
"ns3::PfFfMacScheduler");
213 lteHelper->SetEnbDeviceAttribute(
"DlBandwidth",
UintegerValue(bandwidth));
214 lteHelper->SetEnbDeviceAttribute(
"UlBandwidth",
UintegerValue(bandwidth));
216 std::string frAlgorithmType = lteHelper->GetFfrAlgorithmType();
219 if (frAlgorithmType ==
"ns3::LteFrHardAlgorithm")
223 else if (frAlgorithmType ==
"ns3::LteFrStrictAlgorithm")
225 lteHelper->SetFfrAlgorithmAttribute(
"RsrqThreshold",
UintegerValue(32));
226 lteHelper->SetFfrAlgorithmAttribute(
"CenterPowerOffset",
228 lteHelper->SetFfrAlgorithmAttribute(
"EdgePowerOffset",
230 lteHelper->SetFfrAlgorithmAttribute(
"CenterAreaTpc",
UintegerValue(0));
231 lteHelper->SetFfrAlgorithmAttribute(
"EdgeAreaTpc",
UintegerValue(3));
236 else if (frAlgorithmType ==
"ns3::LteFrSoftAlgorithm")
238 lteHelper->SetFfrAlgorithmAttribute(
"AllowCenterUeUseEdgeSubBand",
BooleanValue(
true));
239 lteHelper->SetFfrAlgorithmAttribute(
"RsrqThreshold",
UintegerValue(25));
240 lteHelper->SetFfrAlgorithmAttribute(
"CenterPowerOffset",
242 lteHelper->SetFfrAlgorithmAttribute(
"EdgePowerOffset",
244 lteHelper->SetFfrAlgorithmAttribute(
"CenterAreaTpc",
UintegerValue(0));
245 lteHelper->SetFfrAlgorithmAttribute(
"EdgeAreaTpc",
UintegerValue(3));
250 else if (frAlgorithmType ==
"ns3::LteFfrSoftAlgorithm")
252 lteHelper->SetFfrAlgorithmAttribute(
"CenterRsrqThreshold",
UintegerValue(30));
253 lteHelper->SetFfrAlgorithmAttribute(
"EdgeRsrqThreshold",
UintegerValue(25));
254 lteHelper->SetFfrAlgorithmAttribute(
"CenterAreaPowerOffset",
256 lteHelper->SetFfrAlgorithmAttribute(
257 "MediumAreaPowerOffset",
259 lteHelper->SetFfrAlgorithmAttribute(
"EdgeAreaPowerOffset",
261 lteHelper->SetFfrAlgorithmAttribute(
"CenterAreaTpc",
UintegerValue(1));
262 lteHelper->SetFfrAlgorithmAttribute(
"MediumAreaTpc",
UintegerValue(2));
263 lteHelper->SetFfrAlgorithmAttribute(
"EdgeAreaTpc",
UintegerValue(3));
268 else if (frAlgorithmType ==
"ns3::LteFfrEnhancedAlgorithm")
270 lteHelper->SetFfrAlgorithmAttribute(
"RsrqThreshold",
UintegerValue(25));
271 lteHelper->SetFfrAlgorithmAttribute(
"DlCqiThreshold",
UintegerValue(10));
272 lteHelper->SetFfrAlgorithmAttribute(
"UlCqiThreshold",
UintegerValue(10));
273 lteHelper->SetFfrAlgorithmAttribute(
"CenterAreaPowerOffset",
275 lteHelper->SetFfrAlgorithmAttribute(
"EdgeAreaPowerOffset",
277 lteHelper->SetFfrAlgorithmAttribute(
"CenterAreaTpc",
UintegerValue(0));
278 lteHelper->SetFfrAlgorithmAttribute(
"EdgeAreaTpc",
UintegerValue(3));
283 else if (frAlgorithmType ==
"ns3::LteFfrDistributedAlgorithm")
285 NS_FATAL_ERROR(
"ns3::LteFfrDistributedAlgorithm not supported in this example. Please run "
286 "lena-distributed-ffr");
290 lteHelper->SetFfrAlgorithmType(
"ns3::LteFrNoOpAlgorithm");
293 lteHelper->SetFfrAlgorithmAttribute(
"FrCellTypeId",
UintegerValue(1));
294 enbDevs.
Add(lteHelper->InstallEnbDevice(enbNodes.
Get(0)));
296 lteHelper->SetFfrAlgorithmAttribute(
"FrCellTypeId",
UintegerValue(2));
297 enbDevs.
Add(lteHelper->InstallEnbDevice(enbNodes.
Get(1)));
299 lteHelper->SetFfrAlgorithmAttribute(
"FrCellTypeId",
UintegerValue(3));
300 enbDevs.
Add(lteHelper->InstallEnbDevice(enbNodes.
Get(2)));
304 enbDevs.
Get(0)->GetAttribute(
"LteFfrAlgorithm", tmp);
306 ffrAlgorithm->SetAttribute(
"FrCellTypeId",
UintegerValue(1));
309 edgeUeDevs = lteHelper->InstallUeDevice(edgeUeNodes);
310 centerUeDevs = lteHelper->InstallUeDevice(centerUeNodes);
311 randomUeDevs = lteHelper->InstallUeDevice(randomUeNodes);
316 lteHelper->Attach(edgeUeDevs.
Get(i), enbDevs.
Get(i));
321 lteHelper->Attach(centerUeDevs.
Get(i), enbDevs.
Get(i));
325 lteHelper->AttachToClosestEnb(randomUeDevs, enbDevs);
330 lteHelper->ActivateDataRadioBearer(edgeUeDevs, bearer);
331 lteHelper->ActivateDataRadioBearer(centerUeDevs, bearer);
332 lteHelper->ActivateDataRadioBearer(randomUeDevs, bearer);
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.
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.
std::vector< Ptr< Node > >::const_iterator Iterator
Node container iterator.
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.
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.
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.