A Discrete-Event Network Simulator
API
a3-rsrp-handover-algorithm.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 Budiarto Herman
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation;
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  *
17  * Author: Budiarto Herman <budiarto.herman@magister.fi>
18  *
19  */
20 
22 
23 #include <ns3/double.h>
24 #include <ns3/log.h>
25 #include <ns3/lte-common.h>
26 
27 #include <algorithm>
28 #include <list>
29 
30 namespace ns3
31 {
32 
33 NS_LOG_COMPONENT_DEFINE("A3RsrpHandoverAlgorithm");
34 
35 NS_OBJECT_ENSURE_REGISTERED(A3RsrpHandoverAlgorithm);
36 
38  : m_handoverManagementSapUser(nullptr)
39 {
40  NS_LOG_FUNCTION(this);
43 }
44 
46 {
47  NS_LOG_FUNCTION(this);
48 }
49 
50 TypeId
52 {
53  static TypeId tid =
54  TypeId("ns3::A3RsrpHandoverAlgorithm")
56  .SetGroupName("Lte")
57  .AddConstructor<A3RsrpHandoverAlgorithm>()
58  .AddAttribute(
59  "Hysteresis",
60  "Handover margin (hysteresis) in dB "
61  "(rounded to the nearest multiple of 0.5 dB)",
62  DoubleValue(3.0),
64  MakeDoubleChecker<uint8_t>(0.0, 15.0)) // Hysteresis IE value range is [0..30] as
65  // per Section 6.3.5 of 3GPP TS 36.331
66  .AddAttribute("TimeToTrigger",
67  "Time during which neighbour cell's RSRP "
68  "must continuously higher than serving cell's RSRP "
69  "in order to trigger a handover",
70  TimeValue(MilliSeconds(256)), // 3GPP time-to-trigger median value as per
71  // Section 6.3.5 of 3GPP TS 36.331
73  MakeTimeChecker());
74  return tid;
75 }
76 
77 void
79 {
80  NS_LOG_FUNCTION(this << s);
82 }
83 
86 {
87  NS_LOG_FUNCTION(this);
89 }
90 
91 void
93 {
94  NS_LOG_FUNCTION(this);
95 
97  NS_LOG_LOGIC(this << " requesting Event A3 measurements"
98  << " (hysteresis=" << (uint16_t)hysteresisIeValue << ")"
99  << " (ttt=" << m_timeToTrigger.As(Time::MS) << ")");
100 
101  LteRrcSap::ReportConfigEutra reportConfig;
103  reportConfig.a3Offset = 0;
104  reportConfig.hysteresis = hysteresisIeValue;
106  reportConfig.reportOnLeave = false;
110 
112 }
113 
114 void
116 {
117  NS_LOG_FUNCTION(this);
119 }
120 
121 void
123 {
124  NS_LOG_FUNCTION(this << rnti << (uint16_t)measResults.measId);
125 
126  if (std::find(begin(m_measIds), end(m_measIds), measResults.measId) == std::end(m_measIds))
127  {
128  NS_LOG_WARN("Ignoring measId " << (uint16_t)measResults.measId);
129  return;
130  }
131 
132  if (measResults.haveMeasResultNeighCells && !measResults.measResultListEutra.empty())
133  {
134  uint16_t bestNeighbourCellId = 0;
135  uint8_t bestNeighbourRsrp = 0;
136 
137  for (std::list<LteRrcSap::MeasResultEutra>::iterator it =
138  measResults.measResultListEutra.begin();
139  it != measResults.measResultListEutra.end();
140  ++it)
141  {
142  if (it->haveRsrpResult)
143  {
144  if ((bestNeighbourRsrp < it->rsrpResult) && IsValidNeighbour(it->physCellId))
145  {
146  bestNeighbourCellId = it->physCellId;
147  bestNeighbourRsrp = it->rsrpResult;
148  }
149  }
150  else
151  {
152  NS_LOG_WARN("RSRP measurement is missing from cell ID " << it->physCellId);
153  }
154  }
155 
156  if (bestNeighbourCellId > 0)
157  {
158  NS_LOG_LOGIC("Trigger Handover to cellId " << bestNeighbourCellId);
159  NS_LOG_LOGIC("target cell RSRP " << (uint16_t)bestNeighbourRsrp);
160  NS_LOG_LOGIC("serving cell RSRP " << (uint16_t)measResults.measResultPCell.rsrpResult);
161 
162  // Inform eNodeB RRC about handover
163  m_handoverManagementSapUser->TriggerHandover(rnti, bestNeighbourCellId);
164  }
165  }
166  else
167  {
168  NS_LOG_WARN(
169  this << " Event A3 received without measurement results from neighbouring cells");
170  }
171 
172 } // end of DoReportUeMeas
173 
174 bool
176 {
177  NS_LOG_FUNCTION(this << cellId);
178 
185  return true;
186 }
187 
188 } // end of namespace ns3
Implementation of the strongest cell handover algorithm, based on RSRP measurements and Event A3.
bool IsValidNeighbour(uint16_t cellId)
Determines if a neighbour cell is a valid destination for handover.
double m_hysteresisDb
The Hysteresis attribute.
LteHandoverManagementSapUser * m_handoverManagementSapUser
Interface to the eNodeB RRC instance.
static TypeId GetTypeId()
Get the type ID.
LteHandoverManagementSapProvider * m_handoverManagementSapProvider
Receive API calls from the eNodeB RRC instance.
Time m_timeToTrigger
The TimeToTrigger attribute.
void DoDispose() override
Destructor implementation.
friend class MemberLteHandoverManagementSapProvider< A3RsrpHandoverAlgorithm >
let the forwarder class access the protected and private members
A3RsrpHandoverAlgorithm()
Creates a strongest cell handover algorithm instance.
void DoInitialize() override
Initialize() implementation.
LteHandoverManagementSapProvider * GetLteHandoverManagementSapProvider() override
Export the "provider" part of the Handover Management SAP interface.
std::vector< uint8_t > m_measIds
The expected measurement identity for A3 measurements.
void SetLteHandoverManagementSapUser(LteHandoverManagementSapUser *s) override
Set the "user" part of the Handover Management SAP interface that this handover algorithm instance wi...
void DoReportUeMeas(uint16_t rnti, LteRrcSap::MeasResults measResults) override
Implementation of LteHandoverManagementSapProvider::ReportUeMeas.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition: double.h:42
static uint8_t ActualHysteresis2IeValue(double hysteresisDb)
Returns the IE value of hysteresis.
Definition: lte-common.cc:294
The abstract base class of a handover algorithm that operates using the Handover Management SAP inter...
Service Access Point (SAP) offered by the handover algorithm instance to the eNodeB RRC instance.
Service Access Point (SAP) offered by the eNodeB RRC instance to the handover algorithm instance.
virtual std::vector< uint8_t > AddUeMeasReportConfigForHandover(LteRrcSap::ReportConfigEutra reportConfig)=0
Request a certain reporting configuration to be fulfilled by the UEs attached to the eNodeB entity.
virtual void TriggerHandover(uint16_t rnti, uint16_t targetCellId)=0
Instruct the eNodeB RRC entity to prepare a handover.
virtual void DoInitialize()
Initialize() implementation.
Definition: object.cc:360
int64_t GetMilliSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:407
TimeWithUnit As(const Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
Definition: time.cc:417
@ MS
millisecond
Definition: nstime.h:117
AttributeValue implementation for Time.
Definition: nstime.h:1423
a unique identifier for an interface.
Definition: type-id.h:60
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:935
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Definition: double.h:43
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Definition: nstime.h:1424
#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
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1348
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Definition: time.cc:535
uint8_t rsrpResult
the RSRP result
Definition: lte-rrc-sap.h:674
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
MeasResultPCell measResultPCell
measurement result primary cell
Definition: lte-rrc-sap.h:719
Specifies criteria for triggering of an E-UTRA measurement reporting event.
Definition: lte-rrc-sap.h:373
bool reportOnLeave
Indicates whether or not the UE shall initiate the measurement reporting procedure when the leaving c...
Definition: lte-rrc-sap.h:399
@ RSRP
Reference Signal Received Power.
Definition: lte-rrc-sap.h:425
uint8_t hysteresis
Parameter used within the entry and leave condition of an event triggered reporting condition.
Definition: lte-rrc-sap.h:407
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.
@ EVENT_A3
Event A3: Neighbour becomes amount of offset better than PCell.
Definition: lte-rrc-sap.h:386
int8_t a3Offset
Offset value for Event A3.
Definition: lte-rrc-sap.h:403
uint16_t timeToTrigger
Time during which specific criteria for the event needs to be met in order to trigger a measurement r...
Definition: lte-rrc-sap.h:411