A Discrete-Event Network Simulator
API
lte-test-radio-link-failure.cc
Go to the documentation of this file.
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2018 Fraunhofer ESK
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: Vignesh Babu <ns3-dev@esk.fraunhofer.de>
19  *
20  * Modified by:
21  * Zoraze Ali <zoraze.ali@cttc.es> (included both RRC protocol, two
22  * eNB scenario and UE jump away
23  * logic)
24  */
25 
27 
28 #include "ns3/core-module.h"
29 #include "ns3/network-module.h"
30 #include "ns3/internet-module.h"
31 #include "ns3/mobility-module.h"
32 #include "ns3/lte-module.h"
33 #include "ns3/applications-module.h"
34 #include "ns3/point-to-point-module.h"
35 #include "ns3/config-store-module.h"
36 #include "ns3/config-store.h"
37 #include <iostream>
38 #include <vector>
39 #include <stdio.h>
40 #include <iomanip>
41 
42 using namespace ns3;
43 
44 NS_LOG_COMPONENT_DEFINE ("LteRadioLinkFailureTest");
45 
46 /*
47  * Test Suite
48  */
50  : TestSuite ("lte-radio-link-failure", SYSTEM)
51 {
52  std::vector<Vector> uePositionList;
53  std::vector<Vector> enbPositionList;
54  std::vector<Time> checkConnectedList;
55  Vector ueJumpAwayPosition;
56 
57  uePositionList.push_back (Vector (10, 0, 0));
58  enbPositionList.push_back (Vector (0, 0, 0));
59  ueJumpAwayPosition = Vector (7000.0, 0.0, 0.0);
60  // check before jumping
61  checkConnectedList.push_back (Seconds (0.3));
62  // check connection after jumping but before T310 timer expiration.
63  // This is to make sure that UE stays in connected mode
64  // before the expiration of T310 timer.
65  checkConnectedList.push_back (Seconds (1));
66 
67  // One eNB: Ideal RRC PROTOCOL
68  //
69  AddTestCase (new LteRadioLinkFailureTestCase (1, 1, Seconds (2), true,
70  uePositionList, enbPositionList,
71  ueJumpAwayPosition,
72  checkConnectedList),
73  TestCase::QUICK);
74 
75  // One eNB: Real RRC PROTOCOL
76  AddTestCase (new LteRadioLinkFailureTestCase (1, 1, Seconds (2), false,
77  uePositionList, enbPositionList,
78  ueJumpAwayPosition,
79  checkConnectedList),
80  TestCase::QUICK);
81 
82  // Two eNBs: Ideal RRC PROTOCOL
83 
84  // We place the second eNB close to the position where the UE will jump
85  enbPositionList.push_back (Vector (7020, 0, 0));
86 
87  AddTestCase (new LteRadioLinkFailureTestCase (2, 1, Seconds (2), true,
88  uePositionList, enbPositionList,
89  ueJumpAwayPosition,
90  checkConnectedList),
91  TestCase::QUICK);
92 
93  // Two eNBs: Ideal RRC PROTOCOL
94  AddTestCase (new LteRadioLinkFailureTestCase (2, 1, Seconds (2), false,
95  uePositionList, enbPositionList,
96  ueJumpAwayPosition,
97  checkConnectedList),
98  TestCase::QUICK);
99 
100 } // end of LteRadioLinkFailureTestSuite::LteRadioLinkFailureTestSuite ()
101 
102 
104 
105 /*
106  * Test Case
107  */
108 
109 std::string
110 LteRadioLinkFailureTestCase::BuildNameString (uint32_t numEnbs, uint32_t numUes, bool isIdealRrc)
111 {
112  std::ostringstream oss;
113  std::string rrcProtocol;
114  if (isIdealRrc)
115  {
116  rrcProtocol = "RRC Ideal";
117  }
118  else
119  {
120  rrcProtocol = "RRC Real";
121  }
122  oss << numEnbs << " eNBs, " << numUes << " UEs, " << rrcProtocol << " Protocol";
123  return oss.str ();
124 }
125 
127  uint32_t numEnbs, uint32_t numUes, Time simTime, bool isIdealRrc,
128  std::vector<Vector> uePositionList, std::vector<Vector> enbPositionList,
129  Vector ueJumpAwayPosition, std::vector<Time> checkConnectedList)
130  : TestCase (BuildNameString (numEnbs, numUes, isIdealRrc)),
131  m_numEnbs (numEnbs),
132  m_numUes (numUes),
133  m_simTime (simTime),
134  m_isIdealRrc (isIdealRrc),
135  m_uePositionList (uePositionList),
136  m_enbPositionList (enbPositionList),
137  m_checkConnectedList (checkConnectedList),
138  m_ueJumpAwayPosition (ueJumpAwayPosition)
139 {
140  NS_LOG_FUNCTION (this << GetName ());
141  m_lastState = LteUeRrc::NUM_STATES;
145 }
146 
147 
149 {
150  NS_LOG_FUNCTION (this << GetName ());
151 }
152 
153 
154 void
156 {
157  // LogLevel logLevel = (LogLevel) (LOG_PREFIX_FUNC | LOG_PREFIX_TIME | LOG_LEVEL_ALL);
158  // LogComponentEnable ("LteUeRrc", logLevel);
159  // LogComponentEnable ("LteEnbRrc", logLevel);
160  // LogComponentEnable ("LteRadioLinkFailureTest", logLevel);
161 
162  NS_LOG_FUNCTION (this << GetName ());
163  uint16_t numBearersPerUe = 1;
164  Time simTime = m_simTime;
165  double eNodeB_txPower = 43;
166 
167  Config::SetDefault ("ns3::LteHelper::UseIdealRrc", BooleanValue (m_isIdealRrc));
168 
169  Ptr<LteHelper> lteHelper = CreateObject<LteHelper> ();
170  Ptr<PointToPointEpcHelper> epcHelper = CreateObject<PointToPointEpcHelper> ();
171  lteHelper->SetEpcHelper (epcHelper);
172 
173  lteHelper->SetPathlossModelType (TypeId::LookupByName ("ns3::LogDistancePropagationLossModel"));
174  lteHelper->SetPathlossModelAttribute ("Exponent", DoubleValue (3.9));
175  lteHelper->SetPathlossModelAttribute ("ReferenceLoss", DoubleValue (38.57)); //ref. loss in dB at 1m for 2.025GHz
176  lteHelper->SetPathlossModelAttribute ("ReferenceDistance", DoubleValue (1));
177 
178  //----power related (equal for all base stations)----
179  Config::SetDefault ("ns3::LteEnbPhy::TxPower", DoubleValue (eNodeB_txPower));
180  Config::SetDefault ("ns3::LteUePhy::TxPower", DoubleValue (23));
181  Config::SetDefault ("ns3::LteUePhy::NoiseFigure", DoubleValue (7));
182  Config::SetDefault ("ns3::LteEnbPhy::NoiseFigure", DoubleValue (2));
183  Config::SetDefault ("ns3::LteUePhy::EnableUplinkPowerControl", BooleanValue (true));
184  Config::SetDefault ("ns3::LteUePowerControl::ClosedLoop", BooleanValue (true));
185  Config::SetDefault ("ns3::LteUePowerControl::AccumulationEnabled", BooleanValue (true));
186 
187  //----frequency related----
188  lteHelper->SetEnbDeviceAttribute ("DlEarfcn", UintegerValue (100)); //2120MHz
189  lteHelper->SetEnbDeviceAttribute ("UlEarfcn", UintegerValue (18100)); //1930MHz
190  lteHelper->SetEnbDeviceAttribute ("DlBandwidth", UintegerValue (25)); //5MHz
191  lteHelper->SetEnbDeviceAttribute ("UlBandwidth", UintegerValue (25)); //5MHz
192 
193  //----others----
194  lteHelper->SetSchedulerType ("ns3::PfFfMacScheduler");
195  Config::SetDefault ("ns3::LteAmc::AmcModel", EnumValue (LteAmc::PiroEW2010));
196  Config::SetDefault ("ns3::LteAmc::Ber", DoubleValue (0.01));
197  Config::SetDefault ("ns3::PfFfMacScheduler::HarqEnabled", BooleanValue (true));
198 
199  //Radio link failure detection parameters
200  Config::SetDefault ("ns3::LteUeRrc::N310", UintegerValue (1));
201  Config::SetDefault ("ns3::LteUeRrc::N311", UintegerValue (1));
202  Config::SetDefault ("ns3::LteUeRrc::T310", TimeValue (Seconds (1)));
203 
204  // Create the internet
205  Ptr<Node> pgw = epcHelper->GetPgwNode ();
206  // Create a single RemoteHost0x18ab460
207  NodeContainer remoteHostContainer;
208  remoteHostContainer.Create (1);
209  Ptr<Node> remoteHost = remoteHostContainer.Get (0);
210  InternetStackHelper internet;
211  internet.Install (remoteHostContainer);
212  PointToPointHelper p2ph;
213  p2ph.SetDeviceAttribute ("DataRate", DataRateValue (DataRate ("100Gb/s")));
214  p2ph.SetDeviceAttribute ("Mtu", UintegerValue (1500));
215  p2ph.SetChannelAttribute ("Delay", TimeValue (Seconds (0.010)));
216  NetDeviceContainer internetDevices = p2ph.Install (pgw, remoteHost);
217  Ipv4AddressHelper ipv4h;
218  ipv4h.SetBase ("1.0.0.0", "255.0.0.0");
219  Ipv4InterfaceContainer internetIpIfaces = ipv4h.Assign (internetDevices);
220  Ipv4Address remoteHostAddr = internetIpIfaces.GetAddress (1);
221  Ipv4StaticRoutingHelper ipv4RoutingHelper;
222  Ptr<Ipv4StaticRouting> remoteHostStaticRouting = ipv4RoutingHelper.GetStaticRouting (remoteHost->GetObject <Ipv4> ());
223  remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.0.0.0"), 1);
224 
225  // Create Nodes: eNodeB and UE
226  NodeContainer enbNodes;
227  NodeContainer ueNodes;
228  enbNodes.Create (m_numEnbs);
229  ueNodes.Create (m_numUes);
230 
231  //Mobility
232  Ptr<ListPositionAllocator> positionAllocEnb = CreateObject<ListPositionAllocator> ();
233 
234  for (std::vector<Vector>::iterator enbPosIt = m_enbPositionList.begin ();
235  enbPosIt != m_enbPositionList.end (); ++enbPosIt)
236  {
237  positionAllocEnb->Add (*enbPosIt);
238  }
240  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
241  mobility.SetPositionAllocator (positionAllocEnb);
242  mobility.Install (enbNodes);
243 
244  Ptr<ListPositionAllocator> positionAllocUe = CreateObject<ListPositionAllocator> ();
245 
246  for (std::vector<Vector>::iterator uePosIt = m_uePositionList.begin ();
247  uePosIt != m_uePositionList.end (); ++uePosIt)
248  {
249  positionAllocUe->Add (*uePosIt);
250  }
251 
252  mobility.SetPositionAllocator (positionAllocUe);
253  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
254  mobility.Install (ueNodes);
255  m_ueMobility = ueNodes.Get (0)->GetObject<MobilityModel> ();
256 
257  // Install LTE Devices in eNB and UEs
258  NetDeviceContainer enbDevs;
259  NetDeviceContainer ueDevs;
260 
261  int64_t randomStream = 1;
262  enbDevs = lteHelper->InstallEnbDevice (enbNodes);
263  randomStream += lteHelper->AssignStreams (enbDevs, randomStream);
264  ueDevs = lteHelper->InstallUeDevice (ueNodes);
265  randomStream += lteHelper->AssignStreams (ueDevs, randomStream);
266 
267  // Install the IP stack on the UEs
268  internet.Install (ueNodes);
269  Ipv4InterfaceContainer ueIpIfaces;
270  ueIpIfaces = epcHelper->AssignUeIpv4Address (NetDeviceContainer (ueDevs));
271 
272  // Attach a UE to a eNB
273  lteHelper->Attach (ueDevs);
274 
275  // Install and start applications on UEs and remote host
276  uint16_t dlPort = 10000;
277  uint16_t ulPort = 20000;
278 
279  DataRateValue dataRateValue = DataRate ("18.6Mbps");
280  uint64_t bitRate = dataRateValue.Get ().GetBitRate ();
281  uint32_t packetSize = 1024; //bytes
282  NS_LOG_DEBUG ("bit rate " << bitRate);
283  double interPacketInterval = static_cast<double> (packetSize * 8) / bitRate;
284  Time udpInterval = Seconds (interPacketInterval);
285 
286  NS_LOG_DEBUG ("UDP will use application interval " << udpInterval.GetSeconds () << " sec");
287 
288  for (uint32_t u = 0; u < m_numUes; ++u)
289  {
290  Ptr<Node> ue = ueNodes.Get (u);
291  // Set the default gateway for the UE
292  Ptr<Ipv4StaticRouting> ueStaticRouting = ipv4RoutingHelper.GetStaticRouting (ue->GetObject<Ipv4> ());
293  ueStaticRouting->SetDefaultRoute (epcHelper->GetUeDefaultGatewayAddress (), 1);
294 
295  for (uint32_t b = 0; b < numBearersPerUe; ++b)
296  {
297  ApplicationContainer ulClientApps;
298  ApplicationContainer ulServerApps;
299  ApplicationContainer dlClientApps;
300  ApplicationContainer dlServerApps;
301 
302  ++dlPort;
303  ++ulPort;
304 
305  NS_LOG_LOGIC ("installing UDP DL app for UE " << u + 1);
306  UdpClientHelper dlClientHelper (ueIpIfaces.GetAddress (u), dlPort);
307  dlClientHelper.SetAttribute ("Interval", TimeValue (udpInterval));
308  dlClientHelper.SetAttribute ("MaxPackets", UintegerValue (1000000));
309  dlClientApps.Add (dlClientHelper.Install (remoteHost));
310 
311  PacketSinkHelper dlPacketSinkHelper ("ns3::UdpSocketFactory", InetSocketAddress (Ipv4Address::GetAny (), dlPort));
312  dlServerApps.Add (dlPacketSinkHelper.Install (ue));
313 
314  NS_LOG_LOGIC ("installing UDP UL app for UE " << u + 1);
315  UdpClientHelper ulClientHelper (remoteHostAddr, ulPort);
316  ulClientHelper.SetAttribute ("Interval", TimeValue (udpInterval));
317  ulClientHelper.SetAttribute ("MaxPackets", UintegerValue (1000000));
318  ulClientApps.Add (ulClientHelper.Install (ue));
319 
320  PacketSinkHelper ulPacketSinkHelper ("ns3::UdpSocketFactory", InetSocketAddress (Ipv4Address::GetAny (), ulPort));
321  ulServerApps.Add (ulPacketSinkHelper.Install (remoteHost));
322 
323  Ptr<EpcTft> tft = Create<EpcTft> ();
325  dlpf.localPortStart = dlPort;
326  dlpf.localPortEnd = dlPort;
327  tft->Add (dlpf);
329  ulpf.remotePortStart = ulPort;
330  ulpf.remotePortEnd = ulPort;
331  tft->Add (ulpf);
332  EpsBearer bearer (EpsBearer::NGBR_IMS);
333  lteHelper->ActivateDedicatedEpsBearer (ueDevs.Get (u), bearer, tft);
334 
335  dlServerApps.Start (Seconds (0.27));
336  dlClientApps.Start (Seconds (0.27));
337  ulServerApps.Start (Seconds (0.27));
338  ulClientApps.Start (Seconds (0.27));
339 
340  } // end for b
341  }
342 
343  lteHelper->EnableTraces ();
344 
345  for (uint32_t u = 0; u < m_numUes; ++u)
346  {
347  Simulator::Schedule (m_checkConnectedList.at (u), &LteRadioLinkFailureTestCase::CheckConnected, this, ueDevs.Get (u), enbDevs);
348  }
349 
350  Simulator::Schedule (Seconds (0.4), &LteRadioLinkFailureTestCase::JumpAway, this, m_ueJumpAwayPosition);
351 
352  // connect custom trace sinks
353  Config::Connect ("/NodeList/*/DeviceList/*/LteEnbRrc/ConnectionEstablished",
355  Config::Connect ("/NodeList/*/DeviceList/*/LteUeRrc/ConnectionEstablished",
357  Config::Connect ("/NodeList/*/DeviceList/*/LteUeRrc/StateTransition",
359  Config::Connect ("/NodeList/*/DeviceList/*/LteEnbRrc/NotifyConnectionRelease",
361  Config::Connect ("/NodeList/*/DeviceList/*/LteUeRrc/PhySyncDetection",
363  Config::Connect ("/NodeList/*/DeviceList/*/LteUeRrc/RadioLinkFailure",
365 
366  Simulator::Stop (simTime);
367 
368  Simulator::Run ();
369  for (uint32_t u = 0; u < m_numUes; ++u)
370  {
372  "Error, UE transitions to idle state for other than radio link failure");
373  CheckIdle (ueDevs.Get (u), enbDevs);
374  }
375  Simulator::Destroy ();
376 } // end of void LteRadioLinkFailureTestCase::DoRun ()
377 
378 void
380 {
381  NS_LOG_FUNCTION (this);
382  // move to a far away location so that transmission errors occur
383 
384  m_ueMobility->SetPosition (UeJumpAwayPosition);
385 }
386 
387 void
389 {
390  NS_LOG_FUNCTION (ueDevice);
391 
392  Ptr<LteUeNetDevice> ueLteDevice = ueDevice->GetObject<LteUeNetDevice> ();
393  Ptr<LteUeRrc> ueRrc = ueLteDevice->GetRrc ();
394  NS_TEST_ASSERT_MSG_EQ (ueRrc->GetState (), LteUeRrc::CONNECTED_NORMALLY, "Wrong LteUeRrc state!");
395  uint16_t cellId = ueRrc->GetCellId ();
396 
397  Ptr<LteEnbNetDevice> enbLteDevice;
398 
399  for (std::vector<Ptr<NetDevice> >::const_iterator enbDevIt = enbDevices.Begin ();
400  enbDevIt != enbDevices.End (); ++enbDevIt)
401  {
402  if (((*enbDevIt)->GetObject<LteEnbNetDevice> ())->HasCellId (cellId))
403  {
404  enbLteDevice = (*enbDevIt)->GetObject<LteEnbNetDevice> ();
405  }
406  }
407 
408  NS_TEST_ASSERT_MSG_NE (enbLteDevice, 0, "LTE eNB device not found");
409  Ptr<LteEnbRrc> enbRrc = enbLteDevice->GetRrc ();
410  uint16_t rnti = ueRrc->GetRnti ();
411  Ptr<UeManager> ueManager = enbRrc->GetUeManager (rnti);
412  NS_TEST_ASSERT_MSG_NE (ueManager, 0, "RNTI " << rnti << " not found in eNB");
413 
414  UeManager::State ueManagerState = ueManager->GetState ();
415  NS_TEST_ASSERT_MSG_EQ (ueManagerState, UeManager::CONNECTED_NORMALLY, "Wrong UeManager state!");
416  NS_ASSERT_MSG (ueManagerState == UeManager::CONNECTED_NORMALLY, "Wrong UeManager state!");
417 
418  uint16_t ueCellId = ueRrc->GetCellId ();
419  uint16_t enbCellId = enbLteDevice->GetCellId ();
420  uint8_t ueDlBandwidth = ueRrc->GetDlBandwidth ();
421  uint8_t enbDlBandwidth = enbLteDevice->GetDlBandwidth ();
422  uint8_t ueUlBandwidth = ueRrc->GetUlBandwidth ();
423  uint8_t enbUlBandwidth = enbLteDevice->GetUlBandwidth ();
424  uint8_t ueDlEarfcn = ueRrc->GetDlEarfcn ();
425  uint8_t enbDlEarfcn = enbLteDevice->GetDlEarfcn ();
426  uint8_t ueUlEarfcn = ueRrc->GetUlEarfcn ();
427  uint8_t enbUlEarfcn = enbLteDevice->GetUlEarfcn ();
428  uint64_t ueImsi = ueLteDevice->GetImsi ();
429  uint64_t enbImsi = ueManager->GetImsi ();
430 
431  NS_TEST_ASSERT_MSG_EQ (ueImsi, enbImsi, "inconsistent IMSI");
432  NS_TEST_ASSERT_MSG_EQ (ueCellId, enbCellId, "inconsistent CellId");
433  NS_TEST_ASSERT_MSG_EQ (ueDlBandwidth, enbDlBandwidth, "inconsistent DlBandwidth");
434  NS_TEST_ASSERT_MSG_EQ (ueUlBandwidth, enbUlBandwidth, "inconsistent UlBandwidth");
435  NS_TEST_ASSERT_MSG_EQ (ueDlEarfcn, enbDlEarfcn, "inconsistent DlEarfcn");
436  NS_TEST_ASSERT_MSG_EQ (ueUlEarfcn, enbUlEarfcn, "inconsistent UlEarfcn");
437 
438  ObjectMapValue enbDataRadioBearerMapValue;
439  ueManager->GetAttribute ("DataRadioBearerMap", enbDataRadioBearerMapValue);
440  NS_TEST_ASSERT_MSG_EQ (enbDataRadioBearerMapValue.GetN (), 1 + 1, "wrong num bearers at eNB");
441 
442  ObjectMapValue ueDataRadioBearerMapValue;
443  ueRrc->GetAttribute ("DataRadioBearerMap", ueDataRadioBearerMapValue);
444  NS_TEST_ASSERT_MSG_EQ (ueDataRadioBearerMapValue.GetN (), 1 + 1, "wrong num bearers at UE");
445 
446  ObjectMapValue::Iterator enbBearerIt = enbDataRadioBearerMapValue.Begin ();
447  ObjectMapValue::Iterator ueBearerIt = ueDataRadioBearerMapValue.Begin ();
448  while (enbBearerIt != enbDataRadioBearerMapValue.End ()
449  && ueBearerIt != ueDataRadioBearerMapValue.End ())
450  {
451  Ptr<LteDataRadioBearerInfo> enbDrbInfo = enbBearerIt->second->GetObject<LteDataRadioBearerInfo> ();
452  Ptr<LteDataRadioBearerInfo> ueDrbInfo = ueBearerIt->second->GetObject<LteDataRadioBearerInfo> ();
453  NS_TEST_ASSERT_MSG_EQ ((uint32_t) enbDrbInfo->m_epsBearerIdentity, (uint32_t) ueDrbInfo->m_epsBearerIdentity, "epsBearerIdentity differs");
454  NS_TEST_ASSERT_MSG_EQ ((uint32_t) enbDrbInfo->m_drbIdentity, (uint32_t) ueDrbInfo->m_drbIdentity, "drbIdentity differs");
455  NS_TEST_ASSERT_MSG_EQ ((uint32_t) enbDrbInfo->m_logicalChannelIdentity, (uint32_t) ueDrbInfo->m_logicalChannelIdentity, "logicalChannelIdentity differs");
456 
457  ++enbBearerIt;
458  ++ueBearerIt;
459  }
460  NS_ASSERT_MSG (enbBearerIt == enbDataRadioBearerMapValue.End (), "too many bearers at eNB");
461  NS_ASSERT_MSG (ueBearerIt == ueDataRadioBearerMapValue.End (), "too many bearers at UE");
462 }
463 
464 void
466 {
467  NS_LOG_FUNCTION (ueDevice);
468 
469  Ptr<LteUeNetDevice> ueLteDevice = ueDevice->GetObject<LteUeNetDevice> ();
470  Ptr<LteUeRrc> ueRrc = ueLteDevice->GetRrc ();
471  uint16_t rnti = ueRrc->GetRnti ();
472  uint32_t numEnbDevices = enbDevices.GetN ();
473  bool ueManagerFound = false;
474 
475  switch (numEnbDevices)
476  {
477  // 1 eNB
478  case 1:
479  NS_TEST_ASSERT_MSG_EQ (ueRrc->GetState (), LteUeRrc::IDLE_CELL_SEARCH, "Wrong LteUeRrc state!");
480  ueManagerFound = CheckUeExistAtEnb (rnti, enbDevices.Get (0));
481  NS_TEST_ASSERT_MSG_EQ (ueManagerFound, false, "Unexpected RNTI with value " << rnti << " found in eNB");
482  break;
483  // 2 eNBs
484  case 2:
485  NS_TEST_ASSERT_MSG_EQ (ueRrc->GetState (), LteUeRrc::CONNECTED_NORMALLY, "Wrong LteUeRrc state!");
486  ueManagerFound = CheckUeExistAtEnb (rnti, enbDevices.Get (1));
487  NS_TEST_ASSERT_MSG_EQ (ueManagerFound, true, "RNTI " << rnti << " is not attached to the eNB");
488  break;
489  default:
490  NS_FATAL_ERROR ("The RRC state of the UE in more then 2 eNB scenario is not defined. Consider creating more cases");
491  break;
492  }
493 }
494 
495 bool
497 {
498  NS_LOG_FUNCTION (this << rnti);
499  Ptr<LteEnbNetDevice> enbLteDevice = DynamicCast<LteEnbNetDevice> (enbDevice);
500  NS_ABORT_MSG_IF (enbLteDevice == nullptr, "LTE eNB device not found");
501  Ptr<LteEnbRrc> enbRrc = enbLteDevice->GetRrc ();
502  bool ueManagerFound = enbRrc->HasUeManager (rnti);
503  return ueManagerFound;
504 }
505 
506 void
508  uint64_t imsi, uint16_t cellId,
509  uint16_t rnti, LteUeRrc::State oldState,
510  LteUeRrc::State newState)
511 {
512  NS_LOG_FUNCTION (this << imsi << cellId << rnti << oldState << newState);
513  m_lastState = newState;
514 }
515 
516 void
518  std::string context, uint64_t imsi, uint16_t cellId, uint16_t rnti)
519 {
520  NS_LOG_FUNCTION (this << imsi << cellId << rnti);
521 }
522 
523 void
525  std::string context, uint64_t imsi, uint16_t cellId, uint16_t rnti)
526 {
527  NS_LOG_FUNCTION (this << imsi << cellId << rnti);
529  "radio link failure detection should start only in RRC CONNECTED state");
531  "radio link failure detection should start only in RRC CONNECTED state");
532 }
533 
534 void
536  uint16_t cellId, uint16_t rnti)
537 {
538  NS_LOG_FUNCTION (this << imsi << cellId << rnti);
539 }
540 
541 void
542 LteRadioLinkFailureTestCase::PhySyncDetectionCallback (std::string context, uint64_t imsi, uint16_t rnti, uint16_t cellId, std::string type, uint8_t count)
543 {
544  NS_LOG_FUNCTION (this << imsi << cellId << rnti);
545  if (type == "Notify out of sync")
546  {
548  }
549  else if (type == "Notify in sync")
550  {
551  m_numOfInSyncIndications = count;
552  }
553 }
554 
555 void
556 LteRadioLinkFailureTestCase::RadioLinkFailureCallback (std::string context, uint64_t imsi, uint16_t cellId, uint16_t rnti)
557 {
558  NS_LOG_FUNCTION (this << imsi << cellId << rnti);
559  NS_LOG_DEBUG ("RLF at " << Simulator::Now ());
561  //The value of N310 is hard coded to the default value 1
563  "wrong number of out-of-sync indications detected, check configured value for N310");
564  //The value of N311 is hard coded to the default value 1
566  "wrong number of out-of-sync indications detected, check configured value for N311");
567  // Reset the counter for the next RRC connection establishment.
569 }
holds a vector of ns3::Application pointers.
uint32_t GetDlEarfcn() const
uint8_t Add(PacketFilter f)
add a PacketFilter to the Traffic Flow Template
Definition: epc-tft.cc:240
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
void SetPathlossModelAttribute(std::string n, const AttributeValue &v)
Set an attribute for the path loss models to be created.
Definition: lte-helper.cc:393
an Inet address class
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
State
The state of the UeManager at the eNB RRC.
Definition: lte-enb-rrc.h:86
AttributeValue implementation for Boolean.
Definition: boolean.h:36
NetDeviceContainer InstallEnbDevice(NodeContainer c)
Create a set of eNodeB devices.
Definition: lte-helper.cc:474
holds a vector of std::pair of Ptr<Ipv4> and interface index.
void SetDefaultRoute(Ipv4Address nextHop, uint32_t interface, uint32_t metric=0)
Add a default route to the static routing table.
Iterator End(void) const
Get an iterator which indicates past-the-last NetDevice in the container.
NS_ASSERT_MSG(false, "Ipv4AddressGenerator::MaskToIndex(): Impossible")
NetDeviceContainer Install(NodeContainer c)
a class to represent an Ipv4 address mask
Definition: ipv4-address.h:258
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:1342
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:355
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:961
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:204
ApplicationContainer Install(NodeContainer c) const
Install an ns3::PacketSinkApplication on each node of the input container configured with all the att...
aggregate IP/TCP/UDP functionality to existing Nodes.
State GetState() const
uint64_t GetImsi(void) const
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:162
uint8_t GetDlBandwidth() const
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:1155
int64_t AssignStreams(NetDeviceContainer c, int64_t stream)
Assign a fixed random variable stream number to the random variables used.
Definition: lte-helper.cc:1443
void SetDeviceAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each NetDevice created by the helper.
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:1069
uint64_t GetBitRate() const
Get the underlying bitrate.
Definition: data-rate.cc:249
ApplicationContainer Install(NodeContainer c)
void SetSchedulerType(std::string type)
Set the type of scheduler to be used by eNodeB devices.
Definition: lte-helper.cc:279
mobility
Definition: third.py:101
Class for representing data rates.
Definition: data-rate.h:88
Keep track of the current position and velocity of an object.
Ptr< UeManager > GetUeManager(uint16_t rnti)
uint64_t GetImsi() const
Get the IMSI.
store information on active data radio bearer instance
Hold variables of type enum.
Definition: enum.h:54
uint8_t m_logicalChannelIdentity
logical channel identity
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:1124
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:299
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
uint16_t GetCellId() const
Iterator Begin(void) const
Get an iterator which refers to the first NetDevice in the container.
Iterator Begin(void) const
Get an iterator to the first Object.
void EnableTraces(void)
Enables trace sinks for PHY, MAC, RLC and PDCP.
Definition: lte-helper.cc:1426
Hold an unsigned integer type.
Definition: uinteger.h:44
Vector3D Vector
Definition: vector.h:217
#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:168
std::map< std::size_t, Ptr< Object > >::const_iterator Iterator
Iterator type for traversing this container.
bool HasUeManager(uint16_t rnti) const
holds a vector of ns3::NetDevice pointers
void SetPathlossModelType(TypeId type)
Set the type of path loss model to be used for both DL and UL channels.
Definition: lte-helper.cc:385
Iterator End(void) const
Get an iterator to the past-the-end Object.
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
Definition: callback.h:1489
std::size_t GetN(void) const
Get the number of Objects.
void Start(Time start)
Arrange for all of the Applications in this container to Start() at the Time given as a parameter...
void Connect(std::string path, const CallbackBase &cb)
Definition: config.cc:871
Access to the IPv4 forwarding table, interfaces, and configuration.
Definition: ipv4.h:76
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Definition: object.h:459
void SetAttribute(std::string name, const AttributeValue &value)
Record an attribute to be set in each Application after it is is created.
uint16_t remotePortEnd
end of the port number range of the remote host
Definition: epc-tft.h:138
Every class exported by the ns3 library is enclosed in the ns3 namespace.
keep track of a set of node pointers.
uint32_t GetUlEarfcn() const
This class contains the specification of EPS Bearers.
Definition: eps-bearer.h:91
void SetPosition(const Vector &position)
NS_LOG_LOGIC("Net device "<< nd<< " is not bridged")
DataRate Get(void) const
Definition: data-rate.cc:30
void SetChannelAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each Channel created by the helper.
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
NetDeviceContainer InstallUeDevice(NodeContainer c)
Create a set of UE devices.
Definition: lte-helper.cc:489
State
The states of the UE RRC entity.
Definition: lte-ue-rrc.h:105
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
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
std::string GetName(void) const
Definition: test.cc:370
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:272
uint8_t GetUlBandwidth() const
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
Definition: abort.h:108
#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:624
uint8_t m_drbIdentity
DRB identity.
Helper class that adds ns3::Ipv4StaticRouting objects.
AttributeValue implementation for DataRate.
Definition: data-rate.h:242
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:272
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1062
uint32_t GetN(void) const
Get the number of Ptr<NetDevice> stored in this container.
void SetDefault(std::string name, const AttributeValue &value)
Definition: config.cc:810
void Add(Vector v)
Add a position to the list of positions.
Ptr< LteUeRrc > GetRrc() const
Get the RRC.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
Definition: simulator.cc:309
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
static const uint32_t packetSize
Container for a set of ns3::Object pointers.
This class can be used to hold variables of floating point type such as &#39;double&#39; or &#39;float&#39;...
Definition: double.h:41
The eNodeB device implementation.
Ptr< LteEnbRrc > GetRrc() const
void GetAttribute(std::string name, AttributeValue &value) const
Get the value of an attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:223
#define NS_TEST_ASSERT_MSG_LT(actual, limit, msg)
Test that an actual value is less than a limit and report and abort if not.
Definition: test.h:811
uint16_t remotePortStart
start of the port number range of the remote host
Definition: epc-tft.h:137
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 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:74
void SetEnbDeviceAttribute(std::string n, const AttributeValue &v)
Set an attribute for the eNodeB devices (LteEnbNetDevice) to be created.
Definition: lte-helper.cc:400
uint16_t localPortStart
start of the port number range of the UE
Definition: epc-tft.h:139
uint8_t m_epsBearerIdentity
EPS bearer identity.
The LteUeNetDevice class implements the UE net device.