22 #include "ns3/core-module.h" 23 #include "ns3/network-module.h" 24 #include "ns3/mobility-module.h" 25 #include "ns3/lte-module.h" 26 #include "ns3/config-store.h" 27 #include <ns3/buildings-helper.h> 28 #include <ns3/spectrum-module.h> 38 std::ofstream outFile;
39 outFile.open (filename.c_str (), std::ios_base::out | std::ios_base::trunc);
40 if (!outFile.is_open ())
49 for (
int j = 0; j < nDevs; j++)
55 outFile <<
"set label \"" << uedev->
GetImsi ()
56 <<
"\" at " << pos.x <<
"," << pos.y <<
" left font \"Helvetica,4\" textcolor rgb \"grey\" front point pt 1 ps 0.3 lc rgb \"grey\" offset 0,0" 66 std::ofstream outFile;
67 outFile.open (filename.c_str (), 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 ()
84 <<
"\" at " << pos.x <<
"," << pos.y
85 <<
" left font \"Helvetica,4\" textcolor rgb \"white\" front point pt 2 ps 0.3 lc rgb \"white\" offset 0,0" 92 int main (
int argc,
char *argv[])
105 uint16_t numberOfRandomUes = 0;
106 double simTime = 2.500;
107 bool generateSpectrumTrace =
false;
108 bool generateRem =
false;
109 int32_t remRbId = -1;
110 uint8_t bandwidth = 25;
111 double distance = 1000;
112 Box macroUeBox =
Box (-distance * 0.5, distance * 1.5, -distance * 0.5, distance * 1.5, 1.5, 1.5);
116 cmd.AddValue (
"numberOfUes",
"Number of random UEs", numberOfRandomUes);
117 cmd.AddValue (
"simTime",
"Total duration of the simulation (in seconds)", simTime);
118 cmd.AddValue (
"generateSpectrumTrace",
"if true, will generate a Spectrum Analyzer trace", generateSpectrumTrace);
119 cmd.AddValue (
"generateRem",
"if true, will generate a REM and then abort the simulation", generateRem);
120 cmd.AddValue (
"remRbId",
"Resource Block Id, for which REM will be generated," 121 "default value is -1, what means REM will be averaged from all RBs", remRbId);
122 cmd.AddValue (
"runId",
"runId", runId);
123 cmd.Parse (argc, argv);
138 randomUeNodes.
Create (numberOfRandomUes);
159 enbPositionAlloc->
Add (Vector (0.0, 0.0, 0.0));
160 enbPositionAlloc->
Add (Vector (distance, 0.0, 0.0));
161 enbPositionAlloc->
Add (Vector (distance * 0.5, distance * 0.866, 0.0));
163 mobility.SetMobilityModel (
"ns3::ConstantPositionMobilityModel");
164 mobility.SetPositionAllocator (enbPositionAlloc);
169 edgeUePositionAlloc->
Add (Vector (distance * 0.5, distance * 0.28867, 0.0));
170 edgeUePositionAlloc->
Add (Vector (distance * 0.5, distance * 0.28867, 0.0));
171 edgeUePositionAlloc->
Add (Vector (distance * 0.5, distance * 0.28867, 0.0));
172 mobility.SetPositionAllocator (edgeUePositionAlloc);
177 centerUePositionAlloc->
Add (Vector (0.0, 0.0, 0.0));
178 centerUePositionAlloc->
Add (Vector (distance, 0.0, 0.0));
179 centerUePositionAlloc->
Add (Vector (distance * 0.5, distance * 0.866, 0.0));
180 mobility.SetPositionAllocator (centerUePositionAlloc);
197 mobility.SetPositionAllocator (randomUePositionAlloc);
213 if (frAlgorithmType ==
"ns3::LteFrHardAlgorithm")
219 else if (frAlgorithmType ==
"ns3::LteFrStrictAlgorithm")
234 else if (frAlgorithmType ==
"ns3::LteFrSoftAlgorithm")
250 else if (frAlgorithmType ==
"ns3::LteFfrSoftAlgorithm")
269 else if (frAlgorithmType ==
"ns3::LteFfrEnhancedAlgorithm")
286 else if (frAlgorithmType ==
"ns3::LteFfrDistributedAlgorithm")
289 NS_FATAL_ERROR (
"ns3::LteFfrDistributedAlgorithm not supported in this example. Please run lena-distributed-ffr");
308 enbDevs.
Get (0)->GetAttribute (
"LteFfrAlgorithm", tmp);
319 for (uint32_t i = 0; i < edgeUeDevs.
GetN (); i++)
321 lteHelper->
Attach (edgeUeDevs.
Get (i), enbDevs.
Get (i));
324 for (uint32_t i = 0; i < centerUeDevs.
GetN (); i++)
326 lteHelper->
Attach (centerUeDevs.
Get (i), enbDevs.
Get (i));
341 spectrumAnalyzerNodes.
Create (1);
344 if (generateSpectrumTrace)
350 positionAlloc->
Add (Vector (distance * 0.5, distance * 0.866, 0.0));
353 mobility.SetMobilityModel (
"ns3::ConstantPositionMobilityModel");
354 mobility.SetPositionAllocator (positionAlloc);
355 mobility.Install (spectrumAnalyzerNodes);
360 spectrumAnalyzerHelper.
SetChannel (dlChannel);
365 spectrumAnalyzerHelper.
EnableAsciiAll (
"spectrum-analyzer-output");
366 spectrumAnalyzerHelper.
Install (spectrumAnalyzerNodes);
375 remHelper = CreateObject<RadioEnvironmentMapHelper> ();
Class to allow the Spectrum Analysis.
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
double zMin
The z coordinate of the down bound of the box.
AttributeValue implementation for Boolean.
NetDeviceContainer InstallEnbDevice(NodeContainer c)
Create a set of eNodeB devices.
Hold variables of type string.
Ptr< NetDevice > GetDevice(uint32_t index) const
Retrieve the index-th NetDevice associated to this node.
static Vector GetPosition(Ptr< Node > node)
Ptr< Object > GetObject(void) const
Get the Object referenced by the PointerValue.
static void Run(void)
Run the simulation.
Hold a signed integer type.
void Attach(NetDeviceContainer ueDevices)
Enables automatic attachment of a set of UE devices to a suitable cell using Idle mode initial cell s...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
void PrintGnuplottableEnbListToFile(std::string filename)
double xMax
The x coordinate of the right bound of the box.
Ptr< SpectrumChannel > GetChannel()
void ActivateDataRadioBearer(NetDeviceContainer ueDevices, EpsBearer bearer)
Activate a Data Radio Bearer on a given UE devices (for LTE-only simulation).
void SetFfrAlgorithmType(std::string type)
Set the type of FFR algorithm to be used by eNodeB devices.
static void SetRun(uint64_t run)
Set the run number of simulation.
void SetSchedulerType(std::string type)
Set the type of scheduler to be used by eNodeB devices.
double yMax
The y coordinate of the top bound of the box.
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...
Keep track of the current position and velocity of an object.
uint64_t GetImsi() const
Get the IMSI.
This class contains the specification of EPS Bearers.
Hold variables of type enum.
void PrintGnuplottableUeListToFile(std::string filename)
AttributeValue implementation for Time.
uint16_t GetCellId() const
void Add(NetDeviceContainer other)
Append the contents of another NetDeviceContainer to the end of this container.
Hold an unsigned integer type.
static Iterator End(void)
void SetSchedulerAttribute(std::string n, const AttributeValue &v)
Set an attribute for the scheduler to be created.
holds a vector of ns3::NetDevice pointers
static Ptr< SpectrumModel > GetSpectrumModel(uint32_t earfcn, uint8_t bandwidth)
double yMin
The y coordinate of the bottom bound of the box.
Parse command-line arguments.
static void Destroy(void)
Execute the events scheduled with ScheduleDestroy().
void SetPhyAttribute(std::string name, const AttributeValue &v)
NetDeviceContainer Install(NodeContainer c) const
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
keep track of a set of node pointers.
Hold objects of type Ptr<T>.
std::vector< Ptr< Node > >::const_iterator Iterator
Node container iterator.
void Install()
Deploy the RemSpectrumPhy objects that generate the map according to the specified settings...
double zMax
The z coordinate of the up bound of the box.
static void SetSeed(uint32_t seed)
Set the seed.
std::string GetFfrAlgorithmType() const
NetDeviceContainer InstallUeDevice(NodeContainer c)
Create a set of UE devices.
Helper class used to assign positions and mobility models to nodes.
static Iterator Begin(void)
static void Stop(void)
Tell the Simulator the calling event should be the last one executed.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Time Seconds(double value)
Construct a Time in the indicated unit.
uint32_t GetN(void) const
Get the number of Ptr<NetDevice> stored in this container.
void SetDefault(std::string name, const AttributeValue &value)
void Add(Vector v)
Add a position to the list of positions.
void SetChannel(Ptr< SpectrumChannel > channel)
Set the SpectrumChannel that will be used by SpectrumPhy instances created by this helper...
void SetRxSpectrumModel(Ptr< SpectrumModel > m)
Set the spectrum model used by the created SpectrumAnalyzer instances to represent incoming signals...
void EnableAsciiAll(std::string prefix)
Enable ASCII output.
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
This class can be used to hold variables of floating point type such as 'double' or 'float'...
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
The eNodeB device implementation.
void SetFfrAlgorithmAttribute(std::string n, const AttributeValue &v)
Set an attribute for the FFR algorithm to be created.
uint32_t GetNDevices(void) const
double xMin
The x coordinate of the left bound of the box.
void SetEnbDeviceAttribute(std::string n, const AttributeValue &v)
Set an attribute for the eNodeB devices (LteEnbNetDevice) to be created.
The LteUeNetDevice class implements the UE net device.