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/log.h>
16#include <ns3/pointer.h>
17
18#include <iostream>
19
20namespace ns3
21{
22
23NS_LOG_COMPONENT_DEFINE("LteHexGridEnbTopologyHelper");
24
25NS_OBJECT_ENSURE_REGISTERED(LteHexGridEnbTopologyHelper);
26
31
36
39{
40 static TypeId tid =
41 TypeId("ns3::LteHexGridEnbTopologyHelper")
43 .AddConstructor<LteHexGridEnbTopologyHelper>()
44 .AddAttribute("InterSiteDistance",
45 "The distance [m] between nearby sites",
46 DoubleValue(500),
49 .AddAttribute("SectorOffset",
50 "The offset [m] in the position for the node of each sector with respect "
51 "to the center of the three-sector site",
52 DoubleValue(0.5),
55 .AddAttribute("SiteHeight",
56 "The height [m] of each site",
57 DoubleValue(30),
60 .AddAttribute("MinX",
61 "The x coordinate where the hex grid starts.",
62 DoubleValue(0.0),
65 .AddAttribute("MinY",
66 "The y coordinate where the hex grid starts.",
67 DoubleValue(0.0),
70 .AddAttribute(
71 "GridWidth",
72 "The number of sites in even rows (odd rows will have one additional site).",
76 return tid;
77}
78
79void
85
86void
92
95{
96 NS_LOG_FUNCTION(this);
97 NetDeviceContainer enbDevs;
98 const double xydfactor = std::sqrt(0.75);
99 double yd = xydfactor * m_d;
100 for (uint32_t n = 0; n < c.GetN(); ++n)
101 {
102 uint32_t currentSite = n / 3;
103 uint32_t biRowIndex = (currentSite / (m_gridWidth + m_gridWidth + 1));
104 uint32_t biRowRemainder = currentSite % (m_gridWidth + m_gridWidth + 1);
105 uint32_t rowIndex = biRowIndex * 2;
106 uint32_t colIndex = biRowRemainder;
107 if (biRowRemainder >= m_gridWidth)
108 {
109 ++rowIndex;
110 colIndex -= m_gridWidth;
111 }
112 NS_LOG_LOGIC("node " << n << " site " << currentSite << " rowIndex " << rowIndex
113 << " colIndex " << colIndex << " biRowIndex " << biRowIndex
114 << " biRowRemainder " << biRowRemainder);
115 double y = m_yMin + yd * rowIndex;
116 double x;
117 double antennaOrientation;
118 if ((rowIndex % 2) == 0)
119 {
120 x = m_xMin + m_d * colIndex;
121 }
122 else // row is odd
123 {
124 x = m_xMin - (0.5 * m_d) + m_d * colIndex;
125 }
126
127 switch (n % 3)
128 {
129 case 0:
130 antennaOrientation = 0;
131 x += m_offset;
132 m_lteHelper->SetFfrAlgorithmAttribute("FrCellTypeId", UintegerValue(1));
133 break;
134
135 case 1:
136 antennaOrientation = 120;
137 x -= m_offset / 2.0;
138 y += m_offset * xydfactor;
139 m_lteHelper->SetFfrAlgorithmAttribute("FrCellTypeId", UintegerValue(2));
140 break;
141
142 case 2:
143 antennaOrientation = -120;
144 x -= m_offset / 2.0;
145 y -= m_offset * xydfactor;
146 m_lteHelper->SetFfrAlgorithmAttribute("FrCellTypeId", UintegerValue(3));
147 break;
148
149 // no default, n%3 = 0, 1, 2
150 }
151 Ptr<Node> node = c.Get(n);
152 Ptr<MobilityModel> mm = node->GetObject<MobilityModel>();
153 Vector pos(x, y, m_siteHeight);
154 NS_LOG_LOGIC("node " << n << " at " << pos << " antennaOrientation " << antennaOrientation);
155 mm->SetPosition(Vector(x, y, m_siteHeight));
156 m_lteHelper->SetEnbAntennaModelAttribute("Orientation", DoubleValue(antennaOrientation));
157 enbDevs.Add(m_lteHelper->InstallEnbDevice(node));
158 }
159 return enbDevs;
160}
161
162} // namespace ns3
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition double.h:31
void DoDispose() override
Destructor implementation.
static TypeId GetTypeId()
Register this type.
double m_d
The distance [m] between nearby sites.
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.
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.
A base class which provides memory management and object aggregation.
Definition object.h:78
virtual void DoDispose()
Destructor implementation.
Definition object.cc:433
Smart pointer class similar to boost::intrusive_ptr.
a unique identifier for an interface.
Definition type-id.h:48
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
Hold an unsigned integer type.
Definition uinteger.h:34
#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 ",...
#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.
Ptr< const AttributeChecker > MakeUintegerChecker()
Definition uinteger.h:85
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Definition uinteger.h:35
Ptr< const AttributeChecker > MakeDoubleChecker()
Definition double.h:82
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Definition double.h:32