A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
test-lte-handover-delay.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2013 Magister Solutions
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Budiarto Herman <budiarto.herman@magister.fi>
7 * Alexander Krotov <krotov@iitp.ru>
8 */
9
10#include <ns3/boolean.h>
11#include <ns3/callback.h>
12#include <ns3/cc-helper.h>
13#include <ns3/config.h>
14#include <ns3/data-rate.h>
15#include <ns3/internet-stack-helper.h>
16#include <ns3/ipv4-address-helper.h>
17#include <ns3/ipv4-interface-container.h>
18#include <ns3/ipv4-static-routing-helper.h>
19#include <ns3/ipv4-static-routing.h>
20#include <ns3/log.h>
21#include <ns3/lte-helper.h>
22#include <ns3/mobility-helper.h>
23#include <ns3/net-device-container.h>
24#include <ns3/node-container.h>
25#include <ns3/nstime.h>
26#include <ns3/point-to-point-epc-helper.h>
27#include <ns3/point-to-point-helper.h>
28#include <ns3/position-allocator.h>
29#include <ns3/simulator.h>
30#include <ns3/test.h>
31
32using namespace ns3;
33
34NS_LOG_COMPONENT_DEFINE("LteHandoverDelayTest");
35
36/**
37 * @ingroup lte-test
38 *
39 * @brief Verifying that the time needed for handover is under a
40 * specified threshold.
41 */
42
44{
45 public:
46 /**
47 * Constructor
48 *
49 * @param numberOfComponentCarriers number of component carriers
50 * @param useIdealRrc if true, use the ideal RRC
51 * @param handoverTime the time of handover
52 * @param delayThreshold the delay threshold
53 * @param simulationDuration duration of the simulation
54 */
55 LteHandoverDelayTestCase(uint8_t numberOfComponentCarriers,
56 bool useIdealRrc,
57 Time handoverTime,
58 Time delayThreshold,
59 Time simulationDuration)
60 : TestCase("Verifying that the time needed for handover is under a specified threshold"),
61 m_numberOfComponentCarriers(numberOfComponentCarriers),
62 m_useIdealRrc(useIdealRrc),
63 m_handoverTime(handoverTime),
64 m_delayThreshold(delayThreshold),
65 m_simulationDuration(simulationDuration),
68 {
69 }
70
71 private:
72 void DoRun() override;
73
74 /**
75 * UE handover start callback function
76 * @param context the context string
77 * @param imsi the IMSI
78 * @param cellid the cell ID
79 * @param rnti the RNTI
80 * @param targetCellId the target cell ID
81 */
82 void UeHandoverStartCallback(std::string context,
83 uint64_t imsi,
84 uint16_t cellid,
85 uint16_t rnti,
86 uint16_t targetCellId);
87 /**
88 * UE handover end OK callback function
89 * @param context the context string
90 * @param imsi the IMSI
91 * @param cellid the cell ID
92 * @param rnti the RNTI
93 */
94 void UeHandoverEndOkCallback(std::string context,
95 uint64_t imsi,
96 uint16_t cellid,
97 uint16_t rnti);
98 /**
99 * ENB handover start callback function
100 * @param context the context string
101 * @param imsi the IMSI
102 * @param cellid the cell ID
103 * @param rnti the RNTI
104 * @param targetCellId the target cell ID
105 */
106 void EnbHandoverStartCallback(std::string context,
107 uint64_t imsi,
108 uint16_t cellid,
109 uint16_t rnti,
110 uint16_t targetCellId);
111 /**
112 * ENB handover end OK callback function
113 * @param context the context string
114 * @param imsi the IMSI
115 * @param cellid the cell ID
116 * @param rnti the RNTI
117 */
118 void EnbHandoverEndOkCallback(std::string context,
119 uint64_t imsi,
120 uint16_t cellid,
121 uint16_t rnti);
122
123 uint8_t m_numberOfComponentCarriers; ///< Number of component carriers
124 bool m_useIdealRrc; ///< use ideal RRC?
125 Time m_handoverTime; ///< handover time
126 Time m_delayThreshold; ///< the delay threshold
127 Time m_simulationDuration; ///< the simulation duration
128
129 Time m_ueHandoverStart; ///< UE handover start time
130 Time m_enbHandoverStart; ///< ENB handover start time
131};
132
133void
135{
136 NS_LOG_INFO("-----test case: ideal RRC = " << m_useIdealRrc << " handover time = "
137 << m_handoverTime.As(Time::S) << "-----");
138
139 /*
140 * Helpers.
141 */
142 auto epcHelper = CreateObject<PointToPointEpcHelper>();
143
144 auto lteHelper = CreateObject<LteHelper>();
145 lteHelper->SetEpcHelper(epcHelper);
146 lteHelper->SetAttribute("UseIdealRrc", BooleanValue(m_useIdealRrc));
147 lteHelper->SetAttribute("NumberOfComponentCarriers",
149
150 auto ccHelper = CreateObject<CcHelper>();
151 ccHelper->SetUlEarfcn(100 + 18000);
152 ccHelper->SetDlEarfcn(100);
153 ccHelper->SetUlBandwidth(25);
154 ccHelper->SetDlBandwidth(25);
155 ccHelper->SetNumberOfComponentCarriers(m_numberOfComponentCarriers);
156
157 /*
158 * Physical layer.
159 *
160 * eNodeB 0 UE eNodeB 1
161 *
162 * x ----------------------- x ----------------------- x
163 * 500 m 500 m
164 */
165 // Create nodes.
166 NodeContainer enbNodes;
167 enbNodes.Create(2);
168 auto ueNode = CreateObject<Node>();
169
170 // Setup mobility
171 auto posAlloc = CreateObject<ListPositionAllocator>();
172 posAlloc->Add(Vector(0, 0, 0));
173 posAlloc->Add(Vector(1000, 0, 0));
174 posAlloc->Add(Vector(500, 0, 0));
175
176 MobilityHelper mobilityHelper;
177 mobilityHelper.SetMobilityModel("ns3::ConstantPositionMobilityModel");
178 mobilityHelper.SetPositionAllocator(posAlloc);
179 mobilityHelper.Install(enbNodes);
180 mobilityHelper.Install(ueNode);
181
182 /*
183 * Link layer.
184 */
185 auto enbDevs = lteHelper->InstallEnbDevice(enbNodes);
186 auto ueDev = lteHelper->InstallUeDevice(ueNode).Get(0);
187
188 /*
189 * Network layer.
190 */
191 InternetStackHelper inetStackHelper;
192 inetStackHelper.Install(ueNode);
194 ueIfs = epcHelper->AssignUeIpv4Address(ueDev);
195
196 // Setup traces.
197 Config::Connect("/NodeList/*/DeviceList/*/LteUeRrc/HandoverStart",
199 Config::Connect("/NodeList/*/DeviceList/*/LteUeRrc/HandoverEndOk",
201
202 Config::Connect("/NodeList/*/DeviceList/*/LteEnbRrc/HandoverStart",
204 Config::Connect("/NodeList/*/DeviceList/*/LteEnbRrc/HandoverEndOk",
206
207 // Prepare handover.
208 lteHelper->AddX2Interface(enbNodes);
209 lteHelper->Attach(ueDev, enbDevs.Get(0));
210 lteHelper->HandoverRequest(m_handoverTime, ueDev, enbDevs.Get(0), enbDevs.Get(1));
211
212 // Run simulation.
216
217} // end of void LteHandoverDelayTestCase::DoRun ()
218
219void
221 uint64_t imsi,
222 uint16_t cellid,
223 uint16_t rnti,
224 uint16_t targetCellId)
225{
226 NS_LOG_FUNCTION(this << context);
228}
229
230void
232 uint64_t imsi,
233 uint16_t cellid,
234 uint16_t rnti)
235{
236 NS_LOG_FUNCTION(this << context);
239
240 NS_LOG_DEBUG(this << " UE delay = " << delay.As(Time::S));
243 "UE handover delay is higher than the allowed threshold "
244 << "(ideal RRC = " << m_useIdealRrc
245 << " handover time = " << m_handoverTime.As(Time::S) << ")");
246}
247
248void
250 uint64_t imsi,
251 uint16_t cellid,
252 uint16_t rnti,
253 uint16_t targetCellId)
254{
255 NS_LOG_FUNCTION(this << context);
257}
258
259void
261 uint64_t imsi,
262 uint16_t cellid,
263 uint16_t rnti)
264{
265 NS_LOG_FUNCTION(this << context);
268
269 NS_LOG_DEBUG(this << " eNodeB delay = " << delay.As(Time::S));
272 "eNodeB handover delay is higher than the allowed threshold "
273 << "(ideal RRC = " << m_useIdealRrc
274 << " handover time = " << m_handoverTime.As(Time::S) << ")");
275}
276
277/**
278 * @ingroup lte-test
279 *
280 * @brief Lte Handover Delay Test Suite
281 */
282
284{
285 public:
287 : TestSuite("lte-handover-delay", Type::SYSTEM)
288 {
289 // LogComponentEnable ("LteHandoverDelayTest", LOG_PREFIX_TIME);
290 // LogComponentEnable ("LteHandoverDelayTest", LOG_DEBUG);
291 // LogComponentEnable ("LteHandoverDelayTest", LOG_INFO);
292
293 // HANDOVER DELAY TEST CASES WITH IDEAL RRC (THRESHOLD = 0.005 sec)
294
295 for (Time handoverTime = Seconds(0.100); handoverTime < Seconds(0.110);
296 handoverTime += Seconds(0.001))
297 {
298 // arguments: useIdealRrc, handoverTime, delayThreshold, simulationDuration
300 new LteHandoverDelayTestCase(1, true, handoverTime, Seconds(0.005), Seconds(0.200)),
301 TestCase::Duration::QUICK);
303 new LteHandoverDelayTestCase(2, true, handoverTime, Seconds(0.005), Seconds(0.200)),
304 TestCase::Duration::QUICK);
306 new LteHandoverDelayTestCase(4, true, handoverTime, Seconds(0.005), Seconds(0.200)),
307 TestCase::Duration::QUICK);
308 }
309
310 // HANDOVER DELAY TEST CASES WITH REAL RRC (THRESHOLD = 0.020 sec)
311
312 for (Time handoverTime = Seconds(0.100); handoverTime < Seconds(0.110);
313 handoverTime += Seconds(0.001))
314 {
315 // arguments: useIdealRrc, handoverTime, delayThreshold, simulationDuration
317 false,
318 handoverTime,
319 Seconds(0.020),
320 Seconds(0.200)),
321 TestCase::Duration::QUICK);
323 false,
324 handoverTime,
325 Seconds(0.020),
326 Seconds(0.200)),
327 TestCase::Duration::QUICK);
329 false,
330 handoverTime,
331 Seconds(0.020),
332 Seconds(0.200)),
333 TestCase::Duration::QUICK);
334 }
335 }
336} g_lteHandoverDelayTestSuite; ///< the test suite
Verifying that the time needed for handover is under a specified threshold.
void EnbHandoverStartCallback(std::string context, uint64_t imsi, uint16_t cellid, uint16_t rnti, uint16_t targetCellId)
ENB handover start callback function.
Time m_simulationDuration
the simulation duration
void DoRun() override
Implementation to actually run this TestCase.
uint8_t m_numberOfComponentCarriers
Number of component carriers.
void UeHandoverEndOkCallback(std::string context, uint64_t imsi, uint16_t cellid, uint16_t rnti)
UE handover end OK callback function.
void UeHandoverStartCallback(std::string context, uint64_t imsi, uint16_t cellid, uint16_t rnti, uint16_t targetCellId)
UE handover start callback function.
Time m_delayThreshold
the delay threshold
void EnbHandoverEndOkCallback(std::string context, uint64_t imsi, uint16_t cellid, uint16_t rnti)
ENB handover end OK callback function.
Time m_ueHandoverStart
UE handover start time.
LteHandoverDelayTestCase(uint8_t numberOfComponentCarriers, bool useIdealRrc, Time handoverTime, Time delayThreshold, Time simulationDuration)
Constructor.
Time m_enbHandoverStart
ENB handover start time.
Lte Handover Delay Test Suite.
AttributeValue implementation for Boolean.
Definition boolean.h:26
aggregate IP/TCP/UDP functionality to existing Nodes.
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
holds a vector of std::pair of Ptr<Ipv4> and interface index.
Helper class used to assign positions and mobility models to nodes.
void Install(Ptr< Node > node) const
"Layout" a single node according to the current position allocator type.
void SetMobilityModel(std::string type, Ts &&... args)
void SetPositionAllocator(Ptr< PositionAllocator > allocator)
Set the position allocator which will be used to allocate the initial position of every node initiali...
keep track of a set of node pointers.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition simulator.cc:131
static Time Now()
Return the current simulation virtual time.
Definition simulator.cc:197
static void Run()
Run the simulation.
Definition simulator.cc:167
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Definition simulator.cc:175
encapsulates test code
Definition test.h:1050
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Definition test.cc:292
A suite of tests to run.
Definition test.h:1267
Type
Type of test.
Definition test.h:1274
static constexpr auto SYSTEM
Definition test.h:1293
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
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
bool IsStrictlyPositive() const
Exactly equivalent to t > 0.
Definition nstime.h:340
@ S
second
Definition nstime.h:105
Hold an unsigned integer type.
Definition uinteger.h:34
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition assert.h:55
void Connect(std::string path, const CallbackBase &cb)
Definition config.cc:967
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition log.h:257
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition log.h:264
LteHandoverDelayTestSuite g_lteHandoverDelayTestSuite
the test suite
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition object.h:619
#define NS_TEST_ASSERT_MSG_LT(actual, limit, msg)
Test that an actual value is less than a limit and report and abort if not.
Definition test.h:699
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition nstime.h:1344
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Definition callback.h:684