author | Nicola Baldo <nbaldo@cttc.es> |
Mon, 05 Dec 2011 21:27:44 +0100 | |
changeset 8463 | cc818aa536a5 |
parent 8460 | fbb53bda0ec7 |
child 8540 | 5e6afc302fb2 |
child 8556 | f859539f5dd3 |
permissions | -rw-r--r-- |
8261 | 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" |
|
8268
2228db567a14
Update lena-runtime-profiler with buildings initialization
Marco Miozzo <marco.miozzo@cttc.es>
parents:
8266
diff
changeset
|
26 |
#include <ns3/buildings-propagation-loss-model.h> |
8261 | 27 |
#include <iomanip> |
28 |
#include <string> |
|
29 |
#include <vector> |
|
8429 | 30 |
//#include "ns3/gtk-config-store.h" |
8261 | 31 |
|
32 |
using namespace ns3; |
|
33 |
using std::vector; |
|
34 |
||
35 |
int |
|
36 |
main (int argc, char *argv[]) |
|
37 |
{ |
|
38 |
uint32_t nEnbPerFloor = 1; |
|
39 |
uint32_t nUe = 1; |
|
40 |
uint32_t nFloors = 0; |
|
41 |
double simTime = 1.0; |
|
42 |
std::string traceDirectory = ""; |
|
43 |
CommandLine cmd; |
|
44 |
||
45 |
cmd.AddValue("nEnb", "Number of eNodeBs per floor", nEnbPerFloor); |
|
46 |
cmd.AddValue("nUe", "Number of UEs", nUe); |
|
47 |
cmd.AddValue("nFloors", "Number of floors, 0 for Friis propagation model", |
|
48 |
nFloors); |
|
49 |
cmd.AddValue("simTime", "Total duration of the simulation (in seconds)", |
|
50 |
simTime); |
|
51 |
cmd.AddValue("traceDirectory", |
|
52 |
"Destination folder where the traces will be stored", traceDirectory); |
|
53 |
cmd.Parse(argc, argv); |
|
54 |
||
55 |
ConfigStore inputConfig; |
|
56 |
inputConfig.ConfigureDefaults(); |
|
8268
2228db567a14
Update lena-runtime-profiler with buildings initialization
Marco Miozzo <marco.miozzo@cttc.es>
parents:
8266
diff
changeset
|
57 |
|
8261 | 58 |
// parse again so you can override default values from the command line |
59 |
cmd.Parse(argc, argv); |
|
60 |
||
61 |
// Geometry of the scenario (in meters) |
|
62 |
// Assume squared building |
|
63 |
double nodeHeight = 1.5; |
|
64 |
double roomHeight = 3; |
|
65 |
double roomLength = 8; |
|
66 |
uint32_t nRooms = ceil (sqrt (nEnbPerFloor)); |
|
67 |
uint32_t nEnb; |
|
68 |
||
8460
fbb53bda0ec7
renamed LenaHelper --> LteHelper
Nicola Baldo <nbaldo@cttc.es>
parents:
8429
diff
changeset
|
69 |
Ptr < LteHelper > lteHelper = CreateObject<LteHelper> (); |
fbb53bda0ec7
renamed LenaHelper --> LteHelper
Nicola Baldo <nbaldo@cttc.es>
parents:
8429
diff
changeset
|
70 |
//lteHelper->EnableLogComponents (); |
8327
f317a8ae693e
disable logging in lena-runtime-profiler
Nicola Baldo <nbaldo@cttc.es>
parents:
8326
diff
changeset
|
71 |
//LogComponentEnable ("BuildingsPropagationLossModel", LOG_LEVEL_ALL); |
8261 | 72 |
if (nFloors == 0) |
73 |
{ |
|
8460
fbb53bda0ec7
renamed LenaHelper --> LteHelper
Nicola Baldo <nbaldo@cttc.es>
parents:
8429
diff
changeset
|
74 |
lteHelper->SetAttribute("PathlossModel", |
8261 | 75 |
StringValue("ns3::FriisPropagationLossModel")); |
76 |
nEnb = nEnbPerFloor; |
|
77 |
} |
|
78 |
else |
|
79 |
{ |
|
8460
fbb53bda0ec7
renamed LenaHelper --> LteHelper
Nicola Baldo <nbaldo@cttc.es>
parents:
8429
diff
changeset
|
80 |
lteHelper->SetAttribute("PathlossModel", |
8261 | 81 |
StringValue("ns3::BuildingsPropagationLossModel")); |
82 |
nEnb = nFloors * nEnbPerFloor; |
|
83 |
} |
|
84 |
||
85 |
// Create Nodes: eNodeB and UE |
|
86 |
NodeContainer enbNodes; |
|
87 |
vector < NodeContainer > ueNodes; |
|
88 |
||
89 |
enbNodes.Create(nEnb); |
|
90 |
for (uint32_t i = 0; i < nEnb; i++) |
|
91 |
{ |
|
92 |
NodeContainer ueNode; |
|
93 |
ueNode.Create(nUe); |
|
94 |
ueNodes.push_back(ueNode); |
|
95 |
} |
|
96 |
||
97 |
MobilityHelper mobility; |
|
98 |
vector<Vector> enbPosition; |
|
99 |
Ptr < ListPositionAllocator > positionAlloc = CreateObject<ListPositionAllocator> (); |
|
8268
2228db567a14
Update lena-runtime-profiler with buildings initialization
Marco Miozzo <marco.miozzo@cttc.es>
parents:
8266
diff
changeset
|
100 |
Ptr < Building > building; |
8261 | 101 |
|
102 |
if (nFloors == 0) |
|
103 |
{ |
|
104 |
mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel"); |
|
105 |
// Position of eNBs |
|
106 |
uint32_t plantedEnb = 0; |
|
107 |
for (uint32_t row = 0; row < nRooms; row++) |
|
108 |
{ |
|
109 |
for (uint32_t column = 0; column < nRooms && plantedEnb < nEnbPerFloor; column++, plantedEnb++) |
|
110 |
{ |
|
111 |
Vector v(roomLength * (column + 0.5), roomLength * (row + 0.5), nodeHeight); |
|
112 |
positionAlloc->Add(v); |
|
113 |
enbPosition.push_back(v); |
|
8268
2228db567a14
Update lena-runtime-profiler with buildings initialization
Marco Miozzo <marco.miozzo@cttc.es>
parents:
8266
diff
changeset
|
114 |
mobility.Install(ueNodes[plantedEnb]); |
8261 | 115 |
} |
116 |
} |
|
117 |
mobility.SetPositionAllocator(positionAlloc); |
|
118 |
mobility.Install (enbNodes); |
|
8315
2c49ce1438a5
Fixed bug in positioning the UEs for the Friis propagation model
root@pc125
parents:
8268
diff
changeset
|
119 |
|
2c49ce1438a5
Fixed bug in positioning the UEs for the Friis propagation model
root@pc125
parents:
8268
diff
changeset
|
120 |
// Position of UEs attached to eNB |
2c49ce1438a5
Fixed bug in positioning the UEs for the Friis propagation model
root@pc125
parents:
8268
diff
changeset
|
121 |
for (uint32_t i = 0; i < nEnb; i++) |
2c49ce1438a5
Fixed bug in positioning the UEs for the Friis propagation model
root@pc125
parents:
8268
diff
changeset
|
122 |
{ |
2c49ce1438a5
Fixed bug in positioning the UEs for the Friis propagation model
root@pc125
parents:
8268
diff
changeset
|
123 |
UniformVariable posX(enbPosition[i].x - roomLength * 0.5, |
2c49ce1438a5
Fixed bug in positioning the UEs for the Friis propagation model
root@pc125
parents:
8268
diff
changeset
|
124 |
enbPosition[i].x + roomLength * 0.5); |
2c49ce1438a5
Fixed bug in positioning the UEs for the Friis propagation model
root@pc125
parents:
8268
diff
changeset
|
125 |
UniformVariable posY(enbPosition[i].y - roomLength * 0.5, |
2c49ce1438a5
Fixed bug in positioning the UEs for the Friis propagation model
root@pc125
parents:
8268
diff
changeset
|
126 |
enbPosition[i].y + roomLength * 0.5); |
2c49ce1438a5
Fixed bug in positioning the UEs for the Friis propagation model
root@pc125
parents:
8268
diff
changeset
|
127 |
positionAlloc = CreateObject<ListPositionAllocator> (); |
2c49ce1438a5
Fixed bug in positioning the UEs for the Friis propagation model
root@pc125
parents:
8268
diff
changeset
|
128 |
for (uint32_t j = 0; j < nUe; j++) |
2c49ce1438a5
Fixed bug in positioning the UEs for the Friis propagation model
root@pc125
parents:
8268
diff
changeset
|
129 |
{ |
2c49ce1438a5
Fixed bug in positioning the UEs for the Friis propagation model
root@pc125
parents:
8268
diff
changeset
|
130 |
positionAlloc->Add(Vector(posX.GetValue(), posY.GetValue(), nodeHeight)); |
2c49ce1438a5
Fixed bug in positioning the UEs for the Friis propagation model
root@pc125
parents:
8268
diff
changeset
|
131 |
mobility.SetPositionAllocator(positionAlloc); |
2c49ce1438a5
Fixed bug in positioning the UEs for the Friis propagation model
root@pc125
parents:
8268
diff
changeset
|
132 |
} |
2c49ce1438a5
Fixed bug in positioning the UEs for the Friis propagation model
root@pc125
parents:
8268
diff
changeset
|
133 |
mobility.Install(ueNodes[i]); |
2c49ce1438a5
Fixed bug in positioning the UEs for the Friis propagation model
root@pc125
parents:
8268
diff
changeset
|
134 |
} |
2c49ce1438a5
Fixed bug in positioning the UEs for the Friis propagation model
root@pc125
parents:
8268
diff
changeset
|
135 |
|
8261 | 136 |
} |
137 |
else |
|
138 |
{ |
|
8268
2228db567a14
Update lena-runtime-profiler with buildings initialization
Marco Miozzo <marco.miozzo@cttc.es>
parents:
8266
diff
changeset
|
139 |
building = Create<Building> (0.0, nRooms * roomLength, |
8261 | 140 |
0.0, nRooms * roomLength, |
141 |
0.0, nFloors* roomHeight); |
|
142 |
building->SetBuildingType(Building::Residential); |
|
143 |
building->SetExtWallsType(Building::ConcreteWithWindows); |
|
144 |
building->SetFloorsNumber(nFloors); |
|
145 |
building->SetNumberRoomX(nRooms); |
|
146 |
building->SetNumberRoomY(nRooms); |
|
147 |
mobility.SetMobilityModel("ns3::BuildingsMobilityModel"); |
|
8268
2228db567a14
Update lena-runtime-profiler with buildings initialization
Marco Miozzo <marco.miozzo@cttc.es>
parents:
8266
diff
changeset
|
148 |
mobility.Install (enbNodes); |
8326
1ce4fe5083c3
FixBug in lena-runtime-profiler on nEnb generated per floor
Marco Miozzo <marco.miozzo@cttc.es>
parents:
8315
diff
changeset
|
149 |
uint32_t plantedEnb = 0; |
8261 | 150 |
for (uint32_t floor = 0; floor < nFloors; floor++) |
151 |
{ |
|
8326
1ce4fe5083c3
FixBug in lena-runtime-profiler on nEnb generated per floor
Marco Miozzo <marco.miozzo@cttc.es>
parents:
8315
diff
changeset
|
152 |
uint32_t plantedEnbPerFloor = 0; |
8261 | 153 |
for (uint32_t row = 0; row < nRooms; row++) |
154 |
{ |
|
8326
1ce4fe5083c3
FixBug in lena-runtime-profiler on nEnb generated per floor
Marco Miozzo <marco.miozzo@cttc.es>
parents:
8315
diff
changeset
|
155 |
for (uint32_t column = 0; column < nRooms && plantedEnbPerFloor < nEnbPerFloor; column++, plantedEnb++, plantedEnbPerFloor++) |
8261 | 156 |
{ |
157 |
Vector v (roomLength * (column + 0.5), |
|
158 |
roomLength * (row + 0.5), |
|
159 |
nodeHeight + roomHeight * floor); |
|
160 |
positionAlloc->Add(v); |
|
161 |
enbPosition.push_back(v); |
|
8268
2228db567a14
Update lena-runtime-profiler with buildings initialization
Marco Miozzo <marco.miozzo@cttc.es>
parents:
8266
diff
changeset
|
162 |
Ptr<BuildingsMobilityModel> mmEnb = enbNodes.Get (plantedEnb)->GetObject<BuildingsMobilityModel> (); |
2228db567a14
Update lena-runtime-profiler with buildings initialization
Marco Miozzo <marco.miozzo@cttc.es>
parents:
8266
diff
changeset
|
163 |
mmEnb->SetPosition (v); |
2228db567a14
Update lena-runtime-profiler with buildings initialization
Marco Miozzo <marco.miozzo@cttc.es>
parents:
8266
diff
changeset
|
164 |
mmEnb->SetIndoor (building); |
2228db567a14
Update lena-runtime-profiler with buildings initialization
Marco Miozzo <marco.miozzo@cttc.es>
parents:
8266
diff
changeset
|
165 |
mmEnb->SetFloorNumber (floor); |
2228db567a14
Update lena-runtime-profiler with buildings initialization
Marco Miozzo <marco.miozzo@cttc.es>
parents:
8266
diff
changeset
|
166 |
mmEnb->SetRoomNumberX (row); |
2228db567a14
Update lena-runtime-profiler with buildings initialization
Marco Miozzo <marco.miozzo@cttc.es>
parents:
8266
diff
changeset
|
167 |
mmEnb->SetRoomNumberY (column); |
2228db567a14
Update lena-runtime-profiler with buildings initialization
Marco Miozzo <marco.miozzo@cttc.es>
parents:
8266
diff
changeset
|
168 |
|
2228db567a14
Update lena-runtime-profiler with buildings initialization
Marco Miozzo <marco.miozzo@cttc.es>
parents:
8266
diff
changeset
|
169 |
// Positioning UEs attached to eNB |
2228db567a14
Update lena-runtime-profiler with buildings initialization
Marco Miozzo <marco.miozzo@cttc.es>
parents:
8266
diff
changeset
|
170 |
mobility.Install(ueNodes[plantedEnb]); |
2228db567a14
Update lena-runtime-profiler with buildings initialization
Marco Miozzo <marco.miozzo@cttc.es>
parents:
8266
diff
changeset
|
171 |
for (uint32_t ue = 0; ue < nUe; ue++) |
2228db567a14
Update lena-runtime-profiler with buildings initialization
Marco Miozzo <marco.miozzo@cttc.es>
parents:
8266
diff
changeset
|
172 |
{ |
2228db567a14
Update lena-runtime-profiler with buildings initialization
Marco Miozzo <marco.miozzo@cttc.es>
parents:
8266
diff
changeset
|
173 |
Ptr<BuildingsMobilityModel> mmUe = ueNodes[plantedEnb].Get (ue)->GetObject<BuildingsMobilityModel> (); |
2228db567a14
Update lena-runtime-profiler with buildings initialization
Marco Miozzo <marco.miozzo@cttc.es>
parents:
8266
diff
changeset
|
174 |
Vector vUe (v.x, v.y, v.z); |
2228db567a14
Update lena-runtime-profiler with buildings initialization
Marco Miozzo <marco.miozzo@cttc.es>
parents:
8266
diff
changeset
|
175 |
mmUe->SetPosition (vUe); |
2228db567a14
Update lena-runtime-profiler with buildings initialization
Marco Miozzo <marco.miozzo@cttc.es>
parents:
8266
diff
changeset
|
176 |
mmUe->SetIndoor (building); |
2228db567a14
Update lena-runtime-profiler with buildings initialization
Marco Miozzo <marco.miozzo@cttc.es>
parents:
8266
diff
changeset
|
177 |
mmUe->SetFloorNumber (floor); |
2228db567a14
Update lena-runtime-profiler with buildings initialization
Marco Miozzo <marco.miozzo@cttc.es>
parents:
8266
diff
changeset
|
178 |
mmUe->SetRoomNumberX (row); |
2228db567a14
Update lena-runtime-profiler with buildings initialization
Marco Miozzo <marco.miozzo@cttc.es>
parents:
8266
diff
changeset
|
179 |
mmUe->SetRoomNumberY (column); |
2228db567a14
Update lena-runtime-profiler with buildings initialization
Marco Miozzo <marco.miozzo@cttc.es>
parents:
8266
diff
changeset
|
180 |
} |
8261 | 181 |
} |
182 |
} |
|
183 |
} |
|
8268
2228db567a14
Update lena-runtime-profiler with buildings initialization
Marco Miozzo <marco.miozzo@cttc.es>
parents:
8266
diff
changeset
|
184 |
|
8261 | 185 |
|
186 |
} |
|
187 |
||
8315
2c49ce1438a5
Fixed bug in positioning the UEs for the Friis propagation model
root@pc125
parents:
8268
diff
changeset
|
188 |
|
8261 | 189 |
|
190 |
||
191 |
// Create Devices and install them in the Nodes (eNB and UE) |
|
192 |
NetDeviceContainer enbDevs; |
|
193 |
vector < NetDeviceContainer > ueDevs; |
|
8460
fbb53bda0ec7
renamed LenaHelper --> LteHelper
Nicola Baldo <nbaldo@cttc.es>
parents:
8429
diff
changeset
|
194 |
enbDevs = lteHelper->InstallEnbDevice(enbNodes); |
8261 | 195 |
for (uint32_t i = 0; i < nEnb; i++) |
196 |
{ |
|
8460
fbb53bda0ec7
renamed LenaHelper --> LteHelper
Nicola Baldo <nbaldo@cttc.es>
parents:
8429
diff
changeset
|
197 |
NetDeviceContainer ueDev = lteHelper->InstallUeDevice(ueNodes[i]); |
8261 | 198 |
ueDevs.push_back(ueDev); |
8460
fbb53bda0ec7
renamed LenaHelper --> LteHelper
Nicola Baldo <nbaldo@cttc.es>
parents:
8429
diff
changeset
|
199 |
lteHelper->Attach(ueDev, enbDevs.Get(i)); |
8261 | 200 |
enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; |
201 |
EpsBearer bearer(q); |
|
8463 | 202 |
lteHelper->ActivateEpsBearer(ueDev, bearer, EpcTft::Default ()); |
8261 | 203 |
} |
204 |
||
205 |
Simulator::Stop(Seconds(simTime)); |
|
8460
fbb53bda0ec7
renamed LenaHelper --> LteHelper
Nicola Baldo <nbaldo@cttc.es>
parents:
8429
diff
changeset
|
206 |
lteHelper->SetTraceDirectory(traceDirectory); |
fbb53bda0ec7
renamed LenaHelper --> LteHelper
Nicola Baldo <nbaldo@cttc.es>
parents:
8429
diff
changeset
|
207 |
lteHelper->EnableRlcTraces(); |
fbb53bda0ec7
renamed LenaHelper --> LteHelper
Nicola Baldo <nbaldo@cttc.es>
parents:
8429
diff
changeset
|
208 |
lteHelper->EnableMacTraces(); |
8261 | 209 |
|
210 |
Simulator::Run(); |
|
211 |
||
8331
1823cde6f40b
Removed GTK pop up on example script. Set values for profiling script to the standard ones
Jaume Nin
parents:
8330
diff
changeset
|
212 |
/*GtkConfigStore config; |
1823cde6f40b
Removed GTK pop up on example script. Set values for profiling script to the standard ones
Jaume Nin
parents:
8330
diff
changeset
|
213 |
config.ConfigureAttributes ();*/ |
8261 | 214 |
|
215 |
Simulator::Destroy(); |
|
216 |
return 0; |
|
217 |
} |