A Discrete-Event Network Simulator
API
lena-intercell-interference.cc
Go to the documentation of this file.
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Manuel Requena <manuel.requena@cttc.es>
19  * Nicola Baldo <nbaldo@cttc.es>
20  */
21 
22 
23 #include "ns3/core-module.h"
24 #include "ns3/network-module.h"
25 #include "ns3/mobility-module.h"
26 #include "ns3/lte-module.h"
27 #include "ns3/config-store.h"
28 #include "ns3/radio-bearer-stats-calculator.h"
29 
30 #include <iomanip>
31 #include <string>
32 
33 using namespace ns3;
34 
40 int main (int argc, char *argv[])
41 {
42  double enbDist = 100.0;
43  double radius = 50.0;
44  uint32_t numUes = 1;
45  double simTime = 1.0;
46 
47  CommandLine cmd (__FILE__);
48  cmd.AddValue ("enbDist", "distance between the two eNBs", enbDist);
49  cmd.AddValue ("radius", "the radius of the disc where UEs are placed around an eNB", radius);
50  cmd.AddValue ("numUes", "how many UEs are attached to each eNB", numUes);
51  cmd.AddValue ("simTime", "Total duration of the simulation (in seconds)", simTime);
52  cmd.Parse (argc, argv);
53 
54  ConfigStore inputConfig;
55  inputConfig.ConfigureDefaults ();
56 
57  // parse again so you can override default values from the command line
58  cmd.Parse (argc, argv);
59 
60  // determine the string tag that identifies this simulation run
61  // this tag is then appended to all filenames
62 
63  UintegerValue runValue;
64  GlobalValue::GetValueByName ("RngRun", runValue);
65 
66  std::ostringstream tag;
67  tag << "_enbDist" << std::setw (3) << std::setfill ('0') << std::fixed << std::setprecision (0) << enbDist
68  << "_radius" << std::setw (3) << std::setfill ('0') << std::fixed << std::setprecision (0) << radius
69  << "_numUes" << std::setw (3) << std::setfill ('0') << numUes
70  << "_rngRun" << std::setw (3) << std::setfill ('0') << runValue.Get () ;
71 
72  Ptr<LteHelper> lteHelper = CreateObject<LteHelper> ();
73 
74  lteHelper->SetAttribute ("PathlossModel", StringValue ("ns3::FriisSpectrumPropagationLossModel"));
75 
76  // Create Nodes: eNodeB and UE
77  NodeContainer enbNodes;
78  NodeContainer ueNodes1, 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", DoubleValue (0.0),
96  "Y", DoubleValue (0.0),
97  "rho", DoubleValue (radius));
98  ue1mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
99  ue1mobility.Install (ueNodes1);
100 
101  // Position of UEs attached to eNB 2
102  MobilityHelper ue2mobility;
103  ue2mobility.SetPositionAllocator ("ns3::UniformDiscPositionAllocator",
104  "X", DoubleValue (enbDist),
105  "Y", DoubleValue (0.0),
106  "rho", DoubleValue (radius));
107  ue2mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
108  ue2mobility.Install (ueNodes2);
109 
110 
111 
112  // Create Devices and install them in the Nodes (eNB and UE)
113  NetDeviceContainer enbDevs;
114  NetDeviceContainer ueDevs1;
115  NetDeviceContainer ueDevs2;
116  enbDevs = lteHelper->InstallEnbDevice (enbNodes);
117  ueDevs1 = lteHelper->InstallUeDevice (ueNodes1);
118  ueDevs2 = lteHelper->InstallUeDevice (ueNodes2);
119 
120  // Attach UEs to a eNB
121  lteHelper->Attach (ueDevs1, enbDevs.Get (0));
122  lteHelper->Attach (ueDevs2, enbDevs.Get (1));
123 
124  // Activate a data radio bearer each UE
126  EpsBearer bearer (q);
127  lteHelper->ActivateDataRadioBearer (ueDevs1, bearer);
128  lteHelper->ActivateDataRadioBearer (ueDevs2, bearer);
129 
130  Simulator::Stop (Seconds (simTime));
131 
132  // Insert RLC Performance Calculator
133  std::string dlOutFname = "DlRlcStats";
134  dlOutFname.append (tag.str ());
135  std::string ulOutFname = "UlRlcStats";
136  ulOutFname.append (tag.str ());
137 
138  lteHelper->EnableMacTraces ();
139  lteHelper->EnableRlcTraces ();
140 
141  Simulator::Run ();
143  return 0;
144 }
Introspection did not find any typical Config paths.
Definition: config-store.h:59
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
NetDeviceContainer InstallEnbDevice(NodeContainer c)
Create a set of eNodeB devices.
Definition: lte-helper.cc:474
Hold variables of type string.
Definition: string.h:41
static void Run(void)
Run the simulation.
Definition: simulator.cc:172
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:961
void EnableRlcTraces(void)
Enable trace sinks for RLC layer.
Definition: lte-helper.cc:1436
cmd
Definition: second.py:35
void ActivateDataRadioBearer(NetDeviceContainer ueDevices, EpsBearer bearer)
Activate a Data Radio Bearer on a given UE devices (for LTE-only simulation).
Definition: lte-helper.cc:1314
Hold an unsigned integer type.
Definition: uinteger.h:44
holds a vector of ns3::NetDevice pointers
Parse command-line arguments.
Definition: command-line.h:226
static void Destroy(void)
Execute the events scheduled with ScheduleDestroy().
Definition: simulator.cc:136
void ConfigureDefaults(void)
Configure the default values.
uint64_t Get(void) const
Definition: uinteger.cc:35
Every class exported by the ns3 library is enclosed in the ns3 namespace.
keep track of a set of node pointers.
void SetMobilityModel(std::string type, std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue(), std::string n8="", const AttributeValue &v8=EmptyAttributeValue(), std::string n9="", const AttributeValue &v9=EmptyAttributeValue())
This class contains the specification of EPS Bearers.
Definition: eps-bearer.h:91
void Install(Ptr< Node > node) const
"Layout" a single node according to the current position allocator type.
NetDeviceContainer InstallUeDevice(NodeContainer c)
Create a set of UE devices.
Definition: lte-helper.cc:489
Helper class used to assign positions and mobility models to nodes.
static void Stop(void)
Tell the Simulator the calling event should be the last one executed.
Definition: simulator.cc:180
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1278
GBR Conversational Voice.
Definition: eps-bearer.h:108
void Add(Vector v)
Add a position to the list of positions.
static void GetValueByName(std::string name, AttributeValue &value)
Finds the GlobalValue with the given name and returns its value.
Qci
QoS Class Indicator.
Definition: eps-bearer.h:106
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
void EnableMacTraces(void)
Enable trace sinks for MAC layer.
Definition: lte-helper.cc:1530
void SetPositionAllocator(Ptr< PositionAllocator > allocator)
Set the position allocator which will be used to allocate the initial position of every node initiali...
This class can be used to hold variables of floating point type such as &#39;double&#39; or &#39;float&#39;...
Definition: double.h:41
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:185