A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
test-lte-x2-handover.cc
Go to the documentation of this file.
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2012 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  * Author: Nicola Baldo <nbaldo@cttc.es>
19  */
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 ("LteX2HandoverTest");
31 
32 namespace ns3 {
33 
35 {
37  uint32_t ueDeviceIndex;
40 };
41 
42 
44 {
45 public:
46 
58  LteX2HandoverTestCase (uint32_t nUes, uint32_t nDedicatedBearers, std::list<HandoverEvent> handoverEventList, std::string handoverEventListName, bool useUdp, std::string schedulerType, bool admitHo, bool useIdealRrc);
59 
60 private:
61  static std::string BuildNameString (uint32_t nUes, uint32_t nDedicatedBearers, std::string handoverEventListName, bool useUdp, std::string schedulerType, bool admitHo, bool useIdealRrc);
62  virtual void DoRun (void);
63  void CheckConnected (Ptr<NetDevice> ueDevice, Ptr<NetDevice> enbDevice);
64 
65  uint32_t m_nUes; // number of UEs in the test
66  uint32_t m_nDedicatedBearers; // number of UEs in the test
67  std::list<HandoverEvent> m_handoverEventList;
69  bool m_epc;
70  bool m_useUdp;
71  std::string m_schedulerType;
72  bool m_admitHo;
76 
77  struct BearerData
78  {
79  uint32_t bid;
82  uint32_t dlOldTotalRx;
83  uint32_t ulOldTotalRx;
84  };
85 
86  struct UeData
87  {
88  uint32_t id;
89  std::list<BearerData> bearerDataList;
90  };
91 
92  void SaveStatsAfterHandover (uint32_t ueIndex);
93  void CheckStatsAWhileAfterHandover (uint32_t ueIndex);
94 
95  std::vector<UeData> m_ueDataVector;
96 
100  const uint32_t m_udpClientPktSize;
101 
102 };
103 
104 
105 std::string LteX2HandoverTestCase::BuildNameString (uint32_t nUes, uint32_t nDedicatedBearers, std::string handoverEventListName, bool useUdp, std::string schedulerType, bool admitHo, bool useIdealRrc)
106 {
107  std::ostringstream oss;
108  oss << " nUes=" << nUes
109  << " nDedicatedBearers=" << nDedicatedBearers
110  << " udp=" << useUdp
111  << " " << schedulerType
112  << " admitHo=" << admitHo
113  << " hoList: " << handoverEventListName;
114  if (useIdealRrc)
115  {
116  oss << ", ideal RRC";
117  }
118  else
119  {
120  oss << ", real RRC";
121  }
122  return oss.str ();
123 }
124 
125 LteX2HandoverTestCase::LteX2HandoverTestCase (uint32_t nUes, uint32_t nDedicatedBearers, std::list<HandoverEvent> handoverEventList, std::string handoverEventListName, bool useUdp, std::string schedulerType, bool admitHo, bool useIdealRrc)
126  : TestCase (BuildNameString (nUes, nDedicatedBearers, handoverEventListName, useUdp, schedulerType, admitHo, useIdealRrc)),
127  m_nUes (nUes),
128  m_nDedicatedBearers (nDedicatedBearers),
129  m_handoverEventList (handoverEventList),
130  m_handoverEventListName (handoverEventListName),
131  m_epc (true),
132  m_useUdp (useUdp),
133  m_schedulerType (schedulerType),
134  m_admitHo (admitHo),
135  m_useIdealRrc (useIdealRrc),
136  m_maxHoDuration (Seconds (0.1)),
137  m_statsDuration (Seconds (0.1)),
138  m_udpClientInterval (Seconds (0.01)),
139  m_udpClientPktSize (100)
140 
141 {
142 }
143 
144 void
146 {
148 
149  Config::Reset ();
150  Config::SetDefault ("ns3::UdpClient::Interval", TimeValue (m_udpClientInterval));
151  Config::SetDefault ("ns3::UdpClient::MaxPackets", UintegerValue (1000000));
152  Config::SetDefault ("ns3::UdpClient::PacketSize", UintegerValue (m_udpClientPktSize));
153 
154  int64_t stream = 1;
155 
156  m_lteHelper = CreateObject<LteHelper> ();
157  m_lteHelper->SetAttribute ("PathlossModel", StringValue ("ns3::FriisSpectrumPropagationLossModel"));
158  m_lteHelper->SetSchedulerType (m_schedulerType);
159  m_lteHelper->SetHandoverAlgorithmType ("ns3::NoOpHandoverAlgorithm"); // disable automatic handover
160  m_lteHelper->SetAttribute ("UseIdealRrc", BooleanValue (m_useIdealRrc));
161 
162 
163  NodeContainer enbNodes;
164  enbNodes.Create (2);
165  NodeContainer ueNodes;
166  ueNodes.Create (m_nUes);
167 
168  if (m_epc)
169  {
170  m_epcHelper = CreateObject<PointToPointEpcHelper> ();
171  m_lteHelper->SetEpcHelper (m_epcHelper);
172  }
173 
174  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
175  positionAlloc->Add (Vector (-3000, 0, 0)); // enb0
176  positionAlloc->Add (Vector ( 3000, 0, 0)); // enb1
177  for (uint16_t i = 0; i < m_nUes; i++)
178  {
179  positionAlloc->Add (Vector (0, 0, 0));
180  }
181  MobilityHelper mobility;
182  mobility.SetPositionAllocator (positionAlloc);
183  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
184  mobility.Install (enbNodes);
185  mobility.Install (ueNodes);
186 
187  NetDeviceContainer enbDevices;
188  enbDevices = m_lteHelper->InstallEnbDevice (enbNodes);
189  stream += m_lteHelper->AssignStreams (enbDevices, stream);
190  for (NetDeviceContainer::Iterator it = enbDevices.Begin ();
191  it != enbDevices.End ();
192  ++it)
193  {
194  Ptr<LteEnbRrc> enbRrc = (*it)->GetObject<LteEnbNetDevice> ()->GetRrc ();
195  enbRrc->SetAttribute ("AdmitHandoverRequest", BooleanValue (m_admitHo));
196  }
197 
198  NetDeviceContainer ueDevices;
199  ueDevices = m_lteHelper->InstallUeDevice (ueNodes);
200  stream += m_lteHelper->AssignStreams (ueDevices, stream);
201 
202  Ipv4Address remoteHostAddr;
203  Ipv4StaticRoutingHelper ipv4RoutingHelper;
204  Ipv4InterfaceContainer ueIpIfaces;
205  Ptr<Node> remoteHost;
206  if (m_epc)
207  {
208  // Create a single RemoteHost
209  NodeContainer remoteHostContainer;
210  remoteHostContainer.Create (1);
211  remoteHost = remoteHostContainer.Get (0);
212  InternetStackHelper internet;
213  internet.Install (remoteHostContainer);
214 
215  // Create the Internet
216  PointToPointHelper p2ph;
217  p2ph.SetDeviceAttribute ("DataRate", DataRateValue (DataRate ("100Gb/s")));
218  p2ph.SetDeviceAttribute ("Mtu", UintegerValue (1500));
219  p2ph.SetChannelAttribute ("Delay", TimeValue (Seconds (0.010)));
220  Ptr<Node> pgw = m_epcHelper->GetPgwNode ();
221  NetDeviceContainer internetDevices = p2ph.Install (pgw, remoteHost);
222  Ipv4AddressHelper ipv4h;
223  ipv4h.SetBase ("1.0.0.0", "255.0.0.0");
224  Ipv4InterfaceContainer internetIpIfaces = ipv4h.Assign (internetDevices);
225  // in this container, interface 0 is the pgw, 1 is the remoteHost
226  remoteHostAddr = internetIpIfaces.GetAddress (1);
227 
228  Ipv4StaticRoutingHelper ipv4RoutingHelper;
229  Ptr<Ipv4StaticRouting> remoteHostStaticRouting = ipv4RoutingHelper.GetStaticRouting (remoteHost->GetObject<Ipv4> ());
230  remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.0.0.0"), 1);
231 
232  // Install the IP stack on the UEs
233  internet.Install (ueNodes);
234  ueIpIfaces = m_epcHelper->AssignUeIpv4Address (NetDeviceContainer (ueDevices));
235  }
236 
237  // attachment (needs to be done after IP stack configuration)
238  // all UEs attached to eNB 0 at the beginning
239  m_lteHelper->Attach (ueDevices, enbDevices.Get (0));
240 
241  if (m_epc)
242  {
243  // always true: bool epcDl = true;
244  // always true: bool epcUl = true;
245  // the rest of this block is copied from lena-dual-stripe
246 
247 
248  // Install and start applications on UEs and remote host
249  uint16_t dlPort = 10000;
250  uint16_t ulPort = 20000;
251 
252  // randomize a bit start times to avoid simulation artifacts
253  // (e.g., buffer overflows due to packet transmissions happening
254  // exactly at the same time)
255  Ptr<UniformRandomVariable> startTimeSeconds = CreateObject<UniformRandomVariable> ();
256  startTimeSeconds->SetAttribute ("Min", DoubleValue (0));
257  startTimeSeconds->SetAttribute ("Max", DoubleValue (0.010));
258  startTimeSeconds->SetStream (stream++);
259 
260  for (uint32_t u = 0; u < ueNodes.GetN (); ++u)
261  {
262  Ptr<Node> ue = ueNodes.Get (u);
263  // Set the default gateway for the UE
264  Ptr<Ipv4StaticRouting> ueStaticRouting = ipv4RoutingHelper.GetStaticRouting (ue->GetObject<Ipv4> ());
265  ueStaticRouting->SetDefaultRoute (m_epcHelper->GetUeDefaultGatewayAddress (), 1);
266 
267  UeData ueData;
268 
269  for (uint32_t b = 0; b < m_nDedicatedBearers; ++b)
270  {
271  ++dlPort;
272  ++ulPort;
273 
276  BearerData bearerData;
277 
278  if (m_useUdp)
279  {
280  // always true: if (epcDl)
281  {
282  UdpClientHelper dlClientHelper (ueIpIfaces.GetAddress (u), dlPort);
283  clientApps.Add (dlClientHelper.Install (remoteHost));
284  PacketSinkHelper dlPacketSinkHelper ("ns3::UdpSocketFactory",
286  ApplicationContainer sinkContainer = dlPacketSinkHelper.Install (ue);
287  bearerData.dlSink = sinkContainer.Get (0)->GetObject<PacketSink> ();
288  serverApps.Add (sinkContainer);
289 
290  }
291  // always true: if (epcUl)
292  {
293  UdpClientHelper ulClientHelper (remoteHostAddr, ulPort);
294  clientApps.Add (ulClientHelper.Install (ue));
295  PacketSinkHelper ulPacketSinkHelper ("ns3::UdpSocketFactory",
297  ApplicationContainer sinkContainer = ulPacketSinkHelper.Install (remoteHost);
298  bearerData.ulSink = sinkContainer.Get (0)->GetObject<PacketSink> ();
299  serverApps.Add (sinkContainer);
300  }
301  }
302  else // use TCP
303  {
304  // always true: if (epcDl)
305  {
306  BulkSendHelper dlClientHelper ("ns3::TcpSocketFactory",
307  InetSocketAddress (ueIpIfaces.GetAddress (u), dlPort));
308  dlClientHelper.SetAttribute ("MaxBytes", UintegerValue (0));
309  clientApps.Add (dlClientHelper.Install (remoteHost));
310  PacketSinkHelper dlPacketSinkHelper ("ns3::TcpSocketFactory",
312  ApplicationContainer sinkContainer = dlPacketSinkHelper.Install (ue);
313  bearerData.dlSink = sinkContainer.Get (0)->GetObject<PacketSink> ();
314  serverApps.Add (sinkContainer);
315  }
316  // always true: if (epcUl)
317  {
318  BulkSendHelper ulClientHelper ("ns3::TcpSocketFactory",
319  InetSocketAddress (remoteHostAddr, ulPort));
320  ulClientHelper.SetAttribute ("MaxBytes", UintegerValue (0));
321  clientApps.Add (ulClientHelper.Install (ue));
322  PacketSinkHelper ulPacketSinkHelper ("ns3::TcpSocketFactory",
324  ApplicationContainer sinkContainer = ulPacketSinkHelper.Install (remoteHost);
325  bearerData.ulSink = sinkContainer.Get (0)->GetObject<PacketSink> ();
326  serverApps.Add (sinkContainer);
327  }
328  } // end if (useUdp)
329 
330  Ptr<EpcTft> tft = Create<EpcTft> ();
331  // always true: if (epcDl)
332  {
334  dlpf.localPortStart = dlPort;
335  dlpf.localPortEnd = dlPort;
336  tft->Add (dlpf);
337  }
338  // always true: if (epcUl)
339  {
341  ulpf.remotePortStart = ulPort;
342  ulpf.remotePortEnd = ulPort;
343  tft->Add (ulpf);
344  }
345 
346  // always true: if (epcDl || epcUl)
347  {
349  m_lteHelper->ActivateDedicatedEpsBearer (ueDevices.Get (u), bearer, tft);
350  }
351  Time startTime = Seconds (startTimeSeconds->GetValue ());
352  serverApps.Start (startTime);
353  clientApps.Start (startTime);
354 
355  ueData.bearerDataList.push_back (bearerData);
356 
357  } // end for b
358 
359  m_ueDataVector.push_back (ueData);
360  }
361 
362  }
363  else // (epc == false)
364  {
365  // for radio bearer activation purposes, consider together home UEs and macro UEs
366  for (uint32_t u = 0; u < ueDevices.GetN (); ++u)
367  {
368  Ptr<NetDevice> ueDev = ueDevices.Get (u);
369  for (uint32_t b = 0; b < m_nDedicatedBearers; ++b)
370  {
372  EpsBearer bearer (q);
373  m_lteHelper->ActivateDataRadioBearer (ueDev, bearer);
374  }
375  }
376  }
377 
378 
379  m_lteHelper->AddX2Interface (enbNodes);
380 
381  // check initial RRC connection
382  const Time maxRrcConnectionEstablishmentDuration = Seconds (0.080);
383  for (NetDeviceContainer::Iterator it = ueDevices.Begin (); it != ueDevices.End (); ++it)
384  {
385  Simulator::Schedule (maxRrcConnectionEstablishmentDuration,
387  this, *it, enbDevices.Get (0));
388  }
389 
390  // schedule handover events and corresponding checks
391 
392  Time stopTime = Seconds (0);
393  for (std::list<HandoverEvent>::iterator hoEventIt = m_handoverEventList.begin ();
394  hoEventIt != m_handoverEventList.end ();
395  ++hoEventIt)
396  {
397  Simulator::Schedule (hoEventIt->startTime,
399  this,
400  ueDevices.Get (hoEventIt->ueDeviceIndex),
401  enbDevices.Get (hoEventIt->sourceEnbDeviceIndex));
402  m_lteHelper->HandoverRequest (hoEventIt->startTime,
403  ueDevices.Get (hoEventIt->ueDeviceIndex),
404  enbDevices.Get (hoEventIt->sourceEnbDeviceIndex),
405  enbDevices.Get (hoEventIt->targetEnbDeviceIndex));
406  Time hoEndTime = hoEventIt->startTime + m_maxHoDuration;
407  Simulator::Schedule (hoEndTime,
409  this,
410  ueDevices.Get (hoEventIt->ueDeviceIndex),
411  enbDevices.Get (m_admitHo ? hoEventIt->targetEnbDeviceIndex : hoEventIt->sourceEnbDeviceIndex));
413  this, hoEventIt->ueDeviceIndex);
414 
415  Time checkStatsAfterHoTime = hoEndTime + m_statsDuration;
417  this, hoEventIt->ueDeviceIndex);
418  if (stopTime <= checkStatsAfterHoTime)
419  {
420  stopTime = checkStatsAfterHoTime + MilliSeconds (1);
421  }
422  }
423 
424  // m_lteHelper->EnableRlcTraces ();
425  // m_lteHelper->EnablePdcpTraces();
426 
427 
428  Simulator::Stop (stopTime);
429 
430  Simulator::Run ();
431 
433 
434 }
435 
436 void
438 {
439  Ptr<LteUeNetDevice> ueLteDevice = ueDevice->GetObject<LteUeNetDevice> ();
440  Ptr<LteUeRrc> ueRrc = ueLteDevice->GetRrc ();
441  NS_TEST_ASSERT_MSG_EQ (ueRrc->GetState (), LteUeRrc::CONNECTED_NORMALLY, "Wrong LteUeRrc state!");
442 
443 
444  Ptr<LteEnbNetDevice> enbLteDevice = enbDevice->GetObject<LteEnbNetDevice> ();
445  Ptr<LteEnbRrc> enbRrc = enbLteDevice->GetRrc ();
446  uint16_t rnti = ueRrc->GetRnti ();
447  Ptr<UeManager> ueManager = enbRrc->GetUeManager (rnti);
448  NS_TEST_ASSERT_MSG_NE (ueManager, 0, "RNTI " << rnti << " not found in eNB");
449 
450  UeManager::State ueManagerState = ueManager->GetState ();
451  NS_TEST_ASSERT_MSG_EQ (ueManagerState, UeManager::CONNECTED_NORMALLY, "Wrong UeManager state!");
452  NS_ASSERT_MSG (ueManagerState == UeManager::CONNECTED_NORMALLY, "Wrong UeManager state!");
453 
454  uint16_t ueCellId = ueRrc->GetCellId ();
455  uint16_t enbCellId = enbLteDevice->GetCellId ();
456  uint8_t ueDlBandwidth = ueRrc->GetDlBandwidth ();
457  uint8_t enbDlBandwidth = enbLteDevice->GetDlBandwidth ();
458  uint8_t ueUlBandwidth = ueRrc->GetUlBandwidth ();
459  uint8_t enbUlBandwidth = enbLteDevice->GetUlBandwidth ();
460  uint8_t ueDlEarfcn = ueRrc->GetDlEarfcn ();
461  uint8_t enbDlEarfcn = enbLteDevice->GetDlEarfcn ();
462  uint8_t ueUlEarfcn = ueRrc->GetUlEarfcn ();
463  uint8_t enbUlEarfcn = enbLteDevice->GetUlEarfcn ();
464  uint64_t ueImsi = ueLteDevice->GetImsi ();
465  uint64_t enbImsi = ueManager->GetImsi ();
466 
467  NS_TEST_ASSERT_MSG_EQ (ueImsi, enbImsi, "inconsistent IMSI");
468  NS_TEST_ASSERT_MSG_EQ (ueCellId, enbCellId, "inconsistent CellId");
469  NS_TEST_ASSERT_MSG_EQ (ueDlBandwidth, enbDlBandwidth, "inconsistent DlBandwidth");
470  NS_TEST_ASSERT_MSG_EQ (ueUlBandwidth, enbUlBandwidth, "inconsistent UlBandwidth");
471  NS_TEST_ASSERT_MSG_EQ (ueDlEarfcn, enbDlEarfcn, "inconsistent DlEarfcn");
472  NS_TEST_ASSERT_MSG_EQ (ueUlEarfcn, enbUlEarfcn, "inconsistent UlEarfcn");
473 
474  ObjectMapValue enbDataRadioBearerMapValue;
475  ueManager->GetAttribute ("DataRadioBearerMap", enbDataRadioBearerMapValue);
476  NS_TEST_ASSERT_MSG_EQ (enbDataRadioBearerMapValue.GetN (), m_nDedicatedBearers + 1, "wrong num bearers at eNB");
477 
478  ObjectMapValue ueDataRadioBearerMapValue;
479  ueRrc->GetAttribute ("DataRadioBearerMap", ueDataRadioBearerMapValue);
480  NS_TEST_ASSERT_MSG_EQ (ueDataRadioBearerMapValue.GetN (), m_nDedicatedBearers + 1, "wrong num bearers at UE");
481 
482  ObjectMapValue::Iterator enbBearerIt = enbDataRadioBearerMapValue.Begin ();
483  ObjectMapValue::Iterator ueBearerIt = ueDataRadioBearerMapValue.Begin ();
484  while (enbBearerIt != enbDataRadioBearerMapValue.End () &&
485  ueBearerIt != ueDataRadioBearerMapValue.End ())
486  {
487  Ptr<LteDataRadioBearerInfo> enbDrbInfo = enbBearerIt->second->GetObject<LteDataRadioBearerInfo> ();
488  Ptr<LteDataRadioBearerInfo> ueDrbInfo = ueBearerIt->second->GetObject<LteDataRadioBearerInfo> ();
489  //NS_TEST_ASSERT_MSG_EQ (enbDrbInfo->m_epsBearer, ueDrbInfo->m_epsBearer, "epsBearer differs");
490  NS_TEST_ASSERT_MSG_EQ ((uint32_t) enbDrbInfo->m_epsBearerIdentity, (uint32_t) ueDrbInfo->m_epsBearerIdentity, "epsBearerIdentity differs");
491  NS_TEST_ASSERT_MSG_EQ ((uint32_t) enbDrbInfo->m_drbIdentity, (uint32_t) ueDrbInfo->m_drbIdentity, "drbIdentity differs");
492  //NS_TEST_ASSERT_MSG_EQ (enbDrbInfo->m_rlcConfig, ueDrbInfo->m_rlcConfig, "rlcConfig differs");
493  NS_TEST_ASSERT_MSG_EQ ((uint32_t) enbDrbInfo->m_logicalChannelIdentity, (uint32_t) ueDrbInfo->m_logicalChannelIdentity, "logicalChannelIdentity differs");
494  //NS_TEST_ASSERT_MSG_EQ (enbDrbInfo->m_logicalChannelConfig, ueDrbInfo->m_logicalChannelConfig, "logicalChannelConfig differs");
495 
496  ++enbBearerIt;
497  ++ueBearerIt;
498  }
499  NS_ASSERT_MSG (enbBearerIt == enbDataRadioBearerMapValue.End (), "too many bearers at eNB");
500  NS_ASSERT_MSG (ueBearerIt == ueDataRadioBearerMapValue.End (), "too many bearers at UE");
501 }
502 
503 void
505 {
506  for (std::list<BearerData>::iterator it = m_ueDataVector.at (ueIndex).bearerDataList.begin ();
507  it != m_ueDataVector.at (ueIndex).bearerDataList.end ();
508  ++it)
509  {
510  it->dlOldTotalRx = it->dlSink->GetTotalRx ();
511  it->ulOldTotalRx = it->ulSink->GetTotalRx ();
512  }
513 }
514 
515 void
517 {
518  uint32_t b = 1;
519  for (std::list<BearerData>::iterator it = m_ueDataVector.at (ueIndex).bearerDataList.begin ();
520  it != m_ueDataVector.at (ueIndex).bearerDataList.end ();
521  ++it)
522  {
523  uint32_t dlRx = it->dlSink->GetTotalRx () - it->dlOldTotalRx;
524  uint32_t ulRx = it->ulSink->GetTotalRx () - it->ulOldTotalRx;
525  uint32_t expectedBytes = m_udpClientPktSize * (m_statsDuration.GetSeconds () / m_udpClientInterval.GetSeconds ());
526  // tolerance
527  NS_TEST_ASSERT_MSG_GT (dlRx, 0.500 * expectedBytes, "too few RX bytes in DL, ue=" << ueIndex << ", b=" << b);
528  NS_TEST_ASSERT_MSG_GT (ulRx, 0.500 * expectedBytes, "too few RX bytes in UL, ue=" << ueIndex << ", b=" << b);
529  ++b;
530  }
531 }
532 
533 
535 {
536 public:
538 };
539 
540 
542  : TestSuite ("lte-x2-handover", SYSTEM)
543 {
544  // in the following:
545  // fwd means handover from enb 0 to enb 1
546  // bwd means handover from enb 1 to enb 0
547 
548  HandoverEvent ue1fwd;
549  ue1fwd.startTime = MilliSeconds (100);
550  ue1fwd.ueDeviceIndex = 0;
551  ue1fwd.sourceEnbDeviceIndex = 0;
552  ue1fwd.targetEnbDeviceIndex = 1;
553 
554  HandoverEvent ue1bwd;
555  ue1bwd.startTime = MilliSeconds (300);
556  ue1bwd.ueDeviceIndex = 0;
557  ue1bwd.sourceEnbDeviceIndex = 1;
558  ue1bwd.targetEnbDeviceIndex = 0;
559 
560  HandoverEvent ue1fwdagain;
561  ue1fwdagain.startTime = MilliSeconds (500);
562  ue1fwdagain.ueDeviceIndex = 0;
563  ue1fwdagain.sourceEnbDeviceIndex = 0;
564  ue1fwdagain.targetEnbDeviceIndex = 1;
565 
566  HandoverEvent ue2fwd;
567  ue2fwd.startTime = MilliSeconds (110);
568  ue2fwd.ueDeviceIndex = 1;
569  ue2fwd.sourceEnbDeviceIndex = 0;
570  ue2fwd.targetEnbDeviceIndex = 1;
571 
572  HandoverEvent ue2bwd;
573  ue2bwd.startTime = MilliSeconds (250);
574  ue2bwd.ueDeviceIndex = 1;
575  ue2bwd.sourceEnbDeviceIndex = 1;
576  ue2bwd.targetEnbDeviceIndex = 0;
577 
578  std::string hel0name ("none");
579  std::list<HandoverEvent> hel0;
580 
581  std::string hel1name ("1 fwd");
582  std::list<HandoverEvent> hel1;
583  hel1.push_back (ue1fwd);
584 
585  std::string hel2name ("1 fwd & bwd");
586  std::list<HandoverEvent> hel2;
587  hel2.push_back (ue1fwd);
588  hel2.push_back (ue1bwd);
589 
590  std::string hel3name ("1 fwd & bwd & fwd");
591  std::list<HandoverEvent> hel3;
592  hel3.push_back (ue1fwd);
593  hel3.push_back (ue1bwd);
594  hel3.push_back (ue1fwdagain);
595 
596  std::string hel4name ("1+2 fwd");
597  std::list<HandoverEvent> hel4;
598  hel4.push_back (ue1fwd);
599  hel4.push_back (ue2fwd);
600 
601  std::string hel5name ("1+2 fwd & bwd");
602  std::list<HandoverEvent> hel5;
603  hel5.push_back (ue1fwd);
604  hel5.push_back (ue1bwd);
605  hel5.push_back (ue2fwd);
606  hel5.push_back (ue2bwd);
607 
608  std::string hel6name ("2 fwd");
609  std::list<HandoverEvent> hel6;
610  hel6.push_back (ue2fwd);
611 
612  std::string hel7name ("2 fwd & bwd");
613  std::list<HandoverEvent> hel7;
614  hel7.push_back (ue2fwd);
615  hel7.push_back (ue2bwd);
616 
617  std::vector<std::string> schedulers;
618  schedulers.push_back ("ns3::RrFfMacScheduler");
619  schedulers.push_back ("ns3::PfFfMacScheduler");
620  for (std::vector<std::string>::iterator schedIt = schedulers.begin (); schedIt != schedulers.end (); ++schedIt)
621  {
622  for (int32_t useIdealRrc = 1; useIdealRrc >= 0; --useIdealRrc)
623  {
624  // nUes, nDBearers, helist, name, useUdp, sched, admitHo, idealRrc
625  AddTestCase (new LteX2HandoverTestCase ( 1, 0, hel0, hel0name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
626  AddTestCase (new LteX2HandoverTestCase ( 2, 0, hel0, hel0name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
627  AddTestCase (new LteX2HandoverTestCase ( 1, 5, hel0, hel0name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
628  AddTestCase (new LteX2HandoverTestCase ( 2, 5, hel0, hel0name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
629  AddTestCase (new LteX2HandoverTestCase ( 1, 0, hel1, hel1name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
630  AddTestCase (new LteX2HandoverTestCase ( 1, 1, hel1, hel1name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
631  AddTestCase (new LteX2HandoverTestCase ( 1, 2, hel1, hel1name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
632  AddTestCase (new LteX2HandoverTestCase ( 1, 0, hel1, hel1name, true, *schedIt, false, useIdealRrc), TestCase::EXTENSIVE);
633  AddTestCase (new LteX2HandoverTestCase ( 1, 1, hel1, hel1name, true, *schedIt, false, useIdealRrc), TestCase::EXTENSIVE);
634  AddTestCase (new LteX2HandoverTestCase ( 1, 2, hel1, hel1name, true, *schedIt, false, useIdealRrc), TestCase::EXTENSIVE);
635  AddTestCase (new LteX2HandoverTestCase ( 2, 0, hel1, hel1name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
636  AddTestCase (new LteX2HandoverTestCase ( 2, 1, hel1, hel1name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
637  AddTestCase (new LteX2HandoverTestCase ( 2, 2, hel1, hel1name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
638  AddTestCase (new LteX2HandoverTestCase ( 2, 0, hel1, hel1name, true, *schedIt, false, useIdealRrc), TestCase::EXTENSIVE);
639  AddTestCase (new LteX2HandoverTestCase ( 2, 1, hel1, hel1name, true, *schedIt, false, useIdealRrc), TestCase::EXTENSIVE);
640  AddTestCase (new LteX2HandoverTestCase ( 2, 2, hel1, hel1name, true, *schedIt, false, useIdealRrc), TestCase::EXTENSIVE);
641  AddTestCase (new LteX2HandoverTestCase ( 1, 0, hel2, hel2name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
642  AddTestCase (new LteX2HandoverTestCase ( 1, 1, hel2, hel2name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
643  AddTestCase (new LteX2HandoverTestCase ( 1, 2, hel2, hel2name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
644  AddTestCase (new LteX2HandoverTestCase ( 1, 0, hel3, hel3name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
645  AddTestCase (new LteX2HandoverTestCase ( 1, 1, hel3, hel3name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
646  AddTestCase (new LteX2HandoverTestCase ( 1, 2, hel3, hel3name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
647  AddTestCase (new LteX2HandoverTestCase ( 2, 0, hel3, hel3name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
648  AddTestCase (new LteX2HandoverTestCase ( 2, 1, hel3, hel3name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
649  AddTestCase (new LteX2HandoverTestCase ( 2, 2, hel3, hel3name, true, *schedIt, true, useIdealRrc), TestCase::QUICK);
650  AddTestCase (new LteX2HandoverTestCase ( 2, 0, hel4, hel4name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
651  AddTestCase (new LteX2HandoverTestCase ( 2, 1, hel4, hel4name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
652  AddTestCase (new LteX2HandoverTestCase ( 2, 2, hel4, hel4name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
653  AddTestCase (new LteX2HandoverTestCase ( 2, 0, hel5, hel5name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
654  AddTestCase (new LteX2HandoverTestCase ( 2, 1, hel5, hel5name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
655  AddTestCase (new LteX2HandoverTestCase ( 2, 2, hel5, hel5name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
656  AddTestCase (new LteX2HandoverTestCase ( 3, 0, hel3, hel3name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
657  AddTestCase (new LteX2HandoverTestCase ( 3, 1, hel3, hel3name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
658  AddTestCase (new LteX2HandoverTestCase ( 3, 2, hel3, hel3name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
659  AddTestCase (new LteX2HandoverTestCase ( 3, 0, hel4, hel4name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
660  AddTestCase (new LteX2HandoverTestCase ( 3, 1, hel4, hel4name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
661  AddTestCase (new LteX2HandoverTestCase ( 3, 2, hel4, hel4name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
662  AddTestCase (new LteX2HandoverTestCase ( 3, 0, hel5, hel5name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
663  AddTestCase (new LteX2HandoverTestCase ( 3, 1, hel5, hel5name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
664  AddTestCase (new LteX2HandoverTestCase ( 3, 2, hel5, hel5name, true, *schedIt, true, useIdealRrc), TestCase::QUICK);
665 
666  }
667  }
668 }
669 
671 
672 
673 
674 } // namespace ns3
holds a vector of ns3::Application pointers.
void CheckConnected(Ptr< NetDevice > ueDevice, Ptr< NetDevice > enbDevice)
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
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
std::list< HandoverEvent > m_handoverEventList
static void Run(void)
Run the simulation until one of:
Definition: simulator.cc:157
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...
static LteX2HandoverTestSuite g_lteX2HandoverTestSuiteInstance
Build a set of PointToPointNetDevice objects.
void CheckStatsAWhileAfterHandover(uint32_t ueIndex)
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
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
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
Ptr< PointToPointEpcHelper > m_epcHelper
void Start(Time start)
Arrange for all of the Applications in this container to Start() at the Time given as a parameter...
virtual void DoRun(void)
Implementation to actually run this TestCase.
std::vector< UeData > m_ueDataVector
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
NS_LOG_COMPONENT_DEFINE("LteX2HandoverTest")
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
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
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...
void SaveStatsAfterHandover(uint32_t ueIndex)
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
LteX2HandoverTestCase(uint32_t nUes, uint32_t nDedicatedBearers, std::list< HandoverEvent > handoverEventList, std::string handoverEventListName, bool useUdp, std::string schedulerType, bool admitHo, bool useIdealRrc)
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 std::string BuildNameString(uint32_t nUes, uint32_t nDedicatedBearers, std::string handoverEventListName, bool useUdp, std::string schedulerType, bool admitHo, bool useIdealRrc)
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.