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 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Budiarto Herman <budiarto.herman@magister.fi>
18 * Alexander Krotov <krotov@iitp.ru>
19 */
20
21#include <ns3/boolean.h>
22#include <ns3/callback.h>
23#include <ns3/cc-helper.h>
24#include <ns3/config.h>
25#include <ns3/data-rate.h>
26#include <ns3/internet-stack-helper.h>
27#include <ns3/ipv4-address-helper.h>
28#include <ns3/ipv4-interface-container.h>
29#include <ns3/ipv4-static-routing-helper.h>
30#include <ns3/ipv4-static-routing.h>
31#include <ns3/log.h>
32#include <ns3/lte-helper.h>
33#include <ns3/mobility-helper.h>
34#include <ns3/net-device-container.h>
35#include <ns3/node-container.h>
36#include <ns3/nstime.h>
37#include <ns3/point-to-point-epc-helper.h>
38#include <ns3/point-to-point-helper.h>
39#include <ns3/position-allocator.h>
40#include <ns3/simulator.h>
41#include <ns3/test.h>
42
43using namespace ns3;
44
45NS_LOG_COMPONENT_DEFINE("LteHandoverDelayTest");
46
55{
56 public:
66 LteHandoverDelayTestCase(uint8_t numberOfComponentCarriers,
67 bool useIdealRrc,
68 Time handoverTime,
69 Time delayThreshold,
70 Time simulationDuration)
71 : TestCase("Verifying that the time needed for handover is under a specified threshold"),
72 m_numberOfComponentCarriers(numberOfComponentCarriers),
73 m_useIdealRrc(useIdealRrc),
74 m_handoverTime(handoverTime),
75 m_delayThreshold(delayThreshold),
76 m_simulationDuration(simulationDuration),
79 {
80 }
81
82 private:
83 void DoRun() override;
84
93 void UeHandoverStartCallback(std::string context,
94 uint64_t imsi,
95 uint16_t cellid,
96 uint16_t rnti,
97 uint16_t targetCellId);
105 void UeHandoverEndOkCallback(std::string context,
106 uint64_t imsi,
107 uint16_t cellid,
108 uint16_t rnti);
117 void EnbHandoverStartCallback(std::string context,
118 uint64_t imsi,
119 uint16_t cellid,
120 uint16_t rnti,
121 uint16_t targetCellId);
129 void EnbHandoverEndOkCallback(std::string context,
130 uint64_t imsi,
131 uint16_t cellid,
132 uint16_t rnti);
133
139
142};
143
144void
146{
147 NS_LOG_INFO("-----test case: ideal RRC = " << m_useIdealRrc << " handover time = "
148 << m_handoverTime.As(Time::S) << "-----");
149
150 /*
151 * Helpers.
152 */
153 auto epcHelper = CreateObject<PointToPointEpcHelper>();
154
155 auto lteHelper = CreateObject<LteHelper>();
156 lteHelper->SetEpcHelper(epcHelper);
157 lteHelper->SetAttribute("UseIdealRrc", BooleanValue(m_useIdealRrc));
158 lteHelper->SetAttribute("NumberOfComponentCarriers",
160
161 auto ccHelper = CreateObject<CcHelper>();
162 ccHelper->SetUlEarfcn(100 + 18000);
163 ccHelper->SetDlEarfcn(100);
164 ccHelper->SetUlBandwidth(25);
165 ccHelper->SetDlBandwidth(25);
166 ccHelper->SetNumberOfComponentCarriers(m_numberOfComponentCarriers);
167
168 /*
169 * Physical layer.
170 *
171 * eNodeB 0 UE eNodeB 1
172 *
173 * x ----------------------- x ----------------------- x
174 * 500 m 500 m
175 */
176 // Create nodes.
177 NodeContainer enbNodes;
178 enbNodes.Create(2);
179 auto ueNode = CreateObject<Node>();
180
181 // Setup mobility
182 auto posAlloc = CreateObject<ListPositionAllocator>();
183 posAlloc->Add(Vector(0, 0, 0));
184 posAlloc->Add(Vector(1000, 0, 0));
185 posAlloc->Add(Vector(500, 0, 0));
186
187 MobilityHelper mobilityHelper;
188 mobilityHelper.SetMobilityModel("ns3::ConstantPositionMobilityModel");
189 mobilityHelper.SetPositionAllocator(posAlloc);
190 mobilityHelper.Install(enbNodes);
191 mobilityHelper.Install(ueNode);
192
193 /*
194 * Link layer.
195 */
196 auto enbDevs = lteHelper->InstallEnbDevice(enbNodes);
197 auto ueDev = lteHelper->InstallUeDevice(ueNode).Get(0);
198
199 /*
200 * Network layer.
201 */
202 InternetStackHelper inetStackHelper;
203 inetStackHelper.Install(ueNode);
205 ueIfs = epcHelper->AssignUeIpv4Address(ueDev);
206
207 // Setup traces.
208 Config::Connect("/NodeList/*/DeviceList/*/LteUeRrc/HandoverStart",
210 Config::Connect("/NodeList/*/DeviceList/*/LteUeRrc/HandoverEndOk",
212
213 Config::Connect("/NodeList/*/DeviceList/*/LteEnbRrc/HandoverStart",
215 Config::Connect("/NodeList/*/DeviceList/*/LteEnbRrc/HandoverEndOk",
217
218 // Prepare handover.
219 lteHelper->AddX2Interface(enbNodes);
220 lteHelper->Attach(ueDev, enbDevs.Get(0));
221 lteHelper->HandoverRequest(m_handoverTime, ueDev, enbDevs.Get(0), enbDevs.Get(1));
222
223 // Run simulation.
227
228} // end of void LteHandoverDelayTestCase::DoRun ()
229
230void
232 uint64_t imsi,
233 uint16_t cellid,
234 uint16_t rnti,
235 uint16_t targetCellId)
236{
237 NS_LOG_FUNCTION(this << context);
239}
240
241void
243 uint64_t imsi,
244 uint16_t cellid,
245 uint16_t rnti)
246{
247 NS_LOG_FUNCTION(this << context);
250
251 NS_LOG_DEBUG(this << " UE delay = " << delay.As(Time::S));
254 "UE handover delay is higher than the allowed threshold "
255 << "(ideal RRC = " << m_useIdealRrc
256 << " handover time = " << m_handoverTime.As(Time::S) << ")");
257}
258
259void
261 uint64_t imsi,
262 uint16_t cellid,
263 uint16_t rnti,
264 uint16_t targetCellId)
265{
266 NS_LOG_FUNCTION(this << context);
268}
269
270void
272 uint64_t imsi,
273 uint16_t cellid,
274 uint16_t rnti)
275{
276 NS_LOG_FUNCTION(this << context);
279
280 NS_LOG_DEBUG(this << " eNodeB delay = " << delay.As(Time::S));
283 "eNodeB handover delay is higher than the allowed threshold "
284 << "(ideal RRC = " << m_useIdealRrc
285 << " handover time = " << m_handoverTime.As(Time::S) << ")");
286}
287
295{
296 public:
298 : TestSuite("lte-handover-delay", Type::SYSTEM)
299 {
300 // LogComponentEnable ("LteHandoverDelayTest", LOG_PREFIX_TIME);
301 // LogComponentEnable ("LteHandoverDelayTest", LOG_DEBUG);
302 // LogComponentEnable ("LteHandoverDelayTest", LOG_INFO);
303
304 // HANDOVER DELAY TEST CASES WITH IDEAL RRC (THRESHOLD = 0.005 sec)
305
306 for (Time handoverTime = Seconds(0.100); handoverTime < Seconds(0.110);
307 handoverTime += Seconds(0.001))
308 {
309 // arguments: useIdealRrc, handoverTime, delayThreshold, simulationDuration
311 new LteHandoverDelayTestCase(1, true, handoverTime, Seconds(0.005), Seconds(0.200)),
312 TestCase::Duration::QUICK);
314 new LteHandoverDelayTestCase(2, true, handoverTime, Seconds(0.005), Seconds(0.200)),
315 TestCase::Duration::QUICK);
317 new LteHandoverDelayTestCase(4, true, handoverTime, Seconds(0.005), Seconds(0.200)),
318 TestCase::Duration::QUICK);
319 }
320
321 // HANDOVER DELAY TEST CASES WITH REAL RRC (THRESHOLD = 0.020 sec)
322
323 for (Time handoverTime = Seconds(0.100); handoverTime < Seconds(0.110);
324 handoverTime += Seconds(0.001))
325 {
326 // arguments: useIdealRrc, handoverTime, delayThreshold, simulationDuration
328 false,
329 handoverTime,
330 Seconds(0.020),
331 Seconds(0.200)),
332 TestCase::Duration::QUICK);
334 false,
335 handoverTime,
336 Seconds(0.020),
337 Seconds(0.200)),
338 TestCase::Duration::QUICK);
340 false,
341 handoverTime,
342 Seconds(0.020),
343 Seconds(0.200)),
344 TestCase::Duration::QUICK);
345 }
346 }
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:37
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:142
static Time Now()
Return the current simulation virtual time.
Definition: simulator.cc:208
static void Run()
Run the simulation.
Definition: simulator.cc:178
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Definition: simulator.cc:186
encapsulates test code
Definition: test.h:1061
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:301
A suite of tests to run.
Definition: test.h:1268
Type
Type of test.
Definition: test.h:1275
static constexpr auto SYSTEM
Definition: test.h:1288
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
TimeWithUnit As(const Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
Definition: time.cc:415
@ S
second
Definition: nstime.h:116
Hold an unsigned integer type.
Definition: uinteger.h:45
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition: assert.h:66
void Connect(std::string path, const CallbackBase &cb)
Definition: config.cc:978
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:268
#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:275
LteHandoverDelayTestSuite g_lteHandoverDelayTestSuite
the test suite
#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:710
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1326
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:704