A Discrete-Event Network Simulator
API
test-lte-x2-handover-measures.cc
Go to the documentation of this file.
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2013 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  * Authors: Nicola Baldo <nbaldo@cttc.es>
19  * Manuel Requena <manuel.requena@cttc.es>
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 
30 using namespace ns3;
31 
32 NS_LOG_COMPONENT_DEFINE ("LteX2HandoverMeasuresTest");
33 
41 {
45  uint32_t ueDeviceIndex;
46  uint32_t enbDeviceIndex;
47 
57  CheckPointEvent (Time start, Time stop, Time interval, uint32_t ueIndex, uint32_t enbIndex)
58  : checkStartTime (start),
59  checkStopTime (stop),
60  checkInterval (interval),
61  ueDeviceIndex (ueIndex),
62  enbDeviceIndex (enbIndex)
63  {}
64 };
65 
66 
75 {
76 public:
93  LteX2HandoverMeasuresTestCase (uint32_t nEnbs, uint32_t nUes, uint32_t nDedicatedBearers,
94  std::list<CheckPointEvent> checkPointEventList,
95  std::string checkPointEventListName,
96  bool useUdp, std::string schedulerType,
97  std::string handoverAlgorithmType, bool admitHo,
98  bool useIdealRrc);
99 
100 private:
114  static std::string BuildNameString (uint32_t nEnbs, uint32_t nUes, uint32_t nDedicatedBearers,
115  std::string checkPointEventListName,
116  bool useUdp, std::string schedulerType,
117  std::string handoverAlgorithmType, bool admitHo,
118  bool useIdealRrc);
119  virtual void DoRun (void);
125  void CheckConnected (Ptr<NetDevice> ueDevice, Ptr<NetDevice> enbDevice);
126 
127  uint32_t m_nEnbs;
128  uint32_t m_nUes;
130  std::list<CheckPointEvent> m_checkPointEventList;
132  bool m_epc;
133  bool m_useUdp;
134  std::string m_schedulerType;
136  bool m_admitHo;
140 
147  struct BearerData
148  {
149  uint32_t bid;
152  uint32_t dlOldTotalRx;
153  uint32_t ulOldTotalRx;
154  };
155 
162  struct UeData
163  {
164  uint32_t id;
165  std::list<BearerData> bearerDataList;
166  };
167 
172  void SaveStats (uint32_t ueIndex);
177  void CheckStats (uint32_t ueIndex);
178 
179  std::vector<UeData> m_ueDataVector;
180 
184  const uint32_t m_udpClientPktSize;
185 };
186 
187 
188 std::string
189 LteX2HandoverMeasuresTestCase::BuildNameString (uint32_t nEnbs, uint32_t nUes, uint32_t nDedicatedBearers,
190  std::string checkPointEventListName,
191  bool useUdp, std::string schedulerType,
192  std::string handoverAlgorithmType, bool admitHo,
193  bool useIdealRrc)
194 {
195  std::ostringstream oss;
196  oss << "nEnbs=" << nEnbs
197  << " nUes=" << nUes
198  << " nDedicatedBearers=" << nDedicatedBearers
199  << " udp=" << useUdp
200  << " " << schedulerType
201  << " " << handoverAlgorithmType
202  << " admitHo=" << admitHo
203  << " hoList: " << checkPointEventListName;
204  if (useIdealRrc)
205  {
206  oss << ", ideal RRC";
207  }
208  else
209  {
210  oss << ", real RRC";
211  }
212  return oss.str ();
213 }
214 
215 LteX2HandoverMeasuresTestCase::LteX2HandoverMeasuresTestCase (uint32_t nEnbs, uint32_t nUes, uint32_t nDedicatedBearers,
216  std::list<CheckPointEvent> checkPointEventList,
217  std::string checkPointEventListName,
218  bool useUdp, std::string schedulerType,
219  std::string handoverAlgorithmType, bool admitHo,
220  bool useIdealRrc)
221  : TestCase (BuildNameString (nEnbs, nUes, nDedicatedBearers,
222  checkPointEventListName, useUdp, schedulerType,
223  handoverAlgorithmType, admitHo, useIdealRrc)),
224  m_nEnbs (nEnbs),
225  m_nUes (nUes),
226  m_nDedicatedBearers (nDedicatedBearers),
227  m_checkPointEventList (checkPointEventList),
228  m_checkPointEventListName (checkPointEventListName),
229  m_epc (true),
230  m_useUdp (useUdp),
231  m_schedulerType (schedulerType),
232  m_handoverAlgorithmType (handoverAlgorithmType),
233  m_admitHo (admitHo),
234  m_useIdealRrc (useIdealRrc),
235  m_maxHoDuration (Seconds (0.1)),
236  m_statsDuration (Seconds (0.5)),
237  m_udpClientInterval (Seconds (0.01)),
238  m_udpClientPktSize (100)
239 {}
240 
241 void
243 {
248  m_useIdealRrc));
249 
250  Config::Reset ();
251  Config::SetDefault ("ns3::UdpClient::Interval", TimeValue (m_udpClientInterval));
252  Config::SetDefault ("ns3::UdpClient::MaxPackets", UintegerValue (1000000));
253  Config::SetDefault ("ns3::UdpClient::PacketSize", UintegerValue (m_udpClientPktSize));
254  Config::SetDefault ("ns3::LteEnbRrc::HandoverJoiningTimeoutDuration", TimeValue (MilliSeconds (200)));
255  Config::SetDefault ("ns3::LteEnbPhy::TxPower", DoubleValue (20));
256 
257  //Disable Uplink Power Control
258  Config::SetDefault ("ns3::LteUePhy::EnableUplinkPowerControl", BooleanValue (false));
259 
260  int64_t stream = 1;
261 
262  m_lteHelper = CreateObject<LteHelper> ();
263  m_lteHelper->SetAttribute ("PathlossModel", StringValue ("ns3::FriisSpectrumPropagationLossModel"));
266 
267  if (m_handoverAlgorithmType == "ns3::A2A4RsrqHandoverAlgorithm")
268  {
269  m_lteHelper->SetHandoverAlgorithmType ("ns3::A2A4RsrqHandoverAlgorithm");
270  m_lteHelper->SetHandoverAlgorithmAttribute ("ServingCellThreshold",
271  UintegerValue (30));
272  m_lteHelper->SetHandoverAlgorithmAttribute ("NeighbourCellOffset",
273  UintegerValue (1));
274  }
275  else if (m_handoverAlgorithmType == "ns3::A3RsrpHandoverAlgorithm")
276  {
277  m_lteHelper->SetHandoverAlgorithmType ("ns3::A3RsrpHandoverAlgorithm");
279  DoubleValue (1.5));
280  m_lteHelper->SetHandoverAlgorithmAttribute ("TimeToTrigger",
281  TimeValue (MilliSeconds (128)));
282  }
283  else
284  {
285  NS_FATAL_ERROR ("Unknown handover algorithm " << m_handoverAlgorithmType);
286  }
287 
288  double distance = 1000.0; // m
289  double speed = 150; // m/s
290 
291  NodeContainer enbNodes;
292  enbNodes.Create (m_nEnbs);
293  NodeContainer ueNodes;
294  ueNodes.Create (m_nUes);
295 
296  if (m_epc)
297  {
298  m_epcHelper = CreateObject<PointToPointEpcHelper> ();
300  }
301 
302  // Install Mobility Model in eNBs
303  // eNBs are located along a line in the X axis
304  Ptr<ListPositionAllocator> enbPositionAlloc = CreateObject<ListPositionAllocator> ();
305  for (uint16_t i = 0; i < m_nEnbs; i++)
306  {
307  Vector enbPosition (distance * (i + 1), 0, 0);
308  enbPositionAlloc->Add (enbPosition);
309  }
310  MobilityHelper enbMobility;
311  enbMobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
312  enbMobility.SetPositionAllocator (enbPositionAlloc);
313  enbMobility.Install (enbNodes);
314 
315  // Install Mobility Model in UE
316  // UE moves with a constant speed along the X axis
317  MobilityHelper ueMobility;
318  ueMobility.SetMobilityModel ("ns3::ConstantVelocityMobilityModel");
319  ueMobility.Install (ueNodes);
320  for (uint16_t i = 0; i < m_nUes; i++)
321  {
322  ueNodes.Get (i)->GetObject<MobilityModel> ()->SetPosition (Vector (0, 0, 0));
323  ueNodes.Get (i)->GetObject<ConstantVelocityMobilityModel> ()->SetVelocity (Vector (speed, 0, 0));
324  }
325 
326  NetDeviceContainer enbDevices;
327  enbDevices = m_lteHelper->InstallEnbDevice (enbNodes);
328  stream += m_lteHelper->AssignStreams (enbDevices, stream);
329  for (NetDeviceContainer::Iterator it = enbDevices.Begin ();
330  it != enbDevices.End ();
331  ++it)
332  {
333  Ptr<LteEnbRrc> enbRrc = (*it)->GetObject<LteEnbNetDevice> ()->GetRrc ();
334  enbRrc->SetAttribute ("AdmitHandoverRequest", BooleanValue (m_admitHo));
335  }
336 
337  NetDeviceContainer ueDevices;
338  ueDevices = m_lteHelper->InstallUeDevice (ueNodes);
339  stream += m_lteHelper->AssignStreams (ueDevices, stream);
340 
341  Ipv4Address remoteHostAddr;
342  Ipv4StaticRoutingHelper ipv4RoutingHelper;
343  Ipv4InterfaceContainer ueIpIfaces;
344  Ptr<Node> remoteHost;
345  if (m_epc)
346  {
347  // Create a single RemoteHost
348  NodeContainer remoteHostContainer;
349  remoteHostContainer.Create (1);
350  remoteHost = remoteHostContainer.Get (0);
351  InternetStackHelper internet;
352  internet.Install (remoteHostContainer);
353 
354  // Create the Internet
355  PointToPointHelper p2ph;
356  p2ph.SetDeviceAttribute ("DataRate", DataRateValue (DataRate ("100Gb/s")));
357  p2ph.SetDeviceAttribute ("Mtu", UintegerValue (1500));
358  p2ph.SetChannelAttribute ("Delay", TimeValue (Seconds (0.010)));
359  Ptr<Node> pgw = m_epcHelper->GetPgwNode ();
360  NetDeviceContainer internetDevices = p2ph.Install (pgw, remoteHost);
361  Ipv4AddressHelper ipv4h;
362  ipv4h.SetBase ("1.0.0.0", "255.0.0.0");
363  Ipv4InterfaceContainer internetIpIfaces = ipv4h.Assign (internetDevices);
364  // in this container, interface 0 is the pgw, 1 is the remoteHost
365  remoteHostAddr = internetIpIfaces.GetAddress (1);
366 
367  Ipv4StaticRoutingHelper ipv4RoutingHelper;
368  Ptr<Ipv4StaticRouting> remoteHostStaticRouting = ipv4RoutingHelper.GetStaticRouting (remoteHost->GetObject<Ipv4> ());
369  remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.0.0.0"), 1);
370 
371  // Install the IP stack on the UEs
372  internet.Install (ueNodes);
373  ueIpIfaces = m_epcHelper->AssignUeIpv4Address (NetDeviceContainer (ueDevices));
374  }
375 
376  // attachment (needs to be done after IP stack configuration)
377  // all UEs attached to eNB 0 at the beginning
378  m_lteHelper->Attach (ueDevices, enbDevices.Get (0));
379 
380  if (m_epc)
381  {
382  bool epcDl = true;
383  bool epcUl = false;
384  // the rest of this block is copied from lena-dual-stripe
385 
386 
387  // Install and start applications on UEs and remote host
388  uint16_t dlPort = 10000;
389  uint16_t ulPort = 20000;
390 
391  // randomize a bit start times to avoid simulation artifacts
392  // (e.g., buffer overflows due to packet transmissions happening
393  // exactly at the same time)
394  Ptr<UniformRandomVariable> startTimeSeconds = CreateObject<UniformRandomVariable> ();
395  startTimeSeconds->SetAttribute ("Min", DoubleValue (0));
396  startTimeSeconds->SetAttribute ("Max", DoubleValue (0.010));
397  startTimeSeconds->SetStream (stream++);
398 
399  for (uint32_t u = 0; u < ueNodes.GetN (); ++u)
400  {
401  Ptr<Node> ue = ueNodes.Get (u);
402  // Set the default gateway for the UE
403  Ptr<Ipv4StaticRouting> ueStaticRouting = ipv4RoutingHelper.GetStaticRouting (ue->GetObject<Ipv4> ());
404  ueStaticRouting->SetDefaultRoute (m_epcHelper->GetUeDefaultGatewayAddress (), 1);
405 
406  UeData ueData;
407 
408  for (uint32_t b = 0; b < m_nDedicatedBearers; ++b)
409  {
410  ++dlPort;
411  ++ulPort;
412 
415  BearerData bearerData = BearerData ();
416 
417  if (m_useUdp)
418  {
419  if (epcDl)
420  {
421  UdpClientHelper dlClientHelper (ueIpIfaces.GetAddress (u), dlPort);
422  clientApps.Add (dlClientHelper.Install (remoteHost));
423  PacketSinkHelper dlPacketSinkHelper ("ns3::UdpSocketFactory",
424  InetSocketAddress (Ipv4Address::GetAny (), dlPort));
425  ApplicationContainer sinkContainer = dlPacketSinkHelper.Install (ue);
426  bearerData.dlSink = sinkContainer.Get (0)->GetObject<PacketSink> ();
427  serverApps.Add (sinkContainer);
428 
429  }
430  if (epcUl)
431  {
432  UdpClientHelper ulClientHelper (remoteHostAddr, ulPort);
433  clientApps.Add (ulClientHelper.Install (ue));
434  PacketSinkHelper ulPacketSinkHelper ("ns3::UdpSocketFactory",
435  InetSocketAddress (Ipv4Address::GetAny (), ulPort));
436  ApplicationContainer sinkContainer = ulPacketSinkHelper.Install (remoteHost);
437  bearerData.ulSink = sinkContainer.Get (0)->GetObject<PacketSink> ();
438  serverApps.Add (sinkContainer);
439  }
440  }
441  else // use TCP
442  {
443  if (epcDl)
444  {
445  BulkSendHelper dlClientHelper ("ns3::TcpSocketFactory",
446  InetSocketAddress (ueIpIfaces.GetAddress (u), dlPort));
447  dlClientHelper.SetAttribute ("MaxBytes", UintegerValue (0));
448  clientApps.Add (dlClientHelper.Install (remoteHost));
449  PacketSinkHelper dlPacketSinkHelper ("ns3::TcpSocketFactory",
450  InetSocketAddress (Ipv4Address::GetAny (), dlPort));
451  ApplicationContainer sinkContainer = dlPacketSinkHelper.Install (ue);
452  bearerData.dlSink = sinkContainer.Get (0)->GetObject<PacketSink> ();
453  serverApps.Add (sinkContainer);
454  }
455  if (epcUl)
456  {
457  BulkSendHelper ulClientHelper ("ns3::TcpSocketFactory",
458  InetSocketAddress (remoteHostAddr, ulPort));
459  ulClientHelper.SetAttribute ("MaxBytes", UintegerValue (0));
460  clientApps.Add (ulClientHelper.Install (ue));
461  PacketSinkHelper ulPacketSinkHelper ("ns3::TcpSocketFactory",
462  InetSocketAddress (Ipv4Address::GetAny (), ulPort));
463  ApplicationContainer sinkContainer = ulPacketSinkHelper.Install (remoteHost);
464  bearerData.ulSink = sinkContainer.Get (0)->GetObject<PacketSink> ();
465  serverApps.Add (sinkContainer);
466  }
467  } // end if (useUdp)
468 
469  Ptr<EpcTft> tft = Create<EpcTft> ();
470  if (epcDl)
471  {
473  dlpf.localPortStart = dlPort;
474  dlpf.localPortEnd = dlPort;
475  tft->Add (dlpf);
476  }
477  if (epcUl)
478  {
480  ulpf.remotePortStart = ulPort;
481  ulpf.remotePortEnd = ulPort;
482  tft->Add (ulpf);
483  }
484 
485  if (epcDl || epcUl)
486  {
487  EpsBearer bearer (EpsBearer::NGBR_VIDEO_TCP_DEFAULT);
488  m_lteHelper->ActivateDedicatedEpsBearer (ueDevices.Get (u), bearer, tft);
489  }
490  Time startTime = Seconds (startTimeSeconds->GetValue ());
491  serverApps.Start (startTime);
492  clientApps.Start (startTime);
493 
494  ueData.bearerDataList.push_back (bearerData);
495 
496  } // end for b
497 
498  m_ueDataVector.push_back (ueData);
499  }
500 
501  }
502  else // (epc == false)
503  {
504  // for radio bearer activation purposes, consider together home UEs and macro UEs
505  for (uint32_t u = 0; u < ueDevices.GetN (); ++u)
506  {
507  Ptr<NetDevice> ueDev = ueDevices.Get (u);
508  for (uint32_t b = 0; b < m_nDedicatedBearers; ++b)
509  {
510  enum EpsBearer::Qci q = EpsBearer::NGBR_VIDEO_TCP_DEFAULT;
511  EpsBearer bearer (q);
512  m_lteHelper->ActivateDataRadioBearer (ueDev, bearer);
513  }
514  }
515  }
516 
517 
518  m_lteHelper->AddX2Interface (enbNodes);
519 
520  // check initial RRC connection
521  const Time maxRrcConnectionEstablishmentDuration = Seconds (0.080);
522  for (NetDeviceContainer::Iterator it = ueDevices.Begin (); it != ueDevices.End (); ++it)
523  {
524  NS_LOG_FUNCTION (maxRrcConnectionEstablishmentDuration);
525  Simulator::Schedule (maxRrcConnectionEstablishmentDuration,
527  this, *it, enbDevices.Get (0));
528  }
529 
530  // schedule the checkpoint events
531 
532  Time stopTime = Seconds (0);
533  for (std::list<CheckPointEvent>::iterator checkPointEventIt = m_checkPointEventList.begin ();
534  checkPointEventIt != m_checkPointEventList.end ();
535  ++checkPointEventIt)
536  {
537  for (Time checkPointTime = checkPointEventIt->checkStartTime;
538  checkPointTime < checkPointEventIt->checkStopTime;
539  checkPointTime += checkPointEventIt->checkInterval)
540  {
541  Simulator::Schedule (checkPointTime, &LteX2HandoverMeasuresTestCase::CheckConnected,
542  this, ueDevices.Get (checkPointEventIt->ueDeviceIndex),
543  enbDevices.Get (checkPointEventIt->enbDeviceIndex));
544 
545  Time saveStatsTime = checkPointTime;
546  Simulator::Schedule (saveStatsTime, &LteX2HandoverMeasuresTestCase::SaveStats,
547  this, checkPointEventIt->ueDeviceIndex);
548 
549  Time checkStats = saveStatsTime + m_statsDuration;
550  Simulator::Schedule (checkStats, &LteX2HandoverMeasuresTestCase::CheckStats,
551  this, checkPointEventIt->ueDeviceIndex);
552 
553  if (stopTime <= checkStats)
554  {
555  stopTime = checkStats + Seconds (1);
556  }
557  }
558  }
559 
560  Simulator::Stop (stopTime);
561  Simulator::Run ();
562  Simulator::Destroy ();
563 }
564 
565 void
567 {
568  NS_LOG_FUNCTION (ueDevice << enbDevice);
569 
570  Ptr<LteUeNetDevice> ueLteDevice = ueDevice->GetObject<LteUeNetDevice> ();
571  Ptr<LteUeRrc> ueRrc = ueLteDevice->GetRrc ();
572  NS_TEST_ASSERT_MSG_EQ (ueRrc->GetState (), LteUeRrc::CONNECTED_NORMALLY, "Wrong LteUeRrc state!");
573 
574 
575  Ptr<LteEnbNetDevice> enbLteDevice = enbDevice->GetObject<LteEnbNetDevice> ();
576  Ptr<LteEnbRrc> enbRrc = enbLteDevice->GetRrc ();
577  uint16_t rnti = ueRrc->GetRnti ();
578  Ptr<UeManager> ueManager = enbRrc->GetUeManager (rnti);
579  NS_TEST_ASSERT_MSG_NE (ueManager, 0, "RNTI " << rnti << " not found in eNB");
580 
581  UeManager::State ueManagerState = ueManager->GetState ();
582  NS_TEST_ASSERT_MSG_EQ (ueManagerState, UeManager::CONNECTED_NORMALLY, "Wrong UeManager state!");
583  NS_ASSERT_MSG (ueManagerState == UeManager::CONNECTED_NORMALLY, "Wrong UeManager state!");
584 
585  uint16_t ueCellId = ueRrc->GetCellId ();
586  uint16_t enbCellId = enbLteDevice->GetCellId ();
587  uint8_t ueDlBandwidth = ueRrc->GetDlBandwidth ();
588  uint8_t enbDlBandwidth = enbLteDevice->GetDlBandwidth ();
589  uint8_t ueUlBandwidth = ueRrc->GetUlBandwidth ();
590  uint8_t enbUlBandwidth = enbLteDevice->GetUlBandwidth ();
591  uint8_t ueDlEarfcn = ueRrc->GetDlEarfcn ();
592  uint8_t enbDlEarfcn = enbLteDevice->GetDlEarfcn ();
593  uint8_t ueUlEarfcn = ueRrc->GetUlEarfcn ();
594  uint8_t enbUlEarfcn = enbLteDevice->GetUlEarfcn ();
595  uint64_t ueImsi = ueLteDevice->GetImsi ();
596  uint64_t enbImsi = ueManager->GetImsi ();
597 
598  NS_TEST_ASSERT_MSG_EQ (ueImsi, enbImsi, "inconsistent IMSI");
599  NS_TEST_ASSERT_MSG_EQ (ueCellId, enbCellId, "inconsistent CellId");
600  NS_TEST_ASSERT_MSG_EQ (ueDlBandwidth, enbDlBandwidth, "inconsistent DlBandwidth");
601  NS_TEST_ASSERT_MSG_EQ (ueUlBandwidth, enbUlBandwidth, "inconsistent UlBandwidth");
602  NS_TEST_ASSERT_MSG_EQ (ueDlEarfcn, enbDlEarfcn, "inconsistent DlEarfcn");
603  NS_TEST_ASSERT_MSG_EQ (ueUlEarfcn, enbUlEarfcn, "inconsistent UlEarfcn");
604 
605  ObjectMapValue enbDataRadioBearerMapValue;
606  ueManager->GetAttribute ("DataRadioBearerMap", enbDataRadioBearerMapValue);
607  NS_TEST_ASSERT_MSG_EQ (enbDataRadioBearerMapValue.GetN (), m_nDedicatedBearers + 1, "wrong num bearers at eNB");
608 
609  ObjectMapValue ueDataRadioBearerMapValue;
610  ueRrc->GetAttribute ("DataRadioBearerMap", ueDataRadioBearerMapValue);
611  NS_TEST_ASSERT_MSG_EQ (ueDataRadioBearerMapValue.GetN (), m_nDedicatedBearers + 1, "wrong num bearers at UE");
612 
613  ObjectMapValue::Iterator enbBearerIt = enbDataRadioBearerMapValue.Begin ();
614  ObjectMapValue::Iterator ueBearerIt = ueDataRadioBearerMapValue.Begin ();
615  while (enbBearerIt != enbDataRadioBearerMapValue.End ()
616  && ueBearerIt != ueDataRadioBearerMapValue.End ())
617  {
618  Ptr<LteDataRadioBearerInfo> enbDrbInfo = enbBearerIt->second->GetObject<LteDataRadioBearerInfo> ();
619  Ptr<LteDataRadioBearerInfo> ueDrbInfo = ueBearerIt->second->GetObject<LteDataRadioBearerInfo> ();
620  //NS_TEST_ASSERT_MSG_EQ (enbDrbInfo->m_epsBearer, ueDrbInfo->m_epsBearer, "epsBearer differs");
621  NS_TEST_ASSERT_MSG_EQ ((uint32_t) enbDrbInfo->m_epsBearerIdentity, (uint32_t) ueDrbInfo->m_epsBearerIdentity, "epsBearerIdentity differs");
622  NS_TEST_ASSERT_MSG_EQ ((uint32_t) enbDrbInfo->m_drbIdentity, (uint32_t) ueDrbInfo->m_drbIdentity, "drbIdentity differs");
623  //NS_TEST_ASSERT_MSG_EQ (enbDrbInfo->m_rlcConfig, ueDrbInfo->m_rlcConfig, "rlcConfig differs");
624  NS_TEST_ASSERT_MSG_EQ ((uint32_t) enbDrbInfo->m_logicalChannelIdentity, (uint32_t) ueDrbInfo->m_logicalChannelIdentity, "logicalChannelIdentity differs");
625  //NS_TEST_ASSERT_MSG_EQ (enbDrbInfo->m_logicalChannelConfig, ueDrbInfo->m_logicalChannelConfig, "logicalChannelConfig differs");
626 
627  ++enbBearerIt;
628  ++ueBearerIt;
629  }
630  NS_ASSERT_MSG (enbBearerIt == enbDataRadioBearerMapValue.End (), "too many bearers at eNB");
631  NS_ASSERT_MSG (ueBearerIt == ueDataRadioBearerMapValue.End (), "too many bearers at UE");
632 }
633 
634 void
636 {
637  NS_LOG_FUNCTION (ueIndex);
638  for (std::list<BearerData>::iterator it = m_ueDataVector.at (ueIndex).bearerDataList.begin ();
639  it != m_ueDataVector.at (ueIndex).bearerDataList.end ();
640  ++it)
641  {
642  if (it->dlSink)
643  {
644  it->dlOldTotalRx = it->dlSink->GetTotalRx ();
645  }
646  if (it->ulSink)
647  {
648  it->ulOldTotalRx = it->ulSink->GetTotalRx ();
649  }
650  }
651 }
652 
653 void
655 {
656  NS_LOG_FUNCTION (ueIndex);
657  uint32_t b = 1;
658  for (std::list<BearerData>::iterator it = m_ueDataVector.at (ueIndex).bearerDataList.begin ();
659  it != m_ueDataVector.at (ueIndex).bearerDataList.end ();
660  ++it)
661  {
662  uint32_t dlRx = 0;
663  uint32_t ulRx = 0;
664 
665  if (it->dlSink)
666  {
667  dlRx = it->dlSink->GetTotalRx () - it->dlOldTotalRx;
668  }
669 
670  if (it->ulSink)
671  {
672  ulRx = it->ulSink->GetTotalRx () - it->ulOldTotalRx;
673  }
674  double expectedBytes = m_udpClientPktSize * (m_statsDuration / m_udpClientInterval).GetDouble ();
675 
676  NS_LOG_LOGIC ("expBytes " << expectedBytes << " dlRx " << dlRx << " ulRx " << ulRx);
677 
678  // tolerance
679  if (it->dlSink)
680  {
681  NS_TEST_ASSERT_MSG_GT (dlRx, 0.500 * expectedBytes, "too few RX bytes in DL, ue=" << ueIndex << ", b=" << b);
682  }
683  if (it->ulSink)
684  {
685  NS_TEST_ASSERT_MSG_GT (ulRx, 0.500 * expectedBytes, "too few RX bytes in UL, ue=" << ueIndex << ", b=" << b);
686  }
687  ++b;
688  }
689 }
690 
691 
699 {
700 public:
702 };
703 
704 
706  : TestSuite ("lte-x2-handover-measures", SYSTEM)
707 {
708  Time checkInterval = Seconds (1);
709 
710  std::string cel1name ("ho: 0 -> 1");
711  std::list<CheckPointEvent> cel1;
712  cel1.push_back (CheckPointEvent (Seconds (1), Seconds (10.1), checkInterval, 0, 0));
713  cel1.push_back (CheckPointEvent (Seconds (11), Seconds (17), checkInterval, 0, 1));
714 
715  std::string cel2name ("ho: 0 -> 1 -> 2");
716  std::list<CheckPointEvent> cel2;
717  cel2.push_back (CheckPointEvent (Seconds (1), Seconds (10.1), checkInterval, 0, 0));
718  cel2.push_back (CheckPointEvent (Seconds (11), Seconds (17.1), checkInterval, 0, 1));
719  cel2.push_back (CheckPointEvent (Seconds (18), Seconds (24), checkInterval, 0, 2));
720 
721  std::string cel3name ("ho: 0 -> 1 -> 2 -> 3");
722  std::list<CheckPointEvent> cel3;
723  cel3.push_back (CheckPointEvent (Seconds (1), Seconds (10.1), checkInterval, 0, 0));
724  cel3.push_back (CheckPointEvent (Seconds (11), Seconds (17.1), checkInterval, 0, 1));
725  cel3.push_back (CheckPointEvent (Seconds (18), Seconds (24.1), checkInterval, 0, 2));
726  cel3.push_back (CheckPointEvent (Seconds (25), Seconds (37), checkInterval, 0, 3));
727 
728 
729  int32_t useIdealRrc;
730  std::string sched = "ns3::PfFfMacScheduler";
731  std::string ho = "ns3::A2A4RsrqHandoverAlgorithm";
732  for (useIdealRrc = 1; useIdealRrc >= 0; --useIdealRrc)
733  {
734  // nEnbs, nUes, nDBearers, celist, name, useUdp, sched, ho, admitHo, idealRrc
735  AddTestCase (new LteX2HandoverMeasuresTestCase (2, 1, 0, cel1, cel1name, true, sched, ho, true, useIdealRrc), TestCase::TAKES_FOREVER);
736  AddTestCase (new LteX2HandoverMeasuresTestCase (2, 1, 1, cel1, cel1name, true, sched, ho, true, useIdealRrc), TestCase::QUICK);
737  AddTestCase (new LteX2HandoverMeasuresTestCase (2, 1, 2, cel1, cel1name, true, sched, ho, true, useIdealRrc), TestCase::TAKES_FOREVER);
738  AddTestCase (new LteX2HandoverMeasuresTestCase (3, 1, 0, cel2, cel2name, true, sched, ho, true, useIdealRrc), TestCase::TAKES_FOREVER);
739  AddTestCase (new LteX2HandoverMeasuresTestCase (3, 1, 1, cel2, cel2name, true, sched, ho, true, useIdealRrc), TestCase::TAKES_FOREVER);
740  AddTestCase (new LteX2HandoverMeasuresTestCase (3, 1, 2, cel2, cel2name, true, sched, ho, true, useIdealRrc), TestCase::EXTENSIVE);
741  AddTestCase (new LteX2HandoverMeasuresTestCase (4, 1, 0, cel3, cel3name, true, sched, ho, true, useIdealRrc), TestCase::EXTENSIVE);
742  AddTestCase (new LteX2HandoverMeasuresTestCase (4, 1, 1, cel3, cel3name, true, sched, ho, true, useIdealRrc), TestCase::TAKES_FOREVER);
743  AddTestCase (new LteX2HandoverMeasuresTestCase (4, 1, 2, cel3, cel3name, true, sched, ho, true, useIdealRrc), TestCase::TAKES_FOREVER);
744  }
745 
746  sched = "ns3::RrFfMacScheduler";
747  for (useIdealRrc = 1; useIdealRrc >= 0; --useIdealRrc)
748  {
749  // nEnbs, nUes, nDBearers, celist, name, useUdp, sched, admitHo, idealRrc
750  AddTestCase (new LteX2HandoverMeasuresTestCase (2, 1, 0, cel1, cel1name, true, sched, ho, true, useIdealRrc), TestCase::EXTENSIVE);
751  AddTestCase (new LteX2HandoverMeasuresTestCase (3, 1, 0, cel2, cel2name, true, sched, ho, true, useIdealRrc), TestCase::TAKES_FOREVER);
752  AddTestCase (new LteX2HandoverMeasuresTestCase (4, 1, 0, cel3, cel3name, true, sched, ho, true, useIdealRrc), TestCase::TAKES_FOREVER);
753  }
754 
755  ho = "ns3::A3RsrpHandoverAlgorithm";
756  sched = "ns3::PfFfMacScheduler";
757  for (useIdealRrc = 1; useIdealRrc >= 0; --useIdealRrc)
758  {
759  // nEnbs, nUes, nDBearers, celist, name, useUdp, sched, admitHo, idealRrc
760  AddTestCase (new LteX2HandoverMeasuresTestCase (2, 1, 0, cel1, cel1name, true, sched, ho, true, useIdealRrc), TestCase::EXTENSIVE);
761  AddTestCase (new LteX2HandoverMeasuresTestCase (3, 1, 0, cel2, cel2name, true, sched, ho, true, useIdealRrc), TestCase::TAKES_FOREVER);
762  AddTestCase (new LteX2HandoverMeasuresTestCase (4, 1, 0, cel3, cel3name, true, sched, ho, true, useIdealRrc), TestCase::TAKES_FOREVER);
763  }
764 
765  sched = "ns3::RrFfMacScheduler";
766  for (useIdealRrc = 1; useIdealRrc >= 0; --useIdealRrc)
767  {
768  // nEnbs, nUes, nDBearers, celist, name, useUdp, sched, admitHo, idealRrc
769  AddTestCase (new LteX2HandoverMeasuresTestCase (2, 1, 0, cel1, cel1name, true, sched, ho, true, useIdealRrc), TestCase::QUICK);
770  AddTestCase (new LteX2HandoverMeasuresTestCase (3, 1, 0, cel2, cel2name, true, sched, ho, true, useIdealRrc), TestCase::TAKES_FOREVER);
771  AddTestCase (new LteX2HandoverMeasuresTestCase (4, 1, 0, cel3, cel3name, true, sched, ho, true, useIdealRrc), TestCase::EXTENSIVE);
772  }
773 
774 } // end of LteX2HandoverMeasuresTestSuite ()
775 
Test different X2 handover measures and algorithms, e.g.
Ptr< PointToPointEpcHelper > m_epcHelper
EPC helper.
std::list< CheckPointEvent > m_checkPointEventList
check point event list
std::string m_handoverAlgorithmType
handover algorithm type
bool m_admitHo
whether to configure to admit handover
bool m_useUdp
whether to use UDP traffic
const Time m_udpClientInterval
UDP client interval.
void CheckStats(uint32_t ueIndex)
Check stats function.
virtual void DoRun(void)
Implementation to actually run this TestCase.
LteX2HandoverMeasuresTestCase(uint32_t nEnbs, uint32_t nUes, uint32_t nDedicatedBearers, std::list< CheckPointEvent > checkPointEventList, std::string checkPointEventListName, bool useUdp, std::string schedulerType, std::string handoverAlgorithmType, bool admitHo, bool useIdealRrc)
bool m_useIdealRrc
whether to use ideal RRC
uint32_t m_nEnbs
number of eNBs in the test
static std::string BuildNameString(uint32_t nEnbs, uint32_t nUes, uint32_t nDedicatedBearers, std::string checkPointEventListName, bool useUdp, std::string schedulerType, std::string handoverAlgorithmType, bool admitHo, bool useIdealRrc)
Build name string.
std::string m_checkPointEventListName
check point event list name
void SaveStats(uint32_t ueIndex)
Save stats function.
uint32_t m_nDedicatedBearers
number of UEs in the test
uint32_t m_nUes
number of UEs in the test
std::vector< UeData > m_ueDataVector
UE data vector.
const uint32_t m_udpClientPktSize
UDP client packet size.
const Time m_maxHoDuration
maximum HO duration
void CheckConnected(Ptr< NetDevice > ueDevice, Ptr< NetDevice > enbDevice)
Check connected function.
Lte X2 Handover Measures 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
A helper to make it easier to instantiate an ns3::BulkSendApplication on a set of nodes.
void SetAttribute(std::string name, const AttributeValue &value)
Helper function used to set the underlying application attributes, not the socket attributes.
ApplicationContainer Install(NodeContainer c) const
Install an ns3::BulkSendApplication on each node of the input container configured with all the attri...
Mobility model for which the current speed does not change once it has been set and until it is set a...
Class for representing data rates.
Definition: data-rate.h:89
AttributeValue implementation for DataRate.
Definition: data-rate.h:298
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 SetHandoverAlgorithmAttribute(std::string n, const AttributeValue &v)
Set an attribute for the handover algorithm to be created.
Definition: lte-helper.cc:335
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.
void SetMobilityModel(std::string type, std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue(), std::string n8="", const AttributeValue &v8=EmptyAttributeValue(), std::string n9="", const AttributeValue &v9=EmptyAttributeValue())
void Install(Ptr< Node > node) const
"Layout" a single node according to the current position allocator type.
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 the current position and velocity of an object.
holds a vector of ns3::NetDevice pointers
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.
std::vector< Ptr< NetDevice > >::const_iterator Iterator
NetDevice container iterator.
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.
virtual Ipv4Address GetUeDefaultGatewayAddress()
virtual Ptr< Node > GetPgwNode() const
Get the PGW node.
virtual Ipv4InterfaceContainer AssignUeIpv4Address(NetDeviceContainer ueDevices)
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:72
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)
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:103
AttributeValue implementation for Time.
Definition: nstime.h:1308
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_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:165
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:289
#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
#define NS_TEST_ASSERT_MSG_GT(actual, limit, msg)
Test that an actual value is greater than a limit and report and abort if not.
Definition: test.h:825
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1244
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1252
serverApps
Definition: first.py:52
clientApps
Definition: first.py:61
Every class exported by the ns3 library is enclosed in the ns3 namespace.
def start()
Definition: core.py:1853
CheckPointEvent structure.
CheckPointEvent(Time start, Time stop, Time interval, uint32_t ueIndex, uint32_t enbIndex)
Constructor.
Time checkStopTime
check stop time
uint32_t enbDeviceIndex
ENB device index.
Time checkStartTime
check start time
Time checkInterval
check interval
uint32_t ueDeviceIndex
UE device index.
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
double startTime
static LteX2HandoverMeasuresTestSuite g_lteX2HandoverMeasuresTestSuiteInstance
static void SetPosition(Ptr< Node > node, Vector position)
Definition: wifi-ap.cc:89