A Discrete-Event Network Simulator
API
a3-rsrp-handover-algorithm.cc
Go to the documentation of this file.
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2 /*
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  * Author: Budiarto Herman <budiarto.herman@magister.fi>
19  *
20  */
21 
23 #include <ns3/log.h>
24 #include <ns3/double.h>
25 #include <ns3/lte-common.h>
26 #include <list>
27 
28 namespace ns3 {
29 
30 NS_LOG_COMPONENT_DEFINE ("A3RsrpHandoverAlgorithm");
31 
32 NS_OBJECT_ENSURE_REGISTERED (A3RsrpHandoverAlgorithm);
33 
34 
36  : m_handoverManagementSapUser (0)
37 {
38  NS_LOG_FUNCTION (this);
40 }
41 
42 
44 {
45  NS_LOG_FUNCTION (this);
46 }
47 
48 
49 TypeId
51 {
52  static TypeId tid = TypeId ("ns3::A3RsrpHandoverAlgorithm")
54  .SetGroupName ("Lte")
55  .AddConstructor<A3RsrpHandoverAlgorithm> ()
56  .AddAttribute ("Hysteresis",
57  "Handover margin (hysteresis) in dB "
58  "(rounded to the nearest multiple of 0.5 dB)",
59  DoubleValue (3.0),
61  MakeDoubleChecker<uint8_t> (0.0, 15.0)) // Hysteresis IE value range is [0..30] as per Section 6.3.5 of 3GPP TS 36.331
62  .AddAttribute ("TimeToTrigger",
63  "Time during which neighbour cell's RSRP "
64  "must continuously higher than serving cell's RSRP "
65  "in order to trigger a handover",
66  TimeValue (MilliSeconds (256)), // 3GPP time-to-trigger median value as per Section 6.3.5 of 3GPP TS 36.331
68  MakeTimeChecker ())
69  ;
70  return tid;
71 }
72 
73 
74 void
76 {
77  NS_LOG_FUNCTION (this << s);
79 }
80 
81 
84 {
85  NS_LOG_FUNCTION (this);
87 }
88 
89 
90 void
92 {
93  NS_LOG_FUNCTION (this);
94 
96  NS_LOG_LOGIC (this << " requesting Event A3 measurements"
97  << " (hysteresis=" << (uint16_t) hysteresisIeValue << ")"
98  << " (ttt=" << m_timeToTrigger.As (Time::MS) << ")");
99 
100  LteRrcSap::ReportConfigEutra reportConfig;
102  reportConfig.a3Offset = 0;
103  reportConfig.hysteresis = hysteresisIeValue;
105  reportConfig.reportOnLeave = false;
109 
111 }
112 
113 
114 void
116 {
117  NS_LOG_FUNCTION (this);
119 }
120 
121 
122 void
124  LteRrcSap::MeasResults measResults)
125 {
126  NS_LOG_FUNCTION (this << rnti << (uint16_t) measResults.measId);
127 
128  if (measResults.measId != m_measId)
129  {
130  NS_LOG_WARN ("Ignoring measId " << (uint16_t) measResults.measId);
131  }
132  else
133  {
134  if (measResults.haveMeasResultNeighCells
135  && !measResults.measResultListEutra.empty ())
136  {
137  uint16_t bestNeighbourCellId = 0;
138  uint8_t bestNeighbourRsrp = 0;
139 
140  for (std::list <LteRrcSap::MeasResultEutra>::iterator it = measResults.measResultListEutra.begin ();
141  it != measResults.measResultListEutra.end ();
142  ++it)
143  {
144  if (it->haveRsrpResult)
145  {
146  if ((bestNeighbourRsrp < it->rsrpResult)
147  && IsValidNeighbour (it->physCellId))
148  {
149  bestNeighbourCellId = it->physCellId;
150  bestNeighbourRsrp = it->rsrpResult;
151  }
152  }
153  else
154  {
155  NS_LOG_WARN ("RSRP measurement is missing from cell ID " << it->physCellId);
156  }
157  }
158 
159  if (bestNeighbourCellId > 0)
160  {
161  NS_LOG_LOGIC ("Trigger Handover to cellId " << bestNeighbourCellId);
162  NS_LOG_LOGIC ("target cell RSRP " << (uint16_t) bestNeighbourRsrp);
163  NS_LOG_LOGIC ("serving cell RSRP " << (uint16_t) measResults.rsrpResult);
164 
165  // Inform eNodeB RRC about handover
167  bestNeighbourCellId);
168  }
169  }
170  else
171  {
172  NS_LOG_WARN (this << " Event A3 received without measurement results from neighbouring cells");
173  }
174  } // end of else of if (measResults.measId != m_measId)
175 
176 } // end of DoReportUeMeas
177 
178 
179 bool
181 {
182  NS_LOG_FUNCTION (this << cellId);
183 
190  return true;
191 }
192 
193 
194 } // end of namespace ns3
ns3::A3RsrpHandoverAlgorithm::DoDispose
virtual void DoDispose()
Destructor implementation.
Definition: a3-rsrp-handover-algorithm.cc:115
ns3::LteRrcSap::ReportConfigEutra::reportInterval
enum ns3::LteRrcSap::ReportConfigEutra::@5 reportInterval
Report interval enumeration.
ns3::TypeId
a unique identifier for an interface.
Definition: type-id.h:59
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
ns3::LteHandoverManagementSapUser
Service Access Point (SAP) offered by the eNodeB RRC instance to the handover algorithm instance.
Definition: lte-handover-management-sap.h:68
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
ns3::A3RsrpHandoverAlgorithm::IsValidNeighbour
bool IsValidNeighbour(uint16_t cellId)
Determines if a neighbour cell is a valid destination for handover.
Definition: a3-rsrp-handover-algorithm.cc:180
ns3::MakeTimeChecker
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Definition: time.cc:533
ns3::A3RsrpHandoverAlgorithm::SetLteHandoverManagementSapUser
virtual void SetLteHandoverManagementSapUser(LteHandoverManagementSapUser *s)
Set the "user" part of the Handover Management SAP interface that this handover algorithm instance wi...
Definition: a3-rsrp-handover-algorithm.cc:75
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::EutranMeasurementMapping::ActualHysteresis2IeValue
static uint8_t ActualHysteresis2IeValue(double hysteresisDb)
Returns the IE value of hysteresis.
Definition: lte-common.cc:304
ns3::A3RsrpHandoverAlgorithm::m_handoverManagementSapProvider
LteHandoverManagementSapProvider * m_handoverManagementSapProvider
Receive API calls from the eNodeB RRC instance.
Definition: a3-rsrp-handover-algorithm.h:121
ns3::LteRrcSap::MeasResults::rsrpResult
uint8_t rsrpResult
RSRP result.
Definition: lte-rrc-sap.h:681
NS_LOG_WARN
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Definition: log.h:265
ns3::LteHandoverManagementSapUser::AddUeMeasReportConfigForHandover
virtual uint8_t AddUeMeasReportConfigForHandover(LteRrcSap::ReportConfigEutra reportConfig)=0
Request a certain reporting configuration to be fulfilled by the UEs attached to the eNodeB entity.
ns3::LteRrcSap::ReportConfigEutra::MS1024
@ MS1024
Definition: lte-rrc-sap.h:427
ns3::LteRrcSap::ReportConfigEutra::RSRP
@ RSRP
Reference Signal Received Power.
Definition: lte-rrc-sap.h:406
ns3::Time::As
TimeWithUnit As(const enum Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
Definition: time.cc:429
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:923
ns3::A3RsrpHandoverAlgorithm
Implementation of the strongest cell handover algorithm, based on RSRP measurements and Event A3.
Definition: a3-rsrp-handover-algorithm.h:66
ns3::DoubleValue
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition: double.h:41
ns3::LteHandoverManagementSapProvider
Service Access Point (SAP) offered by the handover algorithm instance to the eNodeB RRC instance.
Definition: lte-handover-management-sap.h:39
ns3::A3RsrpHandoverAlgorithm::DoInitialize
virtual void DoInitialize()
Initialize() implementation.
Definition: a3-rsrp-handover-algorithm.cc:91
ns3::A3RsrpHandoverAlgorithm::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition: a3-rsrp-handover-algorithm.cc:50
ns3::LteRrcSap::ReportConfigEutra::eventId
enum ns3::LteRrcSap::ReportConfigEutra::@2 eventId
Event enumeration.
ns3::A3RsrpHandoverAlgorithm::~A3RsrpHandoverAlgorithm
virtual ~A3RsrpHandoverAlgorithm()
Definition: a3-rsrp-handover-algorithm.cc:43
ns3::LteHandoverManagementSapUser::TriggerHandover
virtual void TriggerHandover(uint16_t rnti, uint16_t targetCellId)=0
Instruct the eNodeB RRC entity to prepare a handover.
ns3::LteRrcSap::ReportConfigEutra::triggerQuantity
enum ns3::LteRrcSap::ReportConfigEutra::@3 triggerQuantity
Trigger type enumeration.
ns3::MilliSeconds
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1297
ns3::LteRrcSap::ReportConfigEutra
Specifies criteria for triggering of an E-UTRA measurement reporting event.
Definition: lte-rrc-sap.h:362
ns3::LteRrcSap::ReportConfigEutra::reportOnLeave
bool reportOnLeave
Indicates whether or not the UE shall initiate the measurement reporting procedure when the leaving c...
Definition: lte-rrc-sap.h:385
ns3::A3RsrpHandoverAlgorithm::DoReportUeMeas
void DoReportUeMeas(uint16_t rnti, LteRrcSap::MeasResults measResults)
Implementation of LteHandoverManagementSapProvider::ReportUeMeas.
Definition: a3-rsrp-handover-algorithm.cc:123
ns3::A3RsrpHandoverAlgorithm::m_measId
uint8_t m_measId
The expected measurement identity for A3 measurements.
Definition: a3-rsrp-handover-algorithm.h:105
ns3::Object::DoInitialize
virtual void DoInitialize(void)
Initialize() implementation.
Definition: object.cc:353
ns3::A3RsrpHandoverAlgorithm::m_timeToTrigger
Time m_timeToTrigger
The TimeToTrigger attribute.
Definition: a3-rsrp-handover-algorithm.h:116
a3-rsrp-handover-algorithm.h
ns3::LteRrcSap::MeasResults::measResultListEutra
std::list< MeasResultEutra > measResultListEutra
measure result list eutra
Definition: lte-rrc-sap.h:684
NS_LOG_LOGIC
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:289
ns3::MakeDoubleAccessor
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:42
ns3::LteRrcSap::MeasResults
MeasResults structure.
Definition: lte-rrc-sap.h:679
ns3::A3RsrpHandoverAlgorithm::GetLteHandoverManagementSapProvider
virtual LteHandoverManagementSapProvider * GetLteHandoverManagementSapProvider()
Export the "provider" part of the Handover Management SAP interface.
Definition: a3-rsrp-handover-algorithm.cc:83
ns3::Time::GetMilliSeconds
int64_t GetMilliSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:384
ns3::A3RsrpHandoverAlgorithm::A3RsrpHandoverAlgorithm
A3RsrpHandoverAlgorithm()
Creates a strongest cell handover algorithm instance.
Definition: a3-rsrp-handover-algorithm.cc:35
ns3::LteRrcSap::ReportConfigEutra::a3Offset
int8_t a3Offset
Offset value for Event A3. An integer between -30 and 30. The actual value is (value * 0....
Definition: lte-rrc-sap.h:388
ns3::LteRrcSap::MeasResults::haveMeasResultNeighCells
bool haveMeasResultNeighCells
have measure result neighbor cells
Definition: lte-rrc-sap.h:683
ns3::A3RsrpHandoverAlgorithm::MemberLteHandoverManagementSapProvider< A3RsrpHandoverAlgorithm >
friend class MemberLteHandoverManagementSapProvider< A3RsrpHandoverAlgorithm >
let the forwarder class access the protected and private members
Definition: a3-rsrp-handover-algorithm.h:84
ns3::LteRrcSap::MeasResults::measId
uint8_t measId
measure ID
Definition: lte-rrc-sap.h:680
ns3::TimeValue
AttributeValue implementation for Time.
Definition: nstime.h:1353
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Definition: log-macros-enabled.h:244
ns3::LteRrcSap::ReportConfigEutra::EVENT_A3
@ EVENT_A3
Event A3: Neighbour becomes amount of offset better than PCell.
Definition: lte-rrc-sap.h:375
ns3::A3RsrpHandoverAlgorithm::m_handoverManagementSapUser
LteHandoverManagementSapUser * m_handoverManagementSapUser
Interface to the eNodeB RRC instance.
Definition: a3-rsrp-handover-algorithm.h:119
ns3::LteRrcSap::ReportConfigEutra::timeToTrigger
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:394
ns3::LteHandoverAlgorithm
The abstract base class of a handover algorithm that operates using the Handover Management SAP inter...
Definition: lte-handover-algorithm.h:67
ns3::A3RsrpHandoverAlgorithm::m_hysteresisDb
double m_hysteresisDb
The Hysteresis attribute.
Definition: a3-rsrp-handover-algorithm.h:111
ns3::Time::MS
@ MS
millisecond
Definition: nstime.h:116
ns3::MakeTimeAccessor
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:1354
ns3::LteRrcSap::ReportConfigEutra::hysteresis
uint8_t hysteresis
Parameter used within the entry and leave condition of an event triggered reporting condition....
Definition: lte-rrc-sap.h:391