author | Vedran Mileti? <rivanvx@gmail.com> |
Sat, 01 Sep 2012 20:57:21 +0200 | |
changeset 9063 | 32755d0516f4 |
parent 8996 | d0e0a162a990 |
child 9653 | 382d27da8905 |
permissions | -rw-r--r-- |
8564 | 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-propagation-loss-model.h> |
|
27 |
#include <ns3/buildings-helper.h> |
|
28 |
#include <ns3/radio-environment-map-helper.h> |
|
29 |
#include <iomanip> |
|
30 |
#include <string> |
|
31 |
#include <vector> |
|
8686 | 32 |
//#include "ns3/gtk-config-store.h" |
8564 | 33 |
|
34 |
using namespace ns3; |
|
35 |
using std::vector; |
|
36 |
||
37 |
int |
|
38 |
main (int argc, char *argv[]) |
|
39 |
{ |
|
40 |
CommandLine cmd; |
|
41 |
cmd.Parse (argc, argv); |
|
42 |
||
43 |
ConfigStore inputConfig; |
|
44 |
inputConfig.ConfigureDefaults (); |
|
45 |
||
46 |
cmd.Parse (argc, argv); |
|
47 |
||
48 |
// Geometry of the scenario (in meters) |
|
49 |
// Assume squared building |
|
50 |
double nodeHeight = 1.5; |
|
51 |
double roomHeight = 3; |
|
52 |
double roomLength = 500; |
|
53 |
uint32_t nRooms = 2; |
|
54 |
// Create one eNodeB per room + one 3 sector eNodeB (i.e. 3 eNodeB) + one regular eNodeB |
|
55 |
uint32_t nEnb = nRooms*nRooms + 4; |
|
56 |
uint32_t nUe = 1; |
|
57 |
||
58 |
Ptr < LteHelper > lteHelper = CreateObject<LteHelper> (); |
|
59 |
//lteHelper->EnableLogComponents (); |
|
8601
105d17d0138b
Replaced access to vector, using .at() instead of []
Jaume Nin
parents:
8581
diff
changeset
|
60 |
lteHelper->SetAttribute ("PathlossModel", StringValue ("ns3::FriisPropagationLossModel")); |
8564 | 61 |
|
62 |
// Create Nodes: eNodeB and UE |
|
63 |
NodeContainer enbNodes; |
|
64 |
NodeContainer oneSectorNodes; |
|
65 |
NodeContainer threeSectorNodes; |
|
66 |
vector < NodeContainer > ueNodes; |
|
67 |
||
68 |
oneSectorNodes.Create (nEnb-3); |
|
69 |
threeSectorNodes.Create (3); |
|
70 |
||
71 |
enbNodes.Add (oneSectorNodes); |
|
72 |
enbNodes.Add (threeSectorNodes); |
|
73 |
||
74 |
for (uint32_t i = 0; i < nEnb; i++) |
|
75 |
{ |
|
76 |
NodeContainer ueNode; |
|
77 |
ueNode.Create (nUe); |
|
78 |
ueNodes.push_back (ueNode); |
|
79 |
} |
|
80 |
||
81 |
MobilityHelper mobility; |
|
82 |
vector<Vector> enbPosition; |
|
83 |
Ptr < ListPositionAllocator > positionAlloc = CreateObject<ListPositionAllocator> (); |
|
84 |
Ptr < Building > building; |
|
8659
01b04e9fbee5
fixed bug in lena-rem-sector-antenna
Nicola Baldo <nbaldo@cttc.es>
parents:
8652
diff
changeset
|
85 |
building = Create<Building> (); |
01b04e9fbee5
fixed bug in lena-rem-sector-antenna
Nicola Baldo <nbaldo@cttc.es>
parents:
8652
diff
changeset
|
86 |
building->SetBoundaries (Box (0.0, nRooms * roomLength, |
01b04e9fbee5
fixed bug in lena-rem-sector-antenna
Nicola Baldo <nbaldo@cttc.es>
parents:
8652
diff
changeset
|
87 |
0.0, nRooms * roomLength, |
01b04e9fbee5
fixed bug in lena-rem-sector-antenna
Nicola Baldo <nbaldo@cttc.es>
parents:
8652
diff
changeset
|
88 |
0.0, roomHeight)); |
8564 | 89 |
building->SetBuildingType (Building::Residential); |
90 |
building->SetExtWallsType (Building::ConcreteWithWindows); |
|
8567 | 91 |
building->SetNFloors (1); |
8564 | 92 |
building->SetNRoomsX (nRooms); |
93 |
building->SetNRoomsY (nRooms); |
|
94 |
mobility.SetMobilityModel ("ns3::BuildingsMobilityModel"); |
|
95 |
mobility.Install (enbNodes); |
|
96 |
uint32_t plantedEnb = 0; |
|
97 |
for (uint32_t row = 0; row < nRooms; row++) |
|
98 |
{ |
|
99 |
for (uint32_t column = 0; column < nRooms; column++, plantedEnb++) |
|
100 |
{ |
|
101 |
Vector v (roomLength * (column + 0.5), |
|
102 |
roomLength * (row + 0.5), |
|
103 |
nodeHeight ); |
|
104 |
positionAlloc->Add (v); |
|
105 |
enbPosition.push_back (v); |
|
106 |
Ptr<BuildingsMobilityModel> mmEnb = enbNodes.Get (plantedEnb)->GetObject<BuildingsMobilityModel> (); |
|
107 |
mmEnb->SetPosition (v); |
|
108 |
} |
|
109 |
} |
|
110 |
||
111 |
// Add a 1-sector site |
|
112 |
Vector v (500, 3000, nodeHeight); |
|
113 |
positionAlloc->Add (v); |
|
114 |
enbPosition.push_back (v); |
|
8601
105d17d0138b
Replaced access to vector, using .at() instead of []
Jaume Nin
parents:
8581
diff
changeset
|
115 |
mobility.Install (ueNodes.at(plantedEnb)); |
8564 | 116 |
plantedEnb++; |
117 |
||
118 |
// Add the 3-sector site |
|
119 |
for (uint32_t index = 0; index < 3; index++, plantedEnb++) |
|
120 |
{ |
|
121 |
Vector v (500, 2000, nodeHeight); |
|
122 |
positionAlloc->Add (v); |
|
123 |
enbPosition.push_back (v); |
|
8601
105d17d0138b
Replaced access to vector, using .at() instead of []
Jaume Nin
parents:
8581
diff
changeset
|
124 |
mobility.Install (ueNodes.at(plantedEnb)); |
8564 | 125 |
} |
126 |
||
127 |
||
128 |
mobility.SetPositionAllocator (positionAlloc); |
|
129 |
mobility.Install (enbNodes); |
|
130 |
||
131 |
// Position of UEs attached to eNB |
|
132 |
for (uint32_t i = 0; i < nEnb; i++) |
|
133 |
{ |
|
8996
d0e0a162a990
Replace various instances of RandomVariable with RandomVariableStream
Mitch Watrous
parents:
8787
diff
changeset
|
134 |
Ptr<UniformRandomVariable> posX = CreateObject<UniformRandomVariable> (); |
d0e0a162a990
Replace various instances of RandomVariable with RandomVariableStream
Mitch Watrous
parents:
8787
diff
changeset
|
135 |
posX->SetAttribute ("Min", DoubleValue (enbPosition.at(i).x - roomLength * 0)); |
d0e0a162a990
Replace various instances of RandomVariable with RandomVariableStream
Mitch Watrous
parents:
8787
diff
changeset
|
136 |
posX->SetAttribute ("Max", DoubleValue (enbPosition.at(i).x + roomLength * 0)); |
d0e0a162a990
Replace various instances of RandomVariable with RandomVariableStream
Mitch Watrous
parents:
8787
diff
changeset
|
137 |
Ptr<UniformRandomVariable> posY = CreateObject<UniformRandomVariable> (); |
d0e0a162a990
Replace various instances of RandomVariable with RandomVariableStream
Mitch Watrous
parents:
8787
diff
changeset
|
138 |
posY->SetAttribute ("Min", DoubleValue (enbPosition.at(i).y - roomLength * 0)); |
d0e0a162a990
Replace various instances of RandomVariable with RandomVariableStream
Mitch Watrous
parents:
8787
diff
changeset
|
139 |
posY->SetAttribute ("Max", DoubleValue (enbPosition.at(i).y + roomLength * 0)); |
8564 | 140 |
positionAlloc = CreateObject<ListPositionAllocator> (); |
141 |
for (uint32_t j = 0; j < nUe; j++) |
|
142 |
{ |
|
143 |
if ( i == nEnb - 3 ) |
|
144 |
{ |
|
8601
105d17d0138b
Replaced access to vector, using .at() instead of []
Jaume Nin
parents:
8581
diff
changeset
|
145 |
positionAlloc->Add (Vector (enbPosition.at(i).x + 10, enbPosition.at(i).y, nodeHeight)); |
8564 | 146 |
} |
147 |
else if ( i == nEnb - 2 ) |
|
148 |
{ |
|
9063
32755d0516f4
Bug 1237 - code cleanups related to includes
Vedran Mileti? <rivanvx@gmail.com>
parents:
8996
diff
changeset
|
149 |
positionAlloc->Add (Vector (enbPosition.at(i).x - std::sqrt (10), enbPosition.at(i).y + std::sqrt (10), nodeHeight)); |
8564 | 150 |
} |
151 |
else if ( i == nEnb - 1 ) |
|
152 |
{ |
|
9063
32755d0516f4
Bug 1237 - code cleanups related to includes
Vedran Mileti? <rivanvx@gmail.com>
parents:
8996
diff
changeset
|
153 |
positionAlloc->Add (Vector (enbPosition.at(i).x - std::sqrt (10), enbPosition.at(i).y - std::sqrt (10), nodeHeight)); |
8564 | 154 |
} |
155 |
else |
|
156 |
{ |
|
8996
d0e0a162a990
Replace various instances of RandomVariable with RandomVariableStream
Mitch Watrous
parents:
8787
diff
changeset
|
157 |
positionAlloc->Add (Vector (posX->GetValue (), posY->GetValue (), nodeHeight)); |
8564 | 158 |
} |
159 |
mobility.SetPositionAllocator (positionAlloc); |
|
160 |
} |
|
8601
105d17d0138b
Replaced access to vector, using .at() instead of []
Jaume Nin
parents:
8581
diff
changeset
|
161 |
mobility.Install (ueNodes.at(i)); |
8564 | 162 |
} |
163 |
||
164 |
// Create Devices and install them in the Nodes (eNB and UE) |
|
165 |
NetDeviceContainer enbDevs; |
|
166 |
vector < NetDeviceContainer > ueDevs; |
|
167 |
||
8608
f746bc78007c
more appropriate scenario parameters for lena-rem-sector-antenna
Nicola Baldo <nbaldo@cttc.es>
parents:
8605
diff
changeset
|
168 |
// power setting in dBm for small cells |
8787
e939e081efd5
lena-rem-sector-antenna: more realistic TxPower values
Jonathan McCrohan <jmccroha@tcd.ie>
parents:
8686
diff
changeset
|
169 |
Config::SetDefault ("ns3::LteEnbPhy::TxPower", DoubleValue (20.0)); |
8564 | 170 |
enbDevs = lteHelper->InstallEnbDevice (oneSectorNodes); |
171 |
||
8608
f746bc78007c
more appropriate scenario parameters for lena-rem-sector-antenna
Nicola Baldo <nbaldo@cttc.es>
parents:
8605
diff
changeset
|
172 |
|
f746bc78007c
more appropriate scenario parameters for lena-rem-sector-antenna
Nicola Baldo <nbaldo@cttc.es>
parents:
8605
diff
changeset
|
173 |
// power setting for three-sector macrocell |
8787
e939e081efd5
lena-rem-sector-antenna: more realistic TxPower values
Jonathan McCrohan <jmccroha@tcd.ie>
parents:
8686
diff
changeset
|
174 |
Config::SetDefault ("ns3::LteEnbPhy::TxPower", DoubleValue (43.0)); |
8608
f746bc78007c
more appropriate scenario parameters for lena-rem-sector-antenna
Nicola Baldo <nbaldo@cttc.es>
parents:
8605
diff
changeset
|
175 |
|
8564 | 176 |
// Beam width is made quite narrow so sectors can be noticed in the REM |
177 |
lteHelper->SetEnbAntennaModelType ("ns3::CosineAntennaModel"); |
|
178 |
lteHelper->SetEnbAntennaModelAttribute ("Orientation", DoubleValue (0)); |
|
8608
f746bc78007c
more appropriate scenario parameters for lena-rem-sector-antenna
Nicola Baldo <nbaldo@cttc.es>
parents:
8605
diff
changeset
|
179 |
lteHelper->SetEnbAntennaModelAttribute ("Beamwidth", DoubleValue (100)); |
8564 | 180 |
lteHelper->SetEnbAntennaModelAttribute ("MaxGain", DoubleValue (0.0)); |
181 |
enbDevs.Add ( lteHelper->InstallEnbDevice (threeSectorNodes.Get (0))); |
|
182 |
||
183 |
lteHelper->SetEnbAntennaModelType ("ns3::CosineAntennaModel"); |
|
184 |
lteHelper->SetEnbAntennaModelAttribute ("Orientation", DoubleValue (360/3)); |
|
8608
f746bc78007c
more appropriate scenario parameters for lena-rem-sector-antenna
Nicola Baldo <nbaldo@cttc.es>
parents:
8605
diff
changeset
|
185 |
lteHelper->SetEnbAntennaModelAttribute ("Beamwidth", DoubleValue (100)); |
8564 | 186 |
lteHelper->SetEnbAntennaModelAttribute ("MaxGain", DoubleValue (0.0)); |
187 |
enbDevs.Add ( lteHelper->InstallEnbDevice (threeSectorNodes.Get (1))); |
|
188 |
||
189 |
lteHelper->SetEnbAntennaModelType ("ns3::CosineAntennaModel"); |
|
190 |
lteHelper->SetEnbAntennaModelAttribute ("Orientation", DoubleValue (2*360/3)); |
|
8608
f746bc78007c
more appropriate scenario parameters for lena-rem-sector-antenna
Nicola Baldo <nbaldo@cttc.es>
parents:
8605
diff
changeset
|
191 |
lteHelper->SetEnbAntennaModelAttribute ("Beamwidth", DoubleValue (100)); |
8564 | 192 |
lteHelper->SetEnbAntennaModelAttribute ("MaxGain", DoubleValue (0.0)); |
193 |
enbDevs.Add ( lteHelper->InstallEnbDevice (threeSectorNodes.Get (2))); |
|
194 |
||
195 |
for (uint32_t i = 0; i < nEnb; i++) |
|
196 |
{ |
|
8601
105d17d0138b
Replaced access to vector, using .at() instead of []
Jaume Nin
parents:
8581
diff
changeset
|
197 |
NetDeviceContainer ueDev = lteHelper->InstallUeDevice (ueNodes.at(i)); |
8564 | 198 |
ueDevs.push_back (ueDev); |
199 |
lteHelper->Attach (ueDev, enbDevs.Get (i)); |
|
200 |
enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; |
|
201 |
EpsBearer bearer (q); |
|
202 |
lteHelper->ActivateEpsBearer (ueDev, bearer, EpcTft::Default ()); |
|
203 |
} |
|
204 |
||
8609 | 205 |
|
206 |
BuildingsHelper::MakeMobilityModelConsistent (); |
|
207 |
||
8605
55a01da4a323
REM examples: allow setting resolution via cmd line
Nicola Baldo <nbaldo@cttc.es>
parents:
8601
diff
changeset
|
208 |
// by default, simulation will anyway stop right after the REM has been generated |
55a01da4a323
REM examples: allow setting resolution via cmd line
Nicola Baldo <nbaldo@cttc.es>
parents:
8601
diff
changeset
|
209 |
Simulator::Stop (Seconds (0.0069)); |
8564 | 210 |
|
211 |
Ptr<RadioEnvironmentMapHelper> remHelper = CreateObject<RadioEnvironmentMapHelper> (); |
|
212 |
remHelper->SetAttribute ("ChannelPath", StringValue ("/ChannelList/0")); |
|
213 |
remHelper->SetAttribute ("OutputFile", StringValue ("rem.out")); |
|
8601
105d17d0138b
Replaced access to vector, using .at() instead of []
Jaume Nin
parents:
8581
diff
changeset
|
214 |
remHelper->SetAttribute ("XMin", DoubleValue (-2000.0)); |
105d17d0138b
Replaced access to vector, using .at() instead of []
Jaume Nin
parents:
8581
diff
changeset
|
215 |
remHelper->SetAttribute ("XMax", DoubleValue (+2000.0)); |
105d17d0138b
Replaced access to vector, using .at() instead of []
Jaume Nin
parents:
8581
diff
changeset
|
216 |
remHelper->SetAttribute ("YMin", DoubleValue (-500.0)); |
8564 | 217 |
remHelper->SetAttribute ("YMax", DoubleValue (+3500.0)); |
218 |
remHelper->SetAttribute ("Z", DoubleValue (1.5)); |
|
219 |
remHelper->Install (); |
|
8605
55a01da4a323
REM examples: allow setting resolution via cmd line
Nicola Baldo <nbaldo@cttc.es>
parents:
8601
diff
changeset
|
220 |
|
8564 | 221 |
Simulator::Run (); |
222 |
||
8679
b222f43aba94
Fixed duplicated position set on the rem-sector-antenna simulation script
jaumenin
parents:
8659
diff
changeset
|
223 |
// GtkConfigStore config; |
b222f43aba94
Fixed duplicated position set on the rem-sector-antenna simulation script
jaumenin
parents:
8659
diff
changeset
|
224 |
// config.ConfigureAttributes (); |
8564 | 225 |
|
8605
55a01da4a323
REM examples: allow setting resolution via cmd line
Nicola Baldo <nbaldo@cttc.es>
parents:
8601
diff
changeset
|
226 |
lteHelper = 0; |
8564 | 227 |
Simulator::Destroy (); |
228 |
return 0; |
|
229 |
} |