A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
lena-profiling.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: Jaume Nin <jnin@cttc.es>
19  */
20 
21 #include "ns3/core-module.h"
22 #include "ns3/network-module.h"
23 #include "ns3/mobility-module.h"
24 #include "ns3/lte-module.h"
25 #include "ns3/config-store.h"
26 #include <ns3/buildings-module.h>
27 #include <iomanip>
28 #include <string>
29 #include <vector>
30 //#include "ns3/gtk-config-store.h"
31 
32 using namespace ns3;
33 
34 int
35 main (int argc, char *argv[])
36 {
37  uint32_t nEnbPerFloor = 1;
38  uint32_t nUe = 1;
39  uint32_t nFloors = 0;
40  double simTime = 1.0;
41  CommandLine cmd;
42 
43  cmd.AddValue ("nEnb", "Number of eNodeBs per floor", nEnbPerFloor);
44  cmd.AddValue ("nUe", "Number of UEs", nUe);
45  cmd.AddValue ("nFloors", "Number of floors, 0 for Friis propagation model",
46  nFloors);
47  cmd.AddValue ("simTime", "Total duration of the simulation (in seconds)",
48  simTime);
49  cmd.Parse (argc, argv);
50 
51  ConfigStore inputConfig;
52  inputConfig.ConfigureDefaults ();
53 
54  // parse again so you can override default values from the command line
55  cmd.Parse (argc, argv);
56 
57  // Geometry of the scenario (in meters)
58  // Assume squared building
59  double nodeHeight = 1.5;
60  double roomHeight = 3;
61  double roomLength = 8;
62  uint32_t nRooms = std::ceil (std::sqrt (nEnbPerFloor));
63  uint32_t nEnb;
64 
65  Ptr<LteHelper> lteHelper = CreateObject<LteHelper> ();
66  //lteHelper->EnableLogComponents ();
67  //LogComponentEnable ("BuildingsPropagationLossModel", LOG_LEVEL_ALL);
68  if (nFloors == 0)
69  {
70  lteHelper->SetAttribute ("PathlossModel",
71  StringValue ("ns3::FriisPropagationLossModel"));
72  nEnb = nEnbPerFloor;
73  }
74  else
75  {
76  lteHelper->SetAttribute ("PathlossModel",
77  StringValue ("ns3::HybridBuildingsPropagationLossModel"));
78  nEnb = nFloors * nEnbPerFloor;
79  }
80 
81  // Create Nodes: eNodeB and UE
82  NodeContainer enbNodes;
83  std::vector<NodeContainer> ueNodes;
84 
85  enbNodes.Create (nEnb);
86  for (uint32_t i = 0; i < nEnb; i++)
87  {
88  NodeContainer ueNode;
89  ueNode.Create (nUe);
90  ueNodes.push_back (ueNode);
91  }
92 
93  MobilityHelper mobility;
94  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
95  std::vector<Vector> enbPosition;
96  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
97  Ptr<Building> building;
98 
99  if (nFloors == 0)
100  {
101  // Position of eNBs
102  uint32_t plantedEnb = 0;
103  for (uint32_t row = 0; row < nRooms; row++)
104  {
105  for (uint32_t column = 0; column < nRooms && plantedEnb < nEnbPerFloor; column++, plantedEnb++)
106  {
107  Vector v (roomLength * (column + 0.5), roomLength * (row + 0.5), nodeHeight);
108  positionAlloc->Add (v);
109  enbPosition.push_back (v);
110  mobility.Install (ueNodes.at(plantedEnb));
111  }
112  }
113  mobility.SetPositionAllocator (positionAlloc);
114  mobility.Install (enbNodes);
115  BuildingsHelper::Install (enbNodes);
116 
117  // Position of UEs attached to eNB
118  for (uint32_t i = 0; i < nEnb; i++)
119  {
120  Ptr<UniformRandomVariable> posX = CreateObject<UniformRandomVariable> ();
121  posX->SetAttribute ("Min", DoubleValue (enbPosition.at(i).x - roomLength * 0.5));
122  posX->SetAttribute ("Max", DoubleValue (enbPosition.at(i).x + roomLength * 0.5));
123  Ptr<UniformRandomVariable> posY = CreateObject<UniformRandomVariable> ();
124  posY->SetAttribute ("Min", DoubleValue (enbPosition.at(i).y - roomLength * 0.5));
125  posY->SetAttribute ("Max", DoubleValue (enbPosition.at(i).y + roomLength * 0.5));
126  positionAlloc = CreateObject<ListPositionAllocator> ();
127  for (uint32_t j = 0; j < nUe; j++)
128  {
129  positionAlloc->Add (Vector (posX->GetValue (), posY->GetValue (), nodeHeight));
130  mobility.SetPositionAllocator (positionAlloc);
131  }
132  mobility.Install (ueNodes.at(i));
133  BuildingsHelper::Install (ueNodes.at(i));
134  }
135 
136  }
137  else
138  {
139  building = CreateObject<Building> ();
140  building->SetBoundaries (Box (0.0, nRooms * roomLength,
141  0.0, nRooms * roomLength,
142  0.0, nFloors* roomHeight));
143  building->SetBuildingType (Building::Residential);
144  building->SetExtWallsType (Building::ConcreteWithWindows);
145  building->SetNFloors (nFloors);
146  building->SetNRoomsX (nRooms);
147  building->SetNRoomsY (nRooms);
148  mobility.Install (enbNodes);
149  BuildingsHelper::Install (enbNodes);
150  uint32_t plantedEnb = 0;
151  for (uint32_t floor = 0; floor < nFloors; floor++)
152  {
153  uint32_t plantedEnbPerFloor = 0;
154  for (uint32_t row = 0; row < nRooms; row++)
155  {
156  for (uint32_t column = 0; column < nRooms && plantedEnbPerFloor < nEnbPerFloor; column++, plantedEnb++, plantedEnbPerFloor++)
157  {
158  Vector v (roomLength * (column + 0.5),
159  roomLength * (row + 0.5),
160  nodeHeight + roomHeight * floor);
161  positionAlloc->Add (v);
162  enbPosition.push_back (v);
163  Ptr<MobilityModel> mmEnb = enbNodes.Get (plantedEnb)->GetObject<MobilityModel> ();
164  mmEnb->SetPosition (v);
165 
166  // Positioning UEs attached to eNB
167  mobility.Install (ueNodes.at(plantedEnb));
168  BuildingsHelper::Install (ueNodes.at(plantedEnb));
169  for (uint32_t ue = 0; ue < nUe; ue++)
170  {
171  Ptr<MobilityModel> mmUe = ueNodes.at(plantedEnb).Get (ue)->GetObject<MobilityModel> ();
172  Vector vUe (v.x, v.y, v.z);
173  mmUe->SetPosition (vUe);
174  }
175  }
176  }
177  }
178  }
179 
180 
181  // Create Devices and install them in the Nodes (eNB and UE)
182  NetDeviceContainer enbDevs;
183  std::vector<NetDeviceContainer> ueDevs;
184  enbDevs = lteHelper->InstallEnbDevice (enbNodes);
185  for (uint32_t i = 0; i < nEnb; i++)
186  {
187  NetDeviceContainer ueDev = lteHelper->InstallUeDevice (ueNodes.at(i));
188  ueDevs.push_back (ueDev);
189  lteHelper->Attach (ueDev, enbDevs.Get (i));
191  EpsBearer bearer (q);
192  lteHelper->ActivateDataRadioBearer (ueDev, bearer);
193  }
194 
195 
197 
198  Simulator::Stop (Seconds (simTime));
199  lteHelper->EnableTraces ();
200 
201  Simulator::Run ();
202 
203  /*GtkConfigStore config;
204  config.ConfigureAttributes ();*/
205 
207  return 0;
208 }
Doxygen introspection did not find any typical Config paths.
Definition: config-store.h:34
double x
x coordinate of vector
Definition: vector.h:49
NetDeviceContainer InstallEnbDevice(NodeContainer c)
create a set of eNB devices
Definition: lte-helper.cc:346
hold variables of type string
Definition: string.h:18
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr stored in this container at a given index.
int main(int argc, char *argv[])
static void Run(void)
Run the simulation until one of:
Definition: simulator.cc:157
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:646
void ActivateDataRadioBearer(NetDeviceContainer ueDevices, EpsBearer bearer)
Call ActivateDataRadioBearer (ueDevice, bearer) for each UE device in a given set.
Definition: lte-helper.cc:900
a 3d vector
Definition: vector.h:31
a 3d box
Definition: box.h:33
Keep track of the current position and velocity of an object.
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.
static void MakeMobilityModelConsistent()
This method goes through the whole NodeList and, for each node in the list, calls BuildingsHelper::Ma...
void EnableTraces(void)
Enables trace sinks for PHY, MAC, RLC and PDCP.
Definition: lte-helper.cc:947
holds a vector of ns3::NetDevice pointers
Parse command-line arguments.
Definition: command-line.h:177
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())
double GetValue(double min, double max)
Returns a random double from the uniform distribution with the specified range.
double y
y coordinate of vector
Definition: vector.h:53
void SetPosition(const Vector &position)
NetDeviceContainer InstallUeDevice(NodeContainer c)
create a set of UE devices
Definition: lte-helper.cc:361
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:435
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
Ptr< Node > Get(uint32_t i) const
Get the Ptr stored in this container at a given index.
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 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:176
Ptr< T > GetObject(void) const
Definition: object.h:362
Qci
QoS Class Indicator.
Definition: eps-bearer.h:77
double z
z coordinate of vector
Definition: vector.h:57
static void Install(Ptr< Node > node)
Install the MobilityBuildingInfo to a node.