A Discrete-Event Network Simulator
API
lte-anr.cc
Go to the documentation of this file.
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
4  * Copyright (c) 2013 Budiarto Herman
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation;
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Original work authors (from lte-enb-rrc.cc):
20  * - Nicola Baldo <nbaldo@cttc.es>
21  * - Marco Miozzo <mmiozzo@cttc.es>
22  * - Manuel Requena <manuel.requena@cttc.es>
23  *
24  * Converted to ANR interface by:
25  * - Budiarto Herman <budiarto.herman@magister.fi>
26  */
27 
28 #include "lte-anr.h"
29 #include <ns3/log.h>
30 #include <ns3/uinteger.h>
31 
32 namespace ns3 {
33 
34 NS_LOG_COMPONENT_DEFINE ("LteAnr");
35 
37 
38 
39 LteAnr::LteAnr (uint16_t servingCellId)
40  : m_anrSapUser (0),
41  m_threshold (0),
42  m_measId (0),
43  m_servingCellId (servingCellId)
44 {
45  NS_LOG_FUNCTION (this << servingCellId);
47 }
48 
49 
51 {
53 }
54 
55 
56 TypeId
58 {
59  static TypeId tid = TypeId ("ns3::LteAnr")
60  .SetParent<Object> ()
61  .SetGroupName("Lte")
62  .AddAttribute ("Threshold",
63  "Minimum RSRQ range value required for detecting a neighbour cell",
64  UintegerValue (0),
66  MakeUintegerChecker<uint8_t> (0, 34)) // RSRQ range is [0..34] as per Section 9.1.7 of 3GPP TS 36.133
67  ;
68  return tid;
69 }
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 
96 void
98 {
99  NS_LOG_FUNCTION (this << m_servingCellId << cellId);
100 
101  NeighbourRelationTable_t::iterator it = m_neighbourRelationTable.find (cellId);
102  if (it != m_neighbourRelationTable.end ())
103  {
104  NS_FATAL_ERROR ("Cell ID " << cellId << " cannot be found in NRT");
105  }
106 
107  m_neighbourRelationTable.erase (it);
108 }
109 
110 
111 void
113 {
114  NS_LOG_FUNCTION (this << s);
115  m_anrSapUser = s;
116 }
117 
118 
121 {
122  NS_LOG_FUNCTION (this);
123  return m_anrSapProvider;
124 }
125 
126 
127 void
129 {
130  NS_LOG_FUNCTION (this);
131  NS_LOG_LOGIC (this << " requesting Event A4 measurements"
132  << " (threshold=" << (uint16_t) m_threshold << ")");
133  LteRrcSap::ReportConfigEutra reportConfig;
136  reportConfig.threshold1.range = m_threshold;
140 }
141 
142 
143 void
145 {
146  NS_LOG_FUNCTION (this);
147  delete m_anrSapProvider;
148  m_neighbourRelationTable.clear ();
149 }
150 
151 
152 void
154 {
155  uint8_t measId = measResults.measId;
156  NS_LOG_FUNCTION (this << m_servingCellId << (uint16_t) measId);
157 
158  if (measId != m_measId)
159  {
160  NS_LOG_WARN (this << " Skipping unexpected measurement identity " << (uint16_t) measId);
161  }
162  else
163  {
164  if (measResults.haveMeasResultNeighCells
165  && !(measResults.measResultListEutra.empty ()))
166  {
167  for (std::list <LteRrcSap::MeasResultEutra>::iterator it = measResults.measResultListEutra.begin ();
168  it != measResults.measResultListEutra.end ();
169  ++it)
170  {
171  // Keep new RSRQ value reported for the neighbour cell
172  NS_ASSERT_MSG (it->haveRsrqResult == true,
173  "RSRQ measure missing for cellId " << it->physCellId);
174 
175  // Update Neighbour Relation Table
176  NeighbourRelationTable_t::iterator itNrt = m_neighbourRelationTable.find (it->physCellId);
177  if (itNrt != m_neighbourRelationTable.end ())
178  {
179  // Update neighbour relation entry
180  NS_LOG_LOGIC (this << " updating NRT of cell " << m_servingCellId
181  << " with entry of cell " << it->physCellId);
182  if (itNrt->second.noX2 == false)
183  {
184  NS_LOG_LOGIC (this << " enabling handover"
185  << " from cell " << m_servingCellId
186  << " to cell " << it->physCellId);
187  itNrt->second.noHo = false;
188  }
189  itNrt->second.detectedAsNeighbour = true;
190  }
191  else
192  {
193  // Discovered new neighbour
194  NS_LOG_LOGIC (this << " inserting NRT of cell " << m_servingCellId
195  << " with newly discovered neighbouring cell "
196  << it->physCellId);
197  NeighbourRelation_t neighbourRelation;
198  neighbourRelation.noRemove = false;
199  neighbourRelation.noHo = true;
200  neighbourRelation.noX2 = true;
201  neighbourRelation.detectedAsNeighbour = true;
202  m_neighbourRelationTable[it->physCellId] = neighbourRelation;
203  }
204 
205  } // end of for (it = measResults.measResultListEutra.begin ())
206 
207  } // end of if (measResults.haveMeasResultNeighCells && !(measResults.measResultListEutra.empty ()))
208  else
209  {
210  NS_LOG_WARN (this << " Event A4 received without measurement results from neighbouring cells");
212  }
213 
214  } // end of else of if (measId != m_measId)
215 
216 } // end of DoReportUeMeas
217 
218 
219 void
221 {
222  NS_LOG_FUNCTION (this << cellId);
223  AddNeighbourRelation (cellId);
224 }
225 
226 
227 bool
228 LteAnr::DoGetNoRemove (uint16_t cellId) const
229 {
230  NS_LOG_FUNCTION (this << m_servingCellId << cellId);
231  return Find (cellId)->noRemove;
232 }
233 
234 
235 bool
236 LteAnr::DoGetNoHo (uint16_t cellId) const
237 {
238  NS_LOG_FUNCTION (this << m_servingCellId << cellId);
239  return Find (cellId)->noHo;
240 }
241 
242 
243 bool
244 LteAnr::DoGetNoX2 (uint16_t cellId) const
245 {
246  NS_LOG_FUNCTION (this << m_servingCellId << cellId);
247  return Find (cellId)->noX2;
248 }
249 
250 
252 LteAnr::Find (uint16_t cellId) const
253 {
254  NeighbourRelationTable_t::const_iterator it = m_neighbourRelationTable.find (cellId);
255  if (it == m_neighbourRelationTable.end ())
256  {
257  NS_FATAL_ERROR ("Cell ID " << cellId << " cannot be found in NRT");
258  }
259  return &(it->second);
260 }
261 
262 
263 } // end of namespace ns3
264 
enum ns3::LteRrcSap::ThresholdEutra::@63 choice
Threshold enumeration.
uint8_t m_threshold
The attribute Threshold.
Definition: lte-anr.h:203
virtual uint8_t AddUeMeasReportConfigForAnr(LteRrcSap::ReportConfigEutra reportConfig)=0
Request a certain reporting configuration to be fulfilled by the UEs attached to the eNodeB entity...
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
virtual void DoInitialize()
Initialize() implementation.
Definition: lte-anr.cc:128
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
void DoAddNeighbourRelation(uint16_t cellId)
Implementation of LteAnrSapProvider::AddNeighbourRelation.
Definition: lte-anr.cc:220
NS_ASSERT_MSG(false, "Ipv4AddressGenerator::MaskToIndex(): Impossible")
std::list< MeasResultEutra > measResultListEutra
measure result list eutra
Definition: lte-rrc-sap.h:684
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
virtual void DoDispose()
Destructor implementation.
Definition: lte-anr.cc:144
ThresholdEutra threshold1
Threshold for event A1, A2, A4, and A5.
Definition: lte-rrc-sap.h:381
Specifies criteria for triggering of an E-UTRA measurement reporting event.
Definition: lte-rrc-sap.h:361
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
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:204
uint16_t m_servingCellId
Serving cell ID.
Definition: lte-anr.h:234
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:162
enum ns3::LteRrcSap::ReportConfigEutra::@66 triggerQuantity
Trigger type enumeration.
bool DoGetNoHo(uint16_t cellId) const
Implementation of LteAnrSapProvider::GetNoHo.
Definition: lte-anr.cc:236
Reference Signal Received Quality.
Definition: lte-rrc-sap.h:407
const NeighbourRelation_t * Find(uint16_t cellId) const
Definition: lte-anr.cc:252
MeasResults structure.
Definition: lte-rrc-sap.h:678
Hold an unsigned integer type.
Definition: uinteger.h:44
bool DoGetNoRemove(uint16_t cellId) const
Implementation of LteAnrSapProvider::GetNoRemove.
Definition: lte-anr.cc:228
Neighbour Relation between two eNodeBs (serving eNodeB and neighbour eNodeB).
Definition: lte-anr.h:209
Service Access Point (SAP) offered by the eNodeB RRC instance to the ANR instance.
Definition: lte-anr-sap.h:97
enum ns3::LteRrcSap::ReportConfigEutra::@68 reportInterval
Report interval enumeration.
enum ns3::LteRrcSap::ReportConfigEutra::@65 eventId
Event enumeration.
bool detectedAsNeighbour
detected as neighbor
Definition: lte-anr.h:214
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:112
void RemoveNeighbourRelation(uint16_t cellId)
Remove an existing Neighbour Relation entry.
Definition: lte-anr.cc:97
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint8_t m_measId
The expected measurement identity.
Definition: lte-anr.h:231
bool haveMeasResultNeighCells
have measure result neighbor cells
Definition: lte-rrc-sap.h:683
uint8_t range
Value range used in RSRP/RSRQ threshold.
Definition: lte-rrc-sap.h:357
LteAnr(uint16_t servingCellId)
Creates an ANR instance.
Definition: lte-anr.cc:39
NS_LOG_LOGIC("Net device "<< nd<< " is not bridged")
uint8_t measId
measure ID
Definition: lte-rrc-sap.h:680
Service Access Point (SAP) offered by the ANR instance to the eNodeB RRC instance.
Definition: lte-anr-sap.h:37
virtual LteAnrSapProvider * GetLteAnrSapProvider()
Export the "provider" part of the ANR SAP interface.
Definition: lte-anr.cc:120
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Definition: log.h:264
void DoReportUeMeas(LteRrcSap::MeasResults measResults)
Implementation of LteAnrSapProvider::ReportUeMeas.
Definition: lte-anr.cc:153
RSRQ is used for the threshold.
Definition: lte-rrc-sap.h:355
bool DoGetNoX2(uint16_t cellId) const
Implementation of LteAnrSapProvider::GetNoX2.
Definition: lte-anr.cc:244
Event A4: Neighbour becomes better than absolute threshold.
Definition: lte-rrc-sap.h:376
A base class which provides memory management and object aggregation.
Definition: object.h:87
static TypeId GetTypeId()
Get the type ID.
Definition: lte-anr.cc:57
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:45
a unique identifier for an interface.
Definition: type-id.h:58
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:915
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
NeighbourRelationTable_t m_neighbourRelationTable
neighbor relation table
Definition: lte-anr.h:221
virtual ~LteAnr()
Definition: lte-anr.cc:50
Template for the implementation of the LteAnrSapProvider as a member of an owner class of type C to w...
Definition: lte-anr-sap.h:128