A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
lte-hex-grid-enb-topology-helper.cc
Go to the documentation of this file.
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright 2012 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Nicola Baldo <nbaldo@cttc.es>
19  */
20 
21 
23 #include <ns3/double.h>
24 #include <ns3/log.h>
25 #include <ns3/abort.h>
26 #include <ns3/pointer.h>
27 #include <ns3/epc-helper.h>
28 #include <iostream>
29 
30 
31 NS_LOG_COMPONENT_DEFINE ("LteHexGridEnbTopologyHelper");
32 
33 namespace ns3 {
34 
35 NS_OBJECT_ENSURE_REGISTERED (LteHexGridEnbTopologyHelper)
36  ;
37 
39 {
40  NS_LOG_FUNCTION (this);
41 }
42 
44 {
45  NS_LOG_FUNCTION (this);
46 }
47 
49 {
50  static TypeId
51  tid =
52  TypeId ("ns3::LteHexGridEnbTopologyHelper")
53  .SetParent<Object> ()
54  .AddConstructor<LteHexGridEnbTopologyHelper> ()
55  .AddAttribute ("InterSiteDistance",
56  "The distance [m] between nearby sites",
57  DoubleValue (500),
58  MakeDoubleAccessor (&LteHexGridEnbTopologyHelper::m_d),
59  MakeDoubleChecker<double> ())
60  .AddAttribute ("SectorOffset",
61  "The offset [m] in the position for the node of each sector with respect "
62  "to the center of the three-sector site",
63  DoubleValue (0.5),
64  MakeDoubleAccessor (&LteHexGridEnbTopologyHelper::m_offset),
65  MakeDoubleChecker<double> ())
66  .AddAttribute ("SiteHeight",
67  "The height [m] of each site",
68  DoubleValue (30),
69  MakeDoubleAccessor (&LteHexGridEnbTopologyHelper::m_siteHeight),
70  MakeDoubleChecker<double> ())
71  .AddAttribute ("MinX", "The x coordinate where the hex grid starts.",
72  DoubleValue (0.0),
73  MakeDoubleAccessor (&LteHexGridEnbTopologyHelper::m_xMin),
74  MakeDoubleChecker<double> ())
75  .AddAttribute ("MinY", "The y coordinate where the hex grid starts.",
76  DoubleValue (0.0),
77  MakeDoubleAccessor (&LteHexGridEnbTopologyHelper::m_yMin),
78  MakeDoubleChecker<double> ())
79  .AddAttribute ("GridWidth", "The number of sites in even rows (odd rows will have one additional site).",
80  UintegerValue (1),
81  MakeUintegerAccessor (&LteHexGridEnbTopologyHelper::m_gridWidth),
82  MakeUintegerChecker<uint32_t> ())
83  ;
84  return tid;
85 }
86 
87 void
89 {
90  NS_LOG_FUNCTION (this);
92 }
93 
94 
95 void
97 {
98  NS_LOG_FUNCTION (this << h);
99  m_lteHelper = h;
100 }
101 
104 {
105  NS_LOG_FUNCTION (this);
106  NetDeviceContainer enbDevs;
107  const double xydfactor = std::sqrt (0.75);
108  double yd = xydfactor*m_d;
109  for (uint32_t n = 0; n < c.GetN (); ++n)
110  {
111  uint32_t currentSite = n / 3;
112  uint32_t biRowIndex = (currentSite / (m_gridWidth + m_gridWidth + 1));
113  uint32_t biRowRemainder = currentSite % (m_gridWidth + m_gridWidth + 1);
114  uint32_t rowIndex = biRowIndex*2;
115  uint32_t colIndex = biRowRemainder;
116  if (biRowRemainder >= m_gridWidth)
117  {
118  ++rowIndex;
119  colIndex -= m_gridWidth;
120  }
121  NS_LOG_LOGIC ("node " << n << " site " << currentSite
122  << " rowIndex " << rowIndex
123  << " colIndex " << colIndex
124  << " biRowIndex " << biRowIndex
125  << " biRowRemainder " << biRowRemainder);
126  double y = m_yMin + yd * rowIndex;
127  double x;
128  double antennaOrientation;
129  if ((rowIndex % 2) == 0)
130  {
131  x = m_xMin + m_d * colIndex;
132  }
133  else // row is odd
134  {
135  x = m_xMin -(0.5*m_d) + m_d * colIndex;
136  }
137 
138  switch (n%3)
139  {
140  case 0:
141  antennaOrientation = 0;
142  x += m_offset;
143  break;
144 
145  case 1:
146  antennaOrientation = 120;
147  x -= m_offset/2.0;
148  y += m_offset*xydfactor;
149  break;
150 
151  case 2:
152  antennaOrientation = -120;
153  x -= m_offset/2.0;
154  y -= m_offset*xydfactor;
155  break;
156 
157  // no default, n%3 = 0, 1, 2
158  }
159  Ptr<Node> node = c.Get (n);
161  Vector pos (x, y, m_siteHeight);
162  NS_LOG_LOGIC ("node " << n << " at " << pos << " antennaOrientation " << antennaOrientation);
163  mm->SetPosition (Vector (x, y, m_siteHeight));
164  m_lteHelper->SetEnbAntennaModelAttribute ("Orientation", DoubleValue (antennaOrientation));
165  enbDevs.Add (m_lteHelper->InstallEnbDevice (node));
166  }
167  return enbDevs;
168 }
169 
170 } // namespace ns3
171 
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:59
#define NS_LOG_FUNCTION(parameters)
Definition: log.h:345
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
Definition: object.cc:336
void SetLteHelper(Ptr< LteHelper > h)
Set the LteHelper to be used to actually create the EnbNetDevices.
a 3d vector
Definition: vector.h:31
NetDeviceContainer SetPositionAndInstallEnbDevice(NodeContainer c)
Position the nodes on a hex grid and install the corresponding EnbNetDevices with antenna boresight c...
uint32_t GetN(void) const
Get the number of Ptr stored in this container.
Keep track of the current position and velocity of an object.
void Add(NetDeviceContainer other)
Append the contents of another NetDeviceContainer to the end of this container.
Hold an unsigned integer type.
Definition: uinteger.h:46
holds a vector of ns3::NetDevice pointers
#define NS_LOG_LOGIC(msg)
Definition: log.h:368
keep track of a set of node pointers.
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
void SetPosition(const Vector &position)
Ptr< Node > Get(uint32_t i) const
Get the Ptr stored in this container at a given index.
a base class which provides memory management and object aggregation
Definition: object.h:63
Hold a floating point type.
Definition: double.h:41
Ptr< T > GetObject(void) const
Definition: object.h:361
a unique identifier for an interface.
Definition: type-id.h:49
TypeId SetParent(TypeId tid)
Definition: type-id.cc:611
NS_LOG_COMPONENT_DEFINE("LteHexGridEnbTopologyHelper")