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:
69  LteX2HandoverMeasuresTestCase (uint32_t nEnbs, uint32_t nUes, uint32_t nDedicatedBearers,
70  std::list<CheckPointEvent> checkPointEventList, std::string checkPointEventListName,
71  bool useUdp, std::string schedulerType, bool admitHo, bool useIdealRrc);
72 
73 private:
74  static std::string BuildNameString (uint32_t nEnbs, uint32_t nUes, uint32_t nDedicatedBearers,
75  std::string checkPointEventListName,
76  bool useUdp, std::string schedulerType, bool admitHo, bool useIdealRrc);
77  virtual void DoRun (void);
78  void CheckConnected (Ptr<NetDevice> ueDevice, Ptr<NetDevice> enbDevice);
79 
80  uint32_t m_nEnbs; // number of eNBs in the test
81  uint32_t m_nUes; // number of UEs in the test
82  uint32_t m_nDedicatedBearers; // number of UEs in the test
83  std::list<CheckPointEvent> m_checkPointEventList;
85  bool m_epc;
86  bool m_useUdp;
87  std::string m_schedulerType;
88  bool m_admitHo;
92 
93  struct BearerData
94  {
95  uint32_t bid;
98  uint32_t dlOldTotalRx;
99  uint32_t ulOldTotalRx;
100  };
101 
102  struct UeData
103  {
104  uint32_t id;
105  std::list<BearerData> bearerDataList;
106  };
107 
108  void SaveStats (uint32_t ueIndex);
109  void CheckStats (uint32_t ueIndex);
110 
111  std::vector<UeData> m_ueDataVector;
112 
116  const uint32_t m_udpClientPktSize;
117 };
118 
119 
120 std::string
121 LteX2HandoverMeasuresTestCase::BuildNameString (uint32_t nEnbs, uint32_t nUes, uint32_t nDedicatedBearers,
122  std::string checkPointEventListName,
123  bool useUdp, std::string schedulerType, bool admitHo, bool useIdealRrc)
124 {
125  std::ostringstream oss;
126  oss << "nEnbs=" << nEnbs
127  << " nUes=" << nUes
128  << " nDedicatedBearers=" << nDedicatedBearers
129  << " udp=" << useUdp
130  << " " << schedulerType
131  << " admitHo=" << admitHo
132  << " hoList: " << checkPointEventListName;
133  if (useIdealRrc)
134  {
135  oss << ", ideal RRC";
136  }
137  else
138  {
139  oss << ", real RRC";
140  }
141  return oss.str ();
142 }
143 
144 LteX2HandoverMeasuresTestCase::LteX2HandoverMeasuresTestCase (uint32_t nEnbs, uint32_t nUes, uint32_t nDedicatedBearers,
145  std::list<CheckPointEvent> checkPointEventList, std::string checkPointEventListName,
146  bool useUdp, std::string schedulerType, bool admitHo, bool useIdealRrc)
147  : TestCase (BuildNameString (nEnbs, nUes, nDedicatedBearers, checkPointEventListName, useUdp, schedulerType, admitHo, useIdealRrc)),
148  m_nEnbs (nEnbs),
149  m_nUes (nUes),
150  m_nDedicatedBearers (nDedicatedBearers),
151  m_checkPointEventList (checkPointEventList),
152  m_checkPointEventListName (checkPointEventListName),
153  m_epc (true),
154  m_useUdp (useUdp),
155  m_schedulerType (schedulerType),
156  m_admitHo (admitHo),
157  m_useIdealRrc (useIdealRrc),
158  m_maxHoDuration (Seconds (0.1)),
159  m_statsDuration (Seconds (0.5)),
160  m_udpClientInterval (Seconds (0.01)),
161  m_udpClientPktSize (100)
162 {
163 }
164 
165 void
167 {
171 
172  Config::Reset ();
173  Config::SetDefault ("ns3::UdpClient::Interval", TimeValue (m_udpClientInterval));
174  Config::SetDefault ("ns3::UdpClient::MaxPackets", UintegerValue (1000000));
175  Config::SetDefault ("ns3::UdpClient::PacketSize", UintegerValue (m_udpClientPktSize));
176  Config::SetDefault ("ns3::LteEnbRrc::ServingCellHandoverThreshold", UintegerValue (30));
177  Config::SetDefault ("ns3::LteEnbRrc::NeighbourCellHandoverOffset", UintegerValue (1));
178  Config::SetDefault ("ns3::LteEnbRrc::HandoverJoiningTimeoutDuration", TimeValue (MilliSeconds (200)));
179  Config::SetDefault ("ns3::LteEnbPhy::TxPower", DoubleValue (20));
180 
181 
182  int64_t stream = 1;
183 
184  m_lteHelper = CreateObject<LteHelper> ();
185  m_lteHelper->SetAttribute ("PathlossModel", StringValue ("ns3::FriisSpectrumPropagationLossModel"));
186  m_lteHelper->SetSchedulerType (m_schedulerType);
187  m_lteHelper->SetAttribute ("UseIdealRrc", BooleanValue (m_useIdealRrc));
188 
189 
190  double distance = 1000.0; // m
191  double speed = 150; // m/s
192 
193  NodeContainer enbNodes;
194  enbNodes.Create (m_nEnbs);
195  NodeContainer ueNodes;
196  ueNodes.Create (m_nUes);
197 
198  if (m_epc)
199  {
200  m_epcHelper = CreateObject<EpcHelper> ();
201  m_lteHelper->SetEpcHelper (m_epcHelper);
202  }
203 
204  // Install Mobility Model in eNBs
205  // eNBs are located along a line in the X axis
206  Ptr<ListPositionAllocator> enbPositionAlloc = CreateObject<ListPositionAllocator> ();
207  for (uint16_t i = 0; i < m_nEnbs; i++)
208  {
209  Vector enbPosition (distance * (i + 1), 0, 0);
210  enbPositionAlloc->Add (enbPosition);
211  }
212  MobilityHelper enbMobility;
213  enbMobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
214  enbMobility.SetPositionAllocator(enbPositionAlloc);
215  enbMobility.Install(enbNodes);
216 
217  // Install Mobility Model in UE
218  // UE moves with a constant speed along the X axis
219  MobilityHelper ueMobility;
220  ueMobility.SetMobilityModel ("ns3::ConstantVelocityMobilityModel");
221  ueMobility.Install(ueNodes);
222  ueNodes.Get (0)->GetObject<MobilityModel> ()->SetPosition (Vector (0, 0, 0));
223  ueNodes.Get (0)->GetObject<ConstantVelocityMobilityModel> ()->SetVelocity (Vector (speed, 0, 0));
224 
225 
226  NetDeviceContainer enbDevices;
227  enbDevices = m_lteHelper->InstallEnbDevice (enbNodes);
228  stream += m_lteHelper->AssignStreams (enbDevices, stream);
229  for (NetDeviceContainer::Iterator it = enbDevices.Begin ();
230  it != enbDevices.End ();
231  ++it)
232  {
233  Ptr<LteEnbRrc> enbRrc = (*it)->GetObject<LteEnbNetDevice> ()->GetRrc ();
234  enbRrc->SetAttribute ("AdmitHandoverRequest", BooleanValue (m_admitHo));
235  }
236 
237  NetDeviceContainer ueDevices;
238  ueDevices = m_lteHelper->InstallUeDevice (ueNodes);
239  stream += m_lteHelper->AssignStreams (ueDevices, stream);
240 
241  Ipv4Address remoteHostAddr;
242  Ipv4StaticRoutingHelper ipv4RoutingHelper;
243  Ipv4InterfaceContainer ueIpIfaces;
244  Ptr<Node> remoteHost;
245  if (m_epc)
246  {
247  // Create a single RemoteHost
248  NodeContainer remoteHostContainer;
249  remoteHostContainer.Create (1);
250  remoteHost = remoteHostContainer.Get (0);
251  InternetStackHelper internet;
252  internet.Install (remoteHostContainer);
253 
254  // Create the Internet
255  PointToPointHelper p2ph;
256  p2ph.SetDeviceAttribute ("DataRate", DataRateValue (DataRate ("100Gb/s")));
257  p2ph.SetDeviceAttribute ("Mtu", UintegerValue (1500));
258  p2ph.SetChannelAttribute ("Delay", TimeValue (Seconds (0.010)));
259  Ptr<Node> pgw = m_epcHelper->GetPgwNode ();
260  NetDeviceContainer internetDevices = p2ph.Install (pgw, remoteHost);
261  Ipv4AddressHelper ipv4h;
262  ipv4h.SetBase ("1.0.0.0", "255.0.0.0");
263  Ipv4InterfaceContainer internetIpIfaces = ipv4h.Assign (internetDevices);
264  // in this container, interface 0 is the pgw, 1 is the remoteHost
265  remoteHostAddr = internetIpIfaces.GetAddress (1);
266 
267  Ipv4StaticRoutingHelper ipv4RoutingHelper;
268  Ptr<Ipv4StaticRouting> remoteHostStaticRouting = ipv4RoutingHelper.GetStaticRouting (remoteHost->GetObject<Ipv4> ());
269  remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.0.0.0"), 1);
270 
271  // Install the IP stack on the UEs
272  internet.Install (ueNodes);
273  ueIpIfaces = m_epcHelper->AssignUeIpv4Address (NetDeviceContainer (ueDevices));
274  }
275 
276  // attachment (needs to be done after IP stack configuration)
277  // all UEs attached to eNB 0 at the beginning
278  m_lteHelper->Attach (ueDevices, enbDevices.Get (0));
279 
280  if (m_epc)
281  {
282  bool epcDl = true;
283  bool epcUl = false;
284  // the rest of this block is copied from lena-dual-stripe
285 
286 
287  // Install and start applications on UEs and remote host
288  uint16_t dlPort = 10000;
289  uint16_t ulPort = 20000;
290 
291  // randomize a bit start times to avoid simulation artifacts
292  // (e.g., buffer overflows due to packet transmissions happening
293  // exactly at the same time)
294  Ptr<UniformRandomVariable> startTimeSeconds = CreateObject<UniformRandomVariable> ();
295  startTimeSeconds->SetAttribute ("Min", DoubleValue (0));
296  startTimeSeconds->SetAttribute ("Max", DoubleValue (0.010));
297  startTimeSeconds->SetStream (stream++);
298 
299  for (uint32_t u = 0; u < ueNodes.GetN (); ++u)
300  {
301  Ptr<Node> ue = ueNodes.Get (u);
302  // Set the default gateway for the UE
303  Ptr<Ipv4StaticRouting> ueStaticRouting = ipv4RoutingHelper.GetStaticRouting (ue->GetObject<Ipv4> ());
304  ueStaticRouting->SetDefaultRoute (m_epcHelper->GetUeDefaultGatewayAddress (), 1);
305 
306  UeData ueData;
307 
308  for (uint32_t b = 0; b < m_nDedicatedBearers; ++b)
309  {
310  ++dlPort;
311  ++ulPort;
312 
315  BearerData bearerData;
316 
317  if (m_useUdp)
318  {
319  if (epcDl)
320  {
321  UdpClientHelper dlClientHelper (ueIpIfaces.GetAddress (u), dlPort);
322  clientApps.Add (dlClientHelper.Install (remoteHost));
323  PacketSinkHelper dlPacketSinkHelper ("ns3::UdpSocketFactory",
325  ApplicationContainer sinkContainer = dlPacketSinkHelper.Install (ue);
326  bearerData.dlSink = sinkContainer.Get (0)->GetObject<PacketSink> ();
327  serverApps.Add (sinkContainer);
328 
329  }
330  if (epcUl)
331  {
332  UdpClientHelper ulClientHelper (remoteHostAddr, ulPort);
333  clientApps.Add (ulClientHelper.Install (ue));
334  PacketSinkHelper ulPacketSinkHelper ("ns3::UdpSocketFactory",
336  ApplicationContainer sinkContainer = ulPacketSinkHelper.Install (remoteHost);
337  bearerData.ulSink = sinkContainer.Get (0)->GetObject<PacketSink> ();
338  serverApps.Add (sinkContainer);
339  }
340  }
341  else // use TCP
342  {
343  if (epcDl)
344  {
345  BulkSendHelper dlClientHelper ("ns3::TcpSocketFactory",
346  InetSocketAddress (ueIpIfaces.GetAddress (u), dlPort));
347  dlClientHelper.SetAttribute ("MaxBytes", UintegerValue (0));
348  clientApps.Add (dlClientHelper.Install (remoteHost));
349  PacketSinkHelper dlPacketSinkHelper ("ns3::TcpSocketFactory",
351  ApplicationContainer sinkContainer = dlPacketSinkHelper.Install (ue);
352  bearerData.dlSink = sinkContainer.Get (0)->GetObject<PacketSink> ();
353  serverApps.Add (sinkContainer);
354  }
355  if (epcUl)
356  {
357  BulkSendHelper ulClientHelper ("ns3::TcpSocketFactory",
358  InetSocketAddress (remoteHostAddr, ulPort));
359  ulClientHelper.SetAttribute ("MaxBytes", UintegerValue (0));
360  clientApps.Add (ulClientHelper.Install (ue));
361  PacketSinkHelper ulPacketSinkHelper ("ns3::TcpSocketFactory",
363  ApplicationContainer sinkContainer = ulPacketSinkHelper.Install (remoteHost);
364  bearerData.ulSink = sinkContainer.Get (0)->GetObject<PacketSink> ();
365  serverApps.Add (sinkContainer);
366  }
367  } // end if (useUdp)
368 
369  Ptr<EpcTft> tft = Create<EpcTft> ();
370  if (epcDl)
371  {
373  dlpf.localPortStart = dlPort;
374  dlpf.localPortEnd = dlPort;
375  tft->Add (dlpf);
376  }
377  if (epcUl)
378  {
380  ulpf.remotePortStart = ulPort;
381  ulpf.remotePortEnd = ulPort;
382  tft->Add (ulpf);
383  }
384 
385  if (epcDl || epcUl)
386  {
388  m_lteHelper->ActivateDedicatedEpsBearer (ueDevices.Get (u), bearer, tft);
389  }
390  Time startTime = Seconds (startTimeSeconds->GetValue ());
391  serverApps.Start (startTime);
392  clientApps.Start (startTime);
393 
394  ueData.bearerDataList.push_back (bearerData);
395 
396  } // end for b
397 
398  m_ueDataVector.push_back (ueData);
399  }
400 
401  }
402  else // (epc == false)
403  {
404  // for radio bearer activation purposes, consider together home UEs and macro UEs
405  for (uint32_t u = 0; u < ueDevices.GetN (); ++u)
406  {
407  Ptr<NetDevice> ueDev = ueDevices.Get (u);
408  for (uint32_t b = 0; b < m_nDedicatedBearers; ++b)
409  {
411  EpsBearer bearer (q);
412  m_lteHelper->ActivateDataRadioBearer (ueDev, bearer);
413  }
414  }
415  }
416 
417 
418  m_lteHelper->AddX2Interface (enbNodes);
419 
420  // check initial RRC connection
421  const Time maxRrcConnectionEstablishmentDuration = Seconds (0.080);
422  for (NetDeviceContainer::Iterator it = ueDevices.Begin (); it != ueDevices.End (); ++it)
423  {
424  NS_LOG_FUNCTION (maxRrcConnectionEstablishmentDuration);
425  Simulator::Schedule (maxRrcConnectionEstablishmentDuration,
427  this, *it, enbDevices.Get (0));
428  }
429 
430  // schedule the checkpoint events
431 
432  Time stopTime = Seconds (0);
433  for (std::list<CheckPointEvent>::iterator checkPointEventIt = m_checkPointEventList.begin ();
434  checkPointEventIt != m_checkPointEventList.end ();
435  ++checkPointEventIt)
436  {
437  for (Time checkPointTime = checkPointEventIt->checkStartTime;
438  checkPointTime < checkPointEventIt->checkStopTime;
439  checkPointTime += checkPointEventIt->checkInterval)
440  {
442  this, ueDevices.Get (checkPointEventIt->ueDeviceIndex),
443  enbDevices.Get (checkPointEventIt->enbDeviceIndex));
444 
445  Time saveStatsTime = checkPointTime;
447  this, checkPointEventIt->ueDeviceIndex);
448 
449  Time checkStats = saveStatsTime + m_statsDuration;
451  this, checkPointEventIt->ueDeviceIndex);
452 
453  if (stopTime <= checkStats)
454  {
455  stopTime = checkStats + Seconds (1);
456  }
457  }
458  }
459 
460  Simulator::Stop (stopTime);
461  Simulator::Run ();
463 }
464 
465 void
467 {
468  NS_LOG_FUNCTION (ueDevice << enbDevice);
469 
470  Ptr<LteUeNetDevice> ueLteDevice = ueDevice->GetObject<LteUeNetDevice> ();
471  Ptr<LteUeRrc> ueRrc = ueLteDevice->GetRrc ();
472  NS_TEST_ASSERT_MSG_EQ (ueRrc->GetState (), LteUeRrc::CONNECTED_NORMALLY, "Wrong LteUeRrc state!");
473 
474 
475  Ptr<LteEnbNetDevice> enbLteDevice = enbDevice->GetObject<LteEnbNetDevice> ();
476  Ptr<LteEnbRrc> enbRrc = enbLteDevice->GetRrc ();
477  uint16_t rnti = ueRrc->GetRnti ();
478  Ptr<UeManager> ueManager = enbRrc->GetUeManager (rnti);
479  NS_TEST_ASSERT_MSG_NE (ueManager, 0, "RNTI " << rnti << " not found in eNB");
480 
481  UeManager::State ueManagerState = ueManager->GetState ();
482  NS_TEST_ASSERT_MSG_EQ (ueManagerState, UeManager::CONNECTED_NORMALLY, "Wrong UeManager state!");
483  NS_ASSERT_MSG (ueManagerState == UeManager::CONNECTED_NORMALLY, "Wrong UeManager state!");
484 
485  uint16_t ueCellId = ueRrc->GetCellId ();
486  uint16_t enbCellId = enbLteDevice->GetCellId ();
487  uint8_t ueDlBandwidth = ueRrc->GetDlBandwidth ();
488  uint8_t enbDlBandwidth = enbLteDevice->GetDlBandwidth ();
489  uint8_t ueUlBandwidth = ueRrc->GetUlBandwidth ();
490  uint8_t enbUlBandwidth = enbLteDevice->GetUlBandwidth ();
491  uint8_t ueDlEarfcn = ueRrc->GetDlEarfcn ();
492  uint8_t enbDlEarfcn = enbLteDevice->GetDlEarfcn ();
493  uint8_t ueUlEarfcn = ueRrc->GetUlEarfcn ();
494  uint8_t enbUlEarfcn = enbLteDevice->GetUlEarfcn ();
495  uint64_t ueImsi = ueLteDevice->GetImsi ();
496  uint64_t enbImsi = ueManager->GetImsi ();
497 
498  NS_TEST_ASSERT_MSG_EQ (ueImsi, enbImsi, "inconsistent IMSI");
499  NS_TEST_ASSERT_MSG_EQ (ueCellId, enbCellId, "inconsistent CellId");
500  NS_TEST_ASSERT_MSG_EQ (ueDlBandwidth, enbDlBandwidth, "inconsistent DlBandwidth");
501  NS_TEST_ASSERT_MSG_EQ (ueUlBandwidth, enbUlBandwidth, "inconsistent UlBandwidth");
502  NS_TEST_ASSERT_MSG_EQ (ueDlEarfcn, enbDlEarfcn, "inconsistent DlEarfcn");
503  NS_TEST_ASSERT_MSG_EQ (ueUlEarfcn, enbUlEarfcn, "inconsistent UlEarfcn");
504 
505  ObjectMapValue enbDataRadioBearerMapValue;
506  ueManager->GetAttribute ("DataRadioBearerMap", enbDataRadioBearerMapValue);
507  NS_TEST_ASSERT_MSG_EQ (enbDataRadioBearerMapValue.GetN (), m_nDedicatedBearers + 1, "wrong num bearers at eNB");
508 
509  ObjectMapValue ueDataRadioBearerMapValue;
510  ueRrc->GetAttribute ("DataRadioBearerMap", ueDataRadioBearerMapValue);
511  NS_TEST_ASSERT_MSG_EQ (ueDataRadioBearerMapValue.GetN (), m_nDedicatedBearers + 1, "wrong num bearers at UE");
512 
513  ObjectMapValue::Iterator enbBearerIt = enbDataRadioBearerMapValue.Begin ();
514  ObjectMapValue::Iterator ueBearerIt = ueDataRadioBearerMapValue.Begin ();
515  while (enbBearerIt != enbDataRadioBearerMapValue.End ()
516  && ueBearerIt != ueDataRadioBearerMapValue.End ())
517  {
518  Ptr<LteDataRadioBearerInfo> enbDrbInfo = enbBearerIt->second->GetObject<LteDataRadioBearerInfo> ();
519  Ptr<LteDataRadioBearerInfo> ueDrbInfo = ueBearerIt->second->GetObject<LteDataRadioBearerInfo> ();
520  //NS_TEST_ASSERT_MSG_EQ (enbDrbInfo->m_epsBearer, ueDrbInfo->m_epsBearer, "epsBearer differs");
521  NS_TEST_ASSERT_MSG_EQ ((uint32_t) enbDrbInfo->m_epsBearerIdentity, (uint32_t) ueDrbInfo->m_epsBearerIdentity, "epsBearerIdentity differs");
522  NS_TEST_ASSERT_MSG_EQ ((uint32_t) enbDrbInfo->m_drbIdentity, (uint32_t) ueDrbInfo->m_drbIdentity, "drbIdentity differs");
523  //NS_TEST_ASSERT_MSG_EQ (enbDrbInfo->m_rlcConfig, ueDrbInfo->m_rlcConfig, "rlcConfig differs");
524  NS_TEST_ASSERT_MSG_EQ ((uint32_t) enbDrbInfo->m_logicalChannelIdentity, (uint32_t) ueDrbInfo->m_logicalChannelIdentity, "logicalChannelIdentity differs");
525  //NS_TEST_ASSERT_MSG_EQ (enbDrbInfo->m_logicalChannelConfig, ueDrbInfo->m_logicalChannelConfig, "logicalChannelConfig differs");
526 
527  ++enbBearerIt;
528  ++ueBearerIt;
529  }
530  NS_ASSERT_MSG (enbBearerIt == enbDataRadioBearerMapValue.End (), "too many bearers at eNB");
531  NS_ASSERT_MSG (ueBearerIt == ueDataRadioBearerMapValue.End (), "too many bearers at UE");
532 }
533 
534 void
536 {
537  NS_LOG_FUNCTION (ueIndex);
538  for (std::list<BearerData>::iterator it = m_ueDataVector.at (ueIndex).bearerDataList.begin ();
539  it != m_ueDataVector.at (ueIndex).bearerDataList.end ();
540  ++it)
541  {
542  if (it->dlSink)
543  {
544  it->dlOldTotalRx = it->dlSink->GetTotalRx ();
545  }
546  if (it->ulSink)
547  {
548  it->ulOldTotalRx = it->ulSink->GetTotalRx ();
549  }
550  }
551 }
552 
553 void
555 {
556  NS_LOG_FUNCTION (ueIndex);
557  uint32_t b = 1;
558  for (std::list<BearerData>::iterator it = m_ueDataVector.at (ueIndex).bearerDataList.begin ();
559  it != m_ueDataVector.at (ueIndex).bearerDataList.end ();
560  ++it)
561  {
562  uint32_t dlRx = 0;
563  uint32_t ulRx = 0;
564 
565  if (it->dlSink)
566  {
567  dlRx = it->dlSink->GetTotalRx () - it->dlOldTotalRx;
568  }
569 
570  if (it->ulSink)
571  {
572  ulRx = it->ulSink->GetTotalRx () - it->ulOldTotalRx;
573  }
575 
576  NS_LOG_LOGIC ("expBytes " << expectedBytes << " dlRx " << dlRx << " ulRx " << ulRx);
577 
578  // tolerance
579  if (it->dlSink)
580  {
581  NS_TEST_ASSERT_MSG_GT (dlRx, 0.500 * expectedBytes, "too few RX bytes in DL, ue=" << ueIndex << ", b=" << b);
582  }
583  if (it->ulSink)
584  {
585  NS_TEST_ASSERT_MSG_GT (ulRx, 0.500 * expectedBytes, "too few RX bytes in UL, ue=" << ueIndex << ", b=" << b);
586  }
587  ++b;
588  }
589 }
590 
591 
593 {
594 public:
596 };
597 
598 
600  : TestSuite ("lte-x2-handover-measures", SYSTEM)
601 {
602  Time checkInterval = Seconds (1);
603 
604  std::string cel1name ("ho: 0 -> 1");
605  std::list<CheckPointEvent> cel1;
606  cel1.push_back (CheckPointEvent (Seconds (1), Seconds (10.1), checkInterval, 0, 0));
607  cel1.push_back (CheckPointEvent (Seconds (11), Seconds (37), checkInterval, 0, 1));
608 
609  std::string cel2name ("ho: 0 -> 1 -> 2");
610  std::list<CheckPointEvent> cel2;
611  cel2.push_back (CheckPointEvent (Seconds (1), Seconds (10.1), Seconds (1), 0, 0));
612  cel2.push_back (CheckPointEvent (Seconds (11), Seconds (17.1), Seconds (1), 0, 1));
613  cel2.push_back (CheckPointEvent (Seconds (18), Seconds (37), Seconds (1), 0, 2));
614 
615  std::string cel3name ("ho: 0 -> 1 -> 2 -> 3");
616  std::list<CheckPointEvent> cel3;
617  cel3.push_back (CheckPointEvent (Seconds (1), Seconds (10.1), Seconds (1), 0, 0));
618  cel3.push_back (CheckPointEvent (Seconds (11), Seconds (17.1), Seconds (1), 0, 1));
619  cel3.push_back (CheckPointEvent (Seconds (18), Seconds (24.1), Seconds (1), 0, 2));
620  cel3.push_back (CheckPointEvent (Seconds (25), Seconds (37), Seconds (1), 0, 3));
621 
622 
623  int32_t useIdealRrc;
624  std::vector<std::string> schedulers;
625  schedulers.push_back ("ns3::PfFfMacScheduler");
626  for (std::vector<std::string>::iterator schedIt = schedulers.begin (); schedIt != schedulers.end (); ++schedIt)
627  {
628  for (useIdealRrc = 1; useIdealRrc >= 0; --useIdealRrc)
629  {
630  // nEnbs, nUes, nDBearers, celist, name, useUdp, sched, admitHo, idealRrc
631  AddTestCase (new LteX2HandoverMeasuresTestCase ( 2, 1, 0, cel1, cel1name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
632  AddTestCase (new LteX2HandoverMeasuresTestCase ( 2, 1, 1, cel1, cel1name, true, *schedIt, true, useIdealRrc), TestCase::QUICK);
633  AddTestCase (new LteX2HandoverMeasuresTestCase ( 2, 1, 2, cel1, cel1name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
634  AddTestCase (new LteX2HandoverMeasuresTestCase ( 3, 1, 0, cel2, cel2name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
635  AddTestCase (new LteX2HandoverMeasuresTestCase ( 3, 1, 1, cel2, cel2name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
636  AddTestCase (new LteX2HandoverMeasuresTestCase ( 3, 1, 2, cel2, cel2name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
637  AddTestCase (new LteX2HandoverMeasuresTestCase ( 4, 1, 0, cel3, cel3name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
638  AddTestCase (new LteX2HandoverMeasuresTestCase ( 4, 1, 1, cel3, cel3name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
639  AddTestCase (new LteX2HandoverMeasuresTestCase ( 4, 1, 2, cel3, cel3name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
640  }
641  }
642 
643  schedulers.resize (0);
644  schedulers.push_back ("ns3::RrFfMacScheduler");
645  for (std::vector<std::string>::iterator schedIt = schedulers.begin (); schedIt != schedulers.end (); ++schedIt)
646  {
647  for (useIdealRrc = 1; useIdealRrc >= 0; --useIdealRrc)
648  {
649  // nEnbs, nUes, nDBearers, celist, name, useUdp, sched, admitHo, idealRrc
650  AddTestCase (new LteX2HandoverMeasuresTestCase ( 2, 1, 0, cel1, cel1name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
651 // AddTestCase (new LteX2HandoverMeasuresTestCase ( 2, 1, 1, cel1b, cel1bname, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
652 // AddTestCase (new LteX2HandoverMeasuresTestCase ( 2, 1, 2, cel1, cel1name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
653  AddTestCase (new LteX2HandoverMeasuresTestCase ( 3, 1, 0, cel2, cel2name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
654 // AddTestCase (new LteX2HandoverMeasuresTestCase ( 3, 1, 1, cel2, cel2name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
655 // AddTestCase (new LteX2HandoverMeasuresTestCase ( 3, 1, 2, cel2, cel2name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
656  AddTestCase (new LteX2HandoverMeasuresTestCase ( 4, 1, 0, cel3, cel3name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
657 // AddTestCase (new LteX2HandoverMeasuresTestCase ( 4, 1, 1, cel3, cel3name, true, *schedIt, true, useIdealRrc), TestCase::QUICK);
658 // AddTestCase (new LteX2HandoverMeasuresTestCase ( 4, 1, 2, cel3, cel3name, true, *schedIt, true, useIdealRrc), TestCase::QUICK);
659  }
660  }
661 
662 }
663 
665 
666 
667 } // namespace ns3
static std::string BuildNameString(uint32_t nEnbs, uint32_t nUes, uint32_t nDedicatedBearers, std::string checkPointEventListName, bool useUdp, std::string schedulerType, bool admitHo, bool useIdealRrc)
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:311
void SetStream(int64_t stream)
Specifies the stream number for this RNG stream.
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)
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
static void Run(void)
Definition: simulator.cc:157
virtual void DoRun(void)
Implementation to actually run this TestCase.
aggregate IP/TCP/UDP functionality to existing Nodes.
#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)
Definition: simulator.h:824
void SetDeviceAttribute(std::string name, const AttributeValue &value)
a 3d vector
Definition: vector.h:31
NS_LOG_COMPONENT_DEFINE("LteX2HandoverMeasuresTest")
ApplicationContainer Install(NodeContainer c)
double stopTime
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:266
ApplicationContainer Install(NodeContainer c) const
#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.
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:828
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
LteX2HandoverMeasuresTestCase(uint32_t nEnbs, uint32_t nUes, uint32_t nDedicatedBearers, std::list< CheckPointEvent > checkPointEventList, std::string checkPointEventListName, bool useUdp, std::string schedulerType, bool admitHo, bool useIdealRrc)
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:334
static void Destroy(void)
Definition: simulator.cc:121
tuple serverApps
Definition: first.py:44
Access to the Ipv4 forwarding table, interfaces, and configuration.
Definition: ipv4.h:75
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.
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
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:172
void SetChannelAttribute(std::string name, const AttributeValue &value)
#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
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)
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
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)
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)
Iterator End(void) const
Get an iterator which indicates past-the-last NetDevice in the container.
Hold an floating point type.
Definition: double.h:41
void SetAttribute(std::string name, const AttributeValue &value)
Definition: object-base.cc:160
Ptr< T > GetObject(void) const
Definition: object.h:360
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
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const