A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 NS_LOG_COMPONENT_DEFINE ("LteX2HandoverMeasuresTest");
31 
32 using namespace ns3;
33 
34 
36 {
40  uint32_t ueDeviceIndex;
41  uint32_t enbDeviceIndex;
42 
43  CheckPointEvent (Time start, Time stop, Time interval, uint32_t ueIndex, uint32_t enbIndex)
44  : checkStartTime (start),
45  checkStopTime (stop),
46  checkInterval (interval),
47  ueDeviceIndex (ueIndex),
48  enbDeviceIndex (enbIndex)
49  {
50  }
51 };
52 
53 
55 {
56 public:
73  LteX2HandoverMeasuresTestCase (uint32_t nEnbs, uint32_t nUes, uint32_t nDedicatedBearers,
74  std::list<CheckPointEvent> checkPointEventList,
75  std::string checkPointEventListName,
76  bool useUdp, std::string schedulerType,
77  std::string handoverAlgorithmType, bool admitHo,
78  bool useIdealRrc);
79 
80 private:
81  static std::string BuildNameString (uint32_t nEnbs, uint32_t nUes, uint32_t nDedicatedBearers,
82  std::string checkPointEventListName,
83  bool useUdp, std::string schedulerType,
84  std::string handoverAlgorithmType, bool admitHo,
85  bool useIdealRrc);
86  virtual void DoRun (void);
87  void CheckConnected (Ptr<NetDevice> ueDevice, Ptr<NetDevice> enbDevice);
88 
89  uint32_t m_nEnbs; // number of eNBs in the test
90  uint32_t m_nUes; // number of UEs in the test
91  uint32_t m_nDedicatedBearers; // number of UEs in the test
92  std::list<CheckPointEvent> m_checkPointEventList;
94  bool m_epc;
95  bool m_useUdp;
96  std::string m_schedulerType;
98  bool m_admitHo;
102 
103  struct BearerData
104  {
105  uint32_t bid;
108  uint32_t dlOldTotalRx;
109  uint32_t ulOldTotalRx;
110  };
111 
112  struct UeData
113  {
114  uint32_t id;
115  std::list<BearerData> bearerDataList;
116  };
117 
118  void SaveStats (uint32_t ueIndex);
119  void CheckStats (uint32_t ueIndex);
120 
121  std::vector<UeData> m_ueDataVector;
122 
126  const uint32_t m_udpClientPktSize;
127 };
128 
129 
130 std::string
131 LteX2HandoverMeasuresTestCase::BuildNameString (uint32_t nEnbs, uint32_t nUes, uint32_t nDedicatedBearers,
132  std::string checkPointEventListName,
133  bool useUdp, std::string schedulerType,
134  std::string handoverAlgorithmType, bool admitHo,
135  bool useIdealRrc)
136 {
137  std::ostringstream oss;
138  oss << "nEnbs=" << nEnbs
139  << " nUes=" << nUes
140  << " nDedicatedBearers=" << nDedicatedBearers
141  << " udp=" << useUdp
142  << " " << schedulerType
143  << " " << handoverAlgorithmType
144  << " admitHo=" << admitHo
145  << " hoList: " << checkPointEventListName;
146  if (useIdealRrc)
147  {
148  oss << ", ideal RRC";
149  }
150  else
151  {
152  oss << ", real RRC";
153  }
154  return oss.str ();
155 }
156 
157 LteX2HandoverMeasuresTestCase::LteX2HandoverMeasuresTestCase (uint32_t nEnbs, uint32_t nUes, uint32_t nDedicatedBearers,
158  std::list<CheckPointEvent> checkPointEventList,
159  std::string checkPointEventListName,
160  bool useUdp, std::string schedulerType,
161  std::string handoverAlgorithmType, bool admitHo,
162  bool useIdealRrc)
163  : TestCase (BuildNameString (nEnbs, nUes, nDedicatedBearers,
164  checkPointEventListName, useUdp, schedulerType,
165  handoverAlgorithmType, admitHo, useIdealRrc)),
166  m_nEnbs (nEnbs),
167  m_nUes (nUes),
168  m_nDedicatedBearers (nDedicatedBearers),
169  m_checkPointEventList (checkPointEventList),
170  m_checkPointEventListName (checkPointEventListName),
171  m_epc (true),
172  m_useUdp (useUdp),
173  m_schedulerType (schedulerType),
174  m_handoverAlgorithmType (handoverAlgorithmType),
175  m_admitHo (admitHo),
176  m_useIdealRrc (useIdealRrc),
177  m_maxHoDuration (Seconds (0.1)),
178  m_statsDuration (Seconds (0.5)),
179  m_udpClientInterval (Seconds (0.01)),
180  m_udpClientPktSize (100)
181 {
182 }
183 
184 void
186 {
191  m_useIdealRrc));
192 
193  Config::Reset ();
194  Config::SetDefault ("ns3::UdpClient::Interval", TimeValue (m_udpClientInterval));
195  Config::SetDefault ("ns3::UdpClient::MaxPackets", UintegerValue (1000000));
196  Config::SetDefault ("ns3::UdpClient::PacketSize", UintegerValue (m_udpClientPktSize));
197  Config::SetDefault ("ns3::LteEnbRrc::HandoverJoiningTimeoutDuration", TimeValue (MilliSeconds (200)));
198  Config::SetDefault ("ns3::LteEnbPhy::TxPower", DoubleValue (20));
199 
200  //Disable Uplink Power Control
201  Config::SetDefault ("ns3::LteUePhy::EnableUplinkPowerControl", BooleanValue (false));
202 
203  int64_t stream = 1;
204 
205  m_lteHelper = CreateObject<LteHelper> ();
206  m_lteHelper->SetAttribute ("PathlossModel", StringValue ("ns3::FriisSpectrumPropagationLossModel"));
209 
210  if (m_handoverAlgorithmType == "ns3::A2A4RsrqHandoverAlgorithm")
211  {
212  m_lteHelper->SetHandoverAlgorithmType ("ns3::A2A4RsrqHandoverAlgorithm");
213  m_lteHelper->SetHandoverAlgorithmAttribute ("ServingCellThreshold",
214  UintegerValue (30));
215  m_lteHelper->SetHandoverAlgorithmAttribute ("NeighbourCellOffset",
216  UintegerValue (1));
217  }
218  else if (m_handoverAlgorithmType == "ns3::A3RsrpHandoverAlgorithm")
219  {
220  m_lteHelper->SetHandoverAlgorithmType ("ns3::A3RsrpHandoverAlgorithm");
222  DoubleValue (1.5));
223  m_lteHelper->SetHandoverAlgorithmAttribute ("TimeToTrigger",
224  TimeValue (MilliSeconds (128)));
225  }
226  else
227  {
228  NS_FATAL_ERROR ("Unknown handover algorithm " << m_handoverAlgorithmType);
229  }
230 
231  double distance = 1000.0; // m
232  double speed = 150; // m/s
233 
234  NodeContainer enbNodes;
235  enbNodes.Create (m_nEnbs);
236  NodeContainer ueNodes;
237  ueNodes.Create (m_nUes);
238 
239  if (m_epc)
240  {
241  m_epcHelper = CreateObject<PointToPointEpcHelper> ();
243  }
244 
245  // Install Mobility Model in eNBs
246  // eNBs are located along a line in the X axis
247  Ptr<ListPositionAllocator> enbPositionAlloc = CreateObject<ListPositionAllocator> ();
248  for (uint16_t i = 0; i < m_nEnbs; i++)
249  {
250  Vector enbPosition (distance * (i + 1), 0, 0);
251  enbPositionAlloc->Add (enbPosition);
252  }
253  MobilityHelper enbMobility;
254  enbMobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
255  enbMobility.SetPositionAllocator (enbPositionAlloc);
256  enbMobility.Install (enbNodes);
257 
258  // Install Mobility Model in UE
259  // UE moves with a constant speed along the X axis
260  MobilityHelper ueMobility;
261  ueMobility.SetMobilityModel ("ns3::ConstantVelocityMobilityModel");
262  ueMobility.Install (ueNodes);
263  for (uint16_t i = 0; i < m_nUes; i++)
264  {
265  ueNodes.Get (i)->GetObject<MobilityModel> ()->SetPosition (Vector (0, 0, 0));
266  ueNodes.Get (i)->GetObject<ConstantVelocityMobilityModel> ()->SetVelocity (Vector (speed, 0, 0));
267  }
268 
269  NetDeviceContainer enbDevices;
270  enbDevices = m_lteHelper->InstallEnbDevice (enbNodes);
271  stream += m_lteHelper->AssignStreams (enbDevices, stream);
272  for (NetDeviceContainer::Iterator it = enbDevices.Begin ();
273  it != enbDevices.End ();
274  ++it)
275  {
276  Ptr<LteEnbRrc> enbRrc = (*it)->GetObject<LteEnbNetDevice> ()->GetRrc ();
277  enbRrc->SetAttribute ("AdmitHandoverRequest", BooleanValue (m_admitHo));
278  }
279 
280  NetDeviceContainer ueDevices;
281  ueDevices = m_lteHelper->InstallUeDevice (ueNodes);
282  stream += m_lteHelper->AssignStreams (ueDevices, stream);
283 
284  Ipv4Address remoteHostAddr;
285  Ipv4StaticRoutingHelper ipv4RoutingHelper;
286  Ipv4InterfaceContainer ueIpIfaces;
287  Ptr<Node> remoteHost;
288  if (m_epc)
289  {
290  // Create a single RemoteHost
291  NodeContainer remoteHostContainer;
292  remoteHostContainer.Create (1);
293  remoteHost = remoteHostContainer.Get (0);
294  InternetStackHelper internet;
295  internet.Install (remoteHostContainer);
296 
297  // Create the Internet
298  PointToPointHelper p2ph;
299  p2ph.SetDeviceAttribute ("DataRate", DataRateValue (DataRate ("100Gb/s")));
300  p2ph.SetDeviceAttribute ("Mtu", UintegerValue (1500));
301  p2ph.SetChannelAttribute ("Delay", TimeValue (Seconds (0.010)));
302  Ptr<Node> pgw = m_epcHelper->GetPgwNode ();
303  NetDeviceContainer internetDevices = p2ph.Install (pgw, remoteHost);
304  Ipv4AddressHelper ipv4h;
305  ipv4h.SetBase ("1.0.0.0", "255.0.0.0");
306  Ipv4InterfaceContainer internetIpIfaces = ipv4h.Assign (internetDevices);
307  // in this container, interface 0 is the pgw, 1 is the remoteHost
308  remoteHostAddr = internetIpIfaces.GetAddress (1);
309 
310  Ipv4StaticRoutingHelper ipv4RoutingHelper;
311  Ptr<Ipv4StaticRouting> remoteHostStaticRouting = ipv4RoutingHelper.GetStaticRouting (remoteHost->GetObject<Ipv4> ());
312  remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.0.0.0"), 1);
313 
314  // Install the IP stack on the UEs
315  internet.Install (ueNodes);
316  ueIpIfaces = m_epcHelper->AssignUeIpv4Address (NetDeviceContainer (ueDevices));
317  }
318 
319  // attachment (needs to be done after IP stack configuration)
320  // all UEs attached to eNB 0 at the beginning
321  m_lteHelper->Attach (ueDevices, enbDevices.Get (0));
322 
323  if (m_epc)
324  {
325  bool epcDl = true;
326  bool epcUl = false;
327  // the rest of this block is copied from lena-dual-stripe
328 
329 
330  // Install and start applications on UEs and remote host
331  uint16_t dlPort = 10000;
332  uint16_t ulPort = 20000;
333 
334  // randomize a bit start times to avoid simulation artifacts
335  // (e.g., buffer overflows due to packet transmissions happening
336  // exactly at the same time)
337  Ptr<UniformRandomVariable> startTimeSeconds = CreateObject<UniformRandomVariable> ();
338  startTimeSeconds->SetAttribute ("Min", DoubleValue (0));
339  startTimeSeconds->SetAttribute ("Max", DoubleValue (0.010));
340  startTimeSeconds->SetStream (stream++);
341 
342  for (uint32_t u = 0; u < ueNodes.GetN (); ++u)
343  {
344  Ptr<Node> ue = ueNodes.Get (u);
345  // Set the default gateway for the UE
346  Ptr<Ipv4StaticRouting> ueStaticRouting = ipv4RoutingHelper.GetStaticRouting (ue->GetObject<Ipv4> ());
347  ueStaticRouting->SetDefaultRoute (m_epcHelper->GetUeDefaultGatewayAddress (), 1);
348 
349  UeData ueData;
350 
351  for (uint32_t b = 0; b < m_nDedicatedBearers; ++b)
352  {
353  ++dlPort;
354  ++ulPort;
355 
358  BearerData bearerData;
359 
360  if (m_useUdp)
361  {
362  if (epcDl)
363  {
364  UdpClientHelper dlClientHelper (ueIpIfaces.GetAddress (u), dlPort);
365  clientApps.Add (dlClientHelper.Install (remoteHost));
366  PacketSinkHelper dlPacketSinkHelper ("ns3::UdpSocketFactory",
367  InetSocketAddress (Ipv4Address::GetAny (), dlPort));
368  ApplicationContainer sinkContainer = dlPacketSinkHelper.Install (ue);
369  bearerData.dlSink = sinkContainer.Get (0)->GetObject<PacketSink> ();
370  serverApps.Add (sinkContainer);
371 
372  }
373  if (epcUl)
374  {
375  UdpClientHelper ulClientHelper (remoteHostAddr, ulPort);
376  clientApps.Add (ulClientHelper.Install (ue));
377  PacketSinkHelper ulPacketSinkHelper ("ns3::UdpSocketFactory",
378  InetSocketAddress (Ipv4Address::GetAny (), ulPort));
379  ApplicationContainer sinkContainer = ulPacketSinkHelper.Install (remoteHost);
380  bearerData.ulSink = sinkContainer.Get (0)->GetObject<PacketSink> ();
381  serverApps.Add (sinkContainer);
382  }
383  }
384  else // use TCP
385  {
386  if (epcDl)
387  {
388  BulkSendHelper dlClientHelper ("ns3::TcpSocketFactory",
389  InetSocketAddress (ueIpIfaces.GetAddress (u), dlPort));
390  dlClientHelper.SetAttribute ("MaxBytes", UintegerValue (0));
391  clientApps.Add (dlClientHelper.Install (remoteHost));
392  PacketSinkHelper dlPacketSinkHelper ("ns3::TcpSocketFactory",
393  InetSocketAddress (Ipv4Address::GetAny (), dlPort));
394  ApplicationContainer sinkContainer = dlPacketSinkHelper.Install (ue);
395  bearerData.dlSink = sinkContainer.Get (0)->GetObject<PacketSink> ();
396  serverApps.Add (sinkContainer);
397  }
398  if (epcUl)
399  {
400  BulkSendHelper ulClientHelper ("ns3::TcpSocketFactory",
401  InetSocketAddress (remoteHostAddr, ulPort));
402  ulClientHelper.SetAttribute ("MaxBytes", UintegerValue (0));
403  clientApps.Add (ulClientHelper.Install (ue));
404  PacketSinkHelper ulPacketSinkHelper ("ns3::TcpSocketFactory",
405  InetSocketAddress (Ipv4Address::GetAny (), ulPort));
406  ApplicationContainer sinkContainer = ulPacketSinkHelper.Install (remoteHost);
407  bearerData.ulSink = sinkContainer.Get (0)->GetObject<PacketSink> ();
408  serverApps.Add (sinkContainer);
409  }
410  } // end if (useUdp)
411 
412  Ptr<EpcTft> tft = Create<EpcTft> ();
413  if (epcDl)
414  {
416  dlpf.localPortStart = dlPort;
417  dlpf.localPortEnd = dlPort;
418  tft->Add (dlpf);
419  }
420  if (epcUl)
421  {
423  ulpf.remotePortStart = ulPort;
424  ulpf.remotePortEnd = ulPort;
425  tft->Add (ulpf);
426  }
427 
428  if (epcDl || epcUl)
429  {
430  EpsBearer bearer (EpsBearer::NGBR_VIDEO_TCP_DEFAULT);
431  m_lteHelper->ActivateDedicatedEpsBearer (ueDevices.Get (u), bearer, tft);
432  }
433  Time startTime = Seconds (startTimeSeconds->GetValue ());
434  serverApps.Start (startTime);
435  clientApps.Start (startTime);
436 
437  ueData.bearerDataList.push_back (bearerData);
438 
439  } // end for b
440 
441  m_ueDataVector.push_back (ueData);
442  }
443 
444  }
445  else // (epc == false)
446  {
447  // for radio bearer activation purposes, consider together home UEs and macro UEs
448  for (uint32_t u = 0; u < ueDevices.GetN (); ++u)
449  {
450  Ptr<NetDevice> ueDev = ueDevices.Get (u);
451  for (uint32_t b = 0; b < m_nDedicatedBearers; ++b)
452  {
453  enum EpsBearer::Qci q = EpsBearer::NGBR_VIDEO_TCP_DEFAULT;
454  EpsBearer bearer (q);
455  m_lteHelper->ActivateDataRadioBearer (ueDev, bearer);
456  }
457  }
458  }
459 
460 
461  m_lteHelper->AddX2Interface (enbNodes);
462 
463  // check initial RRC connection
464  const Time maxRrcConnectionEstablishmentDuration = Seconds (0.080);
465  for (NetDeviceContainer::Iterator it = ueDevices.Begin (); it != ueDevices.End (); ++it)
466  {
467  NS_LOG_FUNCTION (maxRrcConnectionEstablishmentDuration);
468  Simulator::Schedule (maxRrcConnectionEstablishmentDuration,
470  this, *it, enbDevices.Get (0));
471  }
472 
473  // schedule the checkpoint events
474 
475  Time stopTime = Seconds (0);
476  for (std::list<CheckPointEvent>::iterator checkPointEventIt = m_checkPointEventList.begin ();
477  checkPointEventIt != m_checkPointEventList.end ();
478  ++checkPointEventIt)
479  {
480  for (Time checkPointTime = checkPointEventIt->checkStartTime;
481  checkPointTime < checkPointEventIt->checkStopTime;
482  checkPointTime += checkPointEventIt->checkInterval)
483  {
484  Simulator::Schedule (checkPointTime, &LteX2HandoverMeasuresTestCase::CheckConnected,
485  this, ueDevices.Get (checkPointEventIt->ueDeviceIndex),
486  enbDevices.Get (checkPointEventIt->enbDeviceIndex));
487 
488  Time saveStatsTime = checkPointTime;
489  Simulator::Schedule (saveStatsTime, &LteX2HandoverMeasuresTestCase::SaveStats,
490  this, checkPointEventIt->ueDeviceIndex);
491 
492  Time checkStats = saveStatsTime + m_statsDuration;
493  Simulator::Schedule (checkStats, &LteX2HandoverMeasuresTestCase::CheckStats,
494  this, checkPointEventIt->ueDeviceIndex);
495 
496  if (stopTime <= checkStats)
497  {
498  stopTime = checkStats + Seconds (1);
499  }
500  }
501  }
502 
503  Simulator::Stop (stopTime);
504  Simulator::Run ();
505  Simulator::Destroy ();
506 }
507 
508 void
510 {
511  NS_LOG_FUNCTION (ueDevice << enbDevice);
512 
513  Ptr<LteUeNetDevice> ueLteDevice = ueDevice->GetObject<LteUeNetDevice> ();
514  Ptr<LteUeRrc> ueRrc = ueLteDevice->GetRrc ();
515  NS_TEST_ASSERT_MSG_EQ (ueRrc->GetState (), LteUeRrc::CONNECTED_NORMALLY, "Wrong LteUeRrc state!");
516 
517 
518  Ptr<LteEnbNetDevice> enbLteDevice = enbDevice->GetObject<LteEnbNetDevice> ();
519  Ptr<LteEnbRrc> enbRrc = enbLteDevice->GetRrc ();
520  uint16_t rnti = ueRrc->GetRnti ();
521  Ptr<UeManager> ueManager = enbRrc->GetUeManager (rnti);
522  NS_TEST_ASSERT_MSG_NE (ueManager, 0, "RNTI " << rnti << " not found in eNB");
523 
524  UeManager::State ueManagerState = ueManager->GetState ();
525  NS_TEST_ASSERT_MSG_EQ (ueManagerState, UeManager::CONNECTED_NORMALLY, "Wrong UeManager state!");
526  NS_ASSERT_MSG (ueManagerState == UeManager::CONNECTED_NORMALLY, "Wrong UeManager state!");
527 
528  uint16_t ueCellId = ueRrc->GetCellId ();
529  uint16_t enbCellId = enbLteDevice->GetCellId ();
530  uint8_t ueDlBandwidth = ueRrc->GetDlBandwidth ();
531  uint8_t enbDlBandwidth = enbLteDevice->GetDlBandwidth ();
532  uint8_t ueUlBandwidth = ueRrc->GetUlBandwidth ();
533  uint8_t enbUlBandwidth = enbLteDevice->GetUlBandwidth ();
534  uint8_t ueDlEarfcn = ueRrc->GetDlEarfcn ();
535  uint8_t enbDlEarfcn = enbLteDevice->GetDlEarfcn ();
536  uint8_t ueUlEarfcn = ueRrc->GetUlEarfcn ();
537  uint8_t enbUlEarfcn = enbLteDevice->GetUlEarfcn ();
538  uint64_t ueImsi = ueLteDevice->GetImsi ();
539  uint64_t enbImsi = ueManager->GetImsi ();
540 
541  NS_TEST_ASSERT_MSG_EQ (ueImsi, enbImsi, "inconsistent IMSI");
542  NS_TEST_ASSERT_MSG_EQ (ueCellId, enbCellId, "inconsistent CellId");
543  NS_TEST_ASSERT_MSG_EQ (ueDlBandwidth, enbDlBandwidth, "inconsistent DlBandwidth");
544  NS_TEST_ASSERT_MSG_EQ (ueUlBandwidth, enbUlBandwidth, "inconsistent UlBandwidth");
545  NS_TEST_ASSERT_MSG_EQ (ueDlEarfcn, enbDlEarfcn, "inconsistent DlEarfcn");
546  NS_TEST_ASSERT_MSG_EQ (ueUlEarfcn, enbUlEarfcn, "inconsistent UlEarfcn");
547 
548  ObjectMapValue enbDataRadioBearerMapValue;
549  ueManager->GetAttribute ("DataRadioBearerMap", enbDataRadioBearerMapValue);
550  NS_TEST_ASSERT_MSG_EQ (enbDataRadioBearerMapValue.GetN (), m_nDedicatedBearers + 1, "wrong num bearers at eNB");
551 
552  ObjectMapValue ueDataRadioBearerMapValue;
553  ueRrc->GetAttribute ("DataRadioBearerMap", ueDataRadioBearerMapValue);
554  NS_TEST_ASSERT_MSG_EQ (ueDataRadioBearerMapValue.GetN (), m_nDedicatedBearers + 1, "wrong num bearers at UE");
555 
556  ObjectMapValue::Iterator enbBearerIt = enbDataRadioBearerMapValue.Begin ();
557  ObjectMapValue::Iterator ueBearerIt = ueDataRadioBearerMapValue.Begin ();
558  while (enbBearerIt != enbDataRadioBearerMapValue.End ()
559  && ueBearerIt != ueDataRadioBearerMapValue.End ())
560  {
561  Ptr<LteDataRadioBearerInfo> enbDrbInfo = enbBearerIt->second->GetObject<LteDataRadioBearerInfo> ();
562  Ptr<LteDataRadioBearerInfo> ueDrbInfo = ueBearerIt->second->GetObject<LteDataRadioBearerInfo> ();
563  //NS_TEST_ASSERT_MSG_EQ (enbDrbInfo->m_epsBearer, ueDrbInfo->m_epsBearer, "epsBearer differs");
564  NS_TEST_ASSERT_MSG_EQ ((uint32_t) enbDrbInfo->m_epsBearerIdentity, (uint32_t) ueDrbInfo->m_epsBearerIdentity, "epsBearerIdentity differs");
565  NS_TEST_ASSERT_MSG_EQ ((uint32_t) enbDrbInfo->m_drbIdentity, (uint32_t) ueDrbInfo->m_drbIdentity, "drbIdentity differs");
566  //NS_TEST_ASSERT_MSG_EQ (enbDrbInfo->m_rlcConfig, ueDrbInfo->m_rlcConfig, "rlcConfig differs");
567  NS_TEST_ASSERT_MSG_EQ ((uint32_t) enbDrbInfo->m_logicalChannelIdentity, (uint32_t) ueDrbInfo->m_logicalChannelIdentity, "logicalChannelIdentity differs");
568  //NS_TEST_ASSERT_MSG_EQ (enbDrbInfo->m_logicalChannelConfig, ueDrbInfo->m_logicalChannelConfig, "logicalChannelConfig differs");
569 
570  ++enbBearerIt;
571  ++ueBearerIt;
572  }
573  NS_ASSERT_MSG (enbBearerIt == enbDataRadioBearerMapValue.End (), "too many bearers at eNB");
574  NS_ASSERT_MSG (ueBearerIt == ueDataRadioBearerMapValue.End (), "too many bearers at UE");
575 }
576 
577 void
579 {
580  NS_LOG_FUNCTION (ueIndex);
581  for (std::list<BearerData>::iterator it = m_ueDataVector.at (ueIndex).bearerDataList.begin ();
582  it != m_ueDataVector.at (ueIndex).bearerDataList.end ();
583  ++it)
584  {
585  if (it->dlSink)
586  {
587  it->dlOldTotalRx = it->dlSink->GetTotalRx ();
588  }
589  if (it->ulSink)
590  {
591  it->ulOldTotalRx = it->ulSink->GetTotalRx ();
592  }
593  }
594 }
595 
596 void
598 {
599  NS_LOG_FUNCTION (ueIndex);
600  uint32_t b = 1;
601  for (std::list<BearerData>::iterator it = m_ueDataVector.at (ueIndex).bearerDataList.begin ();
602  it != m_ueDataVector.at (ueIndex).bearerDataList.end ();
603  ++it)
604  {
605  uint32_t dlRx = 0;
606  uint32_t ulRx = 0;
607 
608  if (it->dlSink)
609  {
610  dlRx = it->dlSink->GetTotalRx () - it->dlOldTotalRx;
611  }
612 
613  if (it->ulSink)
614  {
615  ulRx = it->ulSink->GetTotalRx () - it->ulOldTotalRx;
616  }
618 
619  NS_LOG_LOGIC ("expBytes " << expectedBytes << " dlRx " << dlRx << " ulRx " << ulRx);
620 
621  // tolerance
622  if (it->dlSink)
623  {
624  NS_TEST_ASSERT_MSG_GT (dlRx, 0.500 * expectedBytes, "too few RX bytes in DL, ue=" << ueIndex << ", b=" << b);
625  }
626  if (it->ulSink)
627  {
628  NS_TEST_ASSERT_MSG_GT (ulRx, 0.500 * expectedBytes, "too few RX bytes in UL, ue=" << ueIndex << ", b=" << b);
629  }
630  ++b;
631  }
632 }
633 
634 
636 {
637 public:
639 };
640 
641 
643  : TestSuite ("lte-x2-handover-measures", SYSTEM)
644 {
645  Time checkInterval = Seconds (1);
646 
647  std::string cel1name ("ho: 0 -> 1");
648  std::list<CheckPointEvent> cel1;
649  cel1.push_back (CheckPointEvent (Seconds (1), Seconds (10.1), checkInterval, 0, 0));
650  cel1.push_back (CheckPointEvent (Seconds (11), Seconds (17), checkInterval, 0, 1));
651 
652  std::string cel2name ("ho: 0 -> 1 -> 2");
653  std::list<CheckPointEvent> cel2;
654  cel2.push_back (CheckPointEvent (Seconds (1), Seconds (10.1), checkInterval, 0, 0));
655  cel2.push_back (CheckPointEvent (Seconds (11), Seconds (17.1), checkInterval, 0, 1));
656  cel2.push_back (CheckPointEvent (Seconds (18), Seconds (24), checkInterval, 0, 2));
657 
658  std::string cel3name ("ho: 0 -> 1 -> 2 -> 3");
659  std::list<CheckPointEvent> cel3;
660  cel3.push_back (CheckPointEvent (Seconds (1), Seconds (10.1), checkInterval, 0, 0));
661  cel3.push_back (CheckPointEvent (Seconds (11), Seconds (17.1), checkInterval, 0, 1));
662  cel3.push_back (CheckPointEvent (Seconds (18), Seconds (24.1), checkInterval, 0, 2));
663  cel3.push_back (CheckPointEvent (Seconds (25), Seconds (37), checkInterval, 0, 3));
664 
665 
666  int32_t useIdealRrc;
667  std::string sched = "ns3::PfFfMacScheduler";
668  std::string ho = "ns3::A2A4RsrqHandoverAlgorithm";
669  for (useIdealRrc = 1; useIdealRrc >= 0; --useIdealRrc)
670  {
671  // nEnbs, nUes, nDBearers, celist, name, useUdp, sched, ho, admitHo, idealRrc
672  AddTestCase (new LteX2HandoverMeasuresTestCase (2, 1, 0, cel1, cel1name, true, sched, ho, true, useIdealRrc), TestCase::TAKES_FOREVER);
673  AddTestCase (new LteX2HandoverMeasuresTestCase (2, 1, 1, cel1, cel1name, true, sched, ho, true, useIdealRrc), TestCase::QUICK);
674  AddTestCase (new LteX2HandoverMeasuresTestCase (2, 1, 2, cel1, cel1name, true, sched, ho, true, useIdealRrc), TestCase::TAKES_FOREVER);
675  AddTestCase (new LteX2HandoverMeasuresTestCase (3, 1, 0, cel2, cel2name, true, sched, ho, true, useIdealRrc), TestCase::TAKES_FOREVER);
676  AddTestCase (new LteX2HandoverMeasuresTestCase (3, 1, 1, cel2, cel2name, true, sched, ho, true, useIdealRrc), TestCase::TAKES_FOREVER);
677  AddTestCase (new LteX2HandoverMeasuresTestCase (3, 1, 2, cel2, cel2name, true, sched, ho, true, useIdealRrc), TestCase::EXTENSIVE);
678  AddTestCase (new LteX2HandoverMeasuresTestCase (4, 1, 0, cel3, cel3name, true, sched, ho, true, useIdealRrc), TestCase::EXTENSIVE);
679  AddTestCase (new LteX2HandoverMeasuresTestCase (4, 1, 1, cel3, cel3name, true, sched, ho, true, useIdealRrc), TestCase::TAKES_FOREVER);
680  AddTestCase (new LteX2HandoverMeasuresTestCase (4, 1, 2, cel3, cel3name, true, sched, ho, true, useIdealRrc), TestCase::TAKES_FOREVER);
681  }
682 
683  sched = "ns3::RrFfMacScheduler";
684  for (useIdealRrc = 1; useIdealRrc >= 0; --useIdealRrc)
685  {
686  // nEnbs, nUes, nDBearers, celist, name, useUdp, sched, admitHo, idealRrc
687  AddTestCase (new LteX2HandoverMeasuresTestCase (2, 1, 0, cel1, cel1name, true, sched, ho, true, useIdealRrc), TestCase::EXTENSIVE);
688  AddTestCase (new LteX2HandoverMeasuresTestCase (3, 1, 0, cel2, cel2name, true, sched, ho, true, useIdealRrc), TestCase::TAKES_FOREVER);
689  AddTestCase (new LteX2HandoverMeasuresTestCase (4, 1, 0, cel3, cel3name, true, sched, ho, true, useIdealRrc), TestCase::TAKES_FOREVER);
690  }
691 
692  ho = "ns3::A3RsrpHandoverAlgorithm";
693  sched = "ns3::PfFfMacScheduler";
694  for (useIdealRrc = 1; useIdealRrc >= 0; --useIdealRrc)
695  {
696  // nEnbs, nUes, nDBearers, celist, name, useUdp, sched, admitHo, idealRrc
697  AddTestCase (new LteX2HandoverMeasuresTestCase (2, 1, 0, cel1, cel1name, true, sched, ho, true, useIdealRrc), TestCase::EXTENSIVE);
698  AddTestCase (new LteX2HandoverMeasuresTestCase (3, 1, 0, cel2, cel2name, true, sched, ho, true, useIdealRrc), TestCase::TAKES_FOREVER);
699  AddTestCase (new LteX2HandoverMeasuresTestCase (4, 1, 0, cel3, cel3name, true, sched, ho, true, useIdealRrc), TestCase::TAKES_FOREVER);
700  }
701 
702  sched = "ns3::RrFfMacScheduler";
703  for (useIdealRrc = 1; useIdealRrc >= 0; --useIdealRrc)
704  {
705  // nEnbs, nUes, nDBearers, celist, name, useUdp, sched, admitHo, idealRrc
706  AddTestCase (new LteX2HandoverMeasuresTestCase (2, 1, 0, cel1, cel1name, true, sched, ho, true, useIdealRrc), TestCase::QUICK);
707  AddTestCase (new LteX2HandoverMeasuresTestCase (3, 1, 0, cel2, cel2name, true, sched, ho, true, useIdealRrc), TestCase::TAKES_FOREVER);
708  AddTestCase (new LteX2HandoverMeasuresTestCase (4, 1, 0, cel3, cel3name, true, sched, ho, true, useIdealRrc), TestCase::EXTENSIVE);
709  }
710 
711 } // end of LteX2HandoverMeasuresTestSuite ()
712 
holds a vector of ns3::Application pointers.
Iterator Begin(void) const
Get an iterator which refers to the first NetDevice in the container.
uint8_t Add(PacketFilter f)
add a PacketFilter to the Traffic Flow Template
Definition: epc-tft.cc:157
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:95
an Inet address class
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:60
#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 this RNG stream.
State
The state of the UeManager at the eNB RRC.
Definition: lte-enb-rrc.h:72
Hold a bool native type.
Definition: boolean.h:38
NetDeviceContainer InstallEnbDevice(NodeContainer c)
create a set of eNB devices
Definition: lte-helper.cc:382
A helper to make it easier to instantiate an ns3::BulkSendApplication on a set of nodes...
Ptr< PointToPointEpcHelper > m_epcHelper
holds a vector of std::pair of Ptr and interface index.
void SetDefaultRoute(Ipv4Address nextHop, uint32_t interface, uint32_t metric=0)
Add a default route to the static routing table.
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:652
hold variables of type string
Definition: string.h:18
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr stored in this container at a given index.
NetDeviceContainer Install(NodeContainer c)
a class to represent an Ipv4 address mask
Definition: ipv4-address.h:222
void Add(ApplicationContainer other)
Append the contents of another ApplicationContainer to the end of this container. ...
A suite of tests to run.
Definition: test.h:1289
Ptr< LteUeRrc > GetRrc() const
uint64_t GetImsi() const
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:709
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:170
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:853
aggregate IP/TCP/UDP functionality to existing Nodes.
uint16_t localPortEnd
end of the port number range of the UE
Definition: epc-tft.h:115
#define NS_FATAL_ERROR(msg)
fatal error handling
Definition: fatal-error.h:95
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:1113
int64_t AssignStreams(NetDeviceContainer c, int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
Definition: lte-helper.cc:1027
void ActivateDataRadioBearer(NetDeviceContainer ueDevices, EpsBearer bearer)
Call ActivateDataRadioBearer (ueDevice, bearer) for each UE device in a given set.
Definition: lte-helper.cc:963
void SetDeviceAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each NetDevice created by the helper.
State GetState() const
a 3d vector
Definition: vector.h:31
void SetHandoverAlgorithmType(std::string type)
Definition: lte-helper.cc:273
ApplicationContainer Install(NodeContainer c)
double stopTime
tuple clientApps
Definition: first.py:53
std::map< uint32_t, Ptr< Object > >::const_iterator Iterator
void SetSchedulerType(std::string type)
Definition: lte-helper.cc:225
uint32_t GetN(void) const
Get the number of Ptr stored in this container.
uint32_t GetN(void) const
Get the number of Ptr stored in this container.
Class for representing data rates.
Definition: data-rate.h:71
Keep track of the current position and velocity of an object.
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:322
ApplicationContainer Install(NodeContainer c) const
Install an ns3::BulkSendApplication on each node of the input container configured with all the attri...
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)
void Install(Ptr< Node > node) const
"Layout" a single node according to the current position allocator type.
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:281
Create a client application which sends UDP packets carrying a 32bit sequence number and a 64 bit tim...
Attribute for objects of type ns3::Time.
Definition: nstime.h:912
std::list< CheckPointEvent > m_checkPointEventList
Hold an unsigned integer type.
Definition: uinteger.h:46
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:148
holds a vector of ns3::NetDevice pointers
virtual void DoRun(void)
Implementation to actually run this TestCase.
void Start(Time start)
Arrange for all of the Applications in this container to Start() at the Time given as a parameter...
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:233
tuple serverApps
Definition: first.py:44
Access to the Ipv4 forwarding table, interfaces, and configuration.
Definition: ipv4.h:76
uint16_t remotePortEnd
end of the port number range of the remote host
Definition: epc-tft.h:113
void SetDefault(std::string name, const AttributeValue &value)
Definition: config.cc:677
void ActivateDedicatedEpsBearer(NetDeviceContainer ueDevices, EpsBearer bearer, Ptr< EpcTft > tft)
Activate a dedicated EPS bearer on a given set of UE devices.
Definition: lte-helper.cc:817
virtual Ipv4Address GetUeDefaultGatewayAddress()
static LteX2HandoverMeasuresTestSuite g_lteX2HandoverMeasuresTestSuiteInstance
keep track of a set of node pointers.
Ptr< Application > Get(uint32_t i) const
Get the Ptr stored in this container at a given index.
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)
Returns a random double from the uniform distribution with the specified range.
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
void AddX2Interface(NodeContainer enbNodes)
Create an X2 interface between all the eNBs in a given set.
Definition: lte-helper.cc:915
void GetAttribute(std::string name, AttributeValue &value) const
Definition: object-base.cc:214
void AddTestCase(TestCase *testCase) NS_DEPRECATED
Add an individual child TestCase case to this TestCase.
Definition: test.cc:184
uint64_t GetImsi(void) const
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)
void SetChannelAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each Channel created by the helper.
#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:84
NetDeviceContainer InstallUeDevice(NodeContainer c)
create a set of UE devices
Definition: lte-helper.cc:397
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:38
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
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 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:218
#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:589
static void SetVelocity(Ptr< Node > node, Vector vel)
Definition: bug780-test.cc:60
Helper class that adds ns3::Ipv4StaticRouting objects.
hold objects of type ns3::DataRate
Ptr< Node > Get(uint32_t i) const
Get the Ptr stored in this container at a given index.
std::vector< Ptr< NetDevice > >::const_iterator Iterator
NetDevice container iterator.
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:845
CheckPointEvent(Time start, Time stop, Time interval, uint32_t ueIndex, uint32_t enbIndex)
Mobility model for which the current speed does not change once it has been set and until it is set a...
ApplicationContainer Install(NodeContainer c) const
Install an ns3::PacketSinkApplication on each node of the input container configured with all the att...
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
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...
static void SetPosition(Ptr< Node > node, Vector position)
contain a set of ns3::Object pointers.
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...
Iterator End(void) const
Get an iterator which indicates past-the-last NetDevice in the container.
#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:964
Hold a floating point type.
Definition: double.h:41
void SetAttribute(std::string name, const AttributeValue &value)
Definition: object-base.cc:176
The eNodeB device implementation.
Ptr< T > GetObject(void) const
Definition: object.h:362
Qci
QoS Class Indicator.
Definition: eps-bearer.h:77
uint16_t remotePortStart
start of the port number range of the remote host
Definition: epc-tft.h:112
void CheckConnected(Ptr< NetDevice > ueDevice, Ptr< NetDevice > enbDevice)
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:73
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
uint16_t localPortStart
start of the port number range of the UE
Definition: epc-tft.h:114
The LteUeNetDevice class implements the UE net device.