A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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;
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  IntegerValue 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 }
Doxygen introspection did not find any typical Config paths.
Definition: config-store.h:34
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:59
NetDeviceContainer InstallEnbDevice(NodeContainer c)
create a set of eNB devices
Definition: lte-helper.cc:347
hold variables of type string
Definition: string.h:19
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr stored in this container at a given index.
static void Run(void)
Run the simulation until one of:
Definition: simulator.cc:157
Hold a signed integer type.
Definition: integer.h:45
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:647
void EnableRlcTraces(void)
Enable trace sinks for RLC layer.
Definition: lte-helper.cc:957
void ActivateDataRadioBearer(NetDeviceContainer ueDevices, EpsBearer bearer)
Call ActivateDataRadioBearer (ueDevice, bearer) for each UE device in a given set.
Definition: lte-helper.cc:901
a 3d vector
Definition: vector.h:31
int64_t Get(void) const
This class contains the specification of EPS Bearers.
Definition: eps-bearer.h:71
void Install(Ptr< Node > node) const
"Layout" a single node according to the current position allocator type.
holds a vector of ns3::NetDevice pointers
Parse command-line arguments.
Definition: command-line.h:152
static void Destroy(void)
Every event scheduled by the Simulator::insertAtDestroy method is invoked.
Definition: simulator.cc:121
void ConfigureDefaults(void)
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())
NetDeviceContainer InstallUeDevice(NodeContainer c)
create a set of UE devices
Definition: lte-helper.cc:362
Helper class used to assign positions and mobility models to nodes.
void AddValue(const std::string &name, const std::string &help, T &value)
Add a program argument, assigning to POD.
Definition: command-line.h:408
static void Stop(void)
If an event invokes this method, it will be the last event scheduled by the Simulator::run method bef...
Definition: simulator.cc:165
static void GetValueByName(std::string name, AttributeValue &value)
finds the GlobalValue with the given name and returns its value.
void Parse(int argc, char *argv[])
Parse the program arguments.
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:1045
void SetPositionAllocator(Ptr< PositionAllocator > allocator)
Set the position allocator which will be used to allocate the initial position of every node initiali...
Hold a floating point type.
Definition: double.h:41
void SetAttribute(std::string name, const AttributeValue &value)
Definition: object-base.cc:161
Qci
QoS Class Indicator.
Definition: eps-bearer.h:77
int main(int argc, char *argv[])
This simulation script creates two eNodeBs and drops randomly several UEs in a disc around them (same...