A Discrete-Event Network Simulator
API
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 using namespace ns3;
31 
32 NS_LOG_COMPONENT_DEFINE ("LteX2HandoverTest");
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  //Disable Uplink Power Control
155  Config::SetDefault ("ns3::LteUePhy::EnableUplinkPowerControl", BooleanValue (false));
156 
157  int64_t stream = 1;
158 
159  m_lteHelper = CreateObject<LteHelper> ();
160  m_lteHelper->SetAttribute ("PathlossModel", StringValue ("ns3::FriisSpectrumPropagationLossModel"));
162  m_lteHelper->SetHandoverAlgorithmType ("ns3::NoOpHandoverAlgorithm"); // disable automatic handover
164 
165 
166  NodeContainer enbNodes;
167  enbNodes.Create (2);
168  NodeContainer ueNodes;
169  ueNodes.Create (m_nUes);
170 
171  if (m_epc)
172  {
173  m_epcHelper = CreateObject<PointToPointEpcHelper> ();
175  }
176 
177  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
178  positionAlloc->Add (Vector (-3000, 0, 0)); // enb0
179  positionAlloc->Add (Vector ( 3000, 0, 0)); // enb1
180  for (uint16_t i = 0; i < m_nUes; i++)
181  {
182  positionAlloc->Add (Vector (0, 0, 0));
183  }
185  mobility.SetPositionAllocator (positionAlloc);
186  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
187  mobility.Install (enbNodes);
188  mobility.Install (ueNodes);
189 
190  NetDeviceContainer enbDevices;
191  enbDevices = m_lteHelper->InstallEnbDevice (enbNodes);
192  stream += m_lteHelper->AssignStreams (enbDevices, stream);
193  for (NetDeviceContainer::Iterator it = enbDevices.Begin ();
194  it != enbDevices.End ();
195  ++it)
196  {
197  Ptr<LteEnbRrc> enbRrc = (*it)->GetObject<LteEnbNetDevice> ()->GetRrc ();
198  enbRrc->SetAttribute ("AdmitHandoverRequest", BooleanValue (m_admitHo));
199  }
200 
201  NetDeviceContainer ueDevices;
202  ueDevices = m_lteHelper->InstallUeDevice (ueNodes);
203  stream += m_lteHelper->AssignStreams (ueDevices, stream);
204 
205  Ipv4Address remoteHostAddr;
206  Ipv4StaticRoutingHelper ipv4RoutingHelper;
207  Ipv4InterfaceContainer ueIpIfaces;
208  Ptr<Node> remoteHost;
209  if (m_epc)
210  {
211  // Create a single RemoteHost
212  NodeContainer remoteHostContainer;
213  remoteHostContainer.Create (1);
214  remoteHost = remoteHostContainer.Get (0);
215  InternetStackHelper internet;
216  internet.Install (remoteHostContainer);
217 
218  // Create the Internet
219  PointToPointHelper p2ph;
220  p2ph.SetDeviceAttribute ("DataRate", DataRateValue (DataRate ("100Gb/s")));
221  p2ph.SetDeviceAttribute ("Mtu", UintegerValue (1500));
222  p2ph.SetChannelAttribute ("Delay", TimeValue (Seconds (0.010)));
223  Ptr<Node> pgw = m_epcHelper->GetPgwNode ();
224  NetDeviceContainer internetDevices = p2ph.Install (pgw, remoteHost);
225  Ipv4AddressHelper ipv4h;
226  ipv4h.SetBase ("1.0.0.0", "255.0.0.0");
227  Ipv4InterfaceContainer internetIpIfaces = ipv4h.Assign (internetDevices);
228  // in this container, interface 0 is the pgw, 1 is the remoteHost
229  remoteHostAddr = internetIpIfaces.GetAddress (1);
230 
231  Ipv4StaticRoutingHelper ipv4RoutingHelper;
232  Ptr<Ipv4StaticRouting> remoteHostStaticRouting = ipv4RoutingHelper.GetStaticRouting (remoteHost->GetObject<Ipv4> ());
233  remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.0.0.0"), 1);
234 
235  // Install the IP stack on the UEs
236  internet.Install (ueNodes);
237  ueIpIfaces = m_epcHelper->AssignUeIpv4Address (NetDeviceContainer (ueDevices));
238  }
239 
240  // attachment (needs to be done after IP stack configuration)
241  // all UEs attached to eNB 0 at the beginning
242  m_lteHelper->Attach (ueDevices, enbDevices.Get (0));
243 
244  if (m_epc)
245  {
246  // always true: bool epcDl = true;
247  // always true: bool epcUl = true;
248  // the rest of this block is copied from lena-dual-stripe
249 
250 
251  // Install and start applications on UEs and remote host
252  uint16_t dlPort = 10000;
253  uint16_t ulPort = 20000;
254 
255  // randomize a bit start times to avoid simulation artifacts
256  // (e.g., buffer overflows due to packet transmissions happening
257  // exactly at the same time)
258  Ptr<UniformRandomVariable> startTimeSeconds = CreateObject<UniformRandomVariable> ();
259  startTimeSeconds->SetAttribute ("Min", DoubleValue (0));
260  startTimeSeconds->SetAttribute ("Max", DoubleValue (0.010));
261  startTimeSeconds->SetStream (stream++);
262 
263  for (uint32_t u = 0; u < ueNodes.GetN (); ++u)
264  {
265  Ptr<Node> ue = ueNodes.Get (u);
266  // Set the default gateway for the UE
267  Ptr<Ipv4StaticRouting> ueStaticRouting = ipv4RoutingHelper.GetStaticRouting (ue->GetObject<Ipv4> ());
268  ueStaticRouting->SetDefaultRoute (m_epcHelper->GetUeDefaultGatewayAddress (), 1);
269 
270  UeData ueData;
271 
272  for (uint32_t b = 0; b < m_nDedicatedBearers; ++b)
273  {
274  ++dlPort;
275  ++ulPort;
276 
279  BearerData bearerData;
280 
281  if (m_useUdp)
282  {
283  // always true: if (epcDl)
284  {
285  UdpClientHelper dlClientHelper (ueIpIfaces.GetAddress (u), dlPort);
286  clientApps.Add (dlClientHelper.Install (remoteHost));
287  PacketSinkHelper dlPacketSinkHelper ("ns3::UdpSocketFactory",
288  InetSocketAddress (Ipv4Address::GetAny (), dlPort));
289  ApplicationContainer sinkContainer = dlPacketSinkHelper.Install (ue);
290  bearerData.dlSink = sinkContainer.Get (0)->GetObject<PacketSink> ();
291  serverApps.Add (sinkContainer);
292 
293  }
294  // always true: if (epcUl)
295  {
296  UdpClientHelper ulClientHelper (remoteHostAddr, ulPort);
297  clientApps.Add (ulClientHelper.Install (ue));
298  PacketSinkHelper ulPacketSinkHelper ("ns3::UdpSocketFactory",
299  InetSocketAddress (Ipv4Address::GetAny (), ulPort));
300  ApplicationContainer sinkContainer = ulPacketSinkHelper.Install (remoteHost);
301  bearerData.ulSink = sinkContainer.Get (0)->GetObject<PacketSink> ();
302  serverApps.Add (sinkContainer);
303  }
304  }
305  else // use TCP
306  {
307  // always true: if (epcDl)
308  {
309  BulkSendHelper dlClientHelper ("ns3::TcpSocketFactory",
310  InetSocketAddress (ueIpIfaces.GetAddress (u), dlPort));
311  dlClientHelper.SetAttribute ("MaxBytes", UintegerValue (0));
312  clientApps.Add (dlClientHelper.Install (remoteHost));
313  PacketSinkHelper dlPacketSinkHelper ("ns3::TcpSocketFactory",
314  InetSocketAddress (Ipv4Address::GetAny (), dlPort));
315  ApplicationContainer sinkContainer = dlPacketSinkHelper.Install (ue);
316  bearerData.dlSink = sinkContainer.Get (0)->GetObject<PacketSink> ();
317  serverApps.Add (sinkContainer);
318  }
319  // always true: if (epcUl)
320  {
321  BulkSendHelper ulClientHelper ("ns3::TcpSocketFactory",
322  InetSocketAddress (remoteHostAddr, ulPort));
323  ulClientHelper.SetAttribute ("MaxBytes", UintegerValue (0));
324  clientApps.Add (ulClientHelper.Install (ue));
325  PacketSinkHelper ulPacketSinkHelper ("ns3::TcpSocketFactory",
326  InetSocketAddress (Ipv4Address::GetAny (), ulPort));
327  ApplicationContainer sinkContainer = ulPacketSinkHelper.Install (remoteHost);
328  bearerData.ulSink = sinkContainer.Get (0)->GetObject<PacketSink> ();
329  serverApps.Add (sinkContainer);
330  }
331  } // end if (useUdp)
332 
333  Ptr<EpcTft> tft = Create<EpcTft> ();
334  // always true: if (epcDl)
335  {
337  dlpf.localPortStart = dlPort;
338  dlpf.localPortEnd = dlPort;
339  tft->Add (dlpf);
340  }
341  // always true: if (epcUl)
342  {
344  ulpf.remotePortStart = ulPort;
345  ulpf.remotePortEnd = ulPort;
346  tft->Add (ulpf);
347  }
348 
349  // always true: if (epcDl || epcUl)
350  {
351  EpsBearer bearer (EpsBearer::NGBR_VIDEO_TCP_DEFAULT);
352  m_lteHelper->ActivateDedicatedEpsBearer (ueDevices.Get (u), bearer, tft);
353  }
354  Time startTime = Seconds (startTimeSeconds->GetValue ());
355  serverApps.Start (startTime);
356  clientApps.Start (startTime);
357 
358  ueData.bearerDataList.push_back (bearerData);
359 
360  } // end for b
361 
362  m_ueDataVector.push_back (ueData);
363  }
364 
365  }
366  else // (epc == false)
367  {
368  // for radio bearer activation purposes, consider together home UEs and macro UEs
369  for (uint32_t u = 0; u < ueDevices.GetN (); ++u)
370  {
371  Ptr<NetDevice> ueDev = ueDevices.Get (u);
372  for (uint32_t b = 0; b < m_nDedicatedBearers; ++b)
373  {
374  enum EpsBearer::Qci q = EpsBearer::NGBR_VIDEO_TCP_DEFAULT;
375  EpsBearer bearer (q);
376  m_lteHelper->ActivateDataRadioBearer (ueDev, bearer);
377  }
378  }
379  }
380 
381 
382  m_lteHelper->AddX2Interface (enbNodes);
383 
384  // check initial RRC connection
385  const Time maxRrcConnectionEstablishmentDuration = Seconds (0.080);
386  for (NetDeviceContainer::Iterator it = ueDevices.Begin (); it != ueDevices.End (); ++it)
387  {
388  Simulator::Schedule (maxRrcConnectionEstablishmentDuration,
390  this, *it, enbDevices.Get (0));
391  }
392 
393  // schedule handover events and corresponding checks
394 
395  Time stopTime = Seconds (0);
396  for (std::list<HandoverEvent>::iterator hoEventIt = m_handoverEventList.begin ();
397  hoEventIt != m_handoverEventList.end ();
398  ++hoEventIt)
399  {
400  Simulator::Schedule (hoEventIt->startTime,
402  this,
403  ueDevices.Get (hoEventIt->ueDeviceIndex),
404  enbDevices.Get (hoEventIt->sourceEnbDeviceIndex));
405  m_lteHelper->HandoverRequest (hoEventIt->startTime,
406  ueDevices.Get (hoEventIt->ueDeviceIndex),
407  enbDevices.Get (hoEventIt->sourceEnbDeviceIndex),
408  enbDevices.Get (hoEventIt->targetEnbDeviceIndex));
409  Time hoEndTime = hoEventIt->startTime + m_maxHoDuration;
410  Simulator::Schedule (hoEndTime,
412  this,
413  ueDevices.Get (hoEventIt->ueDeviceIndex),
414  enbDevices.Get (m_admitHo ? hoEventIt->targetEnbDeviceIndex : hoEventIt->sourceEnbDeviceIndex));
415  Simulator::Schedule (hoEndTime, &LteX2HandoverTestCase::SaveStatsAfterHandover,
416  this, hoEventIt->ueDeviceIndex);
417 
418  Time checkStatsAfterHoTime = hoEndTime + m_statsDuration;
419  Simulator::Schedule (checkStatsAfterHoTime, &LteX2HandoverTestCase::CheckStatsAWhileAfterHandover,
420  this, hoEventIt->ueDeviceIndex);
421  if (stopTime <= checkStatsAfterHoTime)
422  {
423  stopTime = checkStatsAfterHoTime + MilliSeconds (1);
424  }
425  }
426 
427  // m_lteHelper->EnableRlcTraces ();
428  // m_lteHelper->EnablePdcpTraces();
429 
430 
431  Simulator::Stop (stopTime);
432 
433  Simulator::Run ();
434 
435  Simulator::Destroy ();
436 
437 }
438 
439 void
441 {
442  Ptr<LteUeNetDevice> ueLteDevice = ueDevice->GetObject<LteUeNetDevice> ();
443  Ptr<LteUeRrc> ueRrc = ueLteDevice->GetRrc ();
444  NS_TEST_ASSERT_MSG_EQ (ueRrc->GetState (), LteUeRrc::CONNECTED_NORMALLY, "Wrong LteUeRrc state!");
445 
446 
447  Ptr<LteEnbNetDevice> enbLteDevice = enbDevice->GetObject<LteEnbNetDevice> ();
448  Ptr<LteEnbRrc> enbRrc = enbLteDevice->GetRrc ();
449  uint16_t rnti = ueRrc->GetRnti ();
450  Ptr<UeManager> ueManager = enbRrc->GetUeManager (rnti);
451  NS_TEST_ASSERT_MSG_NE (ueManager, 0, "RNTI " << rnti << " not found in eNB");
452 
453  UeManager::State ueManagerState = ueManager->GetState ();
454  NS_TEST_ASSERT_MSG_EQ (ueManagerState, UeManager::CONNECTED_NORMALLY, "Wrong UeManager state!");
455  NS_ASSERT_MSG (ueManagerState == UeManager::CONNECTED_NORMALLY, "Wrong UeManager state!");
456 
457  uint16_t ueCellId = ueRrc->GetCellId ();
458  uint16_t enbCellId = enbLteDevice->GetCellId ();
459  uint8_t ueDlBandwidth = ueRrc->GetDlBandwidth ();
460  uint8_t enbDlBandwidth = enbLteDevice->GetDlBandwidth ();
461  uint8_t ueUlBandwidth = ueRrc->GetUlBandwidth ();
462  uint8_t enbUlBandwidth = enbLteDevice->GetUlBandwidth ();
463  uint8_t ueDlEarfcn = ueRrc->GetDlEarfcn ();
464  uint8_t enbDlEarfcn = enbLteDevice->GetDlEarfcn ();
465  uint8_t ueUlEarfcn = ueRrc->GetUlEarfcn ();
466  uint8_t enbUlEarfcn = enbLteDevice->GetUlEarfcn ();
467  uint64_t ueImsi = ueLteDevice->GetImsi ();
468  uint64_t enbImsi = ueManager->GetImsi ();
469 
470  NS_TEST_ASSERT_MSG_EQ (ueImsi, enbImsi, "inconsistent IMSI");
471  NS_TEST_ASSERT_MSG_EQ (ueCellId, enbCellId, "inconsistent CellId");
472  NS_TEST_ASSERT_MSG_EQ (ueDlBandwidth, enbDlBandwidth, "inconsistent DlBandwidth");
473  NS_TEST_ASSERT_MSG_EQ (ueUlBandwidth, enbUlBandwidth, "inconsistent UlBandwidth");
474  NS_TEST_ASSERT_MSG_EQ (ueDlEarfcn, enbDlEarfcn, "inconsistent DlEarfcn");
475  NS_TEST_ASSERT_MSG_EQ (ueUlEarfcn, enbUlEarfcn, "inconsistent UlEarfcn");
476 
477  ObjectMapValue enbDataRadioBearerMapValue;
478  ueManager->GetAttribute ("DataRadioBearerMap", enbDataRadioBearerMapValue);
479  NS_TEST_ASSERT_MSG_EQ (enbDataRadioBearerMapValue.GetN (), m_nDedicatedBearers + 1, "wrong num bearers at eNB");
480 
481  ObjectMapValue ueDataRadioBearerMapValue;
482  ueRrc->GetAttribute ("DataRadioBearerMap", ueDataRadioBearerMapValue);
483  NS_TEST_ASSERT_MSG_EQ (ueDataRadioBearerMapValue.GetN (), m_nDedicatedBearers + 1, "wrong num bearers at UE");
484 
485  ObjectMapValue::Iterator enbBearerIt = enbDataRadioBearerMapValue.Begin ();
486  ObjectMapValue::Iterator ueBearerIt = ueDataRadioBearerMapValue.Begin ();
487  while (enbBearerIt != enbDataRadioBearerMapValue.End () &&
488  ueBearerIt != ueDataRadioBearerMapValue.End ())
489  {
490  Ptr<LteDataRadioBearerInfo> enbDrbInfo = enbBearerIt->second->GetObject<LteDataRadioBearerInfo> ();
491  Ptr<LteDataRadioBearerInfo> ueDrbInfo = ueBearerIt->second->GetObject<LteDataRadioBearerInfo> ();
492  //NS_TEST_ASSERT_MSG_EQ (enbDrbInfo->m_epsBearer, ueDrbInfo->m_epsBearer, "epsBearer differs");
493  NS_TEST_ASSERT_MSG_EQ ((uint32_t) enbDrbInfo->m_epsBearerIdentity, (uint32_t) ueDrbInfo->m_epsBearerIdentity, "epsBearerIdentity differs");
494  NS_TEST_ASSERT_MSG_EQ ((uint32_t) enbDrbInfo->m_drbIdentity, (uint32_t) ueDrbInfo->m_drbIdentity, "drbIdentity differs");
495  //NS_TEST_ASSERT_MSG_EQ (enbDrbInfo->m_rlcConfig, ueDrbInfo->m_rlcConfig, "rlcConfig differs");
496  NS_TEST_ASSERT_MSG_EQ ((uint32_t) enbDrbInfo->m_logicalChannelIdentity, (uint32_t) ueDrbInfo->m_logicalChannelIdentity, "logicalChannelIdentity differs");
497  //NS_TEST_ASSERT_MSG_EQ (enbDrbInfo->m_logicalChannelConfig, ueDrbInfo->m_logicalChannelConfig, "logicalChannelConfig differs");
498 
499  ++enbBearerIt;
500  ++ueBearerIt;
501  }
502  NS_ASSERT_MSG (enbBearerIt == enbDataRadioBearerMapValue.End (), "too many bearers at eNB");
503  NS_ASSERT_MSG (ueBearerIt == ueDataRadioBearerMapValue.End (), "too many bearers at UE");
504 }
505 
506 void
508 {
509  for (std::list<BearerData>::iterator it = m_ueDataVector.at (ueIndex).bearerDataList.begin ();
510  it != m_ueDataVector.at (ueIndex).bearerDataList.end ();
511  ++it)
512  {
513  it->dlOldTotalRx = it->dlSink->GetTotalRx ();
514  it->ulOldTotalRx = it->ulSink->GetTotalRx ();
515  }
516 }
517 
518 void
520 {
521  uint32_t b = 1;
522  for (std::list<BearerData>::iterator it = m_ueDataVector.at (ueIndex).bearerDataList.begin ();
523  it != m_ueDataVector.at (ueIndex).bearerDataList.end ();
524  ++it)
525  {
526  uint32_t dlRx = it->dlSink->GetTotalRx () - it->dlOldTotalRx;
527  uint32_t ulRx = it->ulSink->GetTotalRx () - it->ulOldTotalRx;
528  uint32_t expectedBytes = m_udpClientPktSize * (m_statsDuration.GetSeconds () / m_udpClientInterval.GetSeconds ());
529  // tolerance
530  NS_TEST_ASSERT_MSG_GT (dlRx, 0.500 * expectedBytes, "too few RX bytes in DL, ue=" << ueIndex << ", b=" << b);
531  NS_TEST_ASSERT_MSG_GT (ulRx, 0.500 * expectedBytes, "too few RX bytes in UL, ue=" << ueIndex << ", b=" << b);
532  ++b;
533  }
534 }
535 
536 
538 {
539 public:
541 };
542 
543 
545  : TestSuite ("lte-x2-handover", SYSTEM)
546 {
547  // in the following:
548  // fwd means handover from enb 0 to enb 1
549  // bwd means handover from enb 1 to enb 0
550 
551  HandoverEvent ue1fwd;
552  ue1fwd.startTime = MilliSeconds (100);
553  ue1fwd.ueDeviceIndex = 0;
554  ue1fwd.sourceEnbDeviceIndex = 0;
555  ue1fwd.targetEnbDeviceIndex = 1;
556 
557  HandoverEvent ue1bwd;
558  ue1bwd.startTime = MilliSeconds (300);
559  ue1bwd.ueDeviceIndex = 0;
560  ue1bwd.sourceEnbDeviceIndex = 1;
561  ue1bwd.targetEnbDeviceIndex = 0;
562 
563  HandoverEvent ue1fwdagain;
564  ue1fwdagain.startTime = MilliSeconds (500);
565  ue1fwdagain.ueDeviceIndex = 0;
566  ue1fwdagain.sourceEnbDeviceIndex = 0;
567  ue1fwdagain.targetEnbDeviceIndex = 1;
568 
569  HandoverEvent ue2fwd;
570  ue2fwd.startTime = MilliSeconds (110);
571  ue2fwd.ueDeviceIndex = 1;
572  ue2fwd.sourceEnbDeviceIndex = 0;
573  ue2fwd.targetEnbDeviceIndex = 1;
574 
575  HandoverEvent ue2bwd;
576  ue2bwd.startTime = MilliSeconds (250);
577  ue2bwd.ueDeviceIndex = 1;
578  ue2bwd.sourceEnbDeviceIndex = 1;
579  ue2bwd.targetEnbDeviceIndex = 0;
580 
581  std::string hel0name ("none");
582  std::list<HandoverEvent> hel0;
583 
584  std::string hel1name ("1 fwd");
585  std::list<HandoverEvent> hel1;
586  hel1.push_back (ue1fwd);
587 
588  std::string hel2name ("1 fwd & bwd");
589  std::list<HandoverEvent> hel2;
590  hel2.push_back (ue1fwd);
591  hel2.push_back (ue1bwd);
592 
593  std::string hel3name ("1 fwd & bwd & fwd");
594  std::list<HandoverEvent> hel3;
595  hel3.push_back (ue1fwd);
596  hel3.push_back (ue1bwd);
597  hel3.push_back (ue1fwdagain);
598 
599  std::string hel4name ("1+2 fwd");
600  std::list<HandoverEvent> hel4;
601  hel4.push_back (ue1fwd);
602  hel4.push_back (ue2fwd);
603 
604  std::string hel5name ("1+2 fwd & bwd");
605  std::list<HandoverEvent> hel5;
606  hel5.push_back (ue1fwd);
607  hel5.push_back (ue1bwd);
608  hel5.push_back (ue2fwd);
609  hel5.push_back (ue2bwd);
610 
611  std::string hel6name ("2 fwd");
612  std::list<HandoverEvent> hel6;
613  hel6.push_back (ue2fwd);
614 
615  std::string hel7name ("2 fwd & bwd");
616  std::list<HandoverEvent> hel7;
617  hel7.push_back (ue2fwd);
618  hel7.push_back (ue2bwd);
619 
620  std::vector<std::string> schedulers;
621  schedulers.push_back ("ns3::RrFfMacScheduler");
622  schedulers.push_back ("ns3::PfFfMacScheduler");
623  for (std::vector<std::string>::iterator schedIt = schedulers.begin (); schedIt != schedulers.end (); ++schedIt)
624  {
625  for (int32_t useIdealRrc = 1; useIdealRrc >= 0; --useIdealRrc)
626  {
627  // nUes, nDBearers, helist, name, useUdp, sched, admitHo, idealRrc
628  AddTestCase (new LteX2HandoverTestCase ( 1, 0, hel0, hel0name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
629  AddTestCase (new LteX2HandoverTestCase ( 2, 0, hel0, hel0name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
630  AddTestCase (new LteX2HandoverTestCase ( 1, 5, hel0, hel0name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
631  AddTestCase (new LteX2HandoverTestCase ( 2, 5, hel0, hel0name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
632  AddTestCase (new LteX2HandoverTestCase ( 1, 0, hel1, hel1name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
633  AddTestCase (new LteX2HandoverTestCase ( 1, 1, hel1, hel1name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
634  AddTestCase (new LteX2HandoverTestCase ( 1, 2, hel1, hel1name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
635  AddTestCase (new LteX2HandoverTestCase ( 1, 0, hel1, hel1name, true, *schedIt, false, useIdealRrc), TestCase::EXTENSIVE);
636  AddTestCase (new LteX2HandoverTestCase ( 1, 1, hel1, hel1name, true, *schedIt, false, useIdealRrc), TestCase::EXTENSIVE);
637  AddTestCase (new LteX2HandoverTestCase ( 1, 2, hel1, hel1name, true, *schedIt, false, useIdealRrc), TestCase::EXTENSIVE);
638  AddTestCase (new LteX2HandoverTestCase ( 2, 0, hel1, hel1name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
639  AddTestCase (new LteX2HandoverTestCase ( 2, 1, hel1, hel1name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
640  AddTestCase (new LteX2HandoverTestCase ( 2, 2, hel1, hel1name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
641  AddTestCase (new LteX2HandoverTestCase ( 2, 0, hel1, hel1name, true, *schedIt, false, useIdealRrc), TestCase::EXTENSIVE);
642  AddTestCase (new LteX2HandoverTestCase ( 2, 1, hel1, hel1name, true, *schedIt, false, useIdealRrc), TestCase::EXTENSIVE);
643  AddTestCase (new LteX2HandoverTestCase ( 2, 2, hel1, hel1name, true, *schedIt, false, useIdealRrc), TestCase::EXTENSIVE);
644  AddTestCase (new LteX2HandoverTestCase ( 1, 0, hel2, hel2name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
645  AddTestCase (new LteX2HandoverTestCase ( 1, 1, hel2, hel2name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
646  AddTestCase (new LteX2HandoverTestCase ( 1, 2, hel2, hel2name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
647  AddTestCase (new LteX2HandoverTestCase ( 1, 0, hel3, hel3name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
648  AddTestCase (new LteX2HandoverTestCase ( 1, 1, hel3, hel3name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
649  AddTestCase (new LteX2HandoverTestCase ( 1, 2, hel3, hel3name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
650  AddTestCase (new LteX2HandoverTestCase ( 2, 0, hel3, hel3name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
651  AddTestCase (new LteX2HandoverTestCase ( 2, 1, hel3, hel3name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
652  AddTestCase (new LteX2HandoverTestCase ( 2, 2, hel3, hel3name, true, *schedIt, true, useIdealRrc), TestCase::QUICK);
653  AddTestCase (new LteX2HandoverTestCase ( 2, 0, hel4, hel4name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
654  AddTestCase (new LteX2HandoverTestCase ( 2, 1, hel4, hel4name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
655  AddTestCase (new LteX2HandoverTestCase ( 2, 2, hel4, hel4name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
656  AddTestCase (new LteX2HandoverTestCase ( 2, 0, hel5, hel5name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
657  AddTestCase (new LteX2HandoverTestCase ( 2, 1, hel5, hel5name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
658  AddTestCase (new LteX2HandoverTestCase ( 2, 2, hel5, hel5name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
659  AddTestCase (new LteX2HandoverTestCase ( 3, 0, hel3, hel3name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
660  AddTestCase (new LteX2HandoverTestCase ( 3, 1, hel3, hel3name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
661  AddTestCase (new LteX2HandoverTestCase ( 3, 2, hel3, hel3name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
662  AddTestCase (new LteX2HandoverTestCase ( 3, 0, hel4, hel4name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
663  AddTestCase (new LteX2HandoverTestCase ( 3, 1, hel4, hel4name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
664  AddTestCase (new LteX2HandoverTestCase ( 3, 2, hel4, hel4name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
665  AddTestCase (new LteX2HandoverTestCase ( 3, 0, hel5, hel5name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
666  AddTestCase (new LteX2HandoverTestCase ( 3, 1, hel5, hel5name, true, *schedIt, true, useIdealRrc), TestCase::EXTENSIVE);
667  AddTestCase (new LteX2HandoverTestCase ( 3, 2, hel5, hel5name, true, *schedIt, true, useIdealRrc), TestCase::QUICK);
668 
669  }
670  }
671 }
672 
holds a vector of ns3::Application pointers.
Iterator Begin(void) const
Get an iterator which refers to the first NetDevice in the container.
uint8_t Add(PacketFilter f)
add a PacketFilter to the Traffic Flow Template
Definition: epc-tft.cc:157
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
an Inet address class
std::list< BearerData > bearerDataList
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
void SetStream(int64_t stream)
Specifies the stream number for this RNG stream.
AttributeValue implementation for Boolean.
Definition: boolean.h:34
NetDeviceContainer InstallEnbDevice(NodeContainer c)
Create a set of eNodeB devices.
Definition: lte-helper.cc:382
A helper to make it easier to instantiate an ns3::BulkSendApplication on a set of nodes...
Ptr< LteHelper > m_lteHelper
holds a vector of std::pair of Ptr and interface index.
void SetDefaultRoute(Ipv4Address nextHop, uint32_t interface, uint32_t metric=0)
Add a default route to the static routing table.
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Definition: object.h:462
Hold variables of type string.
Definition: string.h:41
void HandoverRequest(Time hoTime, Ptr< NetDevice > ueDev, Ptr< NetDevice > sourceEnbDev, Ptr< NetDevice > targetEnbDev)
Manually trigger an X2-based handover.
Definition: lte-helper.cc:1001
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:257
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:1333
Ptr< LteUeRrc > GetRrc() const
uint64_t GetImsi() const
void Attach(NetDeviceContainer ueDevices)
Enables automatic attachment of a set of UE devices to a suitable cell using Idle mode initial cell s...
Definition: lte-helper.cc:716
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:201
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:903
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
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:1147
int64_t AssignStreams(NetDeviceContainer c, int64_t stream)
Assign a fixed random variable stream number to the random variables used.
Definition: lte-helper.cc:1110
static std::string BuildNameString(uint32_t nUes, uint32_t nDedicatedBearers, std::string handoverEventListName, bool useUdp, std::string schedulerType, bool admitHo, bool useIdealRrc)
void ActivateDataRadioBearer(NetDeviceContainer ueDevices, EpsBearer bearer)
Activate a Data Radio Bearer on a given UE devices (for LTE-only simulation).
Definition: lte-helper.cc:1046
void SetDeviceAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each NetDevice created by the helper.
State GetState() const
uint8_t ActivateDedicatedEpsBearer(NetDeviceContainer ueDevices, EpsBearer bearer, Ptr< EpcTft > tft)
Activate a dedicated EPS bearer on a given set of UE devices.
Definition: lte-helper.cc:824
uint32_t targetEnbDeviceIndex
void SetHandoverAlgorithmType(std::string type)
Set the type of handover algorithm to be used by eNodeB devices.
Definition: lte-helper.cc:273
ApplicationContainer Install(NodeContainer c)
double stopTime
tuple clientApps
Definition: first.py:54
std::map< uint32_t, Ptr< Object > >::const_iterator Iterator
Iterator type for traversing this container.
void SetSchedulerType(std::string type)
Set the type of scheduler to be used by eNodeB devices.
Definition: lte-helper.cc:225
uint32_t GetN(void) const
Get the number of Ptr stored in this container.
uint32_t GetN(void) const
Get the number of Ptr stored in this container.
Class for representing data rates.
Definition: data-rate.h:88
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:341
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
LteX2HandoverTestCase(uint32_t nUes, uint32_t nDedicatedBearers, std::list< HandoverEvent > handoverEventList, std::string handoverEventListName, bool useUdp, std::string schedulerType, bool admitHo, bool useIdealRrc)
void SaveStatsAfterHandover(uint32_t ueIndex)
void Install(Ptr< Node > node) const
"Layout" a single node according to the current position allocator type.
tuple mobility
Definition: third.py:101
store information on active data radio bearer instance
void AddTestCase(TestCase *testCase, enum TestDuration duration)
Add an individual child TestCase to this test suite.
Definition: test.cc:298
Create a client application which sends UDP packets carrying a 32bit sequence number and a 64 bit tim...
AttributeValue implementation for Time.
Definition: nstime.h:957
Hold an unsigned integer type.
Definition: uinteger.h:44
double startTime
#define NS_TEST_ASSERT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report and abort if not.
Definition: test.h:161
holds a vector of ns3::NetDevice pointers
static LteX2HandoverTestSuite g_lteX2HandoverTestSuiteInstance
std::vector< UeData > m_ueDataVector
void Start(Time start)
Arrange for all of the Applications in this container to Start() at the Time given as a parameter...
uint32_t sourceEnbDeviceIndex
tuple serverApps
Definition: first.py:45
Access to the IPv4 forwarding table, interfaces, and configuration.
Definition: ipv4.h:76
std::list< HandoverEvent > m_handoverEventList
uint16_t remotePortEnd
end of the port number range of the remote host
Definition: epc-tft.h:113
virtual Ipv4Address GetUeDefaultGatewayAddress()
Every class exported by the ns3 library is enclosed in the ns3 namespace.
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.
State
The state of the UeManager at the eNB RRC.
Definition: lte-enb-rrc.h:73
virtual void DoRun(void)
Implementation to actually run this TestCase.
void SetMobilityModel(std::string type, std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue(), std::string n8="", const AttributeValue &v8=EmptyAttributeValue(), std::string n9="", const AttributeValue &v9=EmptyAttributeValue())
double GetValue(double min, double max)
Get the next random value, as a double in the specified range .
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
void AddX2Interface(NodeContainer enbNodes)
Create an X2 interface between all the eNBs in a given set.
Definition: lte-helper.cc:976
Iterator Begin(void) const
Get an iterator to the first Object.
void GetAttribute(std::string name, AttributeValue &value) const
Get the value of an attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:229
Ptr< PointToPointEpcHelper > m_epcHelper
uint64_t GetImsi(void) const
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:749
void SetChannelAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each Channel created by the helper.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition: assert.h:90
NetDeviceContainer InstallUeDevice(NodeContainer c)
Create a set of UE devices.
Definition: lte-helper.cc:397
virtual Ipv4InterfaceContainer AssignUeIpv4Address(NetDeviceContainer ueDevices)
Assign IPv4 addresses to UE devices.
void CheckConnected(Ptr< NetDevice > ueDevice, Ptr< NetDevice > enbDevice)
Helper class used to assign positions and mobility models to nodes.
void AddNetworkRouteTo(Ipv4Address network, Ipv4Mask networkMask, Ipv4Address nextHop, uint32_t interface, uint32_t metric=0)
Add a network route to the static routing table.
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:40
void CheckStatsAWhileAfterHandover(uint32_t ueIndex)
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
Ptr< Ipv4StaticRouting > GetStaticRouting(Ptr< Ipv4 > ipv4) const
Try and find the static routing protocol as either the main routing protocol or in the list of routin...
void SetEpcHelper(Ptr< EpcHelper > h)
Set the EpcHelper to be used to setup the EPC network in conjunction with the setup of the LTE radio ...
Definition: lte-helper.cc:218
#define NS_TEST_ASSERT_MSG_NE(actual, limit, msg)
Test that an actual and expected (limit) value are not equal and report and abort if not...
Definition: test.h:617
Helper class that adds ns3::Ipv4StaticRouting objects.
AttributeValue implementation for DataRate.
Definition: data-rate.h:242
Ptr< Node > Get(uint32_t i) const
Get the Ptr stored in this container at a given index.
Iterator End(void) const
Get an iterator to the past-the-end Object.
std::vector< Ptr< NetDevice > >::const_iterator Iterator
NetDevice container iterator.
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:895
void SetDefault(std::string name, const AttributeValue &value)
Definition: config.cc:774
void Add(Vector v)
Add a position to the list of positions.
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...
uint32_t GetN(void) const
Get the number of Objects.
Container for a set of ns3::Object pointers.
Receive and consume traffic generated to an IP address and port.
Definition: packet-sink.h:68
void SetPositionAllocator(Ptr< PositionAllocator > allocator)
Set the position allocator which will be used to allocate the initial position of every node initiali...
Iterator End(void) const
Get an iterator which indicates past-the-last NetDevice in the container.
#define NS_TEST_ASSERT_MSG_GT(actual, limit, msg)
Test that an actual value is greater than a limit and report and abort if not.
Definition: test.h:990
This class can be used to hold variables of floating point type such as 'double' or 'float'...
Definition: double.h:41
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:191
The eNodeB device implementation.
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.
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.