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 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 
201  int64_t stream = 1;
202 
203  m_lteHelper = CreateObject<LteHelper> ();
204  m_lteHelper->SetAttribute ("PathlossModel", StringValue ("ns3::FriisSpectrumPropagationLossModel"));
205  m_lteHelper->SetAttribute ("UseIdealRrc", BooleanValue (m_useIdealRrc));
206  m_lteHelper->SetSchedulerType (m_schedulerType);
207 
208  if (m_handoverAlgorithmType == "ns3::A2A4RsrqHandoverAlgorithm")
209  {
210  m_lteHelper->SetHandoverAlgorithmType ("ns3::A2A4RsrqHandoverAlgorithm");
211  m_lteHelper->SetHandoverAlgorithmAttribute ("ServingCellThreshold",
212  UintegerValue (30));
213  m_lteHelper->SetHandoverAlgorithmAttribute ("NeighbourCellOffset",
214  UintegerValue (1));
215  }
216  else if (m_handoverAlgorithmType == "ns3::A3RsrpHandoverAlgorithm")
217  {
218  m_lteHelper->SetHandoverAlgorithmType ("ns3::A3RsrpHandoverAlgorithm");
219  m_lteHelper->SetHandoverAlgorithmAttribute ("Hysteresis",
220  DoubleValue (1.5));
221  m_lteHelper->SetHandoverAlgorithmAttribute ("TimeToTrigger",
222  TimeValue (MilliSeconds (128)));
223  }
224  else
225  {
226  NS_FATAL_ERROR ("Unknown handover algorithm " << m_handoverAlgorithmType);
227  }
228 
229  double distance = 1000.0; // m
230  double speed = 150; // m/s
231 
232  NodeContainer enbNodes;
233  enbNodes.Create (m_nEnbs);
234  NodeContainer ueNodes;
235  ueNodes.Create (m_nUes);
236 
237  if (m_epc)
238  {
239  m_epcHelper = CreateObject<PointToPointEpcHelper> ();
240  m_lteHelper->SetEpcHelper (m_epcHelper);
241  }
242 
243  // Install Mobility Model in eNBs
244  // eNBs are located along a line in the X axis
245  Ptr<ListPositionAllocator> enbPositionAlloc = CreateObject<ListPositionAllocator> ();
246  for (uint16_t i = 0; i < m_nEnbs; i++)
247  {
248  Vector enbPosition (distance * (i + 1), 0, 0);
249  enbPositionAlloc->Add (enbPosition);
250  }
251  MobilityHelper enbMobility;
252  enbMobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
253  enbMobility.SetPositionAllocator (enbPositionAlloc);
254  enbMobility.Install (enbNodes);
255 
256  // Install Mobility Model in UE
257  // UE moves with a constant speed along the X axis
258  MobilityHelper ueMobility;
259  ueMobility.SetMobilityModel ("ns3::ConstantVelocityMobilityModel");
260  ueMobility.Install (ueNodes);
261  for (uint16_t i = 0; i < m_nUes; i++)
262  {
263  ueNodes.Get (i)->GetObject<MobilityModel> ()->SetPosition (Vector (0, 0, 0));
264  ueNodes.Get (i)->GetObject<ConstantVelocityMobilityModel> ()->SetVelocity (Vector (speed, 0, 0));
265  }
266 
267  NetDeviceContainer enbDevices;
268  enbDevices = m_lteHelper->InstallEnbDevice (enbNodes);
269  stream += m_lteHelper->AssignStreams (enbDevices, stream);
270  for (NetDeviceContainer::Iterator it = enbDevices.Begin ();
271  it != enbDevices.End ();
272  ++it)
273  {
274  Ptr<LteEnbRrc> enbRrc = (*it)->GetObject<LteEnbNetDevice> ()->GetRrc ();
275  enbRrc->SetAttribute ("AdmitHandoverRequest", BooleanValue (m_admitHo));
276  }
277 
278  NetDeviceContainer ueDevices;
279  ueDevices = m_lteHelper->InstallUeDevice (ueNodes);
280  stream += m_lteHelper->AssignStreams (ueDevices, stream);
281 
282  Ipv4Address remoteHostAddr;
283  Ipv4StaticRoutingHelper ipv4RoutingHelper;
284  Ipv4InterfaceContainer ueIpIfaces;
285  Ptr<Node> remoteHost;
286  if (m_epc)
287  {
288  // Create a single RemoteHost
289  NodeContainer remoteHostContainer;
290  remoteHostContainer.Create (1);
291  remoteHost = remoteHostContainer.Get (0);
292  InternetStackHelper internet;
293  internet.Install (remoteHostContainer);
294 
295  // Create the Internet
296  PointToPointHelper p2ph;
297  p2ph.SetDeviceAttribute ("DataRate", DataRateValue (DataRate ("100Gb/s")));
298  p2ph.SetDeviceAttribute ("Mtu", UintegerValue (1500));
299  p2ph.SetChannelAttribute ("Delay", TimeValue (Seconds (0.010)));
300  Ptr<Node> pgw = m_epcHelper->GetPgwNode ();
301  NetDeviceContainer internetDevices = p2ph.Install (pgw, remoteHost);
302  Ipv4AddressHelper ipv4h;
303  ipv4h.SetBase ("1.0.0.0", "255.0.0.0");
304  Ipv4InterfaceContainer internetIpIfaces = ipv4h.Assign (internetDevices);
305  // in this container, interface 0 is the pgw, 1 is the remoteHost
306  remoteHostAddr = internetIpIfaces.GetAddress (1);
307 
308  Ipv4StaticRoutingHelper ipv4RoutingHelper;
309  Ptr<Ipv4StaticRouting> remoteHostStaticRouting = ipv4RoutingHelper.GetStaticRouting (remoteHost->GetObject<Ipv4> ());
310  remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.0.0.0"), 1);
311 
312  // Install the IP stack on the UEs
313  internet.Install (ueNodes);
314  ueIpIfaces = m_epcHelper->AssignUeIpv4Address (NetDeviceContainer (ueDevices));
315  }
316 
317  // attachment (needs to be done after IP stack configuration)
318  // all UEs attached to eNB 0 at the beginning
319  m_lteHelper->Attach (ueDevices, enbDevices.Get (0));
320 
321  if (m_epc)
322  {
323  bool epcDl = true;
324  bool epcUl = false;
325  // the rest of this block is copied from lena-dual-stripe
326 
327 
328  // Install and start applications on UEs and remote host
329  uint16_t dlPort = 10000;
330  uint16_t ulPort = 20000;
331 
332  // randomize a bit start times to avoid simulation artifacts
333  // (e.g., buffer overflows due to packet transmissions happening
334  // exactly at the same time)
335  Ptr<UniformRandomVariable> startTimeSeconds = CreateObject<UniformRandomVariable> ();
336  startTimeSeconds->SetAttribute ("Min", DoubleValue (0));
337  startTimeSeconds->SetAttribute ("Max", DoubleValue (0.010));
338  startTimeSeconds->SetStream (stream++);
339 
340  for (uint32_t u = 0; u < ueNodes.GetN (); ++u)
341  {
342  Ptr<Node> ue = ueNodes.Get (u);
343  // Set the default gateway for the UE
344  Ptr<Ipv4StaticRouting> ueStaticRouting = ipv4RoutingHelper.GetStaticRouting (ue->GetObject<Ipv4> ());
345  ueStaticRouting->SetDefaultRoute (m_epcHelper->GetUeDefaultGatewayAddress (), 1);
346 
347  UeData ueData;
348 
349  for (uint32_t b = 0; b < m_nDedicatedBearers; ++b)
350  {
351  ++dlPort;
352  ++ulPort;
353 
356  BearerData bearerData;
357 
358  if (m_useUdp)
359  {
360  if (epcDl)
361  {
362  UdpClientHelper dlClientHelper (ueIpIfaces.GetAddress (u), dlPort);
363  clientApps.Add (dlClientHelper.Install (remoteHost));
364  PacketSinkHelper dlPacketSinkHelper ("ns3::UdpSocketFactory",
366  ApplicationContainer sinkContainer = dlPacketSinkHelper.Install (ue);
367  bearerData.dlSink = sinkContainer.Get (0)->GetObject<PacketSink> ();
368  serverApps.Add (sinkContainer);
369 
370  }
371  if (epcUl)
372  {
373  UdpClientHelper ulClientHelper (remoteHostAddr, ulPort);
374  clientApps.Add (ulClientHelper.Install (ue));
375  PacketSinkHelper ulPacketSinkHelper ("ns3::UdpSocketFactory",
377  ApplicationContainer sinkContainer = ulPacketSinkHelper.Install (remoteHost);
378  bearerData.ulSink = sinkContainer.Get (0)->GetObject<PacketSink> ();
379  serverApps.Add (sinkContainer);
380  }
381  }
382  else // use TCP
383  {
384  if (epcDl)
385  {
386  BulkSendHelper dlClientHelper ("ns3::TcpSocketFactory",
387  InetSocketAddress (ueIpIfaces.GetAddress (u), dlPort));
388  dlClientHelper.SetAttribute ("MaxBytes", UintegerValue (0));
389  clientApps.Add (dlClientHelper.Install (remoteHost));
390  PacketSinkHelper dlPacketSinkHelper ("ns3::TcpSocketFactory",
392  ApplicationContainer sinkContainer = dlPacketSinkHelper.Install (ue);
393  bearerData.dlSink = sinkContainer.Get (0)->GetObject<PacketSink> ();
394  serverApps.Add (sinkContainer);
395  }
396  if (epcUl)
397  {
398  BulkSendHelper ulClientHelper ("ns3::TcpSocketFactory",
399  InetSocketAddress (remoteHostAddr, ulPort));
400  ulClientHelper.SetAttribute ("MaxBytes", UintegerValue (0));
401  clientApps.Add (ulClientHelper.Install (ue));
402  PacketSinkHelper ulPacketSinkHelper ("ns3::TcpSocketFactory",
404  ApplicationContainer sinkContainer = ulPacketSinkHelper.Install (remoteHost);
405  bearerData.ulSink = sinkContainer.Get (0)->GetObject<PacketSink> ();
406  serverApps.Add (sinkContainer);
407  }
408  } // end if (useUdp)
409 
410  Ptr<EpcTft> tft = Create<EpcTft> ();
411  if (epcDl)
412  {
414  dlpf.localPortStart = dlPort;
415  dlpf.localPortEnd = dlPort;
416  tft->Add (dlpf);
417  }
418  if (epcUl)
419  {
421  ulpf.remotePortStart = ulPort;
422  ulpf.remotePortEnd = ulPort;
423  tft->Add (ulpf);
424  }
425 
426  if (epcDl || epcUl)
427  {
429  m_lteHelper->ActivateDedicatedEpsBearer (ueDevices.Get (u), bearer, tft);
430  }
431  Time startTime = Seconds (startTimeSeconds->GetValue ());
432  serverApps.Start (startTime);
433  clientApps.Start (startTime);
434 
435  ueData.bearerDataList.push_back (bearerData);
436 
437  } // end for b
438 
439  m_ueDataVector.push_back (ueData);
440  }
441 
442  }
443  else // (epc == false)
444  {
445  // for radio bearer activation purposes, consider together home UEs and macro UEs
446  for (uint32_t u = 0; u < ueDevices.GetN (); ++u)
447  {
448  Ptr<NetDevice> ueDev = ueDevices.Get (u);
449  for (uint32_t b = 0; b < m_nDedicatedBearers; ++b)
450  {
452  EpsBearer bearer (q);
453  m_lteHelper->ActivateDataRadioBearer (ueDev, bearer);
454  }
455  }
456  }
457 
458 
459  m_lteHelper->AddX2Interface (enbNodes);
460 
461  // check initial RRC connection
462  const Time maxRrcConnectionEstablishmentDuration = Seconds (0.080);
463  for (NetDeviceContainer::Iterator it = ueDevices.Begin (); it != ueDevices.End (); ++it)
464  {
465  NS_LOG_FUNCTION (maxRrcConnectionEstablishmentDuration);
466  Simulator::Schedule (maxRrcConnectionEstablishmentDuration,
468  this, *it, enbDevices.Get (0));
469  }
470 
471  // schedule the checkpoint events
472 
473  Time stopTime = Seconds (0);
474  for (std::list<CheckPointEvent>::iterator checkPointEventIt = m_checkPointEventList.begin ();
475  checkPointEventIt != m_checkPointEventList.end ();
476  ++checkPointEventIt)
477  {
478  for (Time checkPointTime = checkPointEventIt->checkStartTime;
479  checkPointTime < checkPointEventIt->checkStopTime;
480  checkPointTime += checkPointEventIt->checkInterval)
481  {
483  this, ueDevices.Get (checkPointEventIt->ueDeviceIndex),
484  enbDevices.Get (checkPointEventIt->enbDeviceIndex));
485 
486  Time saveStatsTime = checkPointTime;
488  this, checkPointEventIt->ueDeviceIndex);
489 
490  Time checkStats = saveStatsTime + m_statsDuration;
492  this, checkPointEventIt->ueDeviceIndex);
493 
494  if (stopTime <= checkStats)
495  {
496  stopTime = checkStats + Seconds (1);
497  }
498  }
499  }
500 
501  Simulator::Stop (stopTime);
502  Simulator::Run ();
504 }
505 
506 void
508 {
509  NS_LOG_FUNCTION (ueDevice << enbDevice);
510 
511  Ptr<LteUeNetDevice> ueLteDevice = ueDevice->GetObject<LteUeNetDevice> ();
512  Ptr<LteUeRrc> ueRrc = ueLteDevice->GetRrc ();
513  NS_TEST_ASSERT_MSG_EQ (ueRrc->GetState (), LteUeRrc::CONNECTED_NORMALLY, "Wrong LteUeRrc state!");
514 
515 
516  Ptr<LteEnbNetDevice> enbLteDevice = enbDevice->GetObject<LteEnbNetDevice> ();
517  Ptr<LteEnbRrc> enbRrc = enbLteDevice->GetRrc ();
518  uint16_t rnti = ueRrc->GetRnti ();
519  Ptr<UeManager> ueManager = enbRrc->GetUeManager (rnti);
520  NS_TEST_ASSERT_MSG_NE (ueManager, 0, "RNTI " << rnti << " not found in eNB");
521 
522  UeManager::State ueManagerState = ueManager->GetState ();
523  NS_TEST_ASSERT_MSG_EQ (ueManagerState, UeManager::CONNECTED_NORMALLY, "Wrong UeManager state!");
524  NS_ASSERT_MSG (ueManagerState == UeManager::CONNECTED_NORMALLY, "Wrong UeManager state!");
525 
526  uint16_t ueCellId = ueRrc->GetCellId ();
527  uint16_t enbCellId = enbLteDevice->GetCellId ();
528  uint8_t ueDlBandwidth = ueRrc->GetDlBandwidth ();
529  uint8_t enbDlBandwidth = enbLteDevice->GetDlBandwidth ();
530  uint8_t ueUlBandwidth = ueRrc->GetUlBandwidth ();
531  uint8_t enbUlBandwidth = enbLteDevice->GetUlBandwidth ();
532  uint8_t ueDlEarfcn = ueRrc->GetDlEarfcn ();
533  uint8_t enbDlEarfcn = enbLteDevice->GetDlEarfcn ();
534  uint8_t ueUlEarfcn = ueRrc->GetUlEarfcn ();
535  uint8_t enbUlEarfcn = enbLteDevice->GetUlEarfcn ();
536  uint64_t ueImsi = ueLteDevice->GetImsi ();
537  uint64_t enbImsi = ueManager->GetImsi ();
538 
539  NS_TEST_ASSERT_MSG_EQ (ueImsi, enbImsi, "inconsistent IMSI");
540  NS_TEST_ASSERT_MSG_EQ (ueCellId, enbCellId, "inconsistent CellId");
541  NS_TEST_ASSERT_MSG_EQ (ueDlBandwidth, enbDlBandwidth, "inconsistent DlBandwidth");
542  NS_TEST_ASSERT_MSG_EQ (ueUlBandwidth, enbUlBandwidth, "inconsistent UlBandwidth");
543  NS_TEST_ASSERT_MSG_EQ (ueDlEarfcn, enbDlEarfcn, "inconsistent DlEarfcn");
544  NS_TEST_ASSERT_MSG_EQ (ueUlEarfcn, enbUlEarfcn, "inconsistent UlEarfcn");
545 
546  ObjectMapValue enbDataRadioBearerMapValue;
547  ueManager->GetAttribute ("DataRadioBearerMap", enbDataRadioBearerMapValue);
548  NS_TEST_ASSERT_MSG_EQ (enbDataRadioBearerMapValue.GetN (), m_nDedicatedBearers + 1, "wrong num bearers at eNB");
549 
550  ObjectMapValue ueDataRadioBearerMapValue;
551  ueRrc->GetAttribute ("DataRadioBearerMap", ueDataRadioBearerMapValue);
552  NS_TEST_ASSERT_MSG_EQ (ueDataRadioBearerMapValue.GetN (), m_nDedicatedBearers + 1, "wrong num bearers at UE");
553 
554  ObjectMapValue::Iterator enbBearerIt = enbDataRadioBearerMapValue.Begin ();
555  ObjectMapValue::Iterator ueBearerIt = ueDataRadioBearerMapValue.Begin ();
556  while (enbBearerIt != enbDataRadioBearerMapValue.End ()
557  && ueBearerIt != ueDataRadioBearerMapValue.End ())
558  {
559  Ptr<LteDataRadioBearerInfo> enbDrbInfo = enbBearerIt->second->GetObject<LteDataRadioBearerInfo> ();
560  Ptr<LteDataRadioBearerInfo> ueDrbInfo = ueBearerIt->second->GetObject<LteDataRadioBearerInfo> ();
561  //NS_TEST_ASSERT_MSG_EQ (enbDrbInfo->m_epsBearer, ueDrbInfo->m_epsBearer, "epsBearer differs");
562  NS_TEST_ASSERT_MSG_EQ ((uint32_t) enbDrbInfo->m_epsBearerIdentity, (uint32_t) ueDrbInfo->m_epsBearerIdentity, "epsBearerIdentity differs");
563  NS_TEST_ASSERT_MSG_EQ ((uint32_t) enbDrbInfo->m_drbIdentity, (uint32_t) ueDrbInfo->m_drbIdentity, "drbIdentity differs");
564  //NS_TEST_ASSERT_MSG_EQ (enbDrbInfo->m_rlcConfig, ueDrbInfo->m_rlcConfig, "rlcConfig differs");
565  NS_TEST_ASSERT_MSG_EQ ((uint32_t) enbDrbInfo->m_logicalChannelIdentity, (uint32_t) ueDrbInfo->m_logicalChannelIdentity, "logicalChannelIdentity differs");
566  //NS_TEST_ASSERT_MSG_EQ (enbDrbInfo->m_logicalChannelConfig, ueDrbInfo->m_logicalChannelConfig, "logicalChannelConfig differs");
567 
568  ++enbBearerIt;
569  ++ueBearerIt;
570  }
571  NS_ASSERT_MSG (enbBearerIt == enbDataRadioBearerMapValue.End (), "too many bearers at eNB");
572  NS_ASSERT_MSG (ueBearerIt == ueDataRadioBearerMapValue.End (), "too many bearers at UE");
573 }
574 
575 void
577 {
578  NS_LOG_FUNCTION (ueIndex);
579  for (std::list<BearerData>::iterator it = m_ueDataVector.at (ueIndex).bearerDataList.begin ();
580  it != m_ueDataVector.at (ueIndex).bearerDataList.end ();
581  ++it)
582  {
583  if (it->dlSink)
584  {
585  it->dlOldTotalRx = it->dlSink->GetTotalRx ();
586  }
587  if (it->ulSink)
588  {
589  it->ulOldTotalRx = it->ulSink->GetTotalRx ();
590  }
591  }
592 }
593 
594 void
596 {
597  NS_LOG_FUNCTION (ueIndex);
598  uint32_t b = 1;
599  for (std::list<BearerData>::iterator it = m_ueDataVector.at (ueIndex).bearerDataList.begin ();
600  it != m_ueDataVector.at (ueIndex).bearerDataList.end ();
601  ++it)
602  {
603  uint32_t dlRx = 0;
604  uint32_t ulRx = 0;
605 
606  if (it->dlSink)
607  {
608  dlRx = it->dlSink->GetTotalRx () - it->dlOldTotalRx;
609  }
610 
611  if (it->ulSink)
612  {
613  ulRx = it->ulSink->GetTotalRx () - it->ulOldTotalRx;
614  }
616 
617  NS_LOG_LOGIC ("expBytes " << expectedBytes << " dlRx " << dlRx << " ulRx " << ulRx);
618 
619  // tolerance
620  if (it->dlSink)
621  {
622  NS_TEST_ASSERT_MSG_GT (dlRx, 0.500 * expectedBytes, "too few RX bytes in DL, ue=" << ueIndex << ", b=" << b);
623  }
624  if (it->ulSink)
625  {
626  NS_TEST_ASSERT_MSG_GT (ulRx, 0.500 * expectedBytes, "too few RX bytes in UL, ue=" << ueIndex << ", b=" << b);
627  }
628  ++b;
629  }
630 }
631 
632 
634 {
635 public:
637 };
638 
639 
641  : TestSuite ("lte-x2-handover-measures", SYSTEM)
642 {
643  Time checkInterval = Seconds (1);
644 
645  std::string cel1name ("ho: 0 -> 1");
646  std::list<CheckPointEvent> cel1;
647  cel1.push_back (CheckPointEvent (Seconds (1), Seconds (10.1), checkInterval, 0, 0));
648  cel1.push_back (CheckPointEvent (Seconds (11), Seconds (17), checkInterval, 0, 1));
649 
650  std::string cel2name ("ho: 0 -> 1 -> 2");
651  std::list<CheckPointEvent> cel2;
652  cel2.push_back (CheckPointEvent (Seconds (1), Seconds (10.1), checkInterval, 0, 0));
653  cel2.push_back (CheckPointEvent (Seconds (11), Seconds (17.1), checkInterval, 0, 1));
654  cel2.push_back (CheckPointEvent (Seconds (18), Seconds (24), checkInterval, 0, 2));
655 
656  std::string cel3name ("ho: 0 -> 1 -> 2 -> 3");
657  std::list<CheckPointEvent> cel3;
658  cel3.push_back (CheckPointEvent (Seconds (1), Seconds (10.1), checkInterval, 0, 0));
659  cel3.push_back (CheckPointEvent (Seconds (11), Seconds (17.1), checkInterval, 0, 1));
660  cel3.push_back (CheckPointEvent (Seconds (18), Seconds (24.1), checkInterval, 0, 2));
661  cel3.push_back (CheckPointEvent (Seconds (25), Seconds (37), checkInterval, 0, 3));
662 
663 
664  int32_t useIdealRrc;
665  std::string sched = "ns3::PfFfMacScheduler";
666  std::string ho = "ns3::A2A4RsrqHandoverAlgorithm";
667  for (useIdealRrc = 1; useIdealRrc >= 0; --useIdealRrc)
668  {
669  // nEnbs, nUes, nDBearers, celist, name, useUdp, sched, ho, admitHo, idealRrc
670  AddTestCase (new LteX2HandoverMeasuresTestCase (2, 1, 0, cel1, cel1name, true, sched, ho, true, useIdealRrc), TestCase::TAKES_FOREVER);
671  AddTestCase (new LteX2HandoverMeasuresTestCase (2, 1, 1, cel1, cel1name, true, sched, ho, true, useIdealRrc), TestCase::QUICK);
672  AddTestCase (new LteX2HandoverMeasuresTestCase (2, 1, 2, cel1, cel1name, true, sched, ho, true, useIdealRrc), TestCase::TAKES_FOREVER);
673  AddTestCase (new LteX2HandoverMeasuresTestCase (3, 1, 0, cel2, cel2name, true, sched, ho, true, useIdealRrc), TestCase::TAKES_FOREVER);
674  AddTestCase (new LteX2HandoverMeasuresTestCase (3, 1, 1, cel2, cel2name, true, sched, ho, true, useIdealRrc), TestCase::TAKES_FOREVER);
675  AddTestCase (new LteX2HandoverMeasuresTestCase (3, 1, 2, cel2, cel2name, true, sched, ho, true, useIdealRrc), TestCase::EXTENSIVE);
676  AddTestCase (new LteX2HandoverMeasuresTestCase (4, 1, 0, cel3, cel3name, true, sched, ho, true, useIdealRrc), TestCase::EXTENSIVE);
677  AddTestCase (new LteX2HandoverMeasuresTestCase (4, 1, 1, cel3, cel3name, true, sched, ho, true, useIdealRrc), TestCase::TAKES_FOREVER);
678  AddTestCase (new LteX2HandoverMeasuresTestCase (4, 1, 2, cel3, cel3name, true, sched, ho, true, useIdealRrc), TestCase::TAKES_FOREVER);
679  }
680 
681  sched = "ns3::RrFfMacScheduler";
682  for (useIdealRrc = 1; useIdealRrc >= 0; --useIdealRrc)
683  {
684  // nEnbs, nUes, nDBearers, celist, name, useUdp, sched, admitHo, idealRrc
685  AddTestCase (new LteX2HandoverMeasuresTestCase (2, 1, 0, cel1, cel1name, true, sched, ho, true, useIdealRrc), TestCase::EXTENSIVE);
686  AddTestCase (new LteX2HandoverMeasuresTestCase (3, 1, 0, cel2, cel2name, true, sched, ho, true, useIdealRrc), TestCase::TAKES_FOREVER);
687  AddTestCase (new LteX2HandoverMeasuresTestCase (4, 1, 0, cel3, cel3name, true, sched, ho, true, useIdealRrc), TestCase::TAKES_FOREVER);
688  }
689 
690  ho = "ns3::A3RsrpHandoverAlgorithm";
691  sched = "ns3::PfFfMacScheduler";
692  for (useIdealRrc = 1; useIdealRrc >= 0; --useIdealRrc)
693  {
694  // nEnbs, nUes, nDBearers, celist, name, useUdp, sched, admitHo, idealRrc
695  AddTestCase (new LteX2HandoverMeasuresTestCase (2, 1, 0, cel1, cel1name, true, sched, ho, true, useIdealRrc), TestCase::EXTENSIVE);
696  AddTestCase (new LteX2HandoverMeasuresTestCase (3, 1, 0, cel2, cel2name, true, sched, ho, true, useIdealRrc), TestCase::TAKES_FOREVER);
697  AddTestCase (new LteX2HandoverMeasuresTestCase (4, 1, 0, cel3, cel3name, true, sched, ho, true, useIdealRrc), TestCase::TAKES_FOREVER);
698  }
699 
700  sched = "ns3::RrFfMacScheduler";
701  for (useIdealRrc = 1; useIdealRrc >= 0; --useIdealRrc)
702  {
703  // nEnbs, nUes, nDBearers, celist, name, useUdp, sched, admitHo, idealRrc
704  AddTestCase (new LteX2HandoverMeasuresTestCase (2, 1, 0, cel1, cel1name, true, sched, ho, true, useIdealRrc), TestCase::QUICK);
705  AddTestCase (new LteX2HandoverMeasuresTestCase (3, 1, 0, cel2, cel2name, true, sched, ho, true, useIdealRrc), TestCase::TAKES_FOREVER);
706  AddTestCase (new LteX2HandoverMeasuresTestCase (4, 1, 0, cel3, cel3name, true, sched, ho, true, useIdealRrc), TestCase::EXTENSIVE);
707  }
708 
709 } // end of LteX2HandoverMeasuresTestSuite ()
710 
712 
713 
714 
715 } // namespace ns3
716 
holds a vector of ns3::Application pointers.
Iterator Begin(void) const
Get an iterator which refers to the first NetDevice in the container.
keep track of time values and allow control of global simulation resolution
Definition: nstime.h:81
an Inet address class
std::list< CheckPointEvent > m_checkPointEventList
static Ipv4Address GetAny(void)
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:59
#define NS_LOG_FUNCTION(parameters)
Definition: log.h:345
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:71
Hold a bool native type.
Definition: boolean.h:38
A helper to make it easier to instantiate an ns3::BulkSendApplication on a set of nodes...
holds a vector of std::pair of Ptr and interface index.
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:642
hold variables of type string
Definition: string.h:19
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:210
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:1025
Very long running test.
Definition: test.h:859
static void Run(void)
Run the simulation until one of:
Definition: simulator.cc:157
virtual void DoRun(void)
Implementation to actually run this TestCase.
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_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:539
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:849
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
Schedule an event to expire at the relative time "time" is reached.
Definition: simulator.h:824
void SetDeviceAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each NetDevice created by the helper.
a 3d vector
Definition: vector.h:31
NS_LOG_COMPONENT_DEFINE("LteX2HandoverMeasuresTest")
ApplicationContainer Install(NodeContainer c)
double stopTime
#define NS_FATAL_ERROR(msg)
fatal error handling
Definition: fatal-error.h:72
tuple clientApps
Definition: first.py:53
std::map< uint32_t, Ptr< Object > >::const_iterator Iterator
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
Definition: nstime.h:274
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
#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:773
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
Create a client application which sends UDP packets carrying a 32bit sequence number and a 64 bit tim...
hold objects of type ns3::Time
Definition: nstime.h:961
Hold an unsigned integer type.
Definition: uinteger.h:46
double startTime
Medium length test.
Definition: test.h:858
holds a vector of ns3::NetDevice pointers
void Start(Time start)
Arrange for all of the Applications in this container to Start() at the Time given as a parameter...
CheckPointEvent(Time start, Time stop, Time interval, uint32_t ueIndex, uint32_t enbIndex)
#define NS_LOG_LOGIC(msg)
Definition: log.h:368
static void Destroy(void)
Every event scheduled by the Simulator::insertAtDestroy method is invoked.
Definition: simulator.cc:121
tuple serverApps
Definition: first.py:44
Access to the Ipv4 forwarding table, interfaces, and configuration.
Definition: ipv4.h:75
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:667
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.
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 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())
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)
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...
static LteX2HandoverMeasuresTestSuite g_lteX2HandoverMeasuresTestSuiteInstance
void CheckConnected(Ptr< NetDevice > ueDevice, Ptr< NetDevice > enbDevice)
void AddTestCase(TestCase *testCase) NS_DEPRECATED
Add an individual child TestCase case to this TestCase.
Definition: test.cc:173
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)
Definition: assert.h:86
Fast test.
Definition: test.h:857
Helper class used to assign positions and mobility models to nodes.
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...
static void SetVelocity(Ptr< Node > node, Vector vel)
Definition: bug780-test.cc:54
Helper class that adds ns3::Ipv4StaticRouting objects.
hold objects of type ns3::DataRate
static void Stop(void)
If an event invokes this method, it will be the last event scheduled by the Simulator::run method bef...
Definition: simulator.cc:165
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
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.
Hold a floating point type.
Definition: double.h:41
void SetAttribute(std::string name, const AttributeValue &value)
Definition: object-base.cc:161
The eNodeB device implementation.
Ptr< T > GetObject(void) const
Definition: object.h:361
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 SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
#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:137
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.