A Discrete-Event Network Simulator
API
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 
32 namespace ns3
33 {
34 
35 NS_LOG_COMPONENT_DEFINE("LteAnr");
36 
38 
39 LteAnr::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 
54 TypeId
56 {
57  static TypeId tid =
58  TypeId("ns3::LteAnr")
59  .SetParent<Object>()
60  .SetGroupName("Lte")
61  .AddAttribute("Threshold",
62  "Minimum RSRQ range value required for detecting a neighbour cell",
63  UintegerValue(0),
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 
72 void
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 
95 void
97 {
98  NS_LOG_FUNCTION(this << m_servingCellId << cellId);
99 
100  NeighbourRelationTable_t::iterator 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 
109 void
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 
123 void
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 
138 void
140 {
141  NS_LOG_FUNCTION(this);
142  delete m_anrSapProvider;
143  m_neighbourRelationTable.clear();
144 }
145 
146 void
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 (std::list<LteRrcSap::MeasResultEutra>::iterator it =
161  measResults.measResultListEutra.begin();
162  it != measResults.measResultListEutra.end();
163  ++it)
164  {
165  // Keep new RSRQ value reported for the neighbour cell
166  NS_ASSERT_MSG(it->haveRsrqResult == true,
167  "RSRQ measure missing for cellId " << it->physCellId);
168 
169  // Update Neighbour Relation Table
170  NeighbourRelationTable_t::iterator itNrt =
171  m_neighbourRelationTable.find(it->physCellId);
172  if (itNrt != m_neighbourRelationTable.end())
173  {
174  // Update neighbour relation entry
175  NS_LOG_LOGIC(this << " updating NRT of cell " << m_servingCellId
176  << " with entry of cell " << it->physCellId);
177  if (itNrt->second.noX2 == false)
178  {
179  NS_LOG_LOGIC(this << " enabling handover"
180  << " from cell " << m_servingCellId << " to cell "
181  << it->physCellId);
182  itNrt->second.noHo = false;
183  }
184  itNrt->second.detectedAsNeighbour = true;
185  }
186  else
187  {
188  // Discovered new neighbour
189  NS_LOG_LOGIC(this << " inserting NRT of cell " << m_servingCellId
190  << " with newly discovered neighbouring cell "
191  << it->physCellId);
192  NeighbourRelation_t neighbourRelation;
193  neighbourRelation.noRemove = false;
194  neighbourRelation.noHo = true;
195  neighbourRelation.noX2 = true;
196  neighbourRelation.detectedAsNeighbour = true;
197  m_neighbourRelationTable[it->physCellId] = neighbourRelation;
198  }
199 
200  } // end of for (it = measResults.measResultListEutra.begin ())
201 
202  } // end of if (measResults.haveMeasResultNeighCells &&
203  // !(measResults.measResultListEutra.empty ()))
204  else
205  {
206  NS_LOG_WARN(
207  this << " Event A4 received without measurement results from neighbouring cells");
209  }
210 
211  } // end of else of if (measId != m_measId)
212 
213 } // end of DoReportUeMeas
214 
215 void
217 {
218  NS_LOG_FUNCTION(this << cellId);
219  AddNeighbourRelation(cellId);
220 }
221 
222 bool
223 LteAnr::DoGetNoRemove(uint16_t cellId) const
224 {
225  NS_LOG_FUNCTION(this << m_servingCellId << cellId);
226  return Find(cellId)->noRemove;
227 }
228 
229 bool
230 LteAnr::DoGetNoHo(uint16_t cellId) const
231 {
232  NS_LOG_FUNCTION(this << m_servingCellId << cellId);
233  return Find(cellId)->noHo;
234 }
235 
236 bool
237 LteAnr::DoGetNoX2(uint16_t cellId) const
238 {
239  NS_LOG_FUNCTION(this << m_servingCellId << cellId);
240  return Find(cellId)->noX2;
241 }
242 
244 LteAnr::Find(uint16_t cellId) const
245 {
246  NeighbourRelationTable_t::const_iterator it = m_neighbourRelationTable.find(cellId);
247  if (it == m_neighbourRelationTable.end())
248  {
249  NS_FATAL_ERROR("Cell ID " << cellId << " cannot be found in NRT");
250  }
251  return &(it->second);
252 }
253 
254 } // 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:139
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:230
LteAnrSapProvider * m_anrSapProvider
Reference to the "provider" part of the ANR SAP interface, which is automatically created when this c...
Definition: lte-anr.h:191
uint8_t m_measId
The expected measurement identity.
Definition: lte-anr.h:230
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:197
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:223
const NeighbourRelation_t * Find(uint16_t cellId) const
Definition: lte-anr.cc:244
uint8_t m_threshold
The attribute Threshold.
Definition: lte-anr.h:202
LteAnr(uint16_t servingCellId)
Creates an ANR instance.
Definition: lte-anr.cc:39
NeighbourRelationTable_t m_neighbourRelationTable
neighbor relation table
Definition: lte-anr.h:220
void DoAddNeighbourRelation(uint16_t cellId)
Implementation of LteAnrSapProvider::AddNeighbourRelation.
Definition: lte-anr.cc:216
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:233
bool DoGetNoX2(uint16_t cellId) const
Implementation of LteAnrSapProvider::GetNoX2.
Definition: lte-anr.cc:237
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:60
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:935
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)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
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:209
bool detectedAsNeighbour
detected as neighbor
Definition: lte-anr.h:213
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
@ RSRQ
Reference Signal Received Quality.
Definition: lte-rrc-sap.h:426
enum ns3::LteRrcSap::ReportConfigEutra::@68 reportInterval
Report interval enumeration.
enum ns3::LteRrcSap::ReportConfigEutra::@65 eventId
Event enumeration.
enum ns3::LteRrcSap::ReportConfigEutra::@66 triggerQuantity
Trigger type enumeration.
ThresholdEutra threshold1
Threshold for event A1, A2, A4, and A5.
Definition: lte-rrc-sap.h:393
@ EVENT_A4
Event A4: Neighbour becomes better than absolute threshold.
Definition: lte-rrc-sap.h:387
@ THRESHOLD_RSRQ
RSRQ is used for the threshold.
Definition: lte-rrc-sap.h:365
uint8_t range
Value range used in RSRP/RSRQ threshold.
Definition: lte-rrc-sap.h:368
enum ns3::LteRrcSap::ThresholdEutra::@63 choice
Threshold enumeration.