5G-LENA nr-v3.3-161-gad18933f
The 5G/NR module for the ns-3 simulator
Loading...
Searching...
No Matches
nr-a3-rsrp-handover-algorithm.cc
1// Copyright (c) 2013 Budiarto Herman
2//
3// SPDX-License-Identifier: GPL-2.0-only
4//
5// Author: Budiarto Herman <budiarto.herman@magister.fi>
6
7#include "nr-a3-rsrp-handover-algorithm.h"
8
9#include "nr-common.h"
10
11#include "ns3/double.h"
12#include "ns3/log.h"
13
14#include <algorithm>
15#include <list>
16
17namespace ns3
18{
19
20NS_LOG_COMPONENT_DEFINE("NrA3RsrpHandoverAlgorithm");
21
22NS_OBJECT_ENSURE_REGISTERED(NrA3RsrpHandoverAlgorithm);
23
25 : m_handoverManagementSapUser(nullptr)
26{
27 NS_LOG_FUNCTION(this);
28 m_handoverManagementSapProvider =
30}
31
32NrA3RsrpHandoverAlgorithm::~NrA3RsrpHandoverAlgorithm()
33{
34 NS_LOG_FUNCTION(this);
35}
36
37TypeId
39{
40 static TypeId tid =
41 TypeId("ns3::NrA3RsrpHandoverAlgorithm")
42 .SetParent<NrHandoverAlgorithm>()
43 .SetGroupName("Nr")
44 .AddConstructor<NrA3RsrpHandoverAlgorithm>()
45 .AddAttribute(
46 "Hysteresis",
47 "Handover margin (hysteresis) in dB "
48 "(rounded to the nearest multiple of 0.5 dB)",
49 DoubleValue(3.0),
50 MakeDoubleAccessor(&NrA3RsrpHandoverAlgorithm::m_hysteresisDb),
51 MakeDoubleChecker<uint8_t>(0.0, 15.0)) // Hysteresis IE value range is [0..30] as
52 // per Section 6.3.5 of 3GPP TS 36.331
53 .AddAttribute("TimeToTrigger",
54 "Time during which neighbour cell's RSRP "
55 "must continuously higher than serving cell's RSRP "
56 "in order to trigger a handover",
57 TimeValue(MilliSeconds(256)), // 3GPP time-to-trigger median value as per
58 // Section 6.3.5 of 3GPP TS 36.331
59 MakeTimeAccessor(&NrA3RsrpHandoverAlgorithm::m_timeToTrigger),
60 MakeTimeChecker());
61 return tid;
62}
63
64void
66{
67 NS_LOG_FUNCTION(this << s);
68 m_handoverManagementSapUser = s;
69}
70
73{
74 NS_LOG_FUNCTION(this);
75 return m_handoverManagementSapProvider;
76}
77
78void
79NrA3RsrpHandoverAlgorithm::DoInitialize()
80{
81 NS_LOG_FUNCTION(this);
82
83 uint8_t hysteresisIeValue =
85 NS_LOG_LOGIC(this << " requesting Event A3 measurements"
86 << " (hysteresis=" << (uint16_t)hysteresisIeValue << ")"
87 << " (ttt=" << m_timeToTrigger.As(Time::MS) << ")");
88
89 NrRrcSap::ReportConfigEutra reportConfig;
91 reportConfig.a3Offset = 0;
92 reportConfig.hysteresis = hysteresisIeValue;
93 reportConfig.timeToTrigger = m_timeToTrigger.GetMilliSeconds();
94 reportConfig.reportOnLeave = false;
96 reportConfig.reportInterval = NrRrcSap::ReportConfigEutra::MS1024;
97 m_measIds = m_handoverManagementSapUser->AddUeMeasReportConfigForHandover(reportConfig);
98
99 NrHandoverAlgorithm::DoInitialize();
100}
101
102void
103NrA3RsrpHandoverAlgorithm::DoDispose()
104{
105 NS_LOG_FUNCTION(this);
106 delete m_handoverManagementSapProvider;
107}
108
109void
111{
112 NS_LOG_FUNCTION(this << rnti << (uint16_t)measResults.measId);
113
114 if (std::find(begin(m_measIds), end(m_measIds), measResults.measId) == std::end(m_measIds))
115 {
116 NS_LOG_WARN("Ignoring measId " << (uint16_t)measResults.measId);
117 return;
118 }
119
120 if (measResults.haveMeasResultNeighCells && !measResults.measResultListEutra.empty())
121 {
122 uint16_t bestNeighbourCellId = 0;
123 uint8_t bestNeighbourRsrp = 0;
124
125 for (auto it = measResults.measResultListEutra.begin();
126 it != measResults.measResultListEutra.end();
127 ++it)
128 {
129 if (it->haveRsrpResult)
130 {
131 if ((bestNeighbourRsrp < it->rsrpResult) && IsValidNeighbour(it->physCellId))
132 {
133 bestNeighbourCellId = it->physCellId;
134 bestNeighbourRsrp = it->rsrpResult;
135 }
136 }
137 else
138 {
139 NS_LOG_WARN("RSRP measurement is missing from cell ID " << it->physCellId);
140 }
141 }
142
143 if (bestNeighbourCellId > 0)
144 {
145 NS_LOG_LOGIC("Trigger Handover to cellId " << bestNeighbourCellId);
146 NS_LOG_LOGIC("target cell RSRP " << (uint16_t)bestNeighbourRsrp);
147 NS_LOG_LOGIC("serving cell RSRP " << (uint16_t)measResults.measResultPCell.rsrpResult);
148
149 // Inform eNodeB RRC about handover
150 m_handoverManagementSapUser->TriggerHandover(rnti, bestNeighbourCellId);
151 }
152 }
153 else
154 {
155 NS_LOG_WARN(
156 this << " Event A3 received without measurement results from neighbouring cells");
157 }
158
159} // end of DoReportUeMeas
160
161bool
162NrA3RsrpHandoverAlgorithm::IsValidNeighbour(uint16_t cellId)
163{
164 NS_LOG_FUNCTION(this << cellId);
165
172 return true;
173}
174
175} // end of namespace ns3
Implementation of the strongest cell handover algorithm, based on RSRP measurements and Event A3.
NrA3RsrpHandoverAlgorithm()
Creates a strongest cell handover algorithm instance.
void SetNrHandoverManagementSapUser(NrHandoverManagementSapUser *s) override
Set the "user" part of the Handover Management SAP interface that this handover algorithm instance wi...
friend class MemberNrHandoverManagementSapProvider< NrA3RsrpHandoverAlgorithm >
let the forwarder class access the protected and private members
static TypeId GetTypeId()
Get the type ID.
void DoReportUeMeas(uint16_t rnti, NrRrcSap::MeasResults measResults) override
Implementation of NrHandoverManagementSapProvider::ReportUeMeas.
NrHandoverManagementSapProvider * GetNrHandoverManagementSapProvider() override
Export the "provider" part of the Handover Management SAP interface.
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(NrRrcSap::ReportConfigEutra reportConfig)=0
Request a certain reporting configuration to be fulfilled by the UEs attached to the eNodeB entity.
static uint8_t ActualHysteresis2IeValue(double hysteresisDb)
Returns the IE value of hysteresis.
Definition nr-common.cc:275
uint8_t rsrpResult
the RSRP result
Definition nr-rrc-sap.h:680
MeasResults structure.
Definition nr-rrc-sap.h:723
uint8_t measId
measure ID
Definition nr-rrc-sap.h:724
bool haveMeasResultNeighCells
have measure result neighbor cells
Definition nr-rrc-sap.h:726
MeasResultPCell measResultPCell
measurement result primary cell
Definition nr-rrc-sap.h:725
std::list< MeasResultEutra > measResultListEutra
measure result list eutra
Definition nr-rrc-sap.h:727
Specifies criteria for triggering of an E-UTRA measurement reporting event.
Definition nr-rrc-sap.h:360
enum ns3::NrRrcSap::ReportConfigEutra::@5 triggerQuantity
Trigger type enumeration.
@ RSRP
Reference Signal Received Power.
Definition nr-rrc-sap.h:412
enum ns3::NrRrcSap::ReportConfigEutra::@7 reportInterval
Report interval enumeration.
@ EVENT_A3
Event A3: Neighbour becomes amount of offset better than PCell.
Definition nr-rrc-sap.h:373
enum ns3::NrRrcSap::ReportConfigEutra::@4 eventId
Event enumeration.