A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
lte-anr.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
3 * Copyright (c) 2013 Budiarto Herman
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 * Original work authors (from lte-enb-rrc.cc):
19 * Nicola Baldo <nbaldo@cttc.es>
20 * Marco Miozzo <mmiozzo@cttc.es>
21 * Manuel Requena <manuel.requena@cttc.es>
22 *
23 * Converted to ANR interface by:
24 * Budiarto Herman <budiarto.herman@magister.fi>
25 */
26
27#include "lte-anr.h"
28
29#include <ns3/log.h>
30#include <ns3/uinteger.h>
31
32namespace ns3
33{
34
36
38
39LteAnr::LteAnr(uint16_t servingCellId)
40 : m_anrSapUser(nullptr),
41 m_threshold(0),
42 m_measId(0),
43 m_servingCellId(servingCellId)
44{
45 NS_LOG_FUNCTION(this << servingCellId);
47}
48
50{
52}
53
56{
57 static TypeId tid =
58 TypeId("ns3::LteAnr")
60 .SetGroupName("Lte")
61 .AddAttribute("Threshold",
62 "Minimum RSRQ range value required for detecting a neighbour cell",
65 MakeUintegerChecker<uint8_t>(
66 0,
67 34)) // RSRQ range is [0..34] as per Section 9.1.7 of 3GPP TS 36.133
68 ;
69 return tid;
70}
71
72void
74{
75 NS_LOG_FUNCTION(this << m_servingCellId << cellId);
76
77 if (cellId == m_servingCellId)
78 {
79 NS_FATAL_ERROR("Serving cell ID " << cellId << " may not be added into NRT");
80 }
81
82 if (m_neighbourRelationTable.find(cellId) != m_neighbourRelationTable.end())
83 {
84 NS_FATAL_ERROR("There is already an entry in the NRT for cell ID " << cellId);
85 }
86
87 NeighbourRelation_t neighbourRelation;
88 neighbourRelation.noRemove = true;
89 neighbourRelation.noHo = true;
90 neighbourRelation.noX2 = false;
91 neighbourRelation.detectedAsNeighbour = false;
92 m_neighbourRelationTable[cellId] = neighbourRelation;
93}
94
95void
97{
98 NS_LOG_FUNCTION(this << m_servingCellId << cellId);
99
100 auto it = m_neighbourRelationTable.find(cellId);
101 if (it != m_neighbourRelationTable.end())
102 {
103 NS_FATAL_ERROR("Cell ID " << cellId << " cannot be found in NRT");
104 }
105
106 m_neighbourRelationTable.erase(it);
107}
108
109void
111{
112 NS_LOG_FUNCTION(this << s);
113 m_anrSapUser = s;
114}
115
118{
119 NS_LOG_FUNCTION(this);
120 return m_anrSapProvider;
121}
122
123void
125{
126 NS_LOG_FUNCTION(this);
127 NS_LOG_LOGIC(this << " requesting Event A4 measurements"
128 << " (threshold=" << (uint16_t)m_threshold << ")");
129 LteRrcSap::ReportConfigEutra reportConfig;
132 reportConfig.threshold1.range = m_threshold;
136}
137
138void
140{
141 NS_LOG_FUNCTION(this);
142 delete m_anrSapProvider;
144}
145
146void
148{
149 uint8_t measId = measResults.measId;
150 NS_LOG_FUNCTION(this << m_servingCellId << (uint16_t)measId);
151
152 if (measId != m_measId)
153 {
154 NS_LOG_WARN(this << " Skipping unexpected measurement identity " << (uint16_t)measId);
155 }
156 else
157 {
158 if (measResults.haveMeasResultNeighCells && !(measResults.measResultListEutra.empty()))
159 {
160 for (auto it = measResults.measResultListEutra.begin();
161 it != measResults.measResultListEutra.end();
162 ++it)
163 {
164 // Keep new RSRQ value reported for the neighbour cell
165 NS_ASSERT_MSG(it->haveRsrqResult == true,
166 "RSRQ measure missing for cellId " << it->physCellId);
167
168 // Update Neighbour Relation Table
169 auto itNrt = m_neighbourRelationTable.find(it->physCellId);
170 if (itNrt != m_neighbourRelationTable.end())
171 {
172 // Update neighbour relation entry
173 NS_LOG_LOGIC(this << " updating NRT of cell " << m_servingCellId
174 << " with entry of cell " << it->physCellId);
175 if (!itNrt->second.noX2)
176 {
177 NS_LOG_LOGIC(this << " enabling handover"
178 << " from cell " << m_servingCellId << " to cell "
179 << it->physCellId);
180 itNrt->second.noHo = false;
181 }
182 itNrt->second.detectedAsNeighbour = true;
183 }
184 else
185 {
186 // Discovered new neighbour
187 NS_LOG_LOGIC(this << " inserting NRT of cell " << m_servingCellId
188 << " with newly discovered neighbouring cell "
189 << it->physCellId);
190 NeighbourRelation_t neighbourRelation;
191 neighbourRelation.noRemove = false;
192 neighbourRelation.noHo = true;
193 neighbourRelation.noX2 = true;
194 neighbourRelation.detectedAsNeighbour = true;
195 m_neighbourRelationTable[it->physCellId] = neighbourRelation;
196 }
197
198 } // end of for (it = measResults.measResultListEutra.begin ())
199
200 } // end of if (measResults.haveMeasResultNeighCells &&
201 // !(measResults.measResultListEutra.empty ()))
202 else
203 {
205 this << " Event A4 received without measurement results from neighbouring cells");
207 }
208
209 } // end of else of if (measId != m_measId)
210
211} // end of DoReportUeMeas
212
213void
215{
216 NS_LOG_FUNCTION(this << cellId);
217 AddNeighbourRelation(cellId);
218}
219
220bool
221LteAnr::DoGetNoRemove(uint16_t cellId) const
222{
223 NS_LOG_FUNCTION(this << m_servingCellId << cellId);
224 return Find(cellId)->noRemove;
225}
226
227bool
228LteAnr::DoGetNoHo(uint16_t cellId) const
229{
230 NS_LOG_FUNCTION(this << m_servingCellId << cellId);
231 return Find(cellId)->noHo;
232}
233
234bool
235LteAnr::DoGetNoX2(uint16_t cellId) const
236{
237 NS_LOG_FUNCTION(this << m_servingCellId << cellId);
238 return Find(cellId)->noX2;
239}
240
242LteAnr::Find(uint16_t cellId) const
243{
244 auto it = m_neighbourRelationTable.find(cellId);
245 if (it == m_neighbourRelationTable.end())
246 {
247 NS_FATAL_ERROR("Cell ID " << cellId << " cannot be found in NRT");
248 }
249 return &(it->second);
250}
251
252} // end of namespace ns3
~LteAnr() override
Definition: lte-anr.cc:49
friend class MemberLteAnrSapProvider< LteAnr >
let the forwarder class access the protected and private members
Definition: lte-anr.h:140
void DoInitialize() override
Initialize() implementation.
Definition: lte-anr.cc:124
virtual LteAnrSapProvider * GetLteAnrSapProvider()
Export the "provider" part of the ANR SAP interface.
Definition: lte-anr.cc:117
void DoReportUeMeas(LteRrcSap::MeasResults measResults)
Implementation of LteAnrSapProvider::ReportUeMeas.
Definition: lte-anr.cc:147
bool DoGetNoHo(uint16_t cellId) const
Implementation of LteAnrSapProvider::GetNoHo.
Definition: lte-anr.cc:228
LteAnrSapProvider * m_anrSapProvider
Reference to the "provider" part of the ANR SAP interface, which is automatically created when this c...
Definition: lte-anr.h:192
uint8_t m_measId
The expected measurement identity.
Definition: lte-anr.h:231
LteAnrSapUser * m_anrSapUser
Reference to the "user" part of the ANR SAP interface, which is provided by the eNodeB RRC instance.
Definition: lte-anr.h:198
static TypeId GetTypeId()
Get the type ID.
Definition: lte-anr.cc:55
void RemoveNeighbourRelation(uint16_t cellId)
Remove an existing Neighbour Relation entry.
Definition: lte-anr.cc:96
bool DoGetNoRemove(uint16_t cellId) const
Implementation of LteAnrSapProvider::GetNoRemove.
Definition: lte-anr.cc:221
const NeighbourRelation_t * Find(uint16_t cellId) const
Definition: lte-anr.cc:242
uint8_t m_threshold
The attribute Threshold.
Definition: lte-anr.h:203
LteAnr(uint16_t servingCellId)
Creates an ANR instance.
Definition: lte-anr.cc:39
NeighbourRelationTable_t m_neighbourRelationTable
neighbor relation table
Definition: lte-anr.h:221
void DoAddNeighbourRelation(uint16_t cellId)
Implementation of LteAnrSapProvider::AddNeighbourRelation.
Definition: lte-anr.cc:214
void AddNeighbourRelation(uint16_t cellId)
Provide an advance information about a related neighbouring cell and add it as a new Neighbour Relati...
Definition: lte-anr.cc:73
uint16_t m_servingCellId
Serving cell ID.
Definition: lte-anr.h:234
bool DoGetNoX2(uint16_t cellId) const
Implementation of LteAnrSapProvider::GetNoX2.
Definition: lte-anr.cc:235
virtual void SetLteAnrSapUser(LteAnrSapUser *s)
Set the "user" part of the ANR SAP interface that this ANR instance will interact with.
Definition: lte-anr.cc:110
void DoDispose() override
Destructor implementation.
Definition: lte-anr.cc:139
Service Access Point (SAP) offered by the ANR instance to the eNodeB RRC instance.
Definition: lte-anr-sap.h:37
Service Access Point (SAP) offered by the eNodeB RRC instance to the ANR instance.
Definition: lte-anr-sap.h:95
virtual uint8_t AddUeMeasReportConfigForAnr(LteRrcSap::ReportConfigEutra reportConfig)=0
Request a certain reporting configuration to be fulfilled by the UEs attached to the eNodeB entity.
A base class which provides memory management and object aggregation.
Definition: object.h:89
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:932
Hold an unsigned integer type.
Definition: uinteger.h:45
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition: assert.h:86
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Definition: uinteger.h:46
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:179
#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_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Definition: log.h:261
#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.
Neighbour Relation between two eNodeBs (serving eNodeB and neighbour eNodeB).
Definition: lte-anr.h:210
bool detectedAsNeighbour
detected as neighbor
Definition: lte-anr.h:214
MeasResults structure.
Definition: lte-rrc-sap.h:717
uint8_t measId
measure ID
Definition: lte-rrc-sap.h:718
bool haveMeasResultNeighCells
have measure result neighbor cells
Definition: lte-rrc-sap.h:720
std::list< MeasResultEutra > measResultListEutra
measure result list eutra
Definition: lte-rrc-sap.h:721
Specifies criteria for triggering of an E-UTRA measurement reporting event.
Definition: lte-rrc-sap.h:373
enum ns3::LteRrcSap::ReportConfigEutra::@62 eventId
Event enumeration.
@ RSRQ
Reference Signal Received Quality.
Definition: lte-rrc-sap.h:426
@ EVENT_A4
Event A4: Neighbour becomes better than absolute threshold.
Definition: lte-rrc-sap.h:387
enum ns3::LteRrcSap::ReportConfigEutra::@65 reportInterval
Report interval enumeration.
enum ns3::LteRrcSap::ReportConfigEutra::@63 triggerQuantity
Trigger type enumeration.
ThresholdEutra threshold1
Threshold for event A1, A2, A4, and A5.
Definition: lte-rrc-sap.h:393
@ THRESHOLD_RSRQ
RSRQ is used for the threshold.
Definition: lte-rrc-sap.h:365
enum ns3::LteRrcSap::ThresholdEutra::@60 choice
Threshold enumeration.
uint8_t range
Value range used in RSRP/RSRQ threshold.
Definition: lte-rrc-sap.h:368