A Discrete-Event Network Simulator
API
test-lte-rrc.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  * Budiarto Herman <budiarto.herman@magister.fi>
20  */
21 
22 
23 #include <ns3/core-module.h>
24 #include <ns3/network-module.h>
25 #include <ns3/mobility-module.h>
26 #include <ns3/lte-module.h>
27 #include <cmath>
28 
29 using namespace ns3;
30 
31 NS_LOG_COMPONENT_DEFINE ("LteRrcTest");
32 
34 {
35 public:
50  uint32_t nBearers,
51  uint32_t tConnBase,
52  uint32_t tConnIncrPerUe,
53  uint32_t delayDiscStart,
54  bool errorExpected,
55  bool useIdealRrc,
56  bool admitRrcConnectionRequest,
57  std::string description = "");
58 
59 protected:
60 
61  virtual void DoRun (void);
62  uint32_t m_nUes; // number of UEs in the test
63 
64  static std::string BuildNameString (uint32_t nUes,
65  uint32_t nBearers,
66  uint32_t tConnBase,
67  uint32_t tConnIncrPerUe,
68  uint32_t delayDiscStart,
69  bool useIdealRrc,
70  bool admitRrcConnectionRequest,
71  std::string description = "");
72  void Connect (Ptr<NetDevice> ueDevice, Ptr<NetDevice> enbDevice);
73  void CheckConnected (Ptr<NetDevice> ueDevice, Ptr<NetDevice> enbDevice);
74  void CheckNotConnected (Ptr<NetDevice> ueDevice, Ptr<NetDevice> enbDevice);
75  void ConnectionEstablishedCallback (std::string context, uint64_t imsi,
76  uint16_t cellId, uint16_t rnti);
77  void ConnectionTimeoutCallback (std::string context, uint64_t imsi,
78  uint16_t cellId, uint16_t rnti);
79 
80  uint32_t m_nBearers; // number of bearers to be setup in each connection
81  uint32_t m_tConnBase; // connection time base value for all UEs in ms
82  uint32_t m_tConnIncrPerUe; // additional connection time increment for each UE index (0...nUes-1) in ms
83  uint32_t m_delayConnEnd; // expected duration to perform connection establishment in ms
84  uint32_t m_delayDiscStart; // delay between connection completed and disconnection request in ms
85  uint32_t m_delayDiscEnd; // expected duration to complete disconnection in ms
86  bool m_useIdealRrc; // If set to false, real RRC protocol model will be used
87  bool m_admitRrcConnectionRequest; // If set to false, eNb will not allow UE connections
89 
90  // key: IMSI
91  std::map<uint64_t, bool> m_isConnectionEstablished;
92 };
93 
94 
95 std::string
97  uint32_t nBearers,
98  uint32_t tConnBase,
99  uint32_t tConnIncrPerUe,
100  uint32_t delayDiscStart,
101  bool useIdealRrc,
102  bool admitRrcConnectionRequest,
103  std::string description)
104 {
105  std::ostringstream oss;
106  oss << "nUes=" << nUes
107  << ", nBearers=" << nBearers
108  << ", tConnBase=" << tConnBase
109  << ", tConnIncrPerUe=" << tConnIncrPerUe
110  << ", delayDiscStart=" << delayDiscStart;
111 
112  if (useIdealRrc)
113  {
114  oss << ", ideal RRC";
115  }
116  else
117  {
118  oss << ", real RRC";
119  }
120 
121  if (admitRrcConnectionRequest)
122  {
123  oss << ", admitRrcConnectionRequest = true";
124  }
125  else
126  {
127  oss << ", admitRrcConnectionRequest = false";
128  }
129 
130  if (!description.empty ())
131  {
132  oss << ", " << description;
133  }
134 
135  return oss.str ();
136 }
137 
139  uint32_t nUes, uint32_t nBearers,
140  uint32_t tConnBase, uint32_t tConnIncrPerUe, uint32_t delayDiscStart,
141  bool errorExpected, bool useIdealRrc, bool admitRrcConnectionRequest,
142  std::string description)
143  : TestCase (BuildNameString (nUes, nBearers,
144  tConnBase, tConnIncrPerUe, delayDiscStart,
145  useIdealRrc, admitRrcConnectionRequest,
146  description)),
147  m_nUes (nUes),
148  m_nBearers (nBearers),
149  m_tConnBase (tConnBase),
150  m_tConnIncrPerUe (tConnIncrPerUe),
151 
152  m_delayDiscStart (delayDiscStart),
153  m_delayDiscEnd (10),
154  m_useIdealRrc (useIdealRrc),
155  m_admitRrcConnectionRequest (admitRrcConnectionRequest)
156 {
157  NS_LOG_FUNCTION (this << GetName ());
158 
159  // see the description of d^e in the LTE testing docs
160  double dsi = 90;
161  double nRaAttempts = 0;
162  if (nUes <= 20)
163  {
164  nRaAttempts += 5;
165  }
166  else
167  {
168  NS_ASSERT (nUes <= 50);
169  nRaAttempts += 10;
170  }
171 
172  nRaAttempts += std::ceil (nUes / 4.0);
173  double dra = nRaAttempts * 7;
174  double dce = 10.0 + (2.0 * nUes) / 4.0;
175  if (errorExpected)
176  {
177  /*
178  * If transmission error happens, the UE has to repeat again from
179  * acquiring system information.
180  */
181  dce += dsi + dce;
182  }
183  double nCrs;
184  if (nUes <= 2)
185  {
186  nCrs = 0;
187  }
188  else if (nUes <= 5)
189  {
190  nCrs = 1;
191  }
192  else if (nUes <= 10)
193  {
194  nCrs = 2;
195  }
196  else if (nUes <= 20)
197  {
198  nCrs = 3;
199  }
200  else
201  {
202  nCrs = 4;
203  }
204  double dcr = (10.0 + (2.0 * nUes) / 4.0) * (m_nBearers + nCrs);
205 
206  m_delayConnEnd = round (dsi + dra + dce + dcr);
207  NS_LOG_LOGIC (this << " " << GetName () << " dsi=" << dsi << " dra=" << dra << " dce=" << dce << " dcr=" << dcr << " m_delayConnEnd=" << m_delayConnEnd);
208 }
209 
210 void
212 {
213  NS_LOG_FUNCTION (this << GetName ());
214  Config::Reset ();
215 
216  if (m_nUes < 25)
217  {
218  Config::SetDefault ("ns3::LteEnbRrc::SrsPeriodicity", UintegerValue (40));
219  }
220  else if (m_nUes < 60)
221  {
222  Config::SetDefault ("ns3::LteEnbRrc::SrsPeriodicity", UintegerValue (80));
223  }
224  else if (m_nUes < 120)
225  {
226  Config::SetDefault ("ns3::LteEnbRrc::SrsPeriodicity", UintegerValue (160));
227  }
228  else
229  {
230  Config::SetDefault ("ns3::LteEnbRrc::SrsPeriodicity", UintegerValue (320));
231  }
232 
233  // normal code
234  m_lteHelper = CreateObject<LteHelper> ();
236 
237  NodeContainer enbNodes;
238  NodeContainer ueNodes;
239 
240 
241  enbNodes.Create (1);
242  ueNodes.Create (m_nUes);
243 
244  // the following positions all nodes at (0, 0, 0)
246  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
247  mobility.Install (enbNodes);
248  mobility.Install (ueNodes);
249 
250  int64_t stream = 1;
251  NetDeviceContainer enbDevs;
252  enbDevs = m_lteHelper->InstallEnbDevice (enbNodes);
253  stream += m_lteHelper->AssignStreams (enbDevs, stream);
254 
255  NetDeviceContainer ueDevs;
256  ueDevs = m_lteHelper->InstallUeDevice (ueNodes);
257  stream += m_lteHelper->AssignStreams (ueDevs, stream);
258 
259  // custom code used for testing purposes
260  // instead of lteHelper->Attach () and lteHelper->ActivateXxx
261 
262  // Set AdmitConnectionRequest attribute
263  for (NetDeviceContainer::Iterator it = enbDevs.Begin ();
264  it != enbDevs.End ();
265  ++it)
266  {
267  Ptr<LteEnbRrc> enbRrc = (*it)->GetObject<LteEnbNetDevice> ()->GetRrc ();
268  enbRrc->SetAttribute ("AdmitRrcConnectionRequest",
270  }
271 
272 
273  uint32_t i = 0;
274  uint32_t tmax = 0;
275  for (NetDeviceContainer::Iterator it = ueDevs.Begin (); it != ueDevs.End (); ++it)
276  {
277  Ptr<NetDevice> ueDevice = *it;
278  Ptr<NetDevice> enbDevice = enbDevs.Get (0);
279  Ptr<LteUeNetDevice> ueLteDevice = ueDevice->GetObject<LteUeNetDevice> ();
280 
281  uint32_t tc = m_tConnBase + m_tConnIncrPerUe * i; // time connection start
282  uint32_t tcc = tc + m_delayConnEnd; // time check connection completed;
283  uint32_t td = tcc + m_delayDiscStart; // time disconnect start
284  uint32_t tcd = td + m_delayDiscEnd; // time check disconnection completed
285  tmax = std::max (tmax, tcd);
286 
287  // trick to resolve overloading
288  //void (LteHelper::* overloadedAttachFunctionPointer) (Ptr<NetDevice>, Ptr<NetDevice>) = &LteHelper::Attach;
289  //Simulator::Schedule (MilliSeconds (tc), overloadedAttachFunctionPointer, lteHelper, *it, enbDevice);
290  Simulator::Schedule (MilliSeconds (tc), &LteRrcConnectionEstablishmentTestCase::Connect, this, ueDevice, enbDevice);
291 
292  Simulator::Schedule (MilliSeconds (tcc), &LteRrcConnectionEstablishmentTestCase::CheckConnected, this, *it, enbDevice);
293 
294  // disconnection not supported yet
295 
296  uint64_t imsi = ueLteDevice->GetImsi ();
297  m_isConnectionEstablished[imsi] = false;
298 
299  ++i;
300  }
301 
302  // Connect to trace sources in UEs
303  Config::Connect ("/NodeList/*/DeviceList/*/LteUeRrc/ConnectionEstablished",
305  this));
306  Config::Connect ("/NodeList/*/DeviceList/*/LteUeRrc/ConnectionTimeout",
308  this));
309 
310  Simulator::Stop (MilliSeconds (tmax + 1));
311 
312  Simulator::Run ();
313 
314  Simulator::Destroy ();
315 
316 }
317 
318 void
320 {
321  NS_LOG_FUNCTION (this);
322  m_lteHelper->Attach (ueDevice, enbDevice);
323 
324  for (uint32_t b = 0; b < m_nBearers; ++b)
325  {
326  enum EpsBearer::Qci q = EpsBearer::NGBR_VIDEO_TCP_DEFAULT;
327  EpsBearer bearer (q);
328  m_lteHelper->ActivateDataRadioBearer (ueDevice, bearer);
329  }
330 }
331 
332 void
334 {
335  Ptr<LteUeNetDevice> ueLteDevice = ueDevice->GetObject<LteUeNetDevice> ();
336  Ptr<LteUeRrc> ueRrc = ueLteDevice->GetRrc ();
337  const uint64_t imsi = ueLteDevice->GetImsi ();
338  const uint16_t rnti = ueRrc->GetRnti ();
339  NS_LOG_FUNCTION (this << imsi << rnti);
341  "Invalid IMSI " << imsi);
342 
344  {
346  "Connection with RNTI " << rnti << " should have been rejected");
347  return;
348  }
349 
350  /*
351  * Verifying UE state in UE RRC. Try to increase the test case duration if
352  * the following checks.
353  */
355  "RNTI " << rnti << " fails to establish connection");
356  NS_TEST_ASSERT_MSG_EQ (ueRrc->GetState (), LteUeRrc::CONNECTED_NORMALLY,
357  "RNTI " << rnti << " is not at CONNECTED_NORMALLY state");
358 
359  // Verifying UE context state in eNodeB RRC.
360 
361  Ptr<LteEnbNetDevice> enbLteDevice = enbDevice->GetObject<LteEnbNetDevice> ();
362  Ptr<LteEnbRrc> enbRrc = enbLteDevice->GetRrc ();
363  const bool hasContext = enbRrc->HasUeManager (rnti);
364 
365  if (hasContext)
366  {
367  Ptr<UeManager> ueManager = enbRrc->GetUeManager (rnti);
368  NS_ASSERT (ueManager != 0);
369  NS_TEST_ASSERT_MSG_EQ (ueManager->GetState (),
370  UeManager::CONNECTED_NORMALLY,
371  "The context of RNTI " << rnti << " is in invalid state");
372  }
373  else
374  {
375  NS_LOG_WARN (this << " RNTI " << rnti << " thinks that it has"
376  << " established connection but the eNodeB thinks"
377  << " that the UE has failed on connection setup.");
378  /*
379  * The standard specifies that this case would exceed the maximum
380  * retransmission limit at UE RLC (SRB1), which will then trigger an RLF.
381  * However, this behaviour is not implemented yet.
382  */
383  }
384 
385  // Verifying other attributes on both sides.
386 
387  uint16_t ueCellId = ueRrc->GetCellId ();
388  uint16_t enbCellId = enbLteDevice->GetCellId ();
389  uint16_t ueImsi = ueLteDevice->GetImsi ();
390 
391  uint8_t ueDlBandwidth = ueRrc->GetDlBandwidth ();
392  uint8_t enbDlBandwidth = enbLteDevice->GetDlBandwidth ();
393  uint8_t ueUlBandwidth = ueRrc->GetUlBandwidth ();
394  uint8_t enbUlBandwidth = enbLteDevice->GetUlBandwidth ();
395  uint8_t ueDlEarfcn = ueRrc->GetDlEarfcn ();
396  uint8_t enbDlEarfcn = enbLteDevice->GetDlEarfcn ();
397  uint8_t ueUlEarfcn = ueRrc->GetUlEarfcn ();
398  uint8_t enbUlEarfcn = enbLteDevice->GetUlEarfcn ();
399 
400  NS_TEST_ASSERT_MSG_EQ (ueCellId, enbCellId, "inconsistent CellId");
401  NS_TEST_ASSERT_MSG_EQ (ueDlBandwidth, enbDlBandwidth, "inconsistent DlBandwidth");
402  NS_TEST_ASSERT_MSG_EQ (ueUlBandwidth, enbUlBandwidth, "inconsistent UlBandwidth");
403  NS_TEST_ASSERT_MSG_EQ (ueDlEarfcn, enbDlEarfcn, "inconsistent DlEarfcn");
404  NS_TEST_ASSERT_MSG_EQ (ueUlEarfcn, enbUlEarfcn, "inconsistent UlEarfcn");
405 
406  if (hasContext)
407  {
408  Ptr<UeManager> ueManager = enbRrc->GetUeManager (rnti);
409  NS_ASSERT (ueManager != 0);
410  UeManager::State state = ueManager->GetState ();
411  uint16_t enbImsi = ueManager->GetImsi ();
412  NS_TEST_ASSERT_MSG_EQ (ueImsi, enbImsi, "inconsistent Imsi");
413 
414  if (state == UeManager::CONNECTED_NORMALLY)
415  {
416  ObjectMapValue enbDataRadioBearerMapValue;
417  ueManager->GetAttribute ("DataRadioBearerMap", enbDataRadioBearerMapValue);
418  NS_TEST_ASSERT_MSG_EQ (enbDataRadioBearerMapValue.GetN (), m_nBearers, "wrong num bearers at eNB");
419  ObjectMapValue ueDataRadioBearerMapValue;
420  ueRrc->GetAttribute ("DataRadioBearerMap", ueDataRadioBearerMapValue);
421  NS_TEST_ASSERT_MSG_EQ (ueDataRadioBearerMapValue.GetN (), m_nBearers, "wrong num bearers at UE");
422 
423  ObjectMapValue::Iterator enbBearerIt = enbDataRadioBearerMapValue.Begin ();
424  ObjectMapValue::Iterator ueBearerIt = ueDataRadioBearerMapValue.Begin ();
425  while (enbBearerIt != enbDataRadioBearerMapValue.End ()
426  && ueBearerIt != ueDataRadioBearerMapValue.End ())
427  {
428  Ptr<LteDataRadioBearerInfo> enbDrbInfo = enbBearerIt->second->GetObject<LteDataRadioBearerInfo> ();
429  Ptr<LteDataRadioBearerInfo> ueDrbInfo = ueBearerIt->second->GetObject<LteDataRadioBearerInfo> ();
430  //NS_TEST_ASSERT_MSG_EQ (enbDrbInfo->m_epsBearer, ueDrbInfo->m_epsBearer, "epsBearer differs");
431  NS_TEST_ASSERT_MSG_EQ ((uint32_t) enbDrbInfo->m_epsBearerIdentity, (uint32_t) ueDrbInfo->m_epsBearerIdentity, "epsBearerIdentity differs");
432  NS_TEST_ASSERT_MSG_EQ ((uint32_t) enbDrbInfo->m_drbIdentity, (uint32_t) ueDrbInfo->m_drbIdentity, "drbIdentity differs");
433  //NS_TEST_ASSERT_MSG_EQ (enbDrbInfo->m_rlcConfig, ueDrbInfo->m_rlcConfig, "rlcConfig differs");
434  NS_TEST_ASSERT_MSG_EQ ((uint32_t) enbDrbInfo->m_logicalChannelIdentity, (uint32_t) ueDrbInfo->m_logicalChannelIdentity, "logicalChannelIdentity differs");
435  //NS_TEST_ASSERT_MSG_EQ (enbDrbInfo->m_logicalChannelConfig, ueDrbInfo->m_logicalChannelConfig, "logicalChannelConfig differs");
436 
437  ++enbBearerIt;
438  ++ueBearerIt;
439  }
440 
441  NS_ASSERT_MSG (enbBearerIt == enbDataRadioBearerMapValue.End (), "too many bearers at eNB");
442  NS_ASSERT_MSG (ueBearerIt == ueDataRadioBearerMapValue.End (), "too many bearers at UE");
443  }
444  }
445 }
446 
447 void
449 {
450  Ptr<LteUeNetDevice> ueLteDevice = ueDevice->GetObject<LteUeNetDevice> ();
451  Ptr<LteUeRrc> ueRrc = ueLteDevice->GetRrc ();
452  const uint64_t imsi = ueLteDevice->GetImsi ();
453  const uint16_t rnti = ueRrc->GetRnti ();
454  NS_LOG_FUNCTION (this << imsi << rnti);
456  "Invalid IMSI " << imsi);
457 
458  bool ueStateIsConnectedNormally = (LteUeRrc::CONNECTED_NORMALLY == ueRrc->GetState ());
459 
460  Ptr<LteEnbNetDevice> enbLteDevice = enbDevice->GetObject<LteEnbNetDevice> ();
461  Ptr<LteEnbRrc> enbRrc = enbLteDevice->GetRrc ();
462  const bool hasContext = enbRrc->HasUeManager (rnti);
463  bool contextStateIsConnectedNormally = false;
464  if (hasContext)
465  {
466  Ptr<UeManager> ueManager = enbRrc->GetUeManager (rnti);
467  NS_ASSERT (ueManager != 0);
468  contextStateIsConnectedNormally = (UeManager::CONNECTED_NORMALLY == ueManager->GetState ());
469  }
471  || !ueStateIsConnectedNormally
472  || !hasContext
473  || !contextStateIsConnectedNormally),
474  true,
475  "it should not happen that connection is completed both at the UE and at the eNB side");
476 }
477 
478 void
480  std::string context, uint64_t imsi, uint16_t cellId, uint16_t rnti)
481 {
482  NS_LOG_FUNCTION (this << imsi << cellId);
483  m_isConnectionEstablished[imsi] = true;
484 }
485 
486 
487 void
489  std::string context, uint64_t imsi, uint16_t cellId, uint16_t rnti)
490 {
491  NS_LOG_FUNCTION (this << imsi << cellId);
492 }
493 
494 
495 
498 {
499 public:
508  std::string description = "");
509 protected:
510  virtual void DoRun (void);
511 
512 private:
513  void JumpAway ();
514  void JumpBack ();
515 
518 };
519 
520 
522  Time jumpAwayTime, std::string description)
523  : LteRrcConnectionEstablishmentTestCase (1, 1, 0, 0, 1, true, false, true,
524  description),
525  m_jumpAwayTime (jumpAwayTime)
526 {
527  NS_LOG_FUNCTION (this << GetName ());
528 }
529 
530 
531 void
533 {
534  NS_LOG_FUNCTION (this << GetName ());
535  Config::Reset ();
536 
537  if (m_nUes < 25)
538  {
539  Config::SetDefault ("ns3::LteEnbRrc::SrsPeriodicity", UintegerValue (40));
540  }
541  else if (m_nUes < 60)
542  {
543  Config::SetDefault ("ns3::LteEnbRrc::SrsPeriodicity", UintegerValue (80));
544  }
545  else if (m_nUes < 120)
546  {
547  Config::SetDefault ("ns3::LteEnbRrc::SrsPeriodicity", UintegerValue (160));
548  }
549  else
550  {
551  Config::SetDefault ("ns3::LteEnbRrc::SrsPeriodicity", UintegerValue (320));
552  }
553 
554  // normal code
555  m_lteHelper = CreateObject<LteHelper> ();
557 
558  NodeContainer enbNodes;
559  NodeContainer ueNodes;
560 
561 
562  enbNodes.Create (4);
563  ueNodes.Create (1);
564 
566  mobility.Install (ueNodes); // UE position at (0, 0, 0)
567  m_ueMobility = ueNodes.Get (0)->GetObject<MobilityModel> ();
568 
569  Ptr<ListPositionAllocator> enbPosition = CreateObject<ListPositionAllocator> ();
570  enbPosition->Add (Vector (0, 0, 0));
571  enbPosition->Add (Vector (100.0, 0, 0));
572  enbPosition->Add (Vector (0, 100.0, 0));
573  enbPosition->Add (Vector (100.0, 100.0, 0));
574  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
575  mobility.SetPositionAllocator (enbPosition);
576  mobility.Install (enbNodes);
577 
578  int64_t stream = 1;
579  NetDeviceContainer enbDevs;
580  enbDevs = m_lteHelper->InstallEnbDevice (enbNodes);
581  stream += m_lteHelper->AssignStreams (enbDevs, stream);
582 
583  NetDeviceContainer ueDevs;
584  ueDevs = m_lteHelper->InstallUeDevice (ueNodes);
585  stream += m_lteHelper->AssignStreams (ueDevs, stream);
586 
587  // custom code used for testing purposes
588  // instead of lteHelper->Attach () and lteHelper->ActivateXxx
589 
590  // Set AdmitConnectionRequest attribute
591  for (NetDeviceContainer::Iterator it = enbDevs.Begin ();
592  it != enbDevs.End ();
593  ++it)
594  {
595  Ptr<LteEnbRrc> enbRrc = (*it)->GetObject<LteEnbNetDevice> ()->GetRrc ();
596  enbRrc->SetAttribute ("AdmitRrcConnectionRequest",
598  }
599 
600 
601  uint32_t i = 0;
602  uint32_t tmax = 0;
603  for (NetDeviceContainer::Iterator it = ueDevs.Begin (); it != ueDevs.End (); ++it)
604  {
605  Ptr<NetDevice> ueDevice = *it;
606  Ptr<NetDevice> enbDevice = enbDevs.Get (0);
607  Ptr<LteUeNetDevice> ueLteDevice = ueDevice->GetObject<LteUeNetDevice> ();
608 
609  uint32_t tc = m_tConnBase + m_tConnIncrPerUe * i; // time connection start
610  uint32_t tcc = tc + m_delayConnEnd; // time check connection completed;
611  uint32_t td = tcc + m_delayDiscStart; // time disconnect start
612  uint32_t tcd = td + m_delayDiscEnd; // time check disconnection completed
613  tmax = std::max (tmax, tcd);
614 
615  // trick to resolve overloading
616  //void (LteHelper::* overloadedAttachFunctionPointer) (Ptr<NetDevice>, Ptr<NetDevice>) = &LteHelper::Attach;
617  //Simulator::Schedule (MilliSeconds (tc), overloadedAttachFunctionPointer, lteHelper, *it, enbDevice);
618  Simulator::Schedule (MilliSeconds (tc), &LteRrcConnectionEstablishmentErrorTestCase::Connect, this, ueDevice, enbDevice);
619 
620  Simulator::Schedule (MilliSeconds (tcc), &LteRrcConnectionEstablishmentErrorTestCase::CheckConnected, this, *it, enbDevice);
621 
622  // disconnection not supported yet
623 
624  uint64_t imsi = ueLteDevice->GetImsi ();
625  m_isConnectionEstablished[imsi] = false;
626 
627  ++i;
628  }
629 
630  // Connect to trace sources in UEs
631  Config::Connect ("/NodeList/*/DeviceList/*/LteUeRrc/ConnectionEstablished",
633  this));
634  Config::Connect ("/NodeList/*/DeviceList/*/LteUeRrc/ConnectionTimeout",
636  this));
637 
638 
639  Simulator::Schedule (m_jumpAwayTime,
641  this);
642  Simulator::Schedule (m_jumpAwayTime + MilliSeconds (99),
644  this, ueDevs.Get (0), enbDevs.Get (0));
645  Simulator::Schedule (m_jumpAwayTime + MilliSeconds (100),
647  this);
648 
649  Simulator::Stop (MilliSeconds (tmax + 1));
650 
651  Simulator::Run ();
652 
653  Simulator::Destroy ();
654 
655 }
656 
657 
658 void
660 {
661  NS_LOG_FUNCTION (this);
662  // move to a really far away location so that transmission errors occur
663  m_ueMobility->SetPosition (Vector (100000.0, 100000.0, 0.0));
664 }
665 
666 
667 void
669 {
670  NS_LOG_FUNCTION (this);
671  m_ueMobility->SetPosition (Vector (0.0, 0.0, 0.0));
672 }
673 
674 
675 
677 {
678 public:
679  LteRrcTestSuite ();
680 };
681 
682 
684  : TestSuite ("lte-rrc", SYSTEM)
685 {
686 // LogComponentEnableAll (LOG_PREFIX_ALL);
687 // LogComponentEnable ("LteRrcTest", LOG_LEVEL_ALL);
688 // LogComponentEnable ("LteEnbRrc", LOG_INFO);
689 // LogComponentEnable ("LteUeRrc", LOG_INFO);
690 
691  NS_LOG_FUNCTION (this);
692 
693  for (uint32_t useIdealRrc = 0; useIdealRrc <= 1; ++useIdealRrc)
694  {
695  // <----- all times in ms ----------------->
696 
697  // nUes tConnBase delayDiscStart useIdealRrc
698  // nBearers tConnIncrPerUe errorExpected admitRrcConnectionRequest
699  AddTestCase (new LteRrcConnectionEstablishmentTestCase ( 1, 0, 0, 0, 1, false, useIdealRrc, true), TestCase::EXTENSIVE);
700  AddTestCase (new LteRrcConnectionEstablishmentTestCase ( 1, 0, 100, 0, 1, false, useIdealRrc, true), TestCase::EXTENSIVE);
701  AddTestCase (new LteRrcConnectionEstablishmentTestCase ( 1, 1, 0, 0, 1, false, useIdealRrc, true), TestCase::EXTENSIVE);
702  AddTestCase (new LteRrcConnectionEstablishmentTestCase ( 1, 1, 100, 0, 1, false, useIdealRrc, true), TestCase::EXTENSIVE);
703  AddTestCase (new LteRrcConnectionEstablishmentTestCase ( 1, 2, 0, 0, 1, false, useIdealRrc, true), TestCase::EXTENSIVE);
704  AddTestCase (new LteRrcConnectionEstablishmentTestCase ( 1, 2, 100, 0, 1, false, useIdealRrc, true), TestCase::EXTENSIVE);
705  AddTestCase (new LteRrcConnectionEstablishmentTestCase ( 2, 0, 20, 0, 1, false, useIdealRrc, true), TestCase::EXTENSIVE);
706  AddTestCase (new LteRrcConnectionEstablishmentTestCase ( 2, 0, 20, 10, 1, false, useIdealRrc, true), TestCase::EXTENSIVE);
707  AddTestCase (new LteRrcConnectionEstablishmentTestCase ( 2, 0, 20, 100, 1, false, useIdealRrc, true), TestCase::EXTENSIVE);
708  AddTestCase (new LteRrcConnectionEstablishmentTestCase ( 2, 1, 20, 0, 1, false, useIdealRrc, true), TestCase::EXTENSIVE);
709  AddTestCase (new LteRrcConnectionEstablishmentTestCase ( 2, 1, 20, 10, 1, false, useIdealRrc, true), TestCase::EXTENSIVE);
710  AddTestCase (new LteRrcConnectionEstablishmentTestCase ( 2, 1, 20, 100, 1, false, useIdealRrc, true), TestCase::EXTENSIVE);
711  AddTestCase (new LteRrcConnectionEstablishmentTestCase ( 2, 2, 20, 0, 1, false, useIdealRrc, true), TestCase::EXTENSIVE);
712  AddTestCase (new LteRrcConnectionEstablishmentTestCase ( 2, 2, 20, 10, 1, false, useIdealRrc, true), TestCase::QUICK);
713  AddTestCase (new LteRrcConnectionEstablishmentTestCase ( 2, 2, 20, 100, 1, false, useIdealRrc, true), TestCase::EXTENSIVE);
714  AddTestCase (new LteRrcConnectionEstablishmentTestCase ( 3, 0, 20, 0, 1, false, useIdealRrc, true), TestCase::EXTENSIVE);
715  AddTestCase (new LteRrcConnectionEstablishmentTestCase ( 4, 0, 20, 0, 1, false, useIdealRrc, true), TestCase::EXTENSIVE);
716  AddTestCase (new LteRrcConnectionEstablishmentTestCase ( 4, 0, 20, 300, 1, false, useIdealRrc, true), TestCase::EXTENSIVE);
717  AddTestCase (new LteRrcConnectionEstablishmentTestCase ( 20, 0, 10, 1, 1, false, useIdealRrc, true), TestCase::EXTENSIVE);
718  AddTestCase (new LteRrcConnectionEstablishmentTestCase ( 50, 0, 0, 0, 1, false, useIdealRrc, true), TestCase::EXTENSIVE);
719 
720  // Test cases to check admitRrcConnectionRequest=false
721  // nUes tConnBase delayDiscStart useIdealRrc
722  // nBearers tConnIncrPerUe errorExpected admitRrcConnectionRequest
723  AddTestCase (new LteRrcConnectionEstablishmentTestCase ( 1, 0, 0, 0, 1, false, useIdealRrc, false), TestCase::EXTENSIVE);
724  AddTestCase (new LteRrcConnectionEstablishmentTestCase ( 1, 2, 100, 0, 1, false, useIdealRrc, false), TestCase::EXTENSIVE);
725  AddTestCase (new LteRrcConnectionEstablishmentTestCase ( 2, 0, 20, 0, 1, false, useIdealRrc, false), TestCase::EXTENSIVE);
726  AddTestCase (new LteRrcConnectionEstablishmentTestCase ( 2, 1, 20, 0, 1, false, useIdealRrc, false), TestCase::QUICK);
727  AddTestCase (new LteRrcConnectionEstablishmentTestCase ( 3, 0, 20, 0, 1, false, useIdealRrc, false), TestCase::EXTENSIVE);
728  }
729 
730  // Test cases with transmission error
732  Seconds (0.020214),
733  "failure at RRC Connection Request"),
734  TestCase::QUICK);
736  Seconds (0.025),
737  "failure at RRC Connection Setup"),
738  TestCase::QUICK);
739  /*
740  * The following test case is related to the Idle mode, which is an
741  * unsupported feature at the moment. See also Bug 1762 Comment #25.
742  */
743  // AddTestCase (new LteRrcConnectionEstablishmentErrorTestCase (
744  // Seconds (0.030),
745  // "failure at RRC Connection Setup Complete"),
746  // TestCase::QUICK);
747 
748 }
749 
LteRrcConnectionEstablishmentErrorTestCase(Time jumpAwayTime, std::string description="")
Iterator Begin(void) const
Get an iterator which refers to the first NetDevice in the container.
std::map< uint64_t, bool > m_isConnectionEstablished
Definition: test-lte-rrc.cc:91
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
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 CheckConnected(Ptr< NetDevice > ueDevice, Ptr< NetDevice > enbDevice)
AttributeValue implementation for Boolean.
Definition: boolean.h:34
NetDeviceContainer InstallEnbDevice(NodeContainer c)
Create a set of eNodeB devices.
Definition: lte-helper.cc:382
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Definition: object.h:462
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr stored in this container at a given index.
void ConnectionEstablishedCallback(std::string context, uint64_t imsi, uint16_t cellId, uint16_t rnti)
A suite of tests to run.
Definition: test.h:1333
Ptr< LteUeRrc > GetRrc() const
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
Definition: assert.h:67
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
LteRrcConnectionEstablishmentTestCase(uint32_t nUes, uint32_t nBearers, uint32_t tConnBase, uint32_t tConnIncrPerUe, uint32_t delayDiscStart, bool errorExpected, bool useIdealRrc, bool admitRrcConnectionRequest, std::string description="")
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
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
State GetState() const
std::map< uint32_t, Ptr< Object > >::const_iterator Iterator
Iterator type for traversing this container.
Keep track of the current position and velocity of an object.
This class contains the specification of EPS Bearers.
Definition: eps-bearer.h:71
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
#define max(a, b)
Definition: 80211b.c:45
void AddTestCase(TestCase *testCase, enum TestDuration duration)
Add an individual child TestCase to this test suite.
Definition: test.cc:298
Hold an unsigned integer type.
Definition: uinteger.h:44
#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
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
Definition: callback.h:1489
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:252
void Connect(std::string path, const CallbackBase &cb)
Definition: config.cc:835
Ptr< LteEnbRrc > GetRrc() const
Every class exported by the ns3 library is enclosed in the ns3 namespace.
keep track of a set of node pointers.
State
The state of the UeManager at the eNB RRC.
Definition: lte-enb-rrc.h:73
void ConnectionTimeoutCallback(std::string context, uint64_t imsi, uint16_t cellId, uint16_t rnti)
void SetMobilityModel(std::string type, std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue(), std::string n8="", const AttributeValue &v8=EmptyAttributeValue(), std::string n9="", const AttributeValue &v9=EmptyAttributeValue())
static std::string BuildNameString(uint32_t nUes, uint32_t nBearers, uint32_t tConnBase, uint32_t tConnIncrPerUe, uint32_t delayDiscStart, bool useIdealRrc, bool admitRrcConnectionRequest, std::string description="")
Definition: test-lte-rrc.cc:96
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
void SetPosition(const Vector &position)
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
#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
Helper class used to assign positions and mobility models to nodes.
static LteRrcTestSuite g_lteRrcTestSuiteInstance
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Definition: log.h:228
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 Connect(Ptr< NetDevice > ueDevice, Ptr< NetDevice > enbDevice)
std::string GetName(void) const
Definition: test.cc:369
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
uint32_t GetN(void) const
Get the number of Objects.
Container for a set of ns3::Object pointers.
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.
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
virtual void DoRun(void)
Implementation to actually run this TestCase.
void CheckNotConnected(Ptr< NetDevice > ueDevice, Ptr< NetDevice > enbDevice)
virtual void DoRun(void)
Implementation to actually run this TestCase.
The LteUeNetDevice class implements the UE net device.