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 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Jaume Nin <jnin@cttc.es>
7 */
8
9#include "ns3/buildings-helper.h"
10#include "ns3/buildings-propagation-loss-model.h"
11#include "ns3/config-store.h"
12#include "ns3/core-module.h"
13#include "ns3/lte-module.h"
14#include "ns3/mobility-module.h"
15#include "ns3/network-module.h"
16#include "ns3/radio-environment-map-helper.h"
17
18#include <iomanip>
19#include <string>
20#include <vector>
21// #include "ns3/gtk-config-store.h"
22
23using namespace ns3;
24
25int
26main(int argc, char* argv[])
27{
28 CommandLine cmd(__FILE__);
29 cmd.Parse(argc, argv);
30
31 ConfigStore inputConfig;
32 inputConfig.ConfigureDefaults();
33
34 cmd.Parse(argc, argv);
35
36 // Geometry of the scenario (in meters)
37 // Assume squared building
38 double nodeHeight = 1.5;
39 double roomHeight = 3;
40 double roomLength = 500;
41 uint32_t nRooms = 2;
42 // Create one eNodeB per room + one 3 sector eNodeB (i.e. 3 eNodeB) + one regular eNodeB
43 uint32_t nEnb = nRooms * nRooms + 4;
44 uint32_t nUe = 1;
45
47 // lteHelper->EnableLogComponents ();
48 lteHelper->SetAttribute("PathlossModel", StringValue("ns3::FriisPropagationLossModel"));
49
50 // Create Nodes: eNodeB and UE
51 NodeContainer enbNodes;
52 NodeContainer oneSectorNodes;
53 NodeContainer threeSectorNodes;
54 std::vector<NodeContainer> ueNodes;
55
56 oneSectorNodes.Create(nEnb - 3);
57 threeSectorNodes.Create(3);
58
59 enbNodes.Add(oneSectorNodes);
60 enbNodes.Add(threeSectorNodes);
61
62 for (uint32_t i = 0; i < nEnb; i++)
63 {
64 NodeContainer ueNode;
65 ueNode.Create(nUe);
66 ueNodes.push_back(ueNode);
67 }
68
70 std::vector<Vector> enbPosition;
72 Ptr<Building> building;
73 building = Create<Building>();
74 building->SetBoundaries(
75 Box(0.0, nRooms * roomLength, 0.0, nRooms * roomLength, 0.0, roomHeight));
76 building->SetBuildingType(Building::Residential);
77 building->SetExtWallsType(Building::ConcreteWithWindows);
78 building->SetNFloors(1);
79 building->SetNRoomsX(nRooms);
80 building->SetNRoomsY(nRooms);
81 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
82 mobility.Install(enbNodes);
84 uint32_t plantedEnb = 0;
85 for (uint32_t row = 0; row < nRooms; row++)
86 {
87 for (uint32_t column = 0; column < nRooms; column++, plantedEnb++)
88 {
89 Vector v(roomLength * (column + 0.5), roomLength * (row + 0.5), nodeHeight);
90 positionAlloc->Add(v);
91 enbPosition.push_back(v);
92 Ptr<MobilityModel> mmEnb = enbNodes.Get(plantedEnb)->GetObject<MobilityModel>();
93 mmEnb->SetPosition(v);
94 }
95 }
96
97 // Add a 1-sector site
98 Vector v(500, 3000, nodeHeight);
99 positionAlloc->Add(v);
100 enbPosition.push_back(v);
101 mobility.Install(ueNodes.at(plantedEnb));
102 plantedEnb++;
103
104 // Add the 3-sector site
105 for (uint32_t index = 0; index < 3; index++, plantedEnb++)
106 {
107 Vector v(500, 2000, 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
116 // Position of UEs attached to eNB
117 for (uint32_t i = 0; i < nEnb; i++)
118 {
120 posX->SetAttribute("Min", DoubleValue(enbPosition.at(i).x - roomLength * 0));
121 posX->SetAttribute("Max", DoubleValue(enbPosition.at(i).x + roomLength * 0));
123 posY->SetAttribute("Min", DoubleValue(enbPosition.at(i).y - roomLength * 0));
124 posY->SetAttribute("Max", DoubleValue(enbPosition.at(i).y + roomLength * 0));
125 positionAlloc = CreateObject<ListPositionAllocator>();
126 for (uint32_t j = 0; j < nUe; j++)
127 {
128 if (i == nEnb - 3)
129 {
130 positionAlloc->Add(
131 Vector(enbPosition.at(i).x + 10, enbPosition.at(i).y, nodeHeight));
132 }
133 else if (i == nEnb - 2)
134 {
135 positionAlloc->Add(Vector(enbPosition.at(i).x - std::sqrt(10),
136 enbPosition.at(i).y + std::sqrt(10),
137 nodeHeight));
138 }
139 else if (i == nEnb - 1)
140 {
141 positionAlloc->Add(Vector(enbPosition.at(i).x - std::sqrt(10),
142 enbPosition.at(i).y - std::sqrt(10),
143 nodeHeight));
144 }
145 else
146 {
147 positionAlloc->Add(Vector(posX->GetValue(), posY->GetValue(), nodeHeight));
148 }
149 mobility.SetPositionAllocator(positionAlloc);
150 }
151 mobility.Install(ueNodes.at(i));
152 BuildingsHelper::Install(ueNodes.at(i));
153 }
154
155 // Create Devices and install them in the Nodes (eNB and UE)
156 NetDeviceContainer enbDevs;
157 std::vector<NetDeviceContainer> ueDevs;
158
159 // power setting in dBm for small cells
160 Config::SetDefault("ns3::LteEnbPhy::TxPower", DoubleValue(20.0));
161 enbDevs = lteHelper->InstallEnbDevice(oneSectorNodes);
162
163 // power setting for three-sector macrocell
164 Config::SetDefault("ns3::LteEnbPhy::TxPower", DoubleValue(43.0));
165
166 // Beam width is made quite narrow so sectors can be noticed in the REM
167 lteHelper->SetEnbAntennaModelType("ns3::CosineAntennaModel");
168 lteHelper->SetEnbAntennaModelAttribute("Orientation", DoubleValue(0));
169 lteHelper->SetEnbAntennaModelAttribute("HorizontalBeamwidth", DoubleValue(100));
170 lteHelper->SetEnbAntennaModelAttribute("MaxGain", DoubleValue(0.0));
171 enbDevs.Add(lteHelper->InstallEnbDevice(threeSectorNodes.Get(0)));
172
173 lteHelper->SetEnbAntennaModelType("ns3::CosineAntennaModel");
174 lteHelper->SetEnbAntennaModelAttribute("Orientation", DoubleValue(360 / 3));
175 lteHelper->SetEnbAntennaModelAttribute("HorizontalBeamwidth", DoubleValue(100));
176 lteHelper->SetEnbAntennaModelAttribute("MaxGain", DoubleValue(0.0));
177 enbDevs.Add(lteHelper->InstallEnbDevice(threeSectorNodes.Get(1)));
178
179 lteHelper->SetEnbAntennaModelType("ns3::CosineAntennaModel");
180 lteHelper->SetEnbAntennaModelAttribute("Orientation", DoubleValue(2 * 360 / 3));
181 lteHelper->SetEnbAntennaModelAttribute("HorizontalBeamwidth", DoubleValue(100));
182 lteHelper->SetEnbAntennaModelAttribute("MaxGain", DoubleValue(0.0));
183 enbDevs.Add(lteHelper->InstallEnbDevice(threeSectorNodes.Get(2)));
184
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));
191 EpsBearer bearer(q);
192 lteHelper->ActivateDataRadioBearer(ueDev, bearer);
193 }
194
195 // by default, simulation will anyway stop right after the REM has been generated
196 Simulator::Stop(Seconds(0.0069));
197
199 remHelper->SetAttribute("ChannelPath", StringValue("/ChannelList/0"));
200 remHelper->SetAttribute("OutputFile", StringValue("rem.out"));
201 remHelper->SetAttribute("XMin", DoubleValue(-2000.0));
202 remHelper->SetAttribute("XMax", DoubleValue(+2000.0));
203 remHelper->SetAttribute("YMin", DoubleValue(-500.0));
204 remHelper->SetAttribute("YMax", DoubleValue(+3500.0));
205 remHelper->SetAttribute("Z", DoubleValue(1.5));
206 remHelper->Install();
207
209
210 // GtkConfigStore config;
211 // config.ConfigureAttributes ();
212
213 lteHelper = nullptr;
215 return 0;
216}
a 3d box
Definition box.h:24
@ ConcreteWithWindows
Definition building.h:58
static void Install(Ptr< Node > node)
Install the MobilityBuildingInfo to a node.
Parse command-line arguments.
Introspection did not find any typical Config paths.
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:31
This class contains the specification of EPS Bearers.
Definition eps-bearer.h:80
Qci
QoS Class Indicator.
Definition eps-bearer.h:95
@ GBR_CONV_VOICE
GBR Conversational Voice.
Definition eps-bearer.h:96
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:511
Smart pointer class similar to boost::intrusive_ptr.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition simulator.cc:131
static void Run()
Run the simulation.
Definition simulator.cc:167
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Definition simulator.cc:175
Hold variables of type string.
Definition string.h:45
void SetDefault(std::string name, const AttributeValue &value)
Definition config.cc:886
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition object.h:619
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Definition ptr.h:436
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition nstime.h:1345
Every class exported by the ns3 library is enclosed in the ns3 namespace.
mobility
Definition third.py:92