A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
lte-hex-grid-enb-topology-helper.cc
Go to the documentation of this file.
1/*
2 * Copyright 2012 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Nicola Baldo <nbaldo@cttc.es>
7 */
8
10
11#include "epc-helper.h"
12
13#include "ns3/abort.h"
14#include "ns3/double.h"
15#include "ns3/hexagonal-wraparound-model.h"
16#include "ns3/log.h"
17#include "ns3/pointer.h"
18
19#include <iostream>
20
21namespace ns3
22{
23
24NS_LOG_COMPONENT_DEFINE("LteHexGridEnbTopologyHelper");
25
27
32
37
40{
41 static TypeId tid =
42 TypeId("ns3::LteHexGridEnbTopologyHelper")
44 .AddConstructor<LteHexGridEnbTopologyHelper>()
45 .AddAttribute("InterSiteDistance",
46 "The distance [m] between nearby sites",
47 DoubleValue(500),
50 .AddAttribute("SectorOffset",
51 "The offset [m] in the position for the node of each sector with respect "
52 "to the center of the three-sector site",
53 DoubleValue(0.5),
56 .AddAttribute("SiteHeight",
57 "The height [m] of each site",
58 DoubleValue(30),
61 .AddAttribute("MinX",
62 "The x coordinate where the hex grid starts.",
63 DoubleValue(0.0),
66 .AddAttribute("MinY",
67 "The y coordinate where the hex grid starts.",
68 DoubleValue(0.0),
71 .AddAttribute(
72 "GridWidth",
73 "The number of sites in even rows (odd rows will have one additional site).",
77 .AddAttribute("EnableWraparound",
78 "Enable hexagonal wraparound model.",
79 BooleanValue(false),
82 return tid;
83}
84
85void
91
92void
98
101{
102 NS_LOG_FUNCTION(this);
103 NetDeviceContainer enbDevs;
104 Ptr<HexagonalWraparoundModel> wraparoundModel;
106 {
107 wraparoundModel = CreateObject<HexagonalWraparoundModel>();
108 wraparoundModel->SetSiteDistance(m_d);
109 wraparoundModel->SetNumSites(c.GetN() / 3);
110 }
111 const double xydfactor = std::sqrt(0.75);
112 double yd = xydfactor * m_d;
113 for (uint32_t n = 0; n < c.GetN(); ++n)
114 {
115 uint32_t currentSite = n / 3;
116 uint32_t biRowIndex = (currentSite / (m_gridWidth + m_gridWidth + 1));
117 uint32_t biRowRemainder = currentSite % (m_gridWidth + m_gridWidth + 1);
118 uint32_t rowIndex = biRowIndex * 2;
119 uint32_t colIndex = biRowRemainder;
120 if (biRowRemainder >= m_gridWidth)
121 {
122 ++rowIndex;
123 colIndex -= m_gridWidth;
124 }
125 NS_LOG_LOGIC("node " << n << " site " << currentSite << " rowIndex " << rowIndex
126 << " colIndex " << colIndex << " biRowIndex " << biRowIndex
127 << " biRowRemainder " << biRowRemainder);
128 double y = m_yMin + yd * rowIndex;
129 double x;
130 double antennaOrientation;
131 if ((rowIndex % 2) == 0)
132 {
133 x = m_xMin + m_d * colIndex;
134 }
135 else // row is odd
136 {
137 x = m_xMin - (0.5 * m_d) + m_d * colIndex;
138 }
139
140 switch (n % 3)
141 {
142 case 0:
143 antennaOrientation = 0;
144 x += m_offset;
145 m_lteHelper->SetFfrAlgorithmAttribute("FrCellTypeId", UintegerValue(1));
146 break;
147
148 case 1:
149 antennaOrientation = 120;
150 x -= m_offset / 2.0;
151 y += m_offset * xydfactor;
152 m_lteHelper->SetFfrAlgorithmAttribute("FrCellTypeId", UintegerValue(2));
153 break;
154
155 case 2:
156 antennaOrientation = -120;
157 x -= m_offset / 2.0;
158 y -= m_offset * xydfactor;
159 m_lteHelper->SetFfrAlgorithmAttribute("FrCellTypeId", UintegerValue(3));
160 break;
161
162 // no default, n%3 = 0, 1, 2
163 }
164 Ptr<Node> node = c.Get(n);
165 Ptr<MobilityModel> mm = node->GetObject<MobilityModel>();
166 Vector pos(x, y, m_siteHeight);
167 NS_LOG_LOGIC("node " << n << " at " << pos << " antennaOrientation " << antennaOrientation);
168 mm->SetPosition(Vector(x, y, m_siteHeight));
169 m_lteHelper->SetEnbAntennaModelAttribute("Orientation", DoubleValue(antennaOrientation));
170 enbDevs.Add(m_lteHelper->InstallEnbDevice(node));
171 if (m_installWraparound && (n % 3 == 0))
172 {
173 wraparoundModel->AddSitePosition(mm->GetPosition());
174 }
175 }
177 {
178 m_wraparoundModel = wraparoundModel;
179 }
180 return enbDevs;
181}
182
188
189} // namespace ns3
AttributeValue implementation for Boolean.
Definition boolean.h:26
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition double.h:31
This helper class allows to easily create a topology with eNBs grouped in three-sector sites laid out...
void DoDispose() override
Destructor implementation.
bool m_installWraparound
Boolean flag indicating whether to install or not wraparound model.
static TypeId GetTypeId()
Register this type.
double m_d
The distance [m] between nearby sites.
Ptr< WraparoundModel > GetWraparoundModel() const
Get the configured wraparound model.
double m_xMin
The x coordinate where the hex grid starts.
Ptr< LteHelper > m_lteHelper
Pointer to LteHelper object.
double m_yMin
The y coordinate where the hex grid starts.
uint32_t m_gridWidth
The number of sites in even rows (odd rows will have one additional site)
NetDeviceContainer SetPositionAndInstallEnbDevice(NodeContainer c)
Position the nodes on a hex grid and install the corresponding EnbNetDevices with antenna boresight c...
double m_offset
The offset [m] in the position for the node of each sector with respect to the center of the three-se...
void SetLteHelper(Ptr< LteHelper > h)
Set the LteHelper to be used to actually create the EnbNetDevices.
uint32_t m_siteHeight
The height [m] of each site.
Ptr< WraparoundModel > m_wraparoundModel
Wraparound model pointer.
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.
keep track of a set of node pointers.
uint32_t GetN() const
Get the number of Ptr<Node> stored in this container.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
Object()
Constructor.
Definition object.cc:96
virtual void DoDispose()
Destructor implementation.
Definition object.cc:433
Smart pointer class similar to boost::intrusive_ptr.
Definition ptr.h:67
a unique identifier for an interface.
Definition type-id.h:49
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
Hold an unsigned integer type.
Definition uinteger.h:34
Ptr< const AttributeChecker > MakeBooleanChecker()
Definition boolean.cc:114
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Definition boolean.h:70
Ptr< const AttributeChecker > MakeDoubleChecker()
Definition double.h:82
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Definition double.h:32
Ptr< const AttributeChecker > MakeUintegerChecker()
Definition uinteger.h:85
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Definition uinteger.h:35
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition log.h:271
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition object.h:619
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition object-base.h:35
Every class exported by the ns3 library is enclosed in the ns3 namespace.