-
Notifications
You must be signed in to change notification settings - Fork 0
/
a2-a4-rsrq-handover-algorithm.h
195 lines (168 loc) · 7.06 KB
/
a2-a4-rsrq-handover-algorithm.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2011, 2012 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
* Copyright (c) 2013 Budiarto Herman
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Original work authors (from lte-enb-rrc.cc):
* - Nicola Baldo <nbaldo@cttc.es>
* - Marco Miozzo <mmiozzo@cttc.es>
* - Manuel Requena <manuel.requena@cttc.es>
*
* Converted to handover algorithm interface by:
* - Budiarto Herman <budiarto.herman@magister.fi>
*/
#ifndef A2_A4_RSRQ_HANDOVER_ALGORITHM_H
#define A2_A4_RSRQ_HANDOVER_ALGORITHM_H
#include <ns3/lte-handover-algorithm.h>
#include <ns3/lte-handover-management-sap.h>
#include <ns3/lte-rrc-sap.h>
#include <ns3/simple-ref-count.h>
#include <ns3/ptr.h>
#include <map>
namespace ns3 {
/**
* \brief Handover algorithm implementation based on RSRQ measurements, Event
* A2 and Event A4.
*
* Handover decision made by this algorithm is primarily based on Event A2
* measurements (serving cell's RSRQ becomes worse than threshold). When the
* event is triggered, the first condition of handover is fulfilled.
*
* Event A4 measurements (neighbour cell's RSRQ becomes better than threshold)
* are used to detect neighbouring cells and their respective RSRQ. When a
* neighbouring cell's RSRQ is higher than the serving cell's RSRQ by a certain
* offset, then the second condition of handover is fulfilled.
*
* When the first and second conditions above are fulfilled, the algorithm
* informs the eNodeB RRC to trigger a handover.
*
* The threshold for Event A2 can be configured in the `ServingCellThreshold`
* attribute. The offset used in the second condition can also be configured by
* setting the `NeighbourCellOffset` attribute.
*
* The following code snippet is an example of using and configuring the
* handover algorithm in a simulation program:
*
* Ptr<LteHelper> lteHelper = CreateObject<LteHelper> ();
*
* NodeContainer enbNodes;
* // configure the nodes here...
*
* lteHelper->SetHandoverAlgorithmType ("ns3::A2A4RsrqHandoverAlgorithm");
* lteHelper->SetHandoverAlgorithmAttribute ("ServingCellThreshold",
* UintegerValue (30));
* lteHelper->SetHandoverAlgorithmAttribute ("NeighbourCellOffset",
* UintegerValue (1));
* NetDeviceContainer enbLteDevs = lteHelper->InstallEnbDevice (enbNodes);
*
* \note Setting the handover algorithm type and attributes after the call to
* LteHelper::InstallEnbDevice does not have any effect to the devices
* that have already been installed.
*/
class A2A4RsrqHandoverAlgorithm : public LteHandoverAlgorithm
{
public:
/// Creates an A2-A4-RSRQ handover algorithm instance.
A2A4RsrqHandoverAlgorithm ();
virtual ~A2A4RsrqHandoverAlgorithm ();
// inherited from Object
static TypeId GetTypeId ();
// inherited from LteHandoverAlgorithm
virtual void SetLteHandoverManagementSapUser (LteHandoverManagementSapUser* s);
virtual LteHandoverManagementSapProvider* GetLteHandoverManagementSapProvider ();
// let the forwarder class access the protected and private members
friend class MemberLteHandoverManagementSapProvider<A2A4RsrqHandoverAlgorithm>;
protected:
// inherited from Object
virtual void DoInitialize ();
virtual void DoDispose ();
// inherited from LteHandoverAlgorithm as a Handover Management SAP implementation
void DoReportUeMeas (uint16_t rnti, LteRrcSap::MeasResults measResults);
private:
/**
* Called when Event A2 is detected, then trigger a handover if needed.
*
* \param rnti The RNTI of the UE who reported the event.
* \param servingCellRsrq The RSRQ of this cell as reported by the UE.
*/
void EvaluateHandover (uint16_t rnti, uint8_t servingCellRsrq);
/**
* Determines if a neighbour cell is a valid destination for handover.
* Currently always return true.
*
* \param cellId The cell ID of the neighbour cell.
* \return True if the cell is a valid destination for handover.
*/
bool IsValidNeighbour (uint16_t cellId);
/**
* Called when Event A4 is reported, then update the measurements table.
* If the RNTI and/or cell ID is not found in the table, a corresponding
* entry will be created. Only the latest measurements are stored in the
* table.
*
* \param rnti The RNTI of the UE who reported the event.
* \param cellId The cell ID of the measured cell.
* \param rsrq The RSRQ of the cell as measured by the UE.
*/
void UpdateNeighbourMeasurements (uint16_t rnti, uint16_t cellId,
uint8_t rsrq);
/// The expected measurement identity for A2 measurements.
uint8_t m_a2MeasId;
/// The expected measurement identity for A4 measurements.
uint8_t m_a4MeasId;
/**
* Measurements reported by a UE for a cell ID. The values are quantized
* according 3GPP TS 36.133 section 9.1.4 and 9.1.7.
*/
class UeMeasure : public SimpleRefCount<UeMeasure>
{
public:
uint16_t m_cellId; ///< Cell ID.
uint8_t m_rsrp; ///< RSRP in quantized format. \todo Can be removed?
uint8_t m_rsrq; ///< RSRQ in quantized format.
};
/**
* Measurements reported by a UE for several cells. The structure is a map
* indexed by the cell ID.
*/
typedef std::map<uint16_t, Ptr<UeMeasure> > MeasurementRow_t;
/**
* Measurements reported by several UEs. The structure is a map indexed by
* the RNTI of the UE.
*/
typedef std::map<uint16_t, MeasurementRow_t> MeasurementTable_t;
/// Table of measurement reports from all UEs.
MeasurementTable_t m_neighbourCellMeasures;
/**
* The `ServingCellThreshold` attribute. If the RSRQ of the serving cell is
* worse than this threshold, neighbour cells are consider for handover.
* Expressed in quantized range of [0..34] as per Section 9.1.7 of
* 3GPP TS 36.133.
*/
uint8_t m_servingCellThreshold;
/**
* The `NeighbourCellOffset` attribute. Minimum offset between the serving
* and the best neighbour cell to trigger the handover. Expressed in
* quantized range of [0..34] as per Section 9.1.7 of 3GPP TS 36.133.
*/
uint8_t m_neighbourCellOffset;
/// Interface to the eNodeB RRC instance.
LteHandoverManagementSapUser* m_handoverManagementSapUser;
/// Receive API calls from the eNodeB RRC instance.
LteHandoverManagementSapProvider* m_handoverManagementSapProvider;
}; // end of class A2A4RsrqHandoverAlgorithm
} // end of namespace ns3
#endif /* A2_A4_RSRQ_HANDOVER_ALGORITHM_H */