A Discrete-Event Network Simulator
API
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  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation;
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  *
17  * Author: Manuel Requena <manuel.requena@cttc.es>
18  * Nicola Baldo <nbaldo@cttc.es>
19  */
20 
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/radio-bearer-stats-calculator.h"
27 
28 #include <iomanip>
29 #include <string>
30 
31 using namespace ns3;
32 
38 int
39 main(int argc, char* argv[])
40 {
41  double enbDist = 100.0;
42  double radius = 50.0;
43  uint32_t numUes = 1;
44  double simTime = 1.0;
45 
46  CommandLine cmd(__FILE__);
47  cmd.AddValue("enbDist", "distance between the two eNBs", enbDist);
48  cmd.AddValue("radius", "the radius of the disc where UEs are placed around an eNB", radius);
49  cmd.AddValue("numUes", "how many UEs are attached to each eNB", numUes);
50  cmd.AddValue("simTime", "Total duration of the simulation (in seconds)", simTime);
51  cmd.Parse(argc, argv);
52 
53  ConfigStore inputConfig;
54  inputConfig.ConfigureDefaults();
55 
56  // parse again so you can override default values from the command line
57  cmd.Parse(argc, argv);
58 
59  // determine the string tag that identifies this simulation run
60  // this tag is then appended to all filenames
61 
62  UintegerValue runValue;
63  GlobalValue::GetValueByName("RngRun", runValue);
64 
65  std::ostringstream tag;
66  tag << "_enbDist" << std::setw(3) << std::setfill('0') << std::fixed << std::setprecision(0)
67  << enbDist << "_radius" << std::setw(3) << std::setfill('0') << std::fixed
68  << std::setprecision(0) << radius << "_numUes" << std::setw(3) << std::setfill('0')
69  << numUes << "_rngRun" << std::setw(3) << std::setfill('0') << runValue.Get();
70 
71  Ptr<LteHelper> lteHelper = CreateObject<LteHelper>();
72 
73  lteHelper->SetAttribute("PathlossModel", StringValue("ns3::FriisSpectrumPropagationLossModel"));
74 
75  // Create Nodes: eNodeB and UE
76  NodeContainer enbNodes;
77  NodeContainer ueNodes1;
78  NodeContainer ueNodes2;
79  enbNodes.Create(2);
80  ueNodes1.Create(numUes);
81  ueNodes2.Create(numUes);
82 
83  // Position of eNBs
84  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator>();
85  positionAlloc->Add(Vector(0.0, 0.0, 0.0));
86  positionAlloc->Add(Vector(enbDist, 0.0, 0.0));
87  MobilityHelper enbMobility;
88  enbMobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
89  enbMobility.SetPositionAllocator(positionAlloc);
90  enbMobility.Install(enbNodes);
91 
92  // Position of UEs attached to eNB 1
93  MobilityHelper ue1mobility;
94  ue1mobility.SetPositionAllocator("ns3::UniformDiscPositionAllocator",
95  "X",
96  DoubleValue(0.0),
97  "Y",
98  DoubleValue(0.0),
99  "rho",
100  DoubleValue(radius));
101  ue1mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
102  ue1mobility.Install(ueNodes1);
103 
104  // Position of UEs attached to eNB 2
105  MobilityHelper ue2mobility;
106  ue2mobility.SetPositionAllocator("ns3::UniformDiscPositionAllocator",
107  "X",
108  DoubleValue(enbDist),
109  "Y",
110  DoubleValue(0.0),
111  "rho",
112  DoubleValue(radius));
113  ue2mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
114  ue2mobility.Install(ueNodes2);
115 
116  // Create Devices and install them in the Nodes (eNB and UE)
117  NetDeviceContainer enbDevs;
118  NetDeviceContainer ueDevs1;
119  NetDeviceContainer ueDevs2;
120  enbDevs = lteHelper->InstallEnbDevice(enbNodes);
121  ueDevs1 = lteHelper->InstallUeDevice(ueNodes1);
122  ueDevs2 = lteHelper->InstallUeDevice(ueNodes2);
123 
124  // Attach UEs to a eNB
125  lteHelper->Attach(ueDevs1, enbDevs.Get(0));
126  lteHelper->Attach(ueDevs2, enbDevs.Get(1));
127 
128  // Activate a data radio bearer each UE
130  EpsBearer bearer(q);
131  lteHelper->ActivateDataRadioBearer(ueDevs1, bearer);
132  lteHelper->ActivateDataRadioBearer(ueDevs2, bearer);
133 
134  Simulator::Stop(Seconds(simTime));
135 
136  // Insert RLC Performance Calculator
137  std::string dlOutFname = "DlRlcStats";
138  dlOutFname.append(tag.str());
139  std::string ulOutFname = "UlRlcStats";
140  ulOutFname.append(tag.str());
141 
142  lteHelper->EnableMacTraces();
143  lteHelper->EnableRlcTraces();
144 
145  Simulator::Run();
147  return 0;
148 }
Parse command-line arguments.
Definition: command-line.h:232
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:42
This class contains the specification of EPS Bearers.
Definition: eps-bearer.h:91
Qci
QoS Class Indicator.
Definition: eps-bearer.h:106
@ GBR_CONV_VOICE
GBR Conversational Voice.
Definition: eps-bearer.h:107
static void GetValueByName(std::string name, AttributeValue &value)
Finds the GlobalValue with the given name and returns its value.
NetDeviceContainer InstallEnbDevice(NodeContainer c)
Create a set of eNodeB devices.
Definition: lte-helper.cc:485
void Attach(NetDeviceContainer ueDevices)
Enables automatic attachment of a set of UE devices to a suitable cell using Idle mode initial cell s...
Definition: lte-helper.cc:1039
void EnableRlcTraces()
Enable trace sinks for RLC layer.
Definition: lte-helper.cc:1558
void ActivateDataRadioBearer(NetDeviceContainer ueDevices, EpsBearer bearer)
Activate a Data Radio Bearer on a given UE devices (for LTE-only simulation).
Definition: lte-helper.cc:1436
NetDeviceContainer InstallUeDevice(NodeContainer c)
Create a set of UE devices.
Definition: lte-helper.cc:500
void EnableMacTraces()
Enable trace sinks for MAC layer.
Definition: lte-helper.cc:1659
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.
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:204
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition: simulator.cc:142
static void Run()
Run the simulation.
Definition: simulator.cc:178
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Definition: simulator.cc:186
Hold variables of type string.
Definition: string.h:56
Hold an unsigned integer type.
Definition: uinteger.h:45
uint64_t Get() const
Definition: uinteger.cc:37
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1326
Every class exported by the ns3 library is enclosed in the ns3 namespace.
cmd
Definition: second.py:40