A Discrete-Event Network Simulator
API
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
32using namespace ns3;
33
34int
35main (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 (__FILE__);
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
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));
190 enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE;
191 EpsBearer bearer (q);
192 lteHelper->ActivateDataRadioBearer (ueDev, bearer);
193 }
194
195
196 Simulator::Stop (Seconds (simTime));
197 lteHelper->EnableTraces ();
198
199 Simulator::Run ();
200
201 /*GtkConfigStore config;
202 config.ConfigureAttributes ();*/
203
204 Simulator::Destroy ();
205 return 0;
206}
a 3d box
Definition: box.h:35
Parse command-line arguments.
Definition: command-line.h:229
Introspection did not find any typical Config paths.
Definition: config-store.h:60
void ConfigureDefaults(void)
Configure the default values.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition: double.h:41
This class contains the specification of EPS Bearers.
Definition: eps-bearer.h:92
Qci
QoS Class Indicator.
Definition: eps-bearer.h:107
NetDeviceContainer InstallEnbDevice(NodeContainer c)
Create a set of eNodeB devices.
Definition: lte-helper.cc:474
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:959
void ActivateDataRadioBearer(NetDeviceContainer ueDevices, EpsBearer bearer)
Activate a Data Radio Bearer on a given UE devices (for LTE-only simulation).
Definition: lte-helper.cc:1313
NetDeviceContainer InstallUeDevice(NodeContainer c)
Create a set of UE devices.
Definition: lte-helper.cc:489
void EnableTraces(void)
Enables trace sinks for PHY, MAC, RLC and PDCP.
Definition: lte-helper.cc:1426
Helper class used to assign positions and mobility models to nodes.
Keep track of the current position and velocity of an object.
void SetPosition(const Vector &position)
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.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:256
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Definition: object.h:470
Hold variables of type string.
Definition: string.h:41
double GetValue(double min, double max)
Get the next random value, as a double in the specified range .
Vector3D Vector
Vector alias typedef for compatibility with mobility models.
Definition: vector.h:324
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1244
Every class exported by the ns3 library is enclosed in the ns3 namespace.
cmd
Definition: second.py:35
mobility
Definition: third.py:107