A Discrete-Event Network Simulator
API
test-lte-x2-handover.cc
Go to the documentation of this file.
1/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2012 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Author: Nicola Baldo <nbaldo@cttc.es>
19 */
20
21
22#include <ns3/core-module.h>
23#include <ns3/network-module.h>
24#include <ns3/mobility-module.h>
25#include <ns3/lte-module.h>
26#include <ns3/internet-module.h>
27#include <ns3/applications-module.h>
28#include <ns3/point-to-point-module.h>
29
30using namespace ns3;
31
32NS_LOG_COMPONENT_DEFINE ("LteX2HandoverTest");
33
41{
46};
47
48
57{
58public:
70 LteX2HandoverTestCase (uint32_t nUes, uint32_t nDedicatedBearers, std::list<HandoverEvent> handoverEventList, std::string handoverEventListName, std::string schedulerType, bool admitHo, bool useIdealRrc);
71
72private:
83 static std::string BuildNameString (uint32_t nUes, uint32_t nDedicatedBearers, std::string handoverEventListName, std::string schedulerType, bool admitHo, bool useIdealRrc);
84 virtual void DoRun (void);
90 void CheckConnected (Ptr<NetDevice> ueDevice, Ptr<NetDevice> enbDevice);
91
96 void TeleportUeToMiddle (Ptr<Node> ueNode);
97
103 void TeleportUeNearTargetEnb (Ptr<Node> ueNode, Ptr<Node> enbNode);
104
107 std::list<HandoverEvent> m_handoverEventList;
109 bool m_epc;
110 std::string m_schedulerType;
115
123 {
129 };
130
137 struct UeData
138 {
140 std::list<BearerData> bearerDataList;
141 };
142
147 void SaveStatsAfterHandover (uint32_t ueIndex);
153
154 std::vector<UeData> m_ueDataVector;
155
160
161};
162
163
164std::string LteX2HandoverTestCase::BuildNameString (uint32_t nUes, uint32_t nDedicatedBearers, std::string handoverEventListName, std::string schedulerType, bool admitHo, bool useIdealRrc)
165{
166 std::ostringstream oss;
167 oss << " nUes=" << nUes
168 << " nDedicatedBearers=" << nDedicatedBearers
169 << " " << schedulerType
170 << " admitHo=" << admitHo
171 << " hoList: " << handoverEventListName;
172 if (useIdealRrc)
173 {
174 oss << ", ideal RRC";
175 }
176 else
177 {
178 oss << ", real RRC";
179 }
180 return oss.str ();
181}
182
183LteX2HandoverTestCase::LteX2HandoverTestCase (uint32_t nUes, uint32_t nDedicatedBearers, std::list<HandoverEvent> handoverEventList, std::string handoverEventListName, std::string schedulerType, bool admitHo, bool useIdealRrc)
184 : TestCase (BuildNameString (nUes, nDedicatedBearers, handoverEventListName, schedulerType, admitHo, useIdealRrc)),
185 m_nUes (nUes),
186 m_nDedicatedBearers (nDedicatedBearers),
187 m_handoverEventList (handoverEventList),
188 m_handoverEventListName (handoverEventListName),
189 m_epc (true),
190 m_schedulerType (schedulerType),
191 m_admitHo (admitHo),
192 m_useIdealRrc (useIdealRrc),
193 m_maxHoDuration (Seconds (0.1)),
194 m_statsDuration (Seconds (0.1)),
195 m_udpClientInterval (Seconds (0.01)),
196 m_udpClientPktSize (100)
197
198{}
199
200void
202{
204
205 uint32_t previousSeed = RngSeedManager::GetSeed ();
206 uint64_t previousRun = RngSeedManager::GetRun ();
207 Config::Reset ();
208 // This test is sensitive to random variable stream assigments
209 RngSeedManager::SetSeed (1);
210 RngSeedManager::SetRun (2);
211 Config::SetDefault ("ns3::UdpClient::Interval", TimeValue (m_udpClientInterval));
212 Config::SetDefault ("ns3::UdpClient::MaxPackets", UintegerValue (1000000));
213 Config::SetDefault ("ns3::UdpClient::PacketSize", UintegerValue (m_udpClientPktSize));
214
215 //Disable Uplink Power Control
216 Config::SetDefault ("ns3::LteUePhy::EnableUplinkPowerControl", BooleanValue (false));
217
218 int64_t stream = 1;
219
220 m_lteHelper = CreateObject<LteHelper> ();
221 m_lteHelper->SetAttribute ("PathlossModel", StringValue ("ns3::FriisSpectrumPropagationLossModel"));
223 m_lteHelper->SetHandoverAlgorithmType ("ns3::NoOpHandoverAlgorithm"); // disable automatic handover
225
226
227 NodeContainer enbNodes;
228 enbNodes.Create (2);
229 NodeContainer ueNodes;
230 ueNodes.Create (m_nUes);
231
232 if (m_epc)
233 {
234 m_epcHelper = CreateObject<PointToPointEpcHelper> ();
236 }
237
238 Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
239 positionAlloc->Add (Vector (-3000, 0, 0)); // enb0
240 positionAlloc->Add (Vector ( 3000, 0, 0)); // enb1
241 for (uint16_t i = 0; i < m_nUes; i++)
242 {
243 positionAlloc->Add (Vector (-3000, 100, 0));
244 }
246 mobility.SetPositionAllocator (positionAlloc);
247 mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
248 mobility.Install (enbNodes);
249 mobility.Install (ueNodes);
250
251 NetDeviceContainer enbDevices;
252 enbDevices = m_lteHelper->InstallEnbDevice (enbNodes);
253 stream += m_lteHelper->AssignStreams (enbDevices, stream);
254 for (NetDeviceContainer::Iterator it = enbDevices.Begin ();
255 it != enbDevices.End ();
256 ++it)
257 {
258 Ptr<LteEnbRrc> enbRrc = (*it)->GetObject<LteEnbNetDevice> ()->GetRrc ();
259 enbRrc->SetAttribute ("AdmitHandoverRequest", BooleanValue (m_admitHo));
260 }
261
262 NetDeviceContainer ueDevices;
263 ueDevices = m_lteHelper->InstallUeDevice (ueNodes);
264 stream += m_lteHelper->AssignStreams (ueDevices, stream);
265
266 Ipv4Address remoteHostAddr;
267 Ipv4StaticRoutingHelper ipv4RoutingHelper;
268 Ipv4InterfaceContainer ueIpIfaces;
269 Ptr<Node> remoteHost;
270 if (m_epc)
271 {
272 // Create a single RemoteHost
273 NodeContainer remoteHostContainer;
274 remoteHostContainer.Create (1);
275 remoteHost = remoteHostContainer.Get (0);
276 InternetStackHelper internet;
277 internet.Install (remoteHostContainer);
278
279 // Create the Internet
281 p2ph.SetDeviceAttribute ("DataRate", DataRateValue (DataRate ("100Gb/s")));
282 p2ph.SetDeviceAttribute ("Mtu", UintegerValue (1500));
283 p2ph.SetChannelAttribute ("Delay", TimeValue (Seconds (0.010)));
285 NetDeviceContainer internetDevices = p2ph.Install (pgw, remoteHost);
286 Ipv4AddressHelper ipv4h;
287 ipv4h.SetBase ("1.0.0.0", "255.0.0.0");
288 Ipv4InterfaceContainer internetIpIfaces = ipv4h.Assign (internetDevices);
289 // in this container, interface 0 is the pgw, 1 is the remoteHost
290 remoteHostAddr = internetIpIfaces.GetAddress (1);
291
292 Ipv4StaticRoutingHelper ipv4RoutingHelper;
293 Ptr<Ipv4StaticRouting> remoteHostStaticRouting = ipv4RoutingHelper.GetStaticRouting (remoteHost->GetObject<Ipv4> ());
294 remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.0.0.0"), 1);
295
296 // Install the IP stack on the UEs
297 internet.Install (ueNodes);
298 ueIpIfaces = m_epcHelper->AssignUeIpv4Address (NetDeviceContainer (ueDevices));
299 }
300
301 // attachment (needs to be done after IP stack configuration)
302 // all UEs attached to eNB 0 at the beginning
303 m_lteHelper->Attach (ueDevices, enbDevices.Get (0));
304
305 if (m_epc)
306 {
307 // always true: bool epcDl = true;
308 // always true: bool epcUl = true;
309 // the rest of this block is copied from lena-dual-stripe
310
311
312 // Install and start applications on UEs and remote host
313 uint16_t dlPort = 10000;
314 uint16_t ulPort = 20000;
315
316 // randomize a bit start times to avoid simulation artifacts
317 // (e.g., buffer overflows due to packet transmissions happening
318 // exactly at the same time)
319 Ptr<UniformRandomVariable> startTimeSeconds = CreateObject<UniformRandomVariable> ();
320 startTimeSeconds->SetAttribute ("Min", DoubleValue (0));
321 startTimeSeconds->SetAttribute ("Max", DoubleValue (0.010));
322 startTimeSeconds->SetStream (stream++);
323
324 for (uint32_t u = 0; u < ueNodes.GetN (); ++u)
325 {
326 Ptr<Node> ue = ueNodes.Get (u);
327 // Set the default gateway for the UE
328 Ptr<Ipv4StaticRouting> ueStaticRouting = ipv4RoutingHelper.GetStaticRouting (ue->GetObject<Ipv4> ());
329 ueStaticRouting->SetDefaultRoute (m_epcHelper->GetUeDefaultGatewayAddress (), 1);
330
331 UeData ueData;
332
333 for (uint32_t b = 0; b < m_nDedicatedBearers; ++b)
334 {
335 ++dlPort;
336 ++ulPort;
337
340 BearerData bearerData = BearerData ();
341
342 // always true: if (epcDl)
343 {
344 UdpClientHelper dlClientHelper (ueIpIfaces.GetAddress (u), dlPort);
345 clientApps.Add (dlClientHelper.Install (remoteHost));
346 PacketSinkHelper dlPacketSinkHelper ("ns3::UdpSocketFactory",
347 InetSocketAddress (Ipv4Address::GetAny (), dlPort));
348 ApplicationContainer sinkContainer = dlPacketSinkHelper.Install (ue);
349 bearerData.dlSink = sinkContainer.Get (0)->GetObject<PacketSink> ();
350 serverApps.Add (sinkContainer);
351
352 }
353 // always true: if (epcUl)
354 {
355 UdpClientHelper ulClientHelper (remoteHostAddr, ulPort);
356 clientApps.Add (ulClientHelper.Install (ue));
357 PacketSinkHelper ulPacketSinkHelper ("ns3::UdpSocketFactory",
358 InetSocketAddress (Ipv4Address::GetAny (), ulPort));
359 ApplicationContainer sinkContainer = ulPacketSinkHelper.Install (remoteHost);
360 bearerData.ulSink = sinkContainer.Get (0)->GetObject<PacketSink> ();
361 serverApps.Add (sinkContainer);
362 }
363
364 Ptr<EpcTft> tft = Create<EpcTft> ();
365 // always true: if (epcDl)
366 {
368 dlpf.localPortStart = dlPort;
369 dlpf.localPortEnd = dlPort;
370 tft->Add (dlpf);
371 }
372 // always true: if (epcUl)
373 {
375 ulpf.remotePortStart = ulPort;
376 ulpf.remotePortEnd = ulPort;
377 tft->Add (ulpf);
378 }
379
380 // always true: if (epcDl || epcUl)
381 {
382 EpsBearer bearer (EpsBearer::NGBR_VIDEO_TCP_DEFAULT);
383 m_lteHelper->ActivateDedicatedEpsBearer (ueDevices.Get (u), bearer, tft);
384 }
385 double d = startTimeSeconds->GetValue ();
386 Time startTime = Seconds (d);
387 serverApps.Start (startTime);
388 clientApps.Start (startTime);
389
390 ueData.bearerDataList.push_back (bearerData);
391
392 } // end for b
393
394 m_ueDataVector.push_back (ueData);
395 }
396
397 }
398 else // (epc == false)
399 {
400 // for radio bearer activation purposes, consider together home UEs and macro UEs
401 for (uint32_t u = 0; u < ueDevices.GetN (); ++u)
402 {
403 Ptr<NetDevice> ueDev = ueDevices.Get (u);
404 for (uint32_t b = 0; b < m_nDedicatedBearers; ++b)
405 {
406 enum EpsBearer::Qci q = EpsBearer::NGBR_VIDEO_TCP_DEFAULT;
407 EpsBearer bearer (q);
408 m_lteHelper->ActivateDataRadioBearer (ueDev, bearer);
409 }
410 }
411 }
412
413
414 m_lteHelper->AddX2Interface (enbNodes);
415
416 // check initial RRC connection
417 const Time maxRrcConnectionEstablishmentDuration = Seconds (0.080);
418 for (NetDeviceContainer::Iterator it = ueDevices.Begin (); it != ueDevices.End (); ++it)
419 {
420 Simulator::Schedule (maxRrcConnectionEstablishmentDuration,
422 this, *it, enbDevices.Get (0));
423 }
424
425 // schedule handover events and corresponding checks
426
427 Time stopTime = Seconds (0);
428 for (std::list<HandoverEvent>::iterator hoEventIt = m_handoverEventList.begin ();
429 hoEventIt != m_handoverEventList.end ();
430 ++hoEventIt)
431 {
432 // Teleport the UE between both eNBs just before the handover starts
433 Simulator::Schedule (hoEventIt->startTime - MilliSeconds (10),
435 this,
436 ueNodes.Get (hoEventIt->ueDeviceIndex));
437
438 Simulator::Schedule (hoEventIt->startTime,
440 this,
441 ueDevices.Get (hoEventIt->ueDeviceIndex),
442 enbDevices.Get (hoEventIt->sourceEnbDeviceIndex));
443
444 m_lteHelper->HandoverRequest (hoEventIt->startTime,
445 ueDevices.Get (hoEventIt->ueDeviceIndex),
446 enbDevices.Get (hoEventIt->sourceEnbDeviceIndex),
447 enbDevices.Get (hoEventIt->targetEnbDeviceIndex));
448
449 // Once the handover is finished, teleport the UE near the target eNB
450 Simulator::Schedule (hoEventIt->startTime + MilliSeconds (40),
452 this,
453 ueNodes.Get (hoEventIt->ueDeviceIndex),
454 enbNodes.Get (m_admitHo ? hoEventIt->targetEnbDeviceIndex
455 : hoEventIt->sourceEnbDeviceIndex));
456
457 Time hoEndTime = hoEventIt->startTime + m_maxHoDuration;
458 Simulator::Schedule (hoEndTime,
460 this,
461 ueDevices.Get (hoEventIt->ueDeviceIndex),
462 enbDevices.Get (m_admitHo ? hoEventIt->targetEnbDeviceIndex : hoEventIt->sourceEnbDeviceIndex));
463 Simulator::Schedule (hoEndTime, &LteX2HandoverTestCase::SaveStatsAfterHandover,
464 this, hoEventIt->ueDeviceIndex);
465
466 Time checkStatsAfterHoTime = hoEndTime + m_statsDuration;
467 Simulator::Schedule (checkStatsAfterHoTime, &LteX2HandoverTestCase::CheckStatsAWhileAfterHandover,
468 this, hoEventIt->ueDeviceIndex);
469 if (stopTime <= checkStatsAfterHoTime)
470 {
471 stopTime = checkStatsAfterHoTime + MilliSeconds (1);
472 }
473 }
474
475 // m_lteHelper->EnableRlcTraces ();
476 // m_lteHelper->EnablePdcpTraces();
477
478
479 Simulator::Stop (stopTime);
480
482
483 Simulator::Destroy ();
484
485 // Undo changes to default settings
486 Config::Reset ();
487 // Restore the previous settings of RngSeed and RngRun
488 RngSeedManager::SetSeed (previousSeed);
489 RngSeedManager::SetRun (previousRun);
490}
491
492void
494{
495 Ptr<LteUeNetDevice> ueLteDevice = ueDevice->GetObject<LteUeNetDevice> ();
496 Ptr<LteUeRrc> ueRrc = ueLteDevice->GetRrc ();
497 NS_TEST_ASSERT_MSG_EQ (ueRrc->GetState (), LteUeRrc::CONNECTED_NORMALLY, "Wrong LteUeRrc state!");
498
499
500 Ptr<LteEnbNetDevice> enbLteDevice = enbDevice->GetObject<LteEnbNetDevice> ();
501 Ptr<LteEnbRrc> enbRrc = enbLteDevice->GetRrc ();
502 uint16_t rnti = ueRrc->GetRnti ();
503 Ptr<UeManager> ueManager = enbRrc->GetUeManager (rnti);
504 NS_TEST_ASSERT_MSG_NE (ueManager, nullptr, "RNTI " << rnti << " not found in eNB");
505
506 UeManager::State ueManagerState = ueManager->GetState ();
507 NS_TEST_ASSERT_MSG_EQ (ueManagerState, UeManager::CONNECTED_NORMALLY, "Wrong UeManager state!");
508 NS_ASSERT_MSG (ueManagerState == UeManager::CONNECTED_NORMALLY, "Wrong UeManager state!");
509
510 uint16_t ueCellId = ueRrc->GetCellId ();
511 uint16_t enbCellId = enbLteDevice->GetCellId ();
512 uint8_t ueDlBandwidth = ueRrc->GetDlBandwidth ();
513 uint8_t enbDlBandwidth = enbLteDevice->GetDlBandwidth ();
514 uint8_t ueUlBandwidth = ueRrc->GetUlBandwidth ();
515 uint8_t enbUlBandwidth = enbLteDevice->GetUlBandwidth ();
516 uint8_t ueDlEarfcn = ueRrc->GetDlEarfcn ();
517 uint8_t enbDlEarfcn = enbLteDevice->GetDlEarfcn ();
518 uint8_t ueUlEarfcn = ueRrc->GetUlEarfcn ();
519 uint8_t enbUlEarfcn = enbLteDevice->GetUlEarfcn ();
520 uint64_t ueImsi = ueLteDevice->GetImsi ();
521 uint64_t enbImsi = ueManager->GetImsi ();
522
523 NS_TEST_ASSERT_MSG_EQ (ueImsi, enbImsi, "inconsistent IMSI");
524 NS_TEST_ASSERT_MSG_EQ (ueCellId, enbCellId, "inconsistent CellId");
525 NS_TEST_ASSERT_MSG_EQ (ueDlBandwidth, enbDlBandwidth, "inconsistent DlBandwidth");
526 NS_TEST_ASSERT_MSG_EQ (ueUlBandwidth, enbUlBandwidth, "inconsistent UlBandwidth");
527 NS_TEST_ASSERT_MSG_EQ (ueDlEarfcn, enbDlEarfcn, "inconsistent DlEarfcn");
528 NS_TEST_ASSERT_MSG_EQ (ueUlEarfcn, enbUlEarfcn, "inconsistent UlEarfcn");
529
530 ObjectMapValue enbDataRadioBearerMapValue;
531 ueManager->GetAttribute ("DataRadioBearerMap", enbDataRadioBearerMapValue);
532 NS_TEST_ASSERT_MSG_EQ (enbDataRadioBearerMapValue.GetN (), m_nDedicatedBearers + 1, "wrong num bearers at eNB");
533
534 ObjectMapValue ueDataRadioBearerMapValue;
535 ueRrc->GetAttribute ("DataRadioBearerMap", ueDataRadioBearerMapValue);
536 NS_TEST_ASSERT_MSG_EQ (ueDataRadioBearerMapValue.GetN (), m_nDedicatedBearers + 1, "wrong num bearers at UE");
537
538 ObjectMapValue::Iterator enbBearerIt = enbDataRadioBearerMapValue.Begin ();
539 ObjectMapValue::Iterator ueBearerIt = ueDataRadioBearerMapValue.Begin ();
540 while (enbBearerIt != enbDataRadioBearerMapValue.End ()
541 && ueBearerIt != ueDataRadioBearerMapValue.End ())
542 {
543 Ptr<LteDataRadioBearerInfo> enbDrbInfo = enbBearerIt->second->GetObject<LteDataRadioBearerInfo> ();
544 Ptr<LteDataRadioBearerInfo> ueDrbInfo = ueBearerIt->second->GetObject<LteDataRadioBearerInfo> ();
545 //NS_TEST_ASSERT_MSG_EQ (enbDrbInfo->m_epsBearer, ueDrbInfo->m_epsBearer, "epsBearer differs");
546 NS_TEST_ASSERT_MSG_EQ ((uint32_t) enbDrbInfo->m_epsBearerIdentity, (uint32_t) ueDrbInfo->m_epsBearerIdentity, "epsBearerIdentity differs");
547 NS_TEST_ASSERT_MSG_EQ ((uint32_t) enbDrbInfo->m_drbIdentity, (uint32_t) ueDrbInfo->m_drbIdentity, "drbIdentity differs");
548 //NS_TEST_ASSERT_MSG_EQ (enbDrbInfo->m_rlcConfig, ueDrbInfo->m_rlcConfig, "rlcConfig differs");
549 NS_TEST_ASSERT_MSG_EQ ((uint32_t) enbDrbInfo->m_logicalChannelIdentity, (uint32_t) ueDrbInfo->m_logicalChannelIdentity, "logicalChannelIdentity differs");
550 //NS_TEST_ASSERT_MSG_EQ (enbDrbInfo->m_logicalChannelConfig, ueDrbInfo->m_logicalChannelConfig, "logicalChannelConfig differs");
551
552 ++enbBearerIt;
553 ++ueBearerIt;
554 }
555 NS_ASSERT_MSG (enbBearerIt == enbDataRadioBearerMapValue.End (), "too many bearers at eNB");
556 NS_ASSERT_MSG (ueBearerIt == ueDataRadioBearerMapValue.End (), "too many bearers at UE");
557}
558
559void
561{
562 Ptr<MobilityModel> ueMobility = ueNode->GetObject<MobilityModel> ();
563 ueMobility->SetPosition (Vector (0.0, 0.0, 0.0));
564}
565
566void
568{
569 Ptr<MobilityModel> enbMobility = enbNode->GetObject<MobilityModel> ();
570 Vector pos = enbMobility->GetPosition ();
571
572 Ptr<MobilityModel> ueMobility = ueNode->GetObject<MobilityModel> ();
573 ueMobility->SetPosition (pos + Vector (0.0, 100.0, 0.0));
574}
575
576void
578{
579 for (std::list<BearerData>::iterator it = m_ueDataVector.at (ueIndex).bearerDataList.begin ();
580 it != m_ueDataVector.at (ueIndex).bearerDataList.end ();
581 ++it)
582 {
583 it->dlOldTotalRx = it->dlSink->GetTotalRx ();
584 it->ulOldTotalRx = it->ulSink->GetTotalRx ();
585 }
586}
587
588void
590{
591 uint32_t b = 1;
592 for (std::list<BearerData>::iterator it = m_ueDataVector.at (ueIndex).bearerDataList.begin ();
593 it != m_ueDataVector.at (ueIndex).bearerDataList.end ();
594 ++it)
595 {
596 uint32_t dlRx = it->dlSink->GetTotalRx () - it->dlOldTotalRx;
597 uint32_t ulRx = it->ulSink->GetTotalRx () - it->ulOldTotalRx;
598 uint32_t expectedBytes = m_udpClientPktSize * (m_statsDuration / m_udpClientInterval).GetDouble ();
599
600 NS_TEST_ASSERT_MSG_EQ (dlRx, expectedBytes, "too few RX bytes in DL, ue=" << ueIndex << ", b=" << b);
601 NS_TEST_ASSERT_MSG_EQ (ulRx, expectedBytes, "too few RX bytes in UL, ue=" << ueIndex << ", b=" << b);
602 ++b;
603 }
604}
605
606
623{
624public:
626};
627
628
630 : TestSuite ("lte-x2-handover", SYSTEM)
631{
632 // in the following:
633 // fwd means handover from enb 0 to enb 1
634 // bwd means handover from enb 1 to enb 0
635
636 HandoverEvent ue1fwd;
637 ue1fwd.startTime = MilliSeconds (100);
638 ue1fwd.ueDeviceIndex = 0;
639 ue1fwd.sourceEnbDeviceIndex = 0;
640 ue1fwd.targetEnbDeviceIndex = 1;
641
642 HandoverEvent ue1bwd;
643 ue1bwd.startTime = MilliSeconds (400);
644 ue1bwd.ueDeviceIndex = 0;
645 ue1bwd.sourceEnbDeviceIndex = 1;
646 ue1bwd.targetEnbDeviceIndex = 0;
647
648 HandoverEvent ue1fwdagain;
649 ue1fwdagain.startTime = MilliSeconds (700);
650 ue1fwdagain.ueDeviceIndex = 0;
651 ue1fwdagain.sourceEnbDeviceIndex = 0;
652 ue1fwdagain.targetEnbDeviceIndex = 1;
653
654 HandoverEvent ue2fwd;
655 ue2fwd.startTime = MilliSeconds (110);
656 ue2fwd.ueDeviceIndex = 1;
657 ue2fwd.sourceEnbDeviceIndex = 0;
658 ue2fwd.targetEnbDeviceIndex = 1;
659
660 HandoverEvent ue2bwd;
661 ue2bwd.startTime = MilliSeconds (350);
662 ue2bwd.ueDeviceIndex = 1;
663 ue2bwd.sourceEnbDeviceIndex = 1;
664 ue2bwd.targetEnbDeviceIndex = 0;
665
666 std::string hel0name ("none");
667 std::list<HandoverEvent> hel0;
668
669 std::string hel1name ("1 fwd");
670 std::list<HandoverEvent> hel1;
671 hel1.push_back (ue1fwd);
672
673 std::string hel2name ("1 fwd & bwd");
674 std::list<HandoverEvent> hel2;
675 hel2.push_back (ue1fwd);
676 hel2.push_back (ue1bwd);
677
678 std::string hel3name ("1 fwd & bwd & fwd");
679 std::list<HandoverEvent> hel3;
680 hel3.push_back (ue1fwd);
681 hel3.push_back (ue1bwd);
682 hel3.push_back (ue1fwdagain);
683
684 std::string hel4name ("1+2 fwd");
685 std::list<HandoverEvent> hel4;
686 hel4.push_back (ue1fwd);
687 hel4.push_back (ue2fwd);
688
689 std::string hel5name ("1+2 fwd & bwd");
690 std::list<HandoverEvent> hel5;
691 hel5.push_back (ue1fwd);
692 hel5.push_back (ue1bwd);
693 hel5.push_back (ue2fwd);
694 hel5.push_back (ue2bwd);
695
696 std::string hel6name ("2 fwd");
697 std::list<HandoverEvent> hel6;
698 hel6.push_back (ue2fwd);
699
700 std::string hel7name ("2 fwd & bwd");
701 std::list<HandoverEvent> hel7;
702 hel7.push_back (ue2fwd);
703 hel7.push_back (ue2bwd);
704
705 std::vector<std::string> schedulers;
706 schedulers.push_back ("ns3::RrFfMacScheduler");
707 schedulers.push_back ("ns3::PfFfMacScheduler");
708 for (std::vector<std::string>::iterator schedIt = schedulers.begin (); schedIt != schedulers.end (); ++schedIt)
709 {
710 for (int32_t useIdealRrc = 1; useIdealRrc >= 0; --useIdealRrc)
711 {
712 // nUes, nDBearers, helist, name, sched, admitHo, idealRrc
713 AddTestCase (new LteX2HandoverTestCase ( 1, 0, hel0, hel0name, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
714 AddTestCase (new LteX2HandoverTestCase ( 2, 0, hel0, hel0name, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
715 AddTestCase (new LteX2HandoverTestCase ( 1, 5, hel0, hel0name, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
716 AddTestCase (new LteX2HandoverTestCase ( 2, 5, hel0, hel0name, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
717 AddTestCase (new LteX2HandoverTestCase ( 1, 0, hel1, hel1name, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
718 AddTestCase (new LteX2HandoverTestCase ( 1, 1, hel1, hel1name, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
719 AddTestCase (new LteX2HandoverTestCase ( 1, 2, hel1, hel1name, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
720 AddTestCase (new LteX2HandoverTestCase ( 1, 0, hel1, hel1name, *schedIt, false, useIdealRrc), TestCase::EXTENSIVE);
721 AddTestCase (new LteX2HandoverTestCase ( 1, 1, hel1, hel1name, *schedIt, false, useIdealRrc), TestCase::EXTENSIVE);
722 AddTestCase (new LteX2HandoverTestCase ( 1, 2, hel1, hel1name, *schedIt, false, useIdealRrc), TestCase::EXTENSIVE);
723 AddTestCase (new LteX2HandoverTestCase ( 2, 0, hel1, hel1name, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
724 AddTestCase (new LteX2HandoverTestCase ( 2, 1, hel1, hel1name, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
725 AddTestCase (new LteX2HandoverTestCase ( 2, 2, hel1, hel1name, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
726 AddTestCase (new LteX2HandoverTestCase ( 2, 0, hel1, hel1name, *schedIt, false, useIdealRrc), TestCase::EXTENSIVE);
727 AddTestCase (new LteX2HandoverTestCase ( 2, 1, hel1, hel1name, *schedIt, false, useIdealRrc), TestCase::EXTENSIVE);
728 AddTestCase (new LteX2HandoverTestCase ( 2, 2, hel1, hel1name, *schedIt, false, useIdealRrc), TestCase::EXTENSIVE);
729 AddTestCase (new LteX2HandoverTestCase ( 1, 0, hel2, hel2name, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
730 AddTestCase (new LteX2HandoverTestCase ( 1, 1, hel2, hel2name, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
731 AddTestCase (new LteX2HandoverTestCase ( 1, 2, hel2, hel2name, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
732 AddTestCase (new LteX2HandoverTestCase ( 1, 0, hel3, hel3name, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
733 AddTestCase (new LteX2HandoverTestCase ( 1, 1, hel3, hel3name, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
734 AddTestCase (new LteX2HandoverTestCase ( 1, 2, hel3, hel3name, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
735 AddTestCase (new LteX2HandoverTestCase ( 2, 0, hel3, hel3name, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
736 AddTestCase (new LteX2HandoverTestCase ( 2, 1, hel3, hel3name, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
737 AddTestCase (new LteX2HandoverTestCase ( 2, 2, hel3, hel3name, *schedIt, true, useIdealRrc), TestCase::QUICK);
738 AddTestCase (new LteX2HandoverTestCase ( 2, 0, hel4, hel4name, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
739 AddTestCase (new LteX2HandoverTestCase ( 2, 1, hel4, hel4name, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
740 AddTestCase (new LteX2HandoverTestCase ( 2, 2, hel4, hel4name, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
741 AddTestCase (new LteX2HandoverTestCase ( 2, 0, hel5, hel5name, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
742 AddTestCase (new LteX2HandoverTestCase ( 2, 1, hel5, hel5name, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
743 AddTestCase (new LteX2HandoverTestCase ( 2, 2, hel5, hel5name, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
744 AddTestCase (new LteX2HandoverTestCase ( 3, 0, hel3, hel3name, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
745 AddTestCase (new LteX2HandoverTestCase ( 3, 1, hel3, hel3name, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
746 AddTestCase (new LteX2HandoverTestCase ( 3, 2, hel3, hel3name, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
747 AddTestCase (new LteX2HandoverTestCase ( 3, 0, hel4, hel4name, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
748 AddTestCase (new LteX2HandoverTestCase ( 3, 1, hel4, hel4name, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
749 AddTestCase (new LteX2HandoverTestCase ( 3, 2, hel4, hel4name, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
750 AddTestCase (new LteX2HandoverTestCase ( 3, 0, hel5, hel5name, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
751 AddTestCase (new LteX2HandoverTestCase ( 3, 1, hel5, hel5name, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
752 AddTestCase (new LteX2HandoverTestCase ( 3, 2, hel5, hel5name, *schedIt, true, useIdealRrc), TestCase::QUICK);
753
754 }
755 }
756}
757
void Run(ObjectFactory &factory, uint32_t pop, uint32_t total, uint32_t runs, Ptr< RandomVariableStream > eventStream, bool calRev)
Perform the runs for a single scheduler type.
static std::string BuildNameString(uint32_t nUes, uint32_t nDedicatedBearers, std::string handoverEventListName, std::string schedulerType, bool admitHo, bool useIdealRrc)
Build name string.
Ptr< PointToPointEpcHelper > m_epcHelper
EPC helper.
uint32_t m_nUes
number of UEs in the test
std::string m_handoverEventListName
handover event list name
std::string m_schedulerType
scheduler type
const uint32_t m_udpClientPktSize
UDP client packet size.
bool m_useIdealRrc
whether to use the ideal RRC
const Time m_statsDuration
stats duration
std::vector< UeData > m_ueDataVector
UE data vector.
virtual void DoRun(void)
Implementation to actually run this TestCase.
void CheckConnected(Ptr< NetDevice > ueDevice, Ptr< NetDevice > enbDevice)
Check connected function.
LteX2HandoverTestCase(uint32_t nUes, uint32_t nDedicatedBearers, std::list< HandoverEvent > handoverEventList, std::string handoverEventListName, std::string schedulerType, bool admitHo, bool useIdealRrc)
void TeleportUeNearTargetEnb(Ptr< Node > ueNode, Ptr< Node > enbNode)
Teleport UE near the target eNB of the handover.
bool m_admitHo
whether to admit the handover request
bool m_epc
whether to use EPC
void SaveStatsAfterHandover(uint32_t ueIndex)
Save stats after handover function.
const Time m_maxHoDuration
maximum HO duration
std::list< HandoverEvent > m_handoverEventList
handover event list
void CheckStatsAWhileAfterHandover(uint32_t ueIndex)
Check stats a while after handover function.
uint32_t m_nDedicatedBearers
number of UEs in the test
const Time m_udpClientInterval
UDP client interval.
void TeleportUeToMiddle(Ptr< Node > ueNode)
Teleport UE between both eNBs of the test.
Ptr< LteHelper > m_lteHelper
LTE helper.
LTE X2 Handover Test Suite.
holds a vector of ns3::Application pointers.
Ptr< Application > Get(uint32_t i) const
Get the Ptr<Application> stored in this container at a given index.
AttributeValue implementation for Boolean.
Definition: boolean.h:37
Class for representing data rates.
Definition: data-rate.h:89
AttributeValue implementation for DataRate.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition: double.h:41
This class contains the specification of EPS Bearers.
Definition: eps-bearer.h:92
Qci
QoS Class Indicator.
Definition: eps-bearer.h:107
an Inet address class
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...
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:41
Access to the IPv4 forwarding table, interfaces, and configuration.
Definition: ipv4.h:77
holds a vector of std::pair of Ptr<Ipv4> and interface index.
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
a class to represent an Ipv4 address mask
Definition: ipv4-address.h:256
Helper class that adds ns3::Ipv4StaticRouting objects.
Ptr< Ipv4StaticRouting > GetStaticRouting(Ptr< Ipv4 > ipv4) const
Try and find the static routing protocol as either the main routing protocol or in the list of routin...
store information on active data radio bearer instance
The eNodeB device implementation.
uint16_t GetDlBandwidth() const
uint32_t GetUlEarfcn() const
uint32_t GetDlEarfcn() const
Ptr< LteEnbRrc > GetRrc() const
uint16_t GetUlBandwidth() const
uint16_t GetCellId() const
void SetEpcHelper(Ptr< EpcHelper > h)
Set the EpcHelper to be used to setup the EPC network in conjunction with the setup of the LTE radio ...
Definition: lte-helper.cc:272
void HandoverRequest(Time hoTime, Ptr< NetDevice > ueDev, Ptr< NetDevice > sourceEnbDev, Ptr< NetDevice > targetEnbDev)
Manually trigger an X2-based handover.
Definition: lte-helper.cc:1245
NetDeviceContainer InstallEnbDevice(NodeContainer c)
Create a set of eNodeB devices.
Definition: lte-helper.cc:474
void SetHandoverAlgorithmType(std::string type)
Set the type of handover algorithm to be used by eNodeB devices.
Definition: lte-helper.cc:327
void SetSchedulerType(std::string type)
Set the type of scheduler to be used by eNodeB devices.
Definition: lte-helper.cc:279
void Attach(NetDeviceContainer ueDevices)
Enables automatic attachment of a set of UE devices to a suitable cell using Idle mode initial cell s...
Definition: lte-helper.cc:959
void ActivateDataRadioBearer(NetDeviceContainer ueDevices, EpsBearer bearer)
Activate a Data Radio Bearer on a given UE devices (for LTE-only simulation).
Definition: lte-helper.cc:1313
NetDeviceContainer InstallUeDevice(NodeContainer c)
Create a set of UE devices.
Definition: lte-helper.cc:489
void AddX2Interface(NodeContainer enbNodes)
Create an X2 interface between all the eNBs in a given set.
Definition: lte-helper.cc:1220
int64_t AssignStreams(NetDeviceContainer c, int64_t stream)
Assign a fixed random variable stream number to the random variables used.
Definition: lte-helper.cc:1443
uint8_t ActivateDedicatedEpsBearer(NetDeviceContainer ueDevices, EpsBearer bearer, Ptr< EpcTft > tft)
Activate a dedicated EPS bearer on a given set of UE devices.
Definition: lte-helper.cc:1068
The LteUeNetDevice class implements the UE net device.
Helper class used to assign positions and mobility models to nodes.
Keep track of the current position and velocity of an object.
void SetPosition(const Vector &position)
Vector GetPosition(void) const
holds a vector of ns3::NetDevice pointers
std::vector< Ptr< NetDevice > >::const_iterator Iterator
NetDevice container iterator.
Iterator End(void) const
Get an iterator which indicates past-the-last NetDevice in the container.
uint32_t GetN(void) const
Get the number of Ptr<NetDevice> stored in this container.
Iterator Begin(void) const
Get an iterator which refers to the first NetDevice in the container.
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
Ptr< Node > GetPgwNode() const override
Get the PGW node.
Ipv4Address GetUeDefaultGatewayAddress() override
Ipv4InterfaceContainer AssignUeIpv4Address(NetDeviceContainer ueDevices) override
Assign IPv4 addresses to UE devices.
keep track of a set of node pointers.
uint32_t GetN(void) const
Get the number of Ptr<Node> stored in this container.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:256
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Definition: object.h:470
Container for a set of ns3::Object pointers.
std::size_t GetN(void) const
Get the number of Objects.
Iterator Begin(void) const
Get an iterator to the first Object.
std::map< std::size_t, Ptr< Object > >::const_iterator Iterator
Iterator type for traversing this container.
Iterator End(void) const
Get an iterator to the past-the-end Object.
A helper to make it easier to instantiate an ns3::PacketSinkApplication on a set of nodes.
ApplicationContainer Install(NodeContainer c) const
Install an ns3::PacketSinkApplication on each node of the input container configured with all the att...
Receive and consume traffic generated to an IP address and port.
Definition: packet-sink.h:73
Build a set of PointToPointNetDevice objects.
void SetDeviceAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each NetDevice created by the helper.
void SetChannelAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each Channel created by the helper.
NetDeviceContainer Install(NodeContainer c)
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:78
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
Hold variables of type string.
Definition: string.h:41
encapsulates test code
Definition: test.h:994
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:299
A suite of tests to run.
Definition: test.h:1188
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:104
AttributeValue implementation for Time.
Definition: nstime.h:1309
Create a client application which sends UDP packets carrying a 32bit sequence number and a 64 bit tim...
ApplicationContainer Install(NodeContainer c)
State
The state of the UeManager at the eNB RRC.
Definition: lte-enb-rrc.h:87
Hold an unsigned integer type.
Definition: uinteger.h:44
double GetValue(double min, double max)
Get the next random value, as a double in the specified range .
Time stopTime
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition: assert.h:88
void Reset(void)
Reset the initial value of every attribute as well as the value of every global to what they were bef...
Definition: config.cc:820
void SetDefault(std::string name, const AttributeValue &value)
Definition: config.cc:849
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:206
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_TEST_ASSERT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report and abort if not.
Definition: test.h:141
#define NS_TEST_ASSERT_MSG_NE(actual, limit, msg)
Test that an actual and expected (limit) value are not equal and report and abort if not.
Definition: test.h:542
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1245
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1253
serverApps
Definition: first.py:48
clientApps
Definition: first.py:58
Every class exported by the ns3 library is enclosed in the ns3 namespace.
mobility
Definition: third.py:98
HandoverEvent structure.
uint32_t ueDeviceIndex
UE device index.
Time startTime
start time
uint32_t targetEnbDeviceIndex
target ENB device index
uint32_t sourceEnbDeviceIndex
source ENB device index
uint32_t dlOldTotalRx
DL old total receive.
uint32_t ulOldTotalRx
UL old total receive.
std::list< BearerData > bearerDataList
bearer ID list
Implement the data structure representing a TrafficFlowTemplate Packet Filter.
Definition: epc-tft.h:75
uint16_t localPortEnd
end of the port number range of the UE
Definition: epc-tft.h:140
uint16_t remotePortEnd
end of the port number range of the remote host
Definition: epc-tft.h:138
uint16_t remotePortStart
start of the port number range of the remote host
Definition: epc-tft.h:137
uint16_t localPortStart
start of the port number range of the UE
Definition: epc-tft.h:139
static LteX2HandoverTestSuite g_lteX2HandoverTestSuiteInstance