A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
a3-rsrp-handover-algorithm.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2013 Budiarto Herman
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Budiarto Herman <budiarto.herman@magister.fi>
7 *
8 */
9
11
12#include "lte-common.h"
13
14#include <ns3/double.h>
15#include <ns3/log.h>
16
17#include <algorithm>
18#include <list>
19
20namespace ns3
21{
22
23NS_LOG_COMPONENT_DEFINE("A3RsrpHandoverAlgorithm");
24
25NS_OBJECT_ENSURE_REGISTERED(A3RsrpHandoverAlgorithm);
26
34
39
42{
43 static TypeId tid =
44 TypeId("ns3::A3RsrpHandoverAlgorithm")
46 .SetGroupName("Lte")
47 .AddConstructor<A3RsrpHandoverAlgorithm>()
48 .AddAttribute(
49 "Hysteresis",
50 "Handover margin (hysteresis) in dB "
51 "(rounded to the nearest multiple of 0.5 dB)",
52 DoubleValue(3.0),
54 MakeDoubleChecker<uint8_t>(0.0, 15.0)) // Hysteresis IE value range is [0..30] as
55 // per Section 6.3.5 of 3GPP TS 36.331
56 .AddAttribute("TimeToTrigger",
57 "Time during which neighbour cell's RSRP "
58 "must continuously higher than serving cell's RSRP "
59 "in order to trigger a handover",
60 TimeValue(MilliSeconds(256)), // 3GPP time-to-trigger median value as per
61 // Section 6.3.5 of 3GPP TS 36.331
64 return tid;
65}
66
67void
73
80
81void
83{
84 NS_LOG_FUNCTION(this);
85
87 NS_LOG_LOGIC(this << " requesting Event A3 measurements"
88 << " (hysteresis=" << (uint16_t)hysteresisIeValue << ")"
89 << " (ttt=" << m_timeToTrigger.As(Time::MS) << ")");
90
93 reportConfig.a3Offset = 0;
94 reportConfig.hysteresis = hysteresisIeValue;
96 reportConfig.reportOnLeave = false;
100
102}
103
104void
110
111void
113{
114 NS_LOG_FUNCTION(this << rnti << (uint16_t)measResults.measId);
115
116 if (std::find(begin(m_measIds), end(m_measIds), measResults.measId) == std::end(m_measIds))
117 {
118 NS_LOG_WARN("Ignoring measId " << (uint16_t)measResults.measId);
119 return;
120 }
121
122 if (measResults.haveMeasResultNeighCells && !measResults.measResultListEutra.empty())
123 {
124 uint16_t bestNeighbourCellId = 0;
125 uint8_t bestNeighbourRsrp = 0;
126
127 for (auto it = measResults.measResultListEutra.begin();
128 it != measResults.measResultListEutra.end();
129 ++it)
130 {
131 if (it->haveRsrpResult)
132 {
133 if ((bestNeighbourRsrp < it->rsrpResult) && IsValidNeighbour(it->physCellId))
134 {
135 bestNeighbourCellId = it->physCellId;
136 bestNeighbourRsrp = it->rsrpResult;
137 }
138 }
139 else
140 {
141 NS_LOG_WARN("RSRP measurement is missing from cell ID " << it->physCellId);
142 }
143 }
144
145 if (bestNeighbourCellId > 0)
146 {
147 NS_LOG_LOGIC("Trigger Handover to cellId " << bestNeighbourCellId);
148 NS_LOG_LOGIC("target cell RSRP " << (uint16_t)bestNeighbourRsrp);
149 NS_LOG_LOGIC("serving cell RSRP " << (uint16_t)measResults.measResultPCell.rsrpResult);
150
151 // Inform eNodeB RRC about handover
152 m_handoverManagementSapUser->TriggerHandover(rnti, bestNeighbourCellId);
153 }
154 }
155 else
156 {
158 this << " Event A3 received without measurement results from neighbouring cells");
159 }
160
161} // end of DoReportUeMeas
162
163bool
165{
166 NS_LOG_FUNCTION(this << cellId);
167
168 /**
169 * \todo In the future, this function can be expanded to validate whether the
170 * neighbour cell is a valid target cell, e.g., taking into account the
171 * NRT in ANR and whether it is a CSG cell with closed access.
172 */
173
174 return true;
175}
176
177} // 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:31
static uint8_t ActualHysteresis2IeValue(double hysteresisDb)
Returns the IE value of hysteresis.
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 void TriggerHandover(uint16_t rnti, uint16_t targetCellId)=0
Instruct the eNodeB RRC entity to prepare a handover.
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 DoInitialize()
Initialize() implementation.
Definition object.cc:440
int64_t GetMilliSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
Definition nstime.h:397
TimeWithUnit As(const Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
Definition time.cc:404
@ MS
millisecond
Definition nstime.h:106
a unique identifier for an interface.
Definition type-id.h:48
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition log.h:271
#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:250
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition object-base.h:35
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition nstime.h:1320
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Definition nstime.h:1396
Ptr< const AttributeChecker > MakeDoubleChecker()
Definition double.h:82
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Definition double.h:32
Ptr< const AttributeChecker > MakeTimeChecker()
Helper to make an unbounded Time checker.
Definition nstime.h:1416
uint8_t rsrpResult
the RSRP result
MeasResults structure.
uint8_t measId
measure ID
bool haveMeasResultNeighCells
have measure result neighbor cells
std::list< MeasResultEutra > measResultListEutra
measure result list eutra
MeasResultPCell measResultPCell
measurement result primary cell
Specifies criteria for triggering of an E-UTRA measurement reporting event.
bool reportOnLeave
Indicates whether or not the UE shall initiate the measurement reporting procedure when the leaving c...
enum ns3::LteRrcSap::ReportConfigEutra::@62 eventId
Event enumeration.
uint8_t hysteresis
Parameter used within the entry and leave condition of an event triggered reporting condition.
@ RSRP
Reference Signal Received Power.
@ EVENT_A3
Event A3: Neighbour becomes amount of offset better than PCell.
enum ns3::LteRrcSap::ReportConfigEutra::@65 reportInterval
Report interval enumeration.
enum ns3::LteRrcSap::ReportConfigEutra::@63 triggerQuantity
Trigger type enumeration.
int8_t a3Offset
Offset value for Event A3.
uint16_t timeToTrigger
Time during which specific criteria for the event needs to be met in order to trigger a measurement r...