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  .AddConstructor<A3RsrpHandoverAlgorithm> ()
55  .AddAttribute ("Hysteresis",
56  "Handover margin (hysteresis) in dB "
57  "(rounded to the nearest multiple of 0.5 dB)",
58  DoubleValue (3.0),
60  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
61  .AddAttribute ("TimeToTrigger",
62  "Time during which neighbour cell's RSRP "
63  "must continuously higher than serving cell's RSRP "
64  "in order to trigger a handover",
65  TimeValue (MilliSeconds (256)), // 3GPP time-to-trigger median value as per Section 6.3.5 of 3GPP TS 36.331
67  MakeTimeChecker ())
68  ;
69  return tid;
70 }
71 
72 
73 void
75 {
76  NS_LOG_FUNCTION (this << s);
78 }
79 
80 
83 {
84  NS_LOG_FUNCTION (this);
86 }
87 
88 
89 void
91 {
92  NS_LOG_FUNCTION (this);
93 
95  NS_LOG_LOGIC (this << " requesting Event A3 measurements"
96  << " (hysteresis=" << (uint16_t) hysteresisIeValue << ")"
97  << " (ttt=" << m_timeToTrigger.GetMilliSeconds () << ")");
98 
99  LteRrcSap::ReportConfigEutra reportConfig;
101  reportConfig.a3Offset = 0;
102  reportConfig.hysteresis = hysteresisIeValue;
103  reportConfig.timeToTrigger = m_timeToTrigger.GetMilliSeconds ();
104  reportConfig.reportOnLeave = false;
105  reportConfig.triggerQuantity = LteRrcSap::ReportConfigEutra::RSRP;
106  reportConfig.reportInterval = LteRrcSap::ReportConfigEutra::MS1024;
108 
110 }
111 
112 
113 void
115 {
116  NS_LOG_FUNCTION (this);
118 }
119 
120 
121 void
123  LteRrcSap::MeasResults measResults)
124 {
125  NS_LOG_FUNCTION (this << rnti << (uint16_t) measResults.measId);
126 
127  if (measResults.measId != m_measId)
128  {
129  NS_LOG_WARN ("Ignoring measId " << (uint16_t) measResults.measId);
130  }
131  else
132  {
133  if (measResults.haveMeasResultNeighCells
134  && !measResults.measResultListEutra.empty ())
135  {
136  uint16_t bestNeighbourCellId = 0;
137  uint8_t bestNeighbourRsrp = 0;
138 
139  for (std::list <LteRrcSap::MeasResultEutra>::iterator it = measResults.measResultListEutra.begin ();
140  it != measResults.measResultListEutra.end ();
141  ++it)
142  {
143  if (it->haveRsrpResult)
144  {
145  if ((bestNeighbourRsrp < it->rsrpResult)
146  && IsValidNeighbour (it->physCellId))
147  {
148  bestNeighbourCellId = it->physCellId;
149  bestNeighbourRsrp = it->rsrpResult;
150  }
151  }
152  else
153  {
154  NS_LOG_WARN ("RSRP measurement is missing from cell ID " << it->physCellId);
155  }
156  }
157 
158  if (bestNeighbourCellId > 0)
159  {
160  NS_LOG_LOGIC ("Trigger Handover to cellId " << bestNeighbourCellId);
161  NS_LOG_LOGIC ("target cell RSRP " << (uint16_t) bestNeighbourRsrp);
162  NS_LOG_LOGIC ("serving cell RSRP " << (uint16_t) measResults.rsrpResult);
163 
164  // Inform eNodeB RRC about handover
166  bestNeighbourCellId);
167  }
168  }
169  else
170  {
171  NS_LOG_WARN (this << " Event A3 received without measurement results from neighbouring cells");
172  }
173  } // end of else of if (measResults.measId != m_measId)
174 
175 } // end of DoReportUeMeas
176 
177 
178 bool
180 {
181  NS_LOG_FUNCTION (this << cellId);
182 
189  return true;
190 }
191 
192 
193 } // end of namespace ns3
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
The abstract base class of a handover algorithm that operates using the Handover Management SAP inter...
double m_hysteresisDb
The Hysteresis attribute.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:44
std::list< MeasResultEutra > measResultListEutra
Definition: lte-rrc-sap.h:582
Specifies criteria for triggering of an E-UTRA measurement reporting event.
Definition: lte-rrc-sap.h:321
enum ns3::LteRrcSap::ReportConfigEutra::@72 eventId
Choice of E-UTRA event triggered reporting criteria.
virtual void TriggerHandover(uint16_t rnti, uint16_t targetCellId)=0
Instruct the eNodeB RRC entity to prepare a handover.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:201
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:867
LteHandoverManagementSapProvider * m_handoverManagementSapProvider
Receive API calls from the eNodeB RRC instance.
void DoReportUeMeas(uint16_t rnti, LteRrcSap::MeasResults measResults)
Implementation of LteHandoverManagementSapProvider::ReportUeMeas.
virtual void DoInitialize()
Initialize() implementation.
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Definition: time.cc:439
AttributeValue implementation for Time.
Definition: nstime.h:921
bool IsValidNeighbour(uint16_t cellId)
Determines if a neighbour cell is a valid destination for handover.
Ptr< SampleEmitter > s
Time m_timeToTrigger
The TimeToTrigger attribute.
Template for the implementation of the LteHandoverManagementSapProvider as a member of an owner class...
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:252
uint8_t m_measId
The expected measurement identity for A3 measurements.
LteHandoverManagementSapUser * m_handoverManagementSapUser
Interface to the eNodeB RRC instance.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
virtual LteHandoverManagementSapProvider * GetLteHandoverManagementSapProvider()
Export the "provider" part of the Handover Management SAP interface.
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:922
Event A3: Neighbour becomes amount of offset better than PCell.
Definition: lte-rrc-sap.h:333
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
static uint8_t ActualHysteresis2IeValue(double hysteresisDb)
Returns the IE value of hysteresis.
Definition: lte-common.cc:261
Reference Signal Received Power.
Definition: lte-rrc-sap.h:362
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Definition: log.h:228
Service Access Point (SAP) offered by the handover algorithm instance to the eNodeB RRC instance...
virtual uint8_t AddUeMeasReportConfigForHandover(LteRrcSap::ReportConfigEutra reportConfig)=0
Request a certain reporting configuration to be fulfilled by the UEs attached to the eNodeB entity...
A3RsrpHandoverAlgorithm()
Creates a strongest cell handover algorithm instance.
This class can be used to hold variables of floating point type such as 'double' or 'float'...
Definition: double.h:41
virtual void DoDispose()
Destructor implementation.
a unique identifier for an interface.
Definition: type-id.h:51
int64_t GetMilliSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:331
TypeId SetParent(TypeId tid)
Definition: type-id.cc:631
virtual void SetLteHandoverManagementSapUser(LteHandoverManagementSapUser *s)
Set the "user" part of the Handover Management SAP interface that this handover algorithm instance wi...
Service Access Point (SAP) offered by the eNodeB RRC instance to the handover algorithm instance...
virtual void DoInitialize(void)
Initialize() implementation.
Definition: object.cc:345