A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
lena-profiling.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: Jaume Nin <jnin@cttc.es>
18 */
19
20#include "ns3/config-store.h"
21#include "ns3/core-module.h"
22#include "ns3/lte-module.h"
23#include "ns3/mobility-module.h"
24#include "ns3/network-module.h"
25#include <ns3/buildings-module.h>
26
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", nFloors);
46 cmd.AddValue("simTime", "Total duration of the simulation (in seconds)", simTime);
47 cmd.Parse(argc, argv);
48
49 ConfigStore inputConfig;
50 inputConfig.ConfigureDefaults();
51
52 // parse again so you can override default values from the command line
53 cmd.Parse(argc, argv);
54
55 // Geometry of the scenario (in meters)
56 // Assume squared building
57 double nodeHeight = 1.5;
58 double roomHeight = 3;
59 double roomLength = 8;
60 uint32_t nRooms = std::ceil(std::sqrt(nEnbPerFloor));
61 uint32_t nEnb;
62
63 Ptr<LteHelper> lteHelper = CreateObject<LteHelper>();
64 // lteHelper->EnableLogComponents ();
65 // LogComponentEnable ("BuildingsPropagationLossModel", LOG_LEVEL_ALL);
66 if (nFloors == 0)
67 {
68 lteHelper->SetAttribute("PathlossModel", StringValue("ns3::FriisPropagationLossModel"));
69 nEnb = nEnbPerFloor;
70 }
71 else
72 {
73 lteHelper->SetAttribute("PathlossModel",
74 StringValue("ns3::HybridBuildingsPropagationLossModel"));
75 nEnb = nFloors * nEnbPerFloor;
76 }
77
78 // Create Nodes: eNodeB and UE
79 NodeContainer enbNodes;
80 std::vector<NodeContainer> ueNodes;
81
82 enbNodes.Create(nEnb);
83 for (uint32_t i = 0; i < nEnb; i++)
84 {
85 NodeContainer ueNode;
86 ueNode.Create(nUe);
87 ueNodes.push_back(ueNode);
88 }
89
91 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
92 std::vector<Vector> enbPosition;
93 Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator>();
94 Ptr<Building> building;
95
96 if (nFloors == 0)
97 {
98 // Position of eNBs
99 uint32_t plantedEnb = 0;
100 for (uint32_t row = 0; row < nRooms; row++)
101 {
102 for (uint32_t column = 0; column < nRooms && plantedEnb < nEnbPerFloor;
103 column++, plantedEnb++)
104 {
105 Vector v(roomLength * (column + 0.5), roomLength * (row + 0.5), nodeHeight);
106 positionAlloc->Add(v);
107 enbPosition.push_back(v);
108 mobility.Install(ueNodes.at(plantedEnb));
109 }
110 }
111 mobility.SetPositionAllocator(positionAlloc);
112 mobility.Install(enbNodes);
113 BuildingsHelper::Install(enbNodes);
114
115 // Position of UEs attached to eNB
116 for (uint32_t i = 0; i < nEnb; i++)
117 {
118 Ptr<UniformRandomVariable> posX = CreateObject<UniformRandomVariable>();
119 posX->SetAttribute("Min", DoubleValue(enbPosition.at(i).x - roomLength * 0.5));
120 posX->SetAttribute("Max", DoubleValue(enbPosition.at(i).x + roomLength * 0.5));
121 Ptr<UniformRandomVariable> posY = CreateObject<UniformRandomVariable>();
122 posY->SetAttribute("Min", DoubleValue(enbPosition.at(i).y - roomLength * 0.5));
123 posY->SetAttribute("Max", DoubleValue(enbPosition.at(i).y + roomLength * 0.5));
124 positionAlloc = CreateObject<ListPositionAllocator>();
125 for (uint32_t j = 0; j < nUe; j++)
126 {
127 positionAlloc->Add(Vector(posX->GetValue(), posY->GetValue(), nodeHeight));
128 mobility.SetPositionAllocator(positionAlloc);
129 }
130 mobility.Install(ueNodes.at(i));
131 BuildingsHelper::Install(ueNodes.at(i));
132 }
133 }
134 else
135 {
136 building = CreateObject<Building>();
137 building->SetBoundaries(
138 Box(0.0, nRooms * roomLength, 0.0, nRooms * roomLength, 0.0, nFloors * roomHeight));
139 building->SetBuildingType(Building::Residential);
140 building->SetExtWallsType(Building::ConcreteWithWindows);
141 building->SetNFloors(nFloors);
142 building->SetNRoomsX(nRooms);
143 building->SetNRoomsY(nRooms);
144 mobility.Install(enbNodes);
145 BuildingsHelper::Install(enbNodes);
146 uint32_t plantedEnb = 0;
147 for (uint32_t floor = 0; floor < nFloors; floor++)
148 {
149 uint32_t plantedEnbPerFloor = 0;
150 for (uint32_t row = 0; row < nRooms; row++)
151 {
152 for (uint32_t column = 0; column < nRooms && plantedEnbPerFloor < nEnbPerFloor;
153 column++, plantedEnb++, plantedEnbPerFloor++)
154 {
155 Vector v(roomLength * (column + 0.5),
156 roomLength * (row + 0.5),
157 nodeHeight + roomHeight * floor);
158 positionAlloc->Add(v);
159 enbPosition.push_back(v);
160 Ptr<MobilityModel> mmEnb = enbNodes.Get(plantedEnb)->GetObject<MobilityModel>();
161 mmEnb->SetPosition(v);
162
163 // Positioning UEs attached to eNB
164 mobility.Install(ueNodes.at(plantedEnb));
165 BuildingsHelper::Install(ueNodes.at(plantedEnb));
166 for (uint32_t ue = 0; ue < nUe; ue++)
167 {
168 Ptr<MobilityModel> mmUe =
169 ueNodes.at(plantedEnb).Get(ue)->GetObject<MobilityModel>();
170 Vector vUe(v.x, v.y, v.z);
171 mmUe->SetPosition(vUe);
172 }
173 }
174 }
175 }
176 }
177
178 // Create Devices and install them in the Nodes (eNB and UE)
179 NetDeviceContainer enbDevs;
180 std::vector<NetDeviceContainer> ueDevs;
181 enbDevs = lteHelper->InstallEnbDevice(enbNodes);
182 for (uint32_t i = 0; i < nEnb; i++)
183 {
184 NetDeviceContainer ueDev = lteHelper->InstallUeDevice(ueNodes.at(i));
185 ueDevs.push_back(ueDev);
186 lteHelper->Attach(ueDev, enbDevs.Get(i));
188 EpsBearer bearer(q);
189 lteHelper->ActivateDataRadioBearer(ueDev, bearer);
190 }
191
192 Simulator::Stop(Seconds(simTime));
193 lteHelper->EnableTraces();
194
196
197 /*GtkConfigStore config;
198 config.ConfigureAttributes ();*/
199
201 return 0;
202}
a 3d box
Definition: box.h:35
@ ConcreteWithWindows
Definition: building.h:69
static void Install(Ptr< Node > node)
Install the MobilityBuildingInfo to a node.
Parse command-line arguments.
Definition: command-line.h:232
Introspection did not find any typical Config paths.
Definition: config-store.h:61
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
Helper class used to assign positions and mobility models to nodes.
Keep track of the current position and velocity of an object.
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.
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
Definition: object.h:522
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
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
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1319
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns cmd
Definition: second.py:40
ns mobility
Definition: third.py:105