A Discrete-Event Network Simulator
API
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  * 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: Nicola Baldo <nbaldo@cttc.es>
18  */
19 
21 
22 #include <ns3/abort.h>
23 #include <ns3/double.h>
24 #include <ns3/epc-helper.h>
25 #include <ns3/log.h>
26 #include <ns3/pointer.h>
27 
28 #include <iostream>
29 
30 namespace ns3
31 {
32 
33 NS_LOG_COMPONENT_DEFINE("LteHexGridEnbTopologyHelper");
34 
35 NS_OBJECT_ENSURE_REGISTERED(LteHexGridEnbTopologyHelper);
36 
38 {
39  NS_LOG_FUNCTION(this);
40 }
41 
43 {
44  NS_LOG_FUNCTION(this);
45 }
46 
47 TypeId
49 {
50  static TypeId tid =
51  TypeId("ns3::LteHexGridEnbTopologyHelper")
52  .SetParent<Object>()
53  .AddConstructor<LteHexGridEnbTopologyHelper>()
54  .AddAttribute("InterSiteDistance",
55  "The distance [m] between nearby sites",
56  DoubleValue(500),
58  MakeDoubleChecker<double>())
59  .AddAttribute("SectorOffset",
60  "The offset [m] in the position for the node of each sector with respect "
61  "to the center of the three-sector site",
62  DoubleValue(0.5),
64  MakeDoubleChecker<double>())
65  .AddAttribute("SiteHeight",
66  "The height [m] of each site",
67  DoubleValue(30),
69  MakeDoubleChecker<double>())
70  .AddAttribute("MinX",
71  "The x coordinate where the hex grid starts.",
72  DoubleValue(0.0),
74  MakeDoubleChecker<double>())
75  .AddAttribute("MinY",
76  "The y coordinate where the hex grid starts.",
77  DoubleValue(0.0),
79  MakeDoubleChecker<double>())
80  .AddAttribute(
81  "GridWidth",
82  "The number of sites in even rows (odd rows will have one additional site).",
83  UintegerValue(1),
85  MakeUintegerChecker<uint32_t>());
86  return tid;
87 }
88 
89 void
91 {
92  NS_LOG_FUNCTION(this);
94 }
95 
96 void
98 {
99  NS_LOG_FUNCTION(this << h);
100  m_lteHelper = h;
101 }
102 
105 {
106  NS_LOG_FUNCTION(this);
107  NetDeviceContainer enbDevs;
108  const double xydfactor = std::sqrt(0.75);
109  double yd = xydfactor * m_d;
110  for (uint32_t n = 0; n < c.GetN(); ++n)
111  {
112  uint32_t currentSite = n / 3;
113  uint32_t biRowIndex = (currentSite / (m_gridWidth + m_gridWidth + 1));
114  uint32_t biRowRemainder = currentSite % (m_gridWidth + m_gridWidth + 1);
115  uint32_t rowIndex = biRowIndex * 2;
116  uint32_t colIndex = biRowRemainder;
117  if (biRowRemainder >= m_gridWidth)
118  {
119  ++rowIndex;
120  colIndex -= m_gridWidth;
121  }
122  NS_LOG_LOGIC("node " << n << " site " << currentSite << " rowIndex " << rowIndex
123  << " colIndex " << colIndex << " biRowIndex " << biRowIndex
124  << " biRowRemainder " << biRowRemainder);
125  double y = m_yMin + yd * rowIndex;
126  double x;
127  double antennaOrientation;
128  if ((rowIndex % 2) == 0)
129  {
130  x = m_xMin + m_d * colIndex;
131  }
132  else // row is odd
133  {
134  x = m_xMin - (0.5 * m_d) + m_d * colIndex;
135  }
136 
137  switch (n % 3)
138  {
139  case 0:
140  antennaOrientation = 0;
141  x += m_offset;
143  break;
144 
145  case 1:
146  antennaOrientation = 120;
147  x -= m_offset / 2.0;
148  y += m_offset * xydfactor;
150  break;
151 
152  case 2:
153  antennaOrientation = -120;
154  x -= m_offset / 2.0;
155  y -= m_offset * xydfactor;
157  break;
158 
159  // no default, n%3 = 0, 1, 2
160  }
161  Ptr<Node> node = c.Get(n);
163  Vector pos(x, y, m_siteHeight);
164  NS_LOG_LOGIC("node " << n << " at " << pos << " antennaOrientation " << antennaOrientation);
165  mm->SetPosition(Vector(x, y, m_siteHeight));
166  m_lteHelper->SetEnbAntennaModelAttribute("Orientation", DoubleValue(antennaOrientation));
167  enbDevs.Add(m_lteHelper->InstallEnbDevice(node));
168  }
169  return enbDevs;
170 }
171 
172 } // namespace ns3
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition: double.h:42
NetDeviceContainer InstallEnbDevice(NodeContainer c)
Create a set of eNodeB devices.
Definition: lte-helper.cc:482
void SetFfrAlgorithmAttribute(std::string n, const AttributeValue &v)
Set an attribute for the FFR algorithm to be created.
Definition: lte-helper.cc:324
void SetEnbAntennaModelAttribute(std::string n, const AttributeValue &v)
Set an attribute for the eNodeB antenna model to be created.
Definition: lte-helper.cc:423
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.
void SetPosition(const Vector &position)
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:89
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
Definition: object.h:471
virtual void DoDispose()
Destructor implementation.
Definition: object.cc:353
a unique identifier for an interface.
Definition: type-id.h:60
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:935
Hold an unsigned integer type.
Definition: uinteger.h:45
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:43
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:46
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:282
#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:46
Every class exported by the ns3 library is enclosed in the ns3 namespace.