forked from nsnam/ns-3-dev-git
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlte-hex-grid-enb-topology-helper.cc
173 lines (154 loc) · 5.47 KB
/
lte-hex-grid-enb-topology-helper.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright 2012 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Nicola Baldo <[email protected]>
*/
#include "lte-hex-grid-enb-topology-helper.h"
#include <ns3/double.h>
#include <ns3/log.h>
#include <ns3/abort.h>
#include <ns3/pointer.h>
#include <ns3/epc-helper.h>
#include <iostream>
namespace ns3 {
NS_LOG_COMPONENT_DEFINE ("LteHexGridEnbTopologyHelper");
NS_OBJECT_ENSURE_REGISTERED (LteHexGridEnbTopologyHelper);
LteHexGridEnbTopologyHelper::LteHexGridEnbTopologyHelper ()
{
NS_LOG_FUNCTION (this);
}
LteHexGridEnbTopologyHelper::~LteHexGridEnbTopologyHelper (void)
{
NS_LOG_FUNCTION (this);
}
TypeId LteHexGridEnbTopologyHelper::GetTypeId (void)
{
static TypeId
tid =
TypeId ("ns3::LteHexGridEnbTopologyHelper")
.SetParent<Object> ()
.AddConstructor<LteHexGridEnbTopologyHelper> ()
.AddAttribute ("InterSiteDistance",
"The distance [m] between nearby sites",
DoubleValue (500),
MakeDoubleAccessor (&LteHexGridEnbTopologyHelper::m_d),
MakeDoubleChecker<double> ())
.AddAttribute ("SectorOffset",
"The offset [m] in the position for the node of each sector with respect "
"to the center of the three-sector site",
DoubleValue (0.5),
MakeDoubleAccessor (&LteHexGridEnbTopologyHelper::m_offset),
MakeDoubleChecker<double> ())
.AddAttribute ("SiteHeight",
"The height [m] of each site",
DoubleValue (30),
MakeDoubleAccessor (&LteHexGridEnbTopologyHelper::m_siteHeight),
MakeDoubleChecker<double> ())
.AddAttribute ("MinX", "The x coordinate where the hex grid starts.",
DoubleValue (0.0),
MakeDoubleAccessor (&LteHexGridEnbTopologyHelper::m_xMin),
MakeDoubleChecker<double> ())
.AddAttribute ("MinY", "The y coordinate where the hex grid starts.",
DoubleValue (0.0),
MakeDoubleAccessor (&LteHexGridEnbTopologyHelper::m_yMin),
MakeDoubleChecker<double> ())
.AddAttribute ("GridWidth", "The number of sites in even rows (odd rows will have one additional site).",
UintegerValue (1),
MakeUintegerAccessor (&LteHexGridEnbTopologyHelper::m_gridWidth),
MakeUintegerChecker<uint32_t> ())
;
return tid;
}
void
LteHexGridEnbTopologyHelper::DoDispose ()
{
NS_LOG_FUNCTION (this);
Object::DoDispose ();
}
void
LteHexGridEnbTopologyHelper::SetLteHelper (Ptr<LteHelper> h)
{
NS_LOG_FUNCTION (this << h);
m_lteHelper = h;
}
NetDeviceContainer
LteHexGridEnbTopologyHelper::SetPositionAndInstallEnbDevice (NodeContainer c)
{
NS_LOG_FUNCTION (this);
NetDeviceContainer enbDevs;
const double xydfactor = std::sqrt (0.75);
double yd = xydfactor*m_d;
for (uint32_t n = 0; n < c.GetN (); ++n)
{
uint32_t currentSite = n / 3;
uint32_t biRowIndex = (currentSite / (m_gridWidth + m_gridWidth + 1));
uint32_t biRowRemainder = currentSite % (m_gridWidth + m_gridWidth + 1);
uint32_t rowIndex = biRowIndex*2;
uint32_t colIndex = biRowRemainder;
if (biRowRemainder >= m_gridWidth)
{
++rowIndex;
colIndex -= m_gridWidth;
}
NS_LOG_LOGIC ("node " << n << " site " << currentSite
<< " rowIndex " << rowIndex
<< " colIndex " << colIndex
<< " biRowIndex " << biRowIndex
<< " biRowRemainder " << biRowRemainder);
double y = m_yMin + yd * rowIndex;
double x;
double antennaOrientation;
if ((rowIndex % 2) == 0)
{
x = m_xMin + m_d * colIndex;
}
else // row is odd
{
x = m_xMin -(0.5*m_d) + m_d * colIndex;
}
switch (n%3)
{
case 0:
antennaOrientation = 0;
x += m_offset;
m_lteHelper->SetFfrAlgorithmAttribute("FrCellTypeId", UintegerValue (1));
break;
case 1:
antennaOrientation = 120;
x -= m_offset/2.0;
y += m_offset*xydfactor;
m_lteHelper->SetFfrAlgorithmAttribute("FrCellTypeId", UintegerValue (2));
break;
case 2:
antennaOrientation = -120;
x -= m_offset/2.0;
y -= m_offset*xydfactor;
m_lteHelper->SetFfrAlgorithmAttribute("FrCellTypeId", UintegerValue (3));
break;
// no default, n%3 = 0, 1, 2
}
Ptr<Node> node = c.Get (n);
Ptr<MobilityModel> mm = node->GetObject<MobilityModel> ();
Vector pos (x, y, m_siteHeight);
NS_LOG_LOGIC ("node " << n << " at " << pos << " antennaOrientation " << antennaOrientation);
mm->SetPosition (Vector (x, y, m_siteHeight));
m_lteHelper->SetEnbAntennaModelAttribute ("Orientation", DoubleValue (antennaOrientation));
enbDevs.Add (m_lteHelper->InstallEnbDevice (node));
}
return enbDevs;
}
} // namespace ns3