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 
67 
76 {
77 public:
94  LteX2HandoverMeasuresTestCase (uint32_t nEnbs, uint32_t nUes, uint32_t nDedicatedBearers,
95  std::list<CheckPointEvent> checkPointEventList,
96  std::string checkPointEventListName,
97  bool useUdp, std::string schedulerType,
98  std::string handoverAlgorithmType, bool admitHo,
99  bool useIdealRrc);
100 
101 private:
115  static std::string BuildNameString (uint32_t nEnbs, uint32_t nUes, uint32_t nDedicatedBearers,
116  std::string checkPointEventListName,
117  bool useUdp, std::string schedulerType,
118  std::string handoverAlgorithmType, bool admitHo,
119  bool useIdealRrc);
120  virtual void DoRun (void);
126  void CheckConnected (Ptr<NetDevice> ueDevice, Ptr<NetDevice> enbDevice);
127 
128  uint32_t m_nEnbs;
129  uint32_t m_nUes;
131  std::list<CheckPointEvent> m_checkPointEventList;
133  bool m_epc;
134  bool m_useUdp;
135  std::string m_schedulerType;
137  bool m_admitHo;
141 
148  struct BearerData
149  {
150  uint32_t bid;
153  uint32_t dlOldTotalRx;
154  uint32_t ulOldTotalRx;
155  };
156 
163  struct UeData
164  {
165  uint32_t id;
166  std::list<BearerData> bearerDataList;
167  };
168 
173  void SaveStats (uint32_t ueIndex);
178  void CheckStats (uint32_t ueIndex);
179 
180  std::vector<UeData> m_ueDataVector;
181 
185  const uint32_t m_udpClientPktSize;
186 };
187 
188 
189 std::string
190 LteX2HandoverMeasuresTestCase::BuildNameString (uint32_t nEnbs, uint32_t nUes, uint32_t nDedicatedBearers,
191  std::string checkPointEventListName,
192  bool useUdp, std::string schedulerType,
193  std::string handoverAlgorithmType, bool admitHo,
194  bool useIdealRrc)
195 {
196  std::ostringstream oss;
197  oss << "nEnbs=" << nEnbs
198  << " nUes=" << nUes
199  << " nDedicatedBearers=" << nDedicatedBearers
200  << " udp=" << useUdp
201  << " " << schedulerType
202  << " " << handoverAlgorithmType
203  << " admitHo=" << admitHo
204  << " hoList: " << checkPointEventListName;
205  if (useIdealRrc)
206  {
207  oss << ", ideal RRC";
208  }
209  else
210  {
211  oss << ", real RRC";
212  }
213  return oss.str ();
214 }
215 
216 LteX2HandoverMeasuresTestCase::LteX2HandoverMeasuresTestCase (uint32_t nEnbs, uint32_t nUes, uint32_t nDedicatedBearers,
217  std::list<CheckPointEvent> checkPointEventList,
218  std::string checkPointEventListName,
219  bool useUdp, std::string schedulerType,
220  std::string handoverAlgorithmType, bool admitHo,
221  bool useIdealRrc)
222  : TestCase (BuildNameString (nEnbs, nUes, nDedicatedBearers,
223  checkPointEventListName, useUdp, schedulerType,
224  handoverAlgorithmType, admitHo, useIdealRrc)),
225  m_nEnbs (nEnbs),
226  m_nUes (nUes),
227  m_nDedicatedBearers (nDedicatedBearers),
228  m_checkPointEventList (checkPointEventList),
229  m_checkPointEventListName (checkPointEventListName),
230  m_epc (true),
231  m_useUdp (useUdp),
232  m_schedulerType (schedulerType),
233  m_handoverAlgorithmType (handoverAlgorithmType),
234  m_admitHo (admitHo),
235  m_useIdealRrc (useIdealRrc),
236  m_maxHoDuration (Seconds (0.1)),
237  m_statsDuration (Seconds (0.5)),
238  m_udpClientInterval (Seconds (0.01)),
239  m_udpClientPktSize (100)
240 {
241 }
242 
243 void
245 {
250  m_useIdealRrc));
251 
252  Config::Reset ();
253  Config::SetDefault ("ns3::UdpClient::Interval", TimeValue (m_udpClientInterval));
254  Config::SetDefault ("ns3::UdpClient::MaxPackets", UintegerValue (1000000));
255  Config::SetDefault ("ns3::UdpClient::PacketSize", UintegerValue (m_udpClientPktSize));
256  Config::SetDefault ("ns3::LteEnbRrc::HandoverJoiningTimeoutDuration", TimeValue (MilliSeconds (200)));
257  Config::SetDefault ("ns3::LteEnbPhy::TxPower", DoubleValue (20));
258 
259  //Disable Uplink Power Control
260  Config::SetDefault ("ns3::LteUePhy::EnableUplinkPowerControl", BooleanValue (false));
261 
262  int64_t stream = 1;
263 
264  m_lteHelper = CreateObject<LteHelper> ();
265  m_lteHelper->SetAttribute ("PathlossModel", StringValue ("ns3::FriisSpectrumPropagationLossModel"));
268 
269  if (m_handoverAlgorithmType == "ns3::A2A4RsrqHandoverAlgorithm")
270  {
271  m_lteHelper->SetHandoverAlgorithmType ("ns3::A2A4RsrqHandoverAlgorithm");
272  m_lteHelper->SetHandoverAlgorithmAttribute ("ServingCellThreshold",
273  UintegerValue (30));
274  m_lteHelper->SetHandoverAlgorithmAttribute ("NeighbourCellOffset",
275  UintegerValue (1));
276  }
277  else if (m_handoverAlgorithmType == "ns3::A3RsrpHandoverAlgorithm")
278  {
279  m_lteHelper->SetHandoverAlgorithmType ("ns3::A3RsrpHandoverAlgorithm");
281  DoubleValue (1.5));
282  m_lteHelper->SetHandoverAlgorithmAttribute ("TimeToTrigger",
283  TimeValue (MilliSeconds (128)));
284  }
285  else
286  {
287  NS_FATAL_ERROR ("Unknown handover algorithm " << m_handoverAlgorithmType);
288  }
289 
290  double distance = 1000.0; // m
291  double speed = 150; // m/s
292 
293  NodeContainer enbNodes;
294  enbNodes.Create (m_nEnbs);
295  NodeContainer ueNodes;
296  ueNodes.Create (m_nUes);
297 
298  if (m_epc)
299  {
300  m_epcHelper = CreateObject<PointToPointEpcHelper> ();
302  }
303 
304  // Install Mobility Model in eNBs
305  // eNBs are located along a line in the X axis
306  Ptr<ListPositionAllocator> enbPositionAlloc = CreateObject<ListPositionAllocator> ();
307  for (uint16_t i = 0; i < m_nEnbs; i++)
308  {
309  Vector enbPosition (distance * (i + 1), 0, 0);
310  enbPositionAlloc->Add (enbPosition);
311  }
312  MobilityHelper enbMobility;
313  enbMobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
314  enbMobility.SetPositionAllocator (enbPositionAlloc);
315  enbMobility.Install (enbNodes);
316 
317  // Install Mobility Model in UE
318  // UE moves with a constant speed along the X axis
319  MobilityHelper ueMobility;
320  ueMobility.SetMobilityModel ("ns3::ConstantVelocityMobilityModel");
321  ueMobility.Install (ueNodes);
322  for (uint16_t i = 0; i < m_nUes; i++)
323  {
324  ueNodes.Get (i)->GetObject<MobilityModel> ()->SetPosition (Vector (0, 0, 0));
325  ueNodes.Get (i)->GetObject<ConstantVelocityMobilityModel> ()->SetVelocity (Vector (speed, 0, 0));
326  }
327 
328  NetDeviceContainer enbDevices;
329  enbDevices = m_lteHelper->InstallEnbDevice (enbNodes);
330  stream += m_lteHelper->AssignStreams (enbDevices, stream);
331  for (NetDeviceContainer::Iterator it = enbDevices.Begin ();
332  it != enbDevices.End ();
333  ++it)
334  {
335  Ptr<LteEnbRrc> enbRrc = (*it)->GetObject<LteEnbNetDevice> ()->GetRrc ();
336  enbRrc->SetAttribute ("AdmitHandoverRequest", BooleanValue (m_admitHo));
337  }
338 
339  NetDeviceContainer ueDevices;
340  ueDevices = m_lteHelper->InstallUeDevice (ueNodes);
341  stream += m_lteHelper->AssignStreams (ueDevices, stream);
342 
343  Ipv4Address remoteHostAddr;
344  Ipv4StaticRoutingHelper ipv4RoutingHelper;
345  Ipv4InterfaceContainer ueIpIfaces;
346  Ptr<Node> remoteHost;
347  if (m_epc)
348  {
349  // Create a single RemoteHost
350  NodeContainer remoteHostContainer;
351  remoteHostContainer.Create (1);
352  remoteHost = remoteHostContainer.Get (0);
353  InternetStackHelper internet;
354  internet.Install (remoteHostContainer);
355 
356  // Create the Internet
357  PointToPointHelper p2ph;
358  p2ph.SetDeviceAttribute ("DataRate", DataRateValue (DataRate ("100Gb/s")));
359  p2ph.SetDeviceAttribute ("Mtu", UintegerValue (1500));
360  p2ph.SetChannelAttribute ("Delay", TimeValue (Seconds (0.010)));
361  Ptr<Node> pgw = m_epcHelper->GetPgwNode ();
362  NetDeviceContainer internetDevices = p2ph.Install (pgw, remoteHost);
363  Ipv4AddressHelper ipv4h;
364  ipv4h.SetBase ("1.0.0.0", "255.0.0.0");
365  Ipv4InterfaceContainer internetIpIfaces = ipv4h.Assign (internetDevices);
366  // in this container, interface 0 is the pgw, 1 is the remoteHost
367  remoteHostAddr = internetIpIfaces.GetAddress (1);
368 
369  Ipv4StaticRoutingHelper ipv4RoutingHelper;
370  Ptr<Ipv4StaticRouting> remoteHostStaticRouting = ipv4RoutingHelper.GetStaticRouting (remoteHost->GetObject<Ipv4> ());
371  remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.0.0.0"), 1);
372 
373  // Install the IP stack on the UEs
374  internet.Install (ueNodes);
375  ueIpIfaces = m_epcHelper->AssignUeIpv4Address (NetDeviceContainer (ueDevices));
376  }
377 
378  // attachment (needs to be done after IP stack configuration)
379  // all UEs attached to eNB 0 at the beginning
380  m_lteHelper->Attach (ueDevices, enbDevices.Get (0));
381 
382  if (m_epc)
383  {
384  bool epcDl = true;
385  bool epcUl = false;
386  // the rest of this block is copied from lena-dual-stripe
387 
388 
389  // Install and start applications on UEs and remote host
390  uint16_t dlPort = 10000;
391  uint16_t ulPort = 20000;
392 
393  // randomize a bit start times to avoid simulation artifacts
394  // (e.g., buffer overflows due to packet transmissions happening
395  // exactly at the same time)
396  Ptr<UniformRandomVariable> startTimeSeconds = CreateObject<UniformRandomVariable> ();
397  startTimeSeconds->SetAttribute ("Min", DoubleValue (0));
398  startTimeSeconds->SetAttribute ("Max", DoubleValue (0.010));
399  startTimeSeconds->SetStream (stream++);
400 
401  for (uint32_t u = 0; u < ueNodes.GetN (); ++u)
402  {
403  Ptr<Node> ue = ueNodes.Get (u);
404  // Set the default gateway for the UE
405  Ptr<Ipv4StaticRouting> ueStaticRouting = ipv4RoutingHelper.GetStaticRouting (ue->GetObject<Ipv4> ());
406  ueStaticRouting->SetDefaultRoute (m_epcHelper->GetUeDefaultGatewayAddress (), 1);
407 
408  UeData ueData;
409 
410  for (uint32_t b = 0; b < m_nDedicatedBearers; ++b)
411  {
412  ++dlPort;
413  ++ulPort;
414 
417  BearerData bearerData;
418 
419  if (m_useUdp)
420  {
421  if (epcDl)
422  {
423  UdpClientHelper dlClientHelper (ueIpIfaces.GetAddress (u), dlPort);
424  clientApps.Add (dlClientHelper.Install (remoteHost));
425  PacketSinkHelper dlPacketSinkHelper ("ns3::UdpSocketFactory",
426  InetSocketAddress (Ipv4Address::GetAny (), dlPort));
427  ApplicationContainer sinkContainer = dlPacketSinkHelper.Install (ue);
428  bearerData.dlSink = sinkContainer.Get (0)->GetObject<PacketSink> ();
429  serverApps.Add (sinkContainer);
430 
431  }
432  if (epcUl)
433  {
434  UdpClientHelper ulClientHelper (remoteHostAddr, ulPort);
435  clientApps.Add (ulClientHelper.Install (ue));
436  PacketSinkHelper ulPacketSinkHelper ("ns3::UdpSocketFactory",
437  InetSocketAddress (Ipv4Address::GetAny (), ulPort));
438  ApplicationContainer sinkContainer = ulPacketSinkHelper.Install (remoteHost);
439  bearerData.ulSink = sinkContainer.Get (0)->GetObject<PacketSink> ();
440  serverApps.Add (sinkContainer);
441  }
442  }
443  else // use TCP
444  {
445  if (epcDl)
446  {
447  BulkSendHelper dlClientHelper ("ns3::TcpSocketFactory",
448  InetSocketAddress (ueIpIfaces.GetAddress (u), dlPort));
449  dlClientHelper.SetAttribute ("MaxBytes", UintegerValue (0));
450  clientApps.Add (dlClientHelper.Install (remoteHost));
451  PacketSinkHelper dlPacketSinkHelper ("ns3::TcpSocketFactory",
452  InetSocketAddress (Ipv4Address::GetAny (), dlPort));
453  ApplicationContainer sinkContainer = dlPacketSinkHelper.Install (ue);
454  bearerData.dlSink = sinkContainer.Get (0)->GetObject<PacketSink> ();
455  serverApps.Add (sinkContainer);
456  }
457  if (epcUl)
458  {
459  BulkSendHelper ulClientHelper ("ns3::TcpSocketFactory",
460  InetSocketAddress (remoteHostAddr, ulPort));
461  ulClientHelper.SetAttribute ("MaxBytes", UintegerValue (0));
462  clientApps.Add (ulClientHelper.Install (ue));
463  PacketSinkHelper ulPacketSinkHelper ("ns3::TcpSocketFactory",
464  InetSocketAddress (Ipv4Address::GetAny (), ulPort));
465  ApplicationContainer sinkContainer = ulPacketSinkHelper.Install (remoteHost);
466  bearerData.ulSink = sinkContainer.Get (0)->GetObject<PacketSink> ();
467  serverApps.Add (sinkContainer);
468  }
469  } // end if (useUdp)
470 
471  Ptr<EpcTft> tft = Create<EpcTft> ();
472  if (epcDl)
473  {
475  dlpf.localPortStart = dlPort;
476  dlpf.localPortEnd = dlPort;
477  tft->Add (dlpf);
478  }
479  if (epcUl)
480  {
482  ulpf.remotePortStart = ulPort;
483  ulpf.remotePortEnd = ulPort;
484  tft->Add (ulpf);
485  }
486 
487  if (epcDl || epcUl)
488  {
489  EpsBearer bearer (EpsBearer::NGBR_VIDEO_TCP_DEFAULT);
490  m_lteHelper->ActivateDedicatedEpsBearer (ueDevices.Get (u), bearer, tft);
491  }
492  Time startTime = Seconds (startTimeSeconds->GetValue ());
493  serverApps.Start (startTime);
494  clientApps.Start (startTime);
495 
496  ueData.bearerDataList.push_back (bearerData);
497 
498  } // end for b
499 
500  m_ueDataVector.push_back (ueData);
501  }
502 
503  }
504  else // (epc == false)
505  {
506  // for radio bearer activation purposes, consider together home UEs and macro UEs
507  for (uint32_t u = 0; u < ueDevices.GetN (); ++u)
508  {
509  Ptr<NetDevice> ueDev = ueDevices.Get (u);
510  for (uint32_t b = 0; b < m_nDedicatedBearers; ++b)
511  {
512  enum EpsBearer::Qci q = EpsBearer::NGBR_VIDEO_TCP_DEFAULT;
513  EpsBearer bearer (q);
514  m_lteHelper->ActivateDataRadioBearer (ueDev, bearer);
515  }
516  }
517  }
518 
519 
520  m_lteHelper->AddX2Interface (enbNodes);
521 
522  // check initial RRC connection
523  const Time maxRrcConnectionEstablishmentDuration = Seconds (0.080);
524  for (NetDeviceContainer::Iterator it = ueDevices.Begin (); it != ueDevices.End (); ++it)
525  {
526  NS_LOG_FUNCTION (maxRrcConnectionEstablishmentDuration);
527  Simulator::Schedule (maxRrcConnectionEstablishmentDuration,
529  this, *it, enbDevices.Get (0));
530  }
531 
532  // schedule the checkpoint events
533 
534  Time stopTime = Seconds (0);
535  for (std::list<CheckPointEvent>::iterator checkPointEventIt = m_checkPointEventList.begin ();
536  checkPointEventIt != m_checkPointEventList.end ();
537  ++checkPointEventIt)
538  {
539  for (Time checkPointTime = checkPointEventIt->checkStartTime;
540  checkPointTime < checkPointEventIt->checkStopTime;
541  checkPointTime += checkPointEventIt->checkInterval)
542  {
543  Simulator::Schedule (checkPointTime, &LteX2HandoverMeasuresTestCase::CheckConnected,
544  this, ueDevices.Get (checkPointEventIt->ueDeviceIndex),
545  enbDevices.Get (checkPointEventIt->enbDeviceIndex));
546 
547  Time saveStatsTime = checkPointTime;
548  Simulator::Schedule (saveStatsTime, &LteX2HandoverMeasuresTestCase::SaveStats,
549  this, checkPointEventIt->ueDeviceIndex);
550 
551  Time checkStats = saveStatsTime + m_statsDuration;
552  Simulator::Schedule (checkStats, &LteX2HandoverMeasuresTestCase::CheckStats,
553  this, checkPointEventIt->ueDeviceIndex);
554 
555  if (stopTime <= checkStats)
556  {
557  stopTime = checkStats + Seconds (1);
558  }
559  }
560  }
561 
562  Simulator::Stop (stopTime);
563  Simulator::Run ();
564  Simulator::Destroy ();
565 }
566 
567 void
569 {
570  NS_LOG_FUNCTION (ueDevice << enbDevice);
571 
572  Ptr<LteUeNetDevice> ueLteDevice = ueDevice->GetObject<LteUeNetDevice> ();
573  Ptr<LteUeRrc> ueRrc = ueLteDevice->GetRrc ();
574  NS_TEST_ASSERT_MSG_EQ (ueRrc->GetState (), LteUeRrc::CONNECTED_NORMALLY, "Wrong LteUeRrc state!");
575 
576 
577  Ptr<LteEnbNetDevice> enbLteDevice = enbDevice->GetObject<LteEnbNetDevice> ();
578  Ptr<LteEnbRrc> enbRrc = enbLteDevice->GetRrc ();
579  uint16_t rnti = ueRrc->GetRnti ();
580  Ptr<UeManager> ueManager = enbRrc->GetUeManager (rnti);
581  NS_TEST_ASSERT_MSG_NE (ueManager, 0, "RNTI " << rnti << " not found in eNB");
582 
583  UeManager::State ueManagerState = ueManager->GetState ();
584  NS_TEST_ASSERT_MSG_EQ (ueManagerState, UeManager::CONNECTED_NORMALLY, "Wrong UeManager state!");
585  NS_ASSERT_MSG (ueManagerState == UeManager::CONNECTED_NORMALLY, "Wrong UeManager state!");
586 
587  uint16_t ueCellId = ueRrc->GetCellId ();
588  uint16_t enbCellId = enbLteDevice->GetCellId ();
589  uint8_t ueDlBandwidth = ueRrc->GetDlBandwidth ();
590  uint8_t enbDlBandwidth = enbLteDevice->GetDlBandwidth ();
591  uint8_t ueUlBandwidth = ueRrc->GetUlBandwidth ();
592  uint8_t enbUlBandwidth = enbLteDevice->GetUlBandwidth ();
593  uint8_t ueDlEarfcn = ueRrc->GetDlEarfcn ();
594  uint8_t enbDlEarfcn = enbLteDevice->GetDlEarfcn ();
595  uint8_t ueUlEarfcn = ueRrc->GetUlEarfcn ();
596  uint8_t enbUlEarfcn = enbLteDevice->GetUlEarfcn ();
597  uint64_t ueImsi = ueLteDevice->GetImsi ();
598  uint64_t enbImsi = ueManager->GetImsi ();
599 
600  NS_TEST_ASSERT_MSG_EQ (ueImsi, enbImsi, "inconsistent IMSI");
601  NS_TEST_ASSERT_MSG_EQ (ueCellId, enbCellId, "inconsistent CellId");
602  NS_TEST_ASSERT_MSG_EQ (ueDlBandwidth, enbDlBandwidth, "inconsistent DlBandwidth");
603  NS_TEST_ASSERT_MSG_EQ (ueUlBandwidth, enbUlBandwidth, "inconsistent UlBandwidth");
604  NS_TEST_ASSERT_MSG_EQ (ueDlEarfcn, enbDlEarfcn, "inconsistent DlEarfcn");
605  NS_TEST_ASSERT_MSG_EQ (ueUlEarfcn, enbUlEarfcn, "inconsistent UlEarfcn");
606 
607  ObjectMapValue enbDataRadioBearerMapValue;
608  ueManager->GetAttribute ("DataRadioBearerMap", enbDataRadioBearerMapValue);
609  NS_TEST_ASSERT_MSG_EQ (enbDataRadioBearerMapValue.GetN (), m_nDedicatedBearers + 1, "wrong num bearers at eNB");
610 
611  ObjectMapValue ueDataRadioBearerMapValue;
612  ueRrc->GetAttribute ("DataRadioBearerMap", ueDataRadioBearerMapValue);
613  NS_TEST_ASSERT_MSG_EQ (ueDataRadioBearerMapValue.GetN (), m_nDedicatedBearers + 1, "wrong num bearers at UE");
614 
615  ObjectMapValue::Iterator enbBearerIt = enbDataRadioBearerMapValue.Begin ();
616  ObjectMapValue::Iterator ueBearerIt = ueDataRadioBearerMapValue.Begin ();
617  while (enbBearerIt != enbDataRadioBearerMapValue.End ()
618  && ueBearerIt != ueDataRadioBearerMapValue.End ())
619  {
620  Ptr<LteDataRadioBearerInfo> enbDrbInfo = enbBearerIt->second->GetObject<LteDataRadioBearerInfo> ();
621  Ptr<LteDataRadioBearerInfo> ueDrbInfo = ueBearerIt->second->GetObject<LteDataRadioBearerInfo> ();
622  //NS_TEST_ASSERT_MSG_EQ (enbDrbInfo->m_epsBearer, ueDrbInfo->m_epsBearer, "epsBearer differs");
623  NS_TEST_ASSERT_MSG_EQ ((uint32_t) enbDrbInfo->m_epsBearerIdentity, (uint32_t) ueDrbInfo->m_epsBearerIdentity, "epsBearerIdentity differs");
624  NS_TEST_ASSERT_MSG_EQ ((uint32_t) enbDrbInfo->m_drbIdentity, (uint32_t) ueDrbInfo->m_drbIdentity, "drbIdentity differs");
625  //NS_TEST_ASSERT_MSG_EQ (enbDrbInfo->m_rlcConfig, ueDrbInfo->m_rlcConfig, "rlcConfig differs");
626  NS_TEST_ASSERT_MSG_EQ ((uint32_t) enbDrbInfo->m_logicalChannelIdentity, (uint32_t) ueDrbInfo->m_logicalChannelIdentity, "logicalChannelIdentity differs");
627  //NS_TEST_ASSERT_MSG_EQ (enbDrbInfo->m_logicalChannelConfig, ueDrbInfo->m_logicalChannelConfig, "logicalChannelConfig differs");
628 
629  ++enbBearerIt;
630  ++ueBearerIt;
631  }
632  NS_ASSERT_MSG (enbBearerIt == enbDataRadioBearerMapValue.End (), "too many bearers at eNB");
633  NS_ASSERT_MSG (ueBearerIt == ueDataRadioBearerMapValue.End (), "too many bearers at UE");
634 }
635 
636 void
638 {
639  NS_LOG_FUNCTION (ueIndex);
640  for (std::list<BearerData>::iterator it = m_ueDataVector.at (ueIndex).bearerDataList.begin ();
641  it != m_ueDataVector.at (ueIndex).bearerDataList.end ();
642  ++it)
643  {
644  if (it->dlSink)
645  {
646  it->dlOldTotalRx = it->dlSink->GetTotalRx ();
647  }
648  if (it->ulSink)
649  {
650  it->ulOldTotalRx = it->ulSink->GetTotalRx ();
651  }
652  }
653 }
654 
655 void
657 {
658  NS_LOG_FUNCTION (ueIndex);
659  uint32_t b = 1;
660  for (std::list<BearerData>::iterator it = m_ueDataVector.at (ueIndex).bearerDataList.begin ();
661  it != m_ueDataVector.at (ueIndex).bearerDataList.end ();
662  ++it)
663  {
664  uint32_t dlRx = 0;
665  uint32_t ulRx = 0;
666 
667  if (it->dlSink)
668  {
669  dlRx = it->dlSink->GetTotalRx () - it->dlOldTotalRx;
670  }
671 
672  if (it->ulSink)
673  {
674  ulRx = it->ulSink->GetTotalRx () - it->ulOldTotalRx;
675  }
677 
678  NS_LOG_LOGIC ("expBytes " << expectedBytes << " dlRx " << dlRx << " ulRx " << ulRx);
679 
680  // tolerance
681  if (it->dlSink)
682  {
683  NS_TEST_ASSERT_MSG_GT (dlRx, 0.500 * expectedBytes, "too few RX bytes in DL, ue=" << ueIndex << ", b=" << b);
684  }
685  if (it->ulSink)
686  {
687  NS_TEST_ASSERT_MSG_GT (ulRx, 0.500 * expectedBytes, "too few RX bytes in UL, ue=" << ueIndex << ", b=" << b);
688  }
689  ++b;
690  }
691 }
692 
693 
701 {
702 public:
704 };
705 
706 
708  : TestSuite ("lte-x2-handover-measures", SYSTEM)
709 {
710  Time checkInterval = Seconds (1);
711 
712  std::string cel1name ("ho: 0 -> 1");
713  std::list<CheckPointEvent> cel1;
714  cel1.push_back (CheckPointEvent (Seconds (1), Seconds (10.1), checkInterval, 0, 0));
715  cel1.push_back (CheckPointEvent (Seconds (11), Seconds (17), checkInterval, 0, 1));
716 
717  std::string cel2name ("ho: 0 -> 1 -> 2");
718  std::list<CheckPointEvent> cel2;
719  cel2.push_back (CheckPointEvent (Seconds (1), Seconds (10.1), checkInterval, 0, 0));
720  cel2.push_back (CheckPointEvent (Seconds (11), Seconds (17.1), checkInterval, 0, 1));
721  cel2.push_back (CheckPointEvent (Seconds (18), Seconds (24), checkInterval, 0, 2));
722 
723  std::string cel3name ("ho: 0 -> 1 -> 2 -> 3");
724  std::list<CheckPointEvent> cel3;
725  cel3.push_back (CheckPointEvent (Seconds (1), Seconds (10.1), checkInterval, 0, 0));
726  cel3.push_back (CheckPointEvent (Seconds (11), Seconds (17.1), checkInterval, 0, 1));
727  cel3.push_back (CheckPointEvent (Seconds (18), Seconds (24.1), checkInterval, 0, 2));
728  cel3.push_back (CheckPointEvent (Seconds (25), Seconds (37), checkInterval, 0, 3));
729 
730 
731  int32_t useIdealRrc;
732  std::string sched = "ns3::PfFfMacScheduler";
733  std::string ho = "ns3::A2A4RsrqHandoverAlgorithm";
734  for (useIdealRrc = 1; useIdealRrc >= 0; --useIdealRrc)
735  {
736  // nEnbs, nUes, nDBearers, celist, name, useUdp, sched, ho, admitHo, idealRrc
737  AddTestCase (new LteX2HandoverMeasuresTestCase (2, 1, 0, cel1, cel1name, true, sched, ho, true, useIdealRrc), TestCase::TAKES_FOREVER);
738  AddTestCase (new LteX2HandoverMeasuresTestCase (2, 1, 1, cel1, cel1name, true, sched, ho, true, useIdealRrc), TestCase::QUICK);
739  AddTestCase (new LteX2HandoverMeasuresTestCase (2, 1, 2, cel1, cel1name, true, sched, ho, true, useIdealRrc), TestCase::TAKES_FOREVER);
740  AddTestCase (new LteX2HandoverMeasuresTestCase (3, 1, 0, cel2, cel2name, true, sched, ho, true, useIdealRrc), TestCase::TAKES_FOREVER);
741  AddTestCase (new LteX2HandoverMeasuresTestCase (3, 1, 1, cel2, cel2name, true, sched, ho, true, useIdealRrc), TestCase::TAKES_FOREVER);
742  AddTestCase (new LteX2HandoverMeasuresTestCase (3, 1, 2, cel2, cel2name, true, sched, ho, true, useIdealRrc), TestCase::EXTENSIVE);
743  AddTestCase (new LteX2HandoverMeasuresTestCase (4, 1, 0, cel3, cel3name, true, sched, ho, true, useIdealRrc), TestCase::EXTENSIVE);
744  AddTestCase (new LteX2HandoverMeasuresTestCase (4, 1, 1, cel3, cel3name, true, sched, ho, true, useIdealRrc), TestCase::TAKES_FOREVER);
745  AddTestCase (new LteX2HandoverMeasuresTestCase (4, 1, 2, cel3, cel3name, true, sched, ho, true, useIdealRrc), TestCase::TAKES_FOREVER);
746  }
747 
748  sched = "ns3::RrFfMacScheduler";
749  for (useIdealRrc = 1; useIdealRrc >= 0; --useIdealRrc)
750  {
751  // nEnbs, nUes, nDBearers, celist, name, useUdp, sched, admitHo, idealRrc
752  AddTestCase (new LteX2HandoverMeasuresTestCase (2, 1, 0, cel1, cel1name, true, sched, ho, true, useIdealRrc), TestCase::EXTENSIVE);
753  AddTestCase (new LteX2HandoverMeasuresTestCase (3, 1, 0, cel2, cel2name, true, sched, ho, true, useIdealRrc), TestCase::TAKES_FOREVER);
754  AddTestCase (new LteX2HandoverMeasuresTestCase (4, 1, 0, cel3, cel3name, true, sched, ho, true, useIdealRrc), TestCase::TAKES_FOREVER);
755  }
756 
757  ho = "ns3::A3RsrpHandoverAlgorithm";
758  sched = "ns3::PfFfMacScheduler";
759  for (useIdealRrc = 1; useIdealRrc >= 0; --useIdealRrc)
760  {
761  // nEnbs, nUes, nDBearers, celist, name, useUdp, sched, admitHo, idealRrc
762  AddTestCase (new LteX2HandoverMeasuresTestCase (2, 1, 0, cel1, cel1name, true, sched, ho, true, useIdealRrc), TestCase::EXTENSIVE);
763  AddTestCase (new LteX2HandoverMeasuresTestCase (3, 1, 0, cel2, cel2name, true, sched, ho, true, useIdealRrc), TestCase::TAKES_FOREVER);
764  AddTestCase (new LteX2HandoverMeasuresTestCase (4, 1, 0, cel3, cel3name, true, sched, ho, true, useIdealRrc), TestCase::TAKES_FOREVER);
765  }
766 
767  sched = "ns3::RrFfMacScheduler";
768  for (useIdealRrc = 1; useIdealRrc >= 0; --useIdealRrc)
769  {
770  // nEnbs, nUes, nDBearers, celist, name, useUdp, sched, admitHo, idealRrc
771  AddTestCase (new LteX2HandoverMeasuresTestCase (2, 1, 0, cel1, cel1name, true, sched, ho, true, useIdealRrc), TestCase::QUICK);
772  AddTestCase (new LteX2HandoverMeasuresTestCase (3, 1, 0, cel2, cel2name, true, sched, ho, true, useIdealRrc), TestCase::TAKES_FOREVER);
773  AddTestCase (new LteX2HandoverMeasuresTestCase (4, 1, 0, cel3, cel3name, true, sched, ho, true, useIdealRrc), TestCase::EXTENSIVE);
774  }
775 
776 } // end of LteX2HandoverMeasuresTestSuite ()
777 
holds a vector of ns3::Application pointers.
void CheckStats(uint32_t ueIndex)
Check stats function.
uint8_t Add(PacketFilter f)
add a PacketFilter to the Traffic Flow Template
Definition: epc-tft.cc:224
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
an Inet address class
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
State
The state of the UeManager at the eNB RRC.
Definition: lte-enb-rrc.h:84
AttributeValue implementation for Boolean.
Definition: boolean.h:36
NetDeviceContainer InstallEnbDevice(NodeContainer c)
Create a set of eNodeB devices.
Definition: lte-helper.cc:474
A helper to make it easier to instantiate an ns3::BulkSendApplication on a set of nodes...
Ptr< PointToPointEpcHelper > m_epcHelper
EPC helper.
holds a vector of std::pair of Ptr<Ipv4> and interface index.
void SetDefaultRoute(Ipv4Address nextHop, uint32_t interface, uint32_t metric=0)
Add a default route to the static routing table.
Iterator End(void) const
Get an iterator which indicates past-the-last NetDevice in the container.
NS_ASSERT_MSG(false, "Ipv4AddressGenerator::MaskToIndex(): Impossible")
Hold variables of type string.
Definition: string.h:41
NetDeviceContainer Install(NodeContainer c)
a class to represent an Ipv4 address mask
Definition: ipv4-address.h:258
const uint32_t m_udpClientPktSize
UDP client packet size.
A suite of tests to run.
Definition: test.h:1342
Test different X2 handover measures and algorithms, e.g.
def start()
Definition: core.py:1844
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:355
serverApps
Definition: first.py:45
Time checkStopTime
check stop time
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:957
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1022
ApplicationContainer Install(NodeContainer c) const
Install an ns3::PacketSinkApplication on each node of the input container configured with all the att...
aggregate IP/TCP/UDP functionality to existing Nodes.
uint16_t localPortEnd
end of the port number range of the UE
Definition: epc-tft.h:137
State GetState() const
ApplicationContainer Install(NodeContainer c) const
Install an ns3::BulkSendApplication on each node of the input container configured with all the attri...
uint64_t GetImsi(void) const
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:162
A helper to make it easier to instantiate an ns3::PacketSinkApplication on a set of nodes...
Build a set of PointToPointNetDevice objects.
encapsulates test code
Definition: test.h:1155
int64_t AssignStreams(NetDeviceContainer c, int64_t stream)
Assign a fixed random variable stream number to the random variables used.
Definition: lte-helper.cc:1439
void ActivateDataRadioBearer(NetDeviceContainer ueDevices, EpsBearer bearer)
Activate a Data Radio Bearer on a given UE devices (for LTE-only simulation).
Definition: lte-helper.cc:1310
uint32_t ueDeviceIndex
UE device index.
void SetDeviceAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each NetDevice created by the helper.
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:1065
void SetHandoverAlgorithmType(std::string type)
Set the type of handover algorithm to be used by eNodeB devices.
Definition: lte-helper.cc:327
ApplicationContainer Install(NodeContainer c)
double stopTime
static void SetPosition(Ptr< Node > node, Vector position)
Definition: wifi-ap.cc:89
void SetSchedulerType(std::string type)
Set the type of scheduler to be used by eNodeB devices.
Definition: lte-helper.cc:279
Class for representing data rates.
Definition: data-rate.h:88
uint32_t m_nEnbs
number of eNBs in the test
Keep track of the current position and velocity of an object.
uint64_t GetImsi() const
Get the IMSI.
This class contains the specification of EPS Bearers.
Definition: eps-bearer.h:71
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)
store information on active data radio bearer instance
void SetHandoverAlgorithmAttribute(std::string n, const AttributeValue &v)
Set an attribute for the handover algorithm to be created.
Definition: lte-helper.cc:335
uint8_t m_logicalChannelIdentity
logical channel identity
Create a client application which sends UDP packets carrying a 32bit sequence number and a 64 bit tim...
AttributeValue implementation for Time.
Definition: nstime.h:1076
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:299
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
Iterator Begin(void) const
Get an iterator which refers to the first NetDevice in the container.
std::list< CheckPointEvent > m_checkPointEventList
check point event list
Iterator Begin(void) const
Get an iterator to the first Object.
Hold an unsigned integer type.
Definition: uinteger.h:44
double startTime
#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:168
std::map< std::size_t, Ptr< Object > >::const_iterator Iterator
Iterator type for traversing this container.
holds a vector of ns3::NetDevice pointers
Time checkInterval
check interval
Iterator End(void) const
Get an iterator to the past-the-end Object.
virtual void DoRun(void)
Implementation to actually run this TestCase.
CheckPointEvent structure.
std::string m_checkPointEventListName
check point event list name
std::size_t GetN(void) const
Get the number of Objects.
std::string m_handoverAlgorithmType
handover algorithm type
void SaveStats(uint32_t ueIndex)
Save stats function.
uint32_t GetN(void) const
Get the number of Ptr<Node> stored in this container.
bool m_useUdp
whether to use UDP traffic
Access to the IPv4 forwarding table, interfaces, and configuration.
Definition: ipv4.h:76
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Definition: object.h:459
bool m_admitHo
whether to configure to admit handover
uint16_t remotePortEnd
end of the port number range of the remote host
Definition: epc-tft.h:135
virtual Ipv4Address GetUeDefaultGatewayAddress()
static LteX2HandoverMeasuresTestSuite g_lteX2HandoverMeasuresTestSuiteInstance
Every class exported by the ns3 library is enclosed in the ns3 namespace.
keep track of a set of node pointers.
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())
double GetValue(double min, double max)
Get the next random value, as a double in the specified range .
void AddX2Interface(NodeContainer enbNodes)
Create an X2 interface between all the eNBs in a given set.
Definition: lte-helper.cc:1217
NS_LOG_LOGIC("Net device "<< nd<< " is not bridged")
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:757
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::list< BearerData > bearerDataList
bearer ID list
void SetChannelAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each Channel created by the helper.
void Install(Ptr< Node > node) const
"Layout" a single node according to the current position allocator type.
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
NetDeviceContainer InstallUeDevice(NodeContainer c)
Create a set of UE devices.
Definition: lte-helper.cc:489
virtual Ipv4InterfaceContainer AssignUeIpv4Address(NetDeviceContainer ueDevices)
Assign IPv4 addresses to UE devices.
Helper class used to assign positions and mobility models to nodes.
void AddNetworkRouteTo(Ipv4Address network, Ipv4Mask networkMask, Ipv4Address nextHop, uint32_t interface, uint32_t metric=0)
Add a network route to the static routing table.
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:40
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
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
#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:624
Lte X2 Handover Measures Test Suite.
uint8_t m_drbIdentity
DRB identity.
Helper class that adds ns3::Ipv4StaticRouting objects.
AttributeValue implementation for DataRate.
Definition: data-rate.h:242
std::vector< UeData > m_ueDataVector
UE data vector.
uint32_t m_nDedicatedBearers
number of UEs in the test
std::vector< Ptr< NetDevice > >::const_iterator Iterator
NetDevice container iterator.
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1014
uint32_t GetN(void) const
Get the number of Ptr<NetDevice> stored in this container.
bool m_useIdealRrc
whether to use ideal RRC
void SetDefault(std::string name, const AttributeValue &value)
Definition: config.cc:782
void Add(Vector v)
Add a position to the list of positions.
Time checkStartTime
check start time
CheckPointEvent(Time start, Time stop, Time interval, uint32_t ueIndex, uint32_t enbIndex)
Constructor.
uint32_t m_nUes
number of UEs in the test
Ptr< LteUeRrc > GetRrc() const
Get the RRC.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
clientApps
Definition: first.py:54
Mobility model for which the current speed does not change once it has been set and until it is set a...
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
const Time m_udpClientInterval
UDP client interval.
uint32_t enbDeviceIndex
ENB device index.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
void SetAttribute(std::string name, const AttributeValue &value)
Helper function used to set the underlying application attributes, not the socket attributes...
Container for a set of ns3::Object pointers.
Ptr< LteHelper > m_lteHelper
LTE helper.
Receive and consume traffic generated to an IP address and port.
Definition: packet-sink.h:68
void SetPositionAllocator(Ptr< PositionAllocator > allocator)
Set the position allocator which will be used to allocate the initial position of every node initiali...
#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:997
This class can be used to hold variables of floating point type such as &#39;double&#39; or &#39;float&#39;...
Definition: double.h:41
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:185
The eNodeB device implementation.
const Time m_maxHoDuration
maximum HO duration
void GetAttribute(std::string name, AttributeValue &value) const
Get the value of an attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:223
Qci
QoS Class Indicator.
Definition: eps-bearer.h:77
Ptr< Application > Get(uint32_t i) const
Get the Ptr<Application> stored in this container at a given index.
uint16_t remotePortStart
start of the port number range of the remote host
Definition: epc-tft.h:134
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...
void CheckConnected(Ptr< NetDevice > ueDevice, Ptr< NetDevice > enbDevice)
Check connected function.
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
Implement the data structure representing a TrafficFlowTemplate Packet Filter.
Definition: epc-tft.h:74
uint16_t localPortStart
start of the port number range of the UE
Definition: epc-tft.h:136
uint8_t m_epsBearerIdentity
EPS bearer identity.
The LteUeNetDevice class implements the UE net device.