A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
lena-rem-sector-antenna.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-helper.h>
26#include <ns3/buildings-propagation-loss-model.h>
27#include <ns3/radio-environment-map-helper.h>
28
29#include <iomanip>
30#include <string>
31#include <vector>
32// #include "ns3/gtk-config-store.h"
33
34using namespace ns3;
35
36int
37main(int argc, char* argv[])
38{
39 CommandLine cmd(__FILE__);
40 cmd.Parse(argc, argv);
41
42 ConfigStore inputConfig;
43 inputConfig.ConfigureDefaults();
44
45 cmd.Parse(argc, argv);
46
47 // Geometry of the scenario (in meters)
48 // Assume squared building
49 double nodeHeight = 1.5;
50 double roomHeight = 3;
51 double roomLength = 500;
52 uint32_t nRooms = 2;
53 // Create one eNodeB per room + one 3 sector eNodeB (i.e. 3 eNodeB) + one regular eNodeB
54 uint32_t nEnb = nRooms * nRooms + 4;
55 uint32_t nUe = 1;
56
57 Ptr<LteHelper> lteHelper = CreateObject<LteHelper>();
58 // lteHelper->EnableLogComponents ();
59 lteHelper->SetAttribute("PathlossModel", StringValue("ns3::FriisPropagationLossModel"));
60
61 // Create Nodes: eNodeB and UE
62 NodeContainer enbNodes;
63 NodeContainer oneSectorNodes;
64 NodeContainer threeSectorNodes;
65 std::vector<NodeContainer> ueNodes;
66
67 oneSectorNodes.Create(nEnb - 3);
68 threeSectorNodes.Create(3);
69
70 enbNodes.Add(oneSectorNodes);
71 enbNodes.Add(threeSectorNodes);
72
73 for (uint32_t i = 0; i < nEnb; i++)
74 {
75 NodeContainer ueNode;
76 ueNode.Create(nUe);
77 ueNodes.push_back(ueNode);
78 }
79
81 std::vector<Vector> enbPosition;
82 Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator>();
83 Ptr<Building> building;
84 building = Create<Building>();
85 building->SetBoundaries(
86 Box(0.0, nRooms * roomLength, 0.0, nRooms * roomLength, 0.0, roomHeight));
87 building->SetBuildingType(Building::Residential);
88 building->SetExtWallsType(Building::ConcreteWithWindows);
89 building->SetNFloors(1);
90 building->SetNRoomsX(nRooms);
91 building->SetNRoomsY(nRooms);
92 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
93 mobility.Install(enbNodes);
95 uint32_t plantedEnb = 0;
96 for (uint32_t row = 0; row < nRooms; row++)
97 {
98 for (uint32_t column = 0; column < nRooms; column++, plantedEnb++)
99 {
100 Vector v(roomLength * (column + 0.5), roomLength * (row + 0.5), nodeHeight);
101 positionAlloc->Add(v);
102 enbPosition.push_back(v);
103 Ptr<MobilityModel> mmEnb = enbNodes.Get(plantedEnb)->GetObject<MobilityModel>();
104 mmEnb->SetPosition(v);
105 }
106 }
107
108 // Add a 1-sector site
109 Vector v(500, 3000, nodeHeight);
110 positionAlloc->Add(v);
111 enbPosition.push_back(v);
112 mobility.Install(ueNodes.at(plantedEnb));
113 plantedEnb++;
114
115 // Add the 3-sector site
116 for (uint32_t index = 0; index < 3; index++, plantedEnb++)
117 {
118 Vector v(500, 2000, nodeHeight);
119 positionAlloc->Add(v);
120 enbPosition.push_back(v);
121 mobility.Install(ueNodes.at(plantedEnb));
122 }
123
124 mobility.SetPositionAllocator(positionAlloc);
125 mobility.Install(enbNodes);
126
127 // Position of UEs attached to eNB
128 for (uint32_t i = 0; i < nEnb; i++)
129 {
130 Ptr<UniformRandomVariable> posX = CreateObject<UniformRandomVariable>();
131 posX->SetAttribute("Min", DoubleValue(enbPosition.at(i).x - roomLength * 0));
132 posX->SetAttribute("Max", DoubleValue(enbPosition.at(i).x + roomLength * 0));
133 Ptr<UniformRandomVariable> posY = CreateObject<UniformRandomVariable>();
134 posY->SetAttribute("Min", DoubleValue(enbPosition.at(i).y - roomLength * 0));
135 posY->SetAttribute("Max", DoubleValue(enbPosition.at(i).y + roomLength * 0));
136 positionAlloc = CreateObject<ListPositionAllocator>();
137 for (uint32_t j = 0; j < nUe; j++)
138 {
139 if (i == nEnb - 3)
140 {
141 positionAlloc->Add(
142 Vector(enbPosition.at(i).x + 10, enbPosition.at(i).y, nodeHeight));
143 }
144 else if (i == nEnb - 2)
145 {
146 positionAlloc->Add(Vector(enbPosition.at(i).x - std::sqrt(10),
147 enbPosition.at(i).y + std::sqrt(10),
148 nodeHeight));
149 }
150 else if (i == nEnb - 1)
151 {
152 positionAlloc->Add(Vector(enbPosition.at(i).x - std::sqrt(10),
153 enbPosition.at(i).y - std::sqrt(10),
154 nodeHeight));
155 }
156 else
157 {
158 positionAlloc->Add(Vector(posX->GetValue(), posY->GetValue(), nodeHeight));
159 }
160 mobility.SetPositionAllocator(positionAlloc);
161 }
162 mobility.Install(ueNodes.at(i));
163 BuildingsHelper::Install(ueNodes.at(i));
164 }
165
166 // Create Devices and install them in the Nodes (eNB and UE)
167 NetDeviceContainer enbDevs;
168 std::vector<NetDeviceContainer> ueDevs;
169
170 // power setting in dBm for small cells
171 Config::SetDefault("ns3::LteEnbPhy::TxPower", DoubleValue(20.0));
172 enbDevs = lteHelper->InstallEnbDevice(oneSectorNodes);
173
174 // power setting for three-sector macrocell
175 Config::SetDefault("ns3::LteEnbPhy::TxPower", DoubleValue(43.0));
176
177 // Beam width is made quite narrow so sectors can be noticed in the REM
178 lteHelper->SetEnbAntennaModelType("ns3::CosineAntennaModel");
179 lteHelper->SetEnbAntennaModelAttribute("Orientation", DoubleValue(0));
180 lteHelper->SetEnbAntennaModelAttribute("HorizontalBeamwidth", DoubleValue(100));
181 lteHelper->SetEnbAntennaModelAttribute("MaxGain", DoubleValue(0.0));
182 enbDevs.Add(lteHelper->InstallEnbDevice(threeSectorNodes.Get(0)));
183
184 lteHelper->SetEnbAntennaModelType("ns3::CosineAntennaModel");
185 lteHelper->SetEnbAntennaModelAttribute("Orientation", DoubleValue(360 / 3));
186 lteHelper->SetEnbAntennaModelAttribute("HorizontalBeamwidth", DoubleValue(100));
187 lteHelper->SetEnbAntennaModelAttribute("MaxGain", DoubleValue(0.0));
188 enbDevs.Add(lteHelper->InstallEnbDevice(threeSectorNodes.Get(1)));
189
190 lteHelper->SetEnbAntennaModelType("ns3::CosineAntennaModel");
191 lteHelper->SetEnbAntennaModelAttribute("Orientation", DoubleValue(2 * 360 / 3));
192 lteHelper->SetEnbAntennaModelAttribute("HorizontalBeamwidth", DoubleValue(100));
193 lteHelper->SetEnbAntennaModelAttribute("MaxGain", DoubleValue(0.0));
194 enbDevs.Add(lteHelper->InstallEnbDevice(threeSectorNodes.Get(2)));
195
196 for (uint32_t i = 0; i < nEnb; i++)
197 {
198 NetDeviceContainer ueDev = lteHelper->InstallUeDevice(ueNodes.at(i));
199 ueDevs.push_back(ueDev);
200 lteHelper->Attach(ueDev, enbDevs.Get(i));
202 EpsBearer bearer(q);
203 lteHelper->ActivateDataRadioBearer(ueDev, bearer);
204 }
205
206 // by default, simulation will anyway stop right after the REM has been generated
207 Simulator::Stop(Seconds(0.0069));
208
209 Ptr<RadioEnvironmentMapHelper> remHelper = CreateObject<RadioEnvironmentMapHelper>();
210 remHelper->SetAttribute("ChannelPath", StringValue("/ChannelList/0"));
211 remHelper->SetAttribute("OutputFile", StringValue("rem.out"));
212 remHelper->SetAttribute("XMin", DoubleValue(-2000.0));
213 remHelper->SetAttribute("XMax", DoubleValue(+2000.0));
214 remHelper->SetAttribute("YMin", DoubleValue(-500.0));
215 remHelper->SetAttribute("YMax", DoubleValue(+3500.0));
216 remHelper->SetAttribute("Z", DoubleValue(1.5));
217 remHelper->Install();
218
220
221 // GtkConfigStore config;
222 // config.ConfigureAttributes ();
223
224 lteHelper = nullptr;
226 return 0;
227}
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
void Add(NetDeviceContainer other)
Append the contents of another NetDeviceContainer to the end of this container.
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.
void Add(const NodeContainer &nc)
Append the contents of another NodeContainer to the end of this container.
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
void SetDefault(std::string name, const AttributeValue &value)
Definition: config.cc:894
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