A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 NS_LOG_COMPONENT_DEFINE ("LteAnr");
33 
34 namespace ns3 {
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  .AddAttribute ("Threshold",
62  "Minimum RSRQ range value required for detecting a neighbour cell",
63  UintegerValue (0),
64  MakeUintegerAccessor (&LteAnr::m_threshold),
65  MakeUintegerChecker<uint8_t> (0, 34)) // RSRQ range is [0..34] as per Section 9.1.7 of 3GPP TS 36.133
66  ;
67  return tid;
68 }
69 
70 
71 void
73 {
74  NS_LOG_FUNCTION (this << m_servingCellId << cellId);
75 
76  if (cellId == m_servingCellId)
77  {
78  NS_FATAL_ERROR ("Serving cell ID " << cellId << " may not be added into NRT");
79  }
80 
81  if (m_neighbourRelationTable.find (cellId) != m_neighbourRelationTable.end ())
82  {
83  NS_FATAL_ERROR ("There is already an entry in the NRT for cell ID " << cellId);
84  }
85 
86  NeighbourRelation_t neighbourRelation;
87  neighbourRelation.noRemove = true;
88  neighbourRelation.noHo = true;
89  neighbourRelation.noX2 = false;
90  neighbourRelation.detectedAsNeighbour = false;
91  m_neighbourRelationTable[cellId] = neighbourRelation;
92 }
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 
110 void
112 {
113  NS_LOG_FUNCTION (this << s);
114  m_anrSapUser = s;
115 }
116 
117 
120 {
121  NS_LOG_FUNCTION (this);
122  return m_anrSapProvider;
123 }
124 
125 
126 void
128 {
129  NS_LOG_FUNCTION (this);
130  NS_LOG_LOGIC (this << " requesting Event A4 measurements"
131  << " (threshold=" << (uint16_t) m_threshold << ")");
132  LteRrcSap::ReportConfigEutra reportConfig;
135  reportConfig.threshold1.range = m_threshold;
139 }
140 
141 
142 void
144 {
145  NS_LOG_FUNCTION (this);
146  delete m_anrSapProvider;
147  m_neighbourRelationTable.clear ();
148 }
149 
150 
151 void
153 {
154  uint8_t measId = measResults.measId;
155  NS_LOG_FUNCTION (this << m_servingCellId << (uint16_t) measId);
156 
157  if (measId != m_measId)
158  {
159  NS_LOG_WARN (this << " Skipping unexpected measurement identity " << (uint16_t) measId);
160  }
161  else
162  {
163  if (measResults.haveMeasResultNeighCells
164  && !(measResults.measResultListEutra.empty ()))
165  {
166  for (std::list <LteRrcSap::MeasResultEutra>::iterator it = measResults.measResultListEutra.begin ();
167  it != measResults.measResultListEutra.end ();
168  ++it)
169  {
170  // Keep new RSRQ value reported for the neighbour cell
171  NS_ASSERT_MSG (it->haveRsrqResult == true,
172  "RSRQ measure missing for cellId " << it->physCellId);
173 
174  // Update Neighbour Relation Table
175  NeighbourRelationTable_t::iterator itNrt = m_neighbourRelationTable.find (it->physCellId);
176  if (itNrt != m_neighbourRelationTable.end ())
177  {
178  // Update neighbour relation entry
179  NS_LOG_LOGIC (this << " updating NRT of cell " << m_servingCellId
180  << " with entry of cell " << it->physCellId);
181  if (itNrt->second.noX2 == false)
182  {
183  NS_LOG_LOGIC (this << " enabling handover"
184  << " from cell " << m_servingCellId
185  << " to cell " << it->physCellId);
186  itNrt->second.noHo = false;
187  }
188  itNrt->second.detectedAsNeighbour = true;
189  }
190  else
191  {
192  // Discovered new neighbour
193  NS_LOG_LOGIC (this << " inserting NRT of cell " << m_servingCellId
194  << " with newly discovered neighbouring cell "
195  << it->physCellId);
196  NeighbourRelation_t neighbourRelation;
197  neighbourRelation.noRemove = false;
198  neighbourRelation.noHo = true;
199  neighbourRelation.noX2 = true;
200  neighbourRelation.detectedAsNeighbour = true;
201  m_neighbourRelationTable[it->physCellId] = neighbourRelation;
202  }
203 
204  } // end of for (it = measResults.measResultListEutra.begin ())
205 
206  } // end of if (measResults.haveMeasResultNeighCells && !(measResults.measResultListEutra.empty ()))
207  else
208  {
209  NS_LOG_WARN (this << " Event A4 received without measurement results from neighbouring cells");
211  }
212 
213  } // end of else of if (measId != m_measId)
214 
215 } // end of DoReportUeMeas
216 
217 
218 void
220 {
221  NS_LOG_FUNCTION (this << cellId);
222  AddNeighbourRelation (cellId);
223 }
224 
225 
226 bool
227 LteAnr::DoGetNoRemove (uint16_t cellId) const
228 {
229  NS_LOG_FUNCTION (this << m_servingCellId << cellId);
230  return Find (cellId)->noRemove;
231 }
232 
233 
234 bool
235 LteAnr::DoGetNoHo (uint16_t cellId) const
236 {
237  NS_LOG_FUNCTION (this << m_servingCellId << cellId);
238  return Find (cellId)->noHo;
239 }
240 
241 
242 bool
243 LteAnr::DoGetNoX2 (uint16_t cellId) const
244 {
245  NS_LOG_FUNCTION (this << m_servingCellId << cellId);
246  return Find (cellId)->noX2;
247 }
248 
249 
251 LteAnr::Find (uint16_t cellId) const
252 {
253  NeighbourRelationTable_t::const_iterator it = m_neighbourRelationTable.find (cellId);
254  if (it == m_neighbourRelationTable.end ())
255  {
256  NS_FATAL_ERROR ("Cell ID " << cellId << " cannot be found in NRT");
257  }
258  return &(it->second);
259 }
260 
261 
262 } // end of namespace ns3
263 
RSRQ is used for the threshold.
Definition: lte-rrc-sap.h:315
uint8_t m_threshold
The attribute Threshold.
Definition: lte-anr.h:200
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()
This method is called only once by Object::Initialize.
Definition: lte-anr.cc:127
const NeighbourRelation_t * Find(uint16_t cellId) const
Definition: lte-anr.cc:251
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register the class in the ns-3 factory.
Definition: object-base.h:38
void DoAddNeighbourRelation(uint16_t cellId)
Implementation of LteAnrSapProvider::AddNeighbourRelation.
Definition: lte-anr.cc:219
std::list< MeasResultEutra > measResultListEutra
Definition: lte-rrc-sap.h:582
LteAnrSapProvider * m_anrSapProvider
Reference to the "provider" part of the ANR SAP interface, which is automatically created when this c...
Definition: lte-anr.h:189
virtual void DoDispose()
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
Definition: lte-anr.cc:143
ThresholdEutra threshold1
Threshold for event A1, A2, A4, and A5.
Definition: lte-rrc-sap.h:339
Specifies criteria for triggering of an E-UTRA measurement reporting event.
Definition: lte-rrc-sap.h:321
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:72
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:170
uint16_t m_servingCellId
Definition: lte-anr.h:225
#define NS_FATAL_ERROR(msg)
fatal error handling
Definition: fatal-error.h:95
Event A4: Neighbour becomes better than absolute threshold.
Definition: lte-rrc-sap.h:334
bool DoGetNoX2(uint16_t cellId) const
Implementation of LteAnrSapProvider::GetNoX2.
Definition: lte-anr.cc:243
Hold an unsigned integer type.
Definition: uinteger.h:46
Ptr< SampleEmitter > s
Neighbour Relation between two eNodeBs (serving eNodeB and neighbour eNodeB).
Definition: lte-anr.h:206
Service Access Point (SAP) offered by the eNodeB RRC instance to the ANR instance.
Definition: lte-anr-sap.h:97
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:233
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:111
void RemoveNeighbourRelation(uint16_t cellId)
Remove an existing Neighbour Relation entry.
Definition: lte-anr.cc:96
uint8_t m_measId
Definition: lte-anr.h:223
enum ns3::LteRrcSap::ReportConfigEutra::@73 eventId
Choice of E-UTRA event triggered reporting criteria.
uint8_t range
Value range used in RSRP/RSRQ threshold.
Definition: lte-rrc-sap.h:317
LteAnr(uint16_t servingCellId)
Creates an ANR instance.
Definition: lte-anr.cc:39
bool DoGetNoRemove(uint16_t cellId) const
Implementation of LteAnrSapProvider::GetNoRemove.
Definition: lte-anr.cc:227
#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:84
enum ns3::LteRrcSap::ReportConfigEutra::@77 reportInterval
Indicates the interval between periodical reports.
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:119
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Definition: log.h:203
void DoReportUeMeas(LteRrcSap::MeasResults measResults)
Implementation of LteAnrSapProvider::ReportUeMeas.
Definition: lte-anr.cc:152
enum ns3::LteRrcSap::ReportConfigEutra::@75 triggerQuantity
The quantities used to evaluate the triggering condition for the event, see 3GPP TS 36...
Reference Signal Received Quality.
Definition: lte-rrc-sap.h:363
a base class which provides memory management and object aggregation
Definition: object.h:64
enum ns3::LteRrcSap::ThresholdEutra::@71 choice
static TypeId GetTypeId()
Definition: lte-anr.cc:57
a unique identifier for an interface.
Definition: type-id.h:49
TypeId SetParent(TypeId tid)
Definition: type-id.cc:610
bool DoGetNoHo(uint16_t cellId) const
Implementation of LteAnrSapProvider::GetNoHo.
Definition: lte-anr.cc:235
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:195
NeighbourRelationTable_t m_neighbourRelationTable
Definition: lte-anr.h:217
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