A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
lena-intercell-interference.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Manuel Requena <manuel.requena@cttc.es>
7 * Nicola Baldo <nbaldo@cttc.es>
8 */
9
10#include "ns3/config-store.h"
11#include "ns3/core-module.h"
12#include "ns3/lte-module.h"
13#include "ns3/mobility-module.h"
14#include "ns3/network-module.h"
15#include "ns3/radio-bearer-stats-calculator.h"
16
17#include <iomanip>
18#include <string>
19
20using namespace ns3;
21
22/**
23 * This simulation script creates two eNodeBs and drops randomly several UEs in
24 * a disc around them (same number on both). The number of UEs , the radius of
25 * that disc and the distance between the eNodeBs can be configured.
26 */
27int
28main(int argc, char* argv[])
29{
30 double enbDist = 100.0;
31 double radius = 50.0;
32 uint32_t numUes = 1;
33 double simTime = 1.0;
34
35 CommandLine cmd(__FILE__);
36 cmd.AddValue("enbDist", "distance between the two eNBs", enbDist);
37 cmd.AddValue("radius", "the radius of the disc where UEs are placed around an eNB", radius);
38 cmd.AddValue("numUes", "how many UEs are attached to each eNB", numUes);
39 cmd.AddValue("simTime", "Total duration of the simulation (in seconds)", simTime);
40 cmd.Parse(argc, argv);
41
42 ConfigStore inputConfig;
43 inputConfig.ConfigureDefaults();
44
45 // parse again so you can override default values from the command line
46 cmd.Parse(argc, argv);
47
48 // determine the string tag that identifies this simulation run
49 // this tag is then appended to all filenames
50
51 UintegerValue runValue;
52 GlobalValue::GetValueByName("RngRun", runValue);
53
54 std::ostringstream tag;
55 tag << "_enbDist" << std::setw(3) << std::setfill('0') << std::fixed << std::setprecision(0)
56 << enbDist << "_radius" << std::setw(3) << std::setfill('0') << std::fixed
57 << std::setprecision(0) << radius << "_numUes" << std::setw(3) << std::setfill('0')
58 << numUes << "_rngRun" << std::setw(3) << std::setfill('0') << runValue.Get();
59
61
62 lteHelper->SetAttribute("PathlossModel", StringValue("ns3::FriisSpectrumPropagationLossModel"));
63
64 // Create Nodes: eNodeB and UE
65 NodeContainer enbNodes;
66 NodeContainer ueNodes1;
67 NodeContainer ueNodes2;
68 enbNodes.Create(2);
69 ueNodes1.Create(numUes);
70 ueNodes2.Create(numUes);
71
72 // Position of eNBs
74 positionAlloc->Add(Vector(0.0, 0.0, 0.0));
75 positionAlloc->Add(Vector(enbDist, 0.0, 0.0));
76 MobilityHelper enbMobility;
77 enbMobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
78 enbMobility.SetPositionAllocator(positionAlloc);
79 enbMobility.Install(enbNodes);
80
81 // Position of UEs attached to eNB 1
82 MobilityHelper ue1mobility;
83 ue1mobility.SetPositionAllocator("ns3::UniformDiscPositionAllocator",
84 "X",
85 DoubleValue(0.0),
86 "Y",
87 DoubleValue(0.0),
88 "rho",
89 DoubleValue(radius));
90 ue1mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
91 ue1mobility.Install(ueNodes1);
92
93 // Position of UEs attached to eNB 2
94 MobilityHelper ue2mobility;
95 ue2mobility.SetPositionAllocator("ns3::UniformDiscPositionAllocator",
96 "X",
97 DoubleValue(enbDist),
98 "Y",
99 DoubleValue(0.0),
100 "rho",
101 DoubleValue(radius));
102 ue2mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
103 ue2mobility.Install(ueNodes2);
104
105 // Create Devices and install them in the Nodes (eNB and UE)
106 NetDeviceContainer enbDevs;
107 NetDeviceContainer ueDevs1;
108 NetDeviceContainer ueDevs2;
109 enbDevs = lteHelper->InstallEnbDevice(enbNodes);
110 ueDevs1 = lteHelper->InstallUeDevice(ueNodes1);
111 ueDevs2 = lteHelper->InstallUeDevice(ueNodes2);
112
113 // Attach UEs to a eNB
114 lteHelper->Attach(ueDevs1, enbDevs.Get(0));
115 lteHelper->Attach(ueDevs2, enbDevs.Get(1));
116
117 // Activate a data radio bearer each UE
119 EpsBearer bearer(q);
120 lteHelper->ActivateDataRadioBearer(ueDevs1, bearer);
121 lteHelper->ActivateDataRadioBearer(ueDevs2, bearer);
122
123 Simulator::Stop(Seconds(simTime));
124
125 // Insert RLC Performance Calculator
126 std::string dlOutFname = "DlRlcStats";
127 dlOutFname.append(tag.str());
128 std::string ulOutFname = "UlRlcStats";
129 ulOutFname.append(tag.str());
130
131 lteHelper->EnableMacTraces();
132 lteHelper->EnableRlcTraces();
133
136 return 0;
137}
Parse command-line arguments.
Introspection did not find any typical Config paths.
void ConfigureDefaults()
Configure the default values.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition double.h:31
This class contains the specification of EPS Bearers.
Definition eps-bearer.h:80
Qci
QoS Class Indicator.
Definition eps-bearer.h:95
@ GBR_CONV_VOICE
GBR Conversational Voice.
Definition eps-bearer.h:96
static void GetValueByName(std::string name, AttributeValue &value)
Finds the GlobalValue with the given name and returns its value.
Helper class used to assign positions and mobility models to nodes.
void Install(Ptr< Node > node) const
"Layout" a single node according to the current position allocator type.
void SetMobilityModel(std::string type, Ts &&... args)
void SetPositionAllocator(Ptr< PositionAllocator > allocator)
Set the position allocator which will be used to allocate the initial position of every node initiali...
holds a vector of ns3::NetDevice pointers
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.
Smart pointer class similar to boost::intrusive_ptr.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition simulator.cc:131
static void Run()
Run the simulation.
Definition simulator.cc:167
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Definition simulator.cc:175
Hold variables of type string.
Definition string.h:45
Hold an unsigned integer type.
Definition uinteger.h:34
uint64_t Get() const
Definition uinteger.cc:26
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition object.h:619
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition nstime.h:1308
Every class exported by the ns3 library is enclosed in the ns3 namespace.