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 * SPDX-License-Identifier: GPL-2.0-only
6 *
7 * Original work authors (from lte-enb-rrc.cc):
8 * Nicola Baldo <nbaldo@cttc.es>
9 * Marco Miozzo <mmiozzo@cttc.es>
10 * Manuel Requena <manuel.requena@cttc.es>
11 *
12 * Converted to ANR interface by:
13 * Budiarto Herman <budiarto.herman@magister.fi>
14 */
15
16#include "lte-anr.h"
17
18#include <ns3/log.h>
19#include <ns3/uinteger.h>
20
21namespace ns3
22{
23
25
27
28LteAnr::LteAnr(uint16_t servingCellId)
29 : m_anrSapUser(nullptr),
30 m_threshold(0),
31 m_measId(0),
32 m_servingCellId(servingCellId)
33{
34 NS_LOG_FUNCTION(this << servingCellId);
36}
37
42
45{
46 static TypeId tid =
47 TypeId("ns3::LteAnr")
49 .SetGroupName("Lte")
50 .AddAttribute("Threshold",
51 "Minimum RSRQ range value required for detecting a neighbour cell",
55 0,
56 34)) // RSRQ range is [0..34] as per Section 9.1.7 of 3GPP TS 36.133
57 ;
58 return tid;
59}
60
61void
63{
64 NS_LOG_FUNCTION(this << m_servingCellId << cellId);
65
66 if (cellId == m_servingCellId)
67 {
68 NS_FATAL_ERROR("Serving cell ID " << cellId << " may not be added into NRT");
69 }
70
71 if (m_neighbourRelationTable.find(cellId) != m_neighbourRelationTable.end())
72 {
73 NS_FATAL_ERROR("There is already an entry in the NRT for cell ID " << cellId);
74 }
75
76 NeighbourRelation_t neighbourRelation;
77 neighbourRelation.noRemove = true;
78 neighbourRelation.noHo = true;
79 neighbourRelation.noX2 = false;
80 neighbourRelation.detectedAsNeighbour = false;
81 m_neighbourRelationTable[cellId] = neighbourRelation;
82}
83
84void
86{
87 NS_LOG_FUNCTION(this << m_servingCellId << cellId);
88
89 auto it = m_neighbourRelationTable.find(cellId);
90 if (it != m_neighbourRelationTable.end())
91 {
92 NS_FATAL_ERROR("Cell ID " << cellId << " cannot be found in NRT");
93 }
94
96}
97
98void
104
111
112void
114{
115 NS_LOG_FUNCTION(this);
116 NS_LOG_LOGIC(this << " requesting Event A4 measurements"
117 << " (threshold=" << (uint16_t)m_threshold << ")");
118 LteRrcSap::ReportConfigEutra reportConfig;
121 reportConfig.threshold1.range = m_threshold;
125}
126
127void
129{
130 NS_LOG_FUNCTION(this);
131 delete m_anrSapProvider;
133}
134
135void
137{
138 uint8_t measId = measResults.measId;
139 NS_LOG_FUNCTION(this << m_servingCellId << (uint16_t)measId);
140
141 if (measId != m_measId)
142 {
143 NS_LOG_WARN(this << " Skipping unexpected measurement identity " << (uint16_t)measId);
144 }
145 else
146 {
147 if (measResults.haveMeasResultNeighCells && !(measResults.measResultListEutra.empty()))
148 {
149 for (auto it = measResults.measResultListEutra.begin();
150 it != measResults.measResultListEutra.end();
151 ++it)
152 {
153 // Keep new RSRQ value reported for the neighbour cell
154 NS_ASSERT_MSG(it->haveRsrqResult == true,
155 "RSRQ measure missing for cellId " << it->physCellId);
156
157 // Update Neighbour Relation Table
158 auto itNrt = m_neighbourRelationTable.find(it->physCellId);
159 if (itNrt != m_neighbourRelationTable.end())
160 {
161 // Update neighbour relation entry
162 NS_LOG_LOGIC(this << " updating NRT of cell " << m_servingCellId
163 << " with entry of cell " << it->physCellId);
164 if (!itNrt->second.noX2)
165 {
166 NS_LOG_LOGIC(this << " enabling handover"
167 << " from cell " << m_servingCellId << " to cell "
168 << it->physCellId);
169 itNrt->second.noHo = false;
170 }
171 itNrt->second.detectedAsNeighbour = true;
172 }
173 else
174 {
175 // Discovered new neighbour
176 NS_LOG_LOGIC(this << " inserting NRT of cell " << m_servingCellId
177 << " with newly discovered neighbouring cell "
178 << it->physCellId);
179 NeighbourRelation_t neighbourRelation;
180 neighbourRelation.noRemove = false;
181 neighbourRelation.noHo = true;
182 neighbourRelation.noX2 = true;
183 neighbourRelation.detectedAsNeighbour = true;
184 m_neighbourRelationTable[it->physCellId] = neighbourRelation;
185 }
186
187 } // end of for (it = measResults.measResultListEutra.begin ())
188
189 } // end of if (measResults.haveMeasResultNeighCells &&
190 // !(measResults.measResultListEutra.empty ()))
191 else
192 {
194 this << " Event A4 received without measurement results from neighbouring cells");
195 /// \todo Remove neighbours in the NRT.
196 }
197
198 } // end of else of if (measId != m_measId)
199
200} // end of DoReportUeMeas
201
202void
204{
205 NS_LOG_FUNCTION(this << cellId);
206 AddNeighbourRelation(cellId);
207}
208
209bool
210LteAnr::DoGetNoRemove(uint16_t cellId) const
211{
212 NS_LOG_FUNCTION(this << m_servingCellId << cellId);
213 return Find(cellId)->noRemove;
214}
215
216bool
217LteAnr::DoGetNoHo(uint16_t cellId) const
218{
219 NS_LOG_FUNCTION(this << m_servingCellId << cellId);
220 return Find(cellId)->noHo;
221}
222
223bool
224LteAnr::DoGetNoX2(uint16_t cellId) const
225{
226 NS_LOG_FUNCTION(this << m_servingCellId << cellId);
227 return Find(cellId)->noX2;
228}
229
231LteAnr::Find(uint16_t cellId) const
232{
233 auto it = m_neighbourRelationTable.find(cellId);
234 if (it == m_neighbourRelationTable.end())
235 {
236 NS_FATAL_ERROR("Cell ID " << cellId << " cannot be found in NRT");
237 }
238 return &(it->second);
239}
240
241} // end of namespace ns3
~LteAnr() override
Definition lte-anr.cc:38
friend class MemberLteAnrSapProvider< LteAnr >
let the forwarder class access the protected and private members
Definition lte-anr.h:129
void DoInitialize() override
Initialize() implementation.
Definition lte-anr.cc:113
virtual LteAnrSapProvider * GetLteAnrSapProvider()
Export the "provider" part of the ANR SAP interface.
Definition lte-anr.cc:106
void DoReportUeMeas(LteRrcSap::MeasResults measResults)
Implementation of LteAnrSapProvider::ReportUeMeas.
Definition lte-anr.cc:136
bool DoGetNoHo(uint16_t cellId) const
Implementation of LteAnrSapProvider::GetNoHo.
Definition lte-anr.cc:217
LteAnrSapProvider * m_anrSapProvider
Reference to the "provider" part of the ANR SAP interface, which is automatically created when this c...
Definition lte-anr.h:181
uint8_t m_measId
The expected measurement identity.
Definition lte-anr.h:220
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:187
static TypeId GetTypeId()
Get the type ID.
Definition lte-anr.cc:44
void RemoveNeighbourRelation(uint16_t cellId)
Remove an existing Neighbour Relation entry.
Definition lte-anr.cc:85
bool DoGetNoRemove(uint16_t cellId) const
Implementation of LteAnrSapProvider::GetNoRemove.
Definition lte-anr.cc:210
const NeighbourRelation_t * Find(uint16_t cellId) const
Definition lte-anr.cc:231
uint8_t m_threshold
The attribute Threshold.
Definition lte-anr.h:192
LteAnr(uint16_t servingCellId)
Creates an ANR instance.
Definition lte-anr.cc:28
NeighbourRelationTable_t m_neighbourRelationTable
neighbor relation table
Definition lte-anr.h:210
void DoAddNeighbourRelation(uint16_t cellId)
Implementation of LteAnrSapProvider::AddNeighbourRelation.
Definition lte-anr.cc:203
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:62
uint16_t m_servingCellId
Serving cell ID.
Definition lte-anr.h:223
bool DoGetNoX2(uint16_t cellId) const
Implementation of LteAnrSapProvider::GetNoX2.
Definition lte-anr.cc:224
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:99
void DoDispose() override
Destructor implementation.
Definition lte-anr.cc:128
Service Access Point (SAP) offered by the ANR instance to the eNodeB RRC instance.
Definition lte-anr-sap.h:26
Service Access Point (SAP) offered by the eNodeB RRC instance to the ANR instance.
Definition lte-anr-sap.h:84
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:78
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_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:75
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#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_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Definition log.h:250
#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
Neighbour Relation between two eNodeBs (serving eNodeB and neighbour eNodeB).
Definition lte-anr.h:199
bool detectedAsNeighbour
detected as neighbor
Definition lte-anr.h:203
MeasResults structure.
uint8_t measId
measure ID
bool haveMeasResultNeighCells
have measure result neighbor cells
std::list< MeasResultEutra > measResultListEutra
measure result list eutra
Specifies criteria for triggering of an E-UTRA measurement reporting event.
enum ns3::LteRrcSap::ReportConfigEutra::@62 eventId
Event enumeration.
@ RSRQ
Reference Signal Received Quality.
@ EVENT_A4
Event A4: Neighbour becomes better than absolute threshold.
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.
@ THRESHOLD_RSRQ
RSRQ is used for the threshold.
enum ns3::LteRrcSap::ThresholdEutra::@60 choice
Threshold enumeration.
uint8_t range
Value range used in RSRP/RSRQ threshold.