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 
40 {
41 public:
56  uint32_t nBearers,
57  uint32_t tConnBase,
58  uint32_t tConnIncrPerUe,
59  uint32_t delayDiscStart,
60  bool errorExpected,
61  bool useIdealRrc,
62  bool admitRrcConnectionRequest,
63  std::string description = "");
64 
65 protected:
66 
67  virtual void DoRun (void);
68  uint32_t m_nUes;
69 
83  static std::string BuildNameString (uint32_t nUes,
84  uint32_t nBearers,
85  uint32_t tConnBase,
86  uint32_t tConnIncrPerUe,
87  uint32_t delayDiscStart,
88  bool useIdealRrc,
89  bool admitRrcConnectionRequest,
90  std::string description = "");
96  void Connect (Ptr<NetDevice> ueDevice, Ptr<NetDevice> enbDevice);
102  void CheckConnected (Ptr<NetDevice> ueDevice, Ptr<NetDevice> enbDevice);
108  void CheckNotConnected (Ptr<NetDevice> ueDevice, Ptr<NetDevice> enbDevice);
116  void ConnectionEstablishedCallback (std::string context, uint64_t imsi,
117  uint16_t cellId, uint16_t rnti);
125  void ConnectionTimeoutCallback (std::string context, uint64_t imsi,
126  uint16_t cellId, uint16_t rnti);
127 
128  uint32_t m_nBearers;
129  uint32_t m_tConnBase;
130  uint32_t m_tConnIncrPerUe;
131  uint32_t m_delayConnEnd;
132  uint32_t m_delayDiscStart;
133  uint32_t m_delayDiscEnd;
137 
139  std::map<uint64_t, bool> m_isConnectionEstablished;
140 };
141 
142 
143 std::string
145  uint32_t nBearers,
146  uint32_t tConnBase,
147  uint32_t tConnIncrPerUe,
148  uint32_t delayDiscStart,
149  bool useIdealRrc,
150  bool admitRrcConnectionRequest,
151  std::string description)
152 {
153  std::ostringstream oss;
154  oss << "nUes=" << nUes
155  << ", nBearers=" << nBearers
156  << ", tConnBase=" << tConnBase
157  << ", tConnIncrPerUe=" << tConnIncrPerUe
158  << ", delayDiscStart=" << delayDiscStart;
159 
160  if (useIdealRrc)
161  {
162  oss << ", ideal RRC";
163  }
164  else
165  {
166  oss << ", real RRC";
167  }
168 
169  if (admitRrcConnectionRequest)
170  {
171  oss << ", admitRrcConnectionRequest = true";
172  }
173  else
174  {
175  oss << ", admitRrcConnectionRequest = false";
176  }
177 
178  if (!description.empty ())
179  {
180  oss << ", " << description;
181  }
182 
183  return oss.str ();
184 }
185 
187  uint32_t nUes, uint32_t nBearers,
188  uint32_t tConnBase, uint32_t tConnIncrPerUe, uint32_t delayDiscStart,
189  bool errorExpected, bool useIdealRrc, bool admitRrcConnectionRequest,
190  std::string description)
191  : TestCase (BuildNameString (nUes, nBearers,
192  tConnBase, tConnIncrPerUe, delayDiscStart,
193  useIdealRrc, admitRrcConnectionRequest,
194  description)),
195  m_nUes (nUes),
196  m_nBearers (nBearers),
197  m_tConnBase (tConnBase),
198  m_tConnIncrPerUe (tConnIncrPerUe),
199 
200  m_delayDiscStart (delayDiscStart),
201  m_delayDiscEnd (10),
202  m_useIdealRrc (useIdealRrc),
203  m_admitRrcConnectionRequest (admitRrcConnectionRequest)
204 {
205  NS_LOG_FUNCTION (this << GetName ());
206 
207  // see the description of d^e in the LTE testing docs
208  double dsi = 90;
209  double nRaAttempts = 0;
210  if (nUes <= 20)
211  {
212  nRaAttempts += 5;
213  }
214  else
215  {
216  NS_ASSERT (nUes <= 50);
217  nRaAttempts += 10;
218  }
219 
220  nRaAttempts += std::ceil (nUes / 4.0);
221  double dra = nRaAttempts * 7;
222  double dce = 10.0 + (2.0 * nUes) / 4.0;
223  if (errorExpected)
224  {
225  /*
226  * If transmission error happens, the UE has to repeat again from
227  * acquiring system information.
228  */
229  dce += dsi + dce;
230  }
231  double nCrs;
232  if (nUes <= 2)
233  {
234  nCrs = 0;
235  }
236  else if (nUes <= 5)
237  {
238  nCrs = 1;
239  }
240  else if (nUes <= 10)
241  {
242  nCrs = 2;
243  }
244  else if (nUes <= 20)
245  {
246  nCrs = 3;
247  }
248  else
249  {
250  nCrs = 4;
251  }
252  double dcr = (10.0 + (2.0 * nUes) / 4.0) * (m_nBearers + nCrs);
253 
254  m_delayConnEnd = round (dsi + dra + dce + dcr);
255  NS_LOG_LOGIC (this << " " << GetName () << " dsi=" << dsi << " dra=" << dra << " dce=" << dce << " dcr=" << dcr << " m_delayConnEnd=" << m_delayConnEnd);
256 }
257 
258 void
260 {
261  NS_LOG_FUNCTION (this << GetName ());
262  Config::Reset ();
263 
264  if (m_nUes < 25)
265  {
266  Config::SetDefault ("ns3::LteEnbRrc::SrsPeriodicity", UintegerValue (40));
267  }
268  else if (m_nUes < 60)
269  {
270  Config::SetDefault ("ns3::LteEnbRrc::SrsPeriodicity", UintegerValue (80));
271  }
272  else if (m_nUes < 120)
273  {
274  Config::SetDefault ("ns3::LteEnbRrc::SrsPeriodicity", UintegerValue (160));
275  }
276  else
277  {
278  Config::SetDefault ("ns3::LteEnbRrc::SrsPeriodicity", UintegerValue (320));
279  }
280 
281  // normal code
282  m_lteHelper = CreateObject<LteHelper> ();
284 
285  NodeContainer enbNodes;
286  NodeContainer ueNodes;
287 
288 
289  enbNodes.Create (1);
290  ueNodes.Create (m_nUes);
291 
292  // the following positions all nodes at (0, 0, 0)
294  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
295  mobility.Install (enbNodes);
296  mobility.Install (ueNodes);
297 
298  int64_t stream = 1;
299  NetDeviceContainer enbDevs;
300  enbDevs = m_lteHelper->InstallEnbDevice (enbNodes);
301  stream += m_lteHelper->AssignStreams (enbDevs, stream);
302 
303  NetDeviceContainer ueDevs;
304  ueDevs = m_lteHelper->InstallUeDevice (ueNodes);
305  stream += m_lteHelper->AssignStreams (ueDevs, stream);
306 
307  // custom code used for testing purposes
308  // instead of lteHelper->Attach () and lteHelper->ActivateXxx
309 
310  // Set AdmitConnectionRequest attribute
311  for (NetDeviceContainer::Iterator it = enbDevs.Begin ();
312  it != enbDevs.End ();
313  ++it)
314  {
315  Ptr<LteEnbRrc> enbRrc = (*it)->GetObject<LteEnbNetDevice> ()->GetRrc ();
316  enbRrc->SetAttribute ("AdmitRrcConnectionRequest",
318  }
319 
320 
321  uint32_t i = 0;
322  uint32_t tmax = 0;
323  for (NetDeviceContainer::Iterator it = ueDevs.Begin (); it != ueDevs.End (); ++it)
324  {
325  Ptr<NetDevice> ueDevice = *it;
326  Ptr<NetDevice> enbDevice = enbDevs.Get (0);
327  Ptr<LteUeNetDevice> ueLteDevice = ueDevice->GetObject<LteUeNetDevice> ();
328 
329  uint32_t tc = m_tConnBase + m_tConnIncrPerUe * i; // time connection start
330  uint32_t tcc = tc + m_delayConnEnd; // time check connection completed;
331  uint32_t td = tcc + m_delayDiscStart; // time disconnect start
332  uint32_t tcd = td + m_delayDiscEnd; // time check disconnection completed
333  tmax = std::max (tmax, tcd);
334 
335  // trick to resolve overloading
336  //void (LteHelper::* overloadedAttachFunctionPointer) (Ptr<NetDevice>, Ptr<NetDevice>) = &LteHelper::Attach;
337  //Simulator::Schedule (MilliSeconds (tc), overloadedAttachFunctionPointer, lteHelper, *it, enbDevice);
338  Simulator::Schedule (MilliSeconds (tc), &LteRrcConnectionEstablishmentTestCase::Connect, this, ueDevice, enbDevice);
339 
340  Simulator::Schedule (MilliSeconds (tcc), &LteRrcConnectionEstablishmentTestCase::CheckConnected, this, *it, enbDevice);
341 
342  // disconnection not supported yet
343 
344  uint64_t imsi = ueLteDevice->GetImsi ();
345  m_isConnectionEstablished[imsi] = false;
346 
347  ++i;
348  }
349 
350  // Connect to trace sources in UEs
351  Config::Connect ("/NodeList/*/DeviceList/*/LteUeRrc/ConnectionEstablished",
353  this));
354  Config::Connect ("/NodeList/*/DeviceList/*/LteUeRrc/ConnectionTimeout",
356  this));
357 
358  Simulator::Stop (MilliSeconds (tmax + 1));
359 
360  Simulator::Run ();
361 
362  Simulator::Destroy ();
363 
364 }
365 
366 void
368 {
369  NS_LOG_FUNCTION (this);
370  m_lteHelper->Attach (ueDevice, enbDevice);
371 
372  for (uint32_t b = 0; b < m_nBearers; ++b)
373  {
374  enum EpsBearer::Qci q = EpsBearer::NGBR_VIDEO_TCP_DEFAULT;
375  EpsBearer bearer (q);
376  m_lteHelper->ActivateDataRadioBearer (ueDevice, bearer);
377  }
378 }
379 
380 void
382 {
383  Ptr<LteUeNetDevice> ueLteDevice = ueDevice->GetObject<LteUeNetDevice> ();
384  Ptr<LteUeRrc> ueRrc = ueLteDevice->GetRrc ();
385  const uint64_t imsi = ueLteDevice->GetImsi ();
386  const uint16_t rnti = ueRrc->GetRnti ();
387  NS_LOG_FUNCTION (this << imsi << rnti);
389  "Invalid IMSI " << imsi);
390 
392  {
394  "Connection with RNTI " << rnti << " should have been rejected");
395  return;
396  }
397 
398  /*
399  * Verifying UE state in UE RRC. Try to increase the test case duration if
400  * the following checks.
401  */
403  "RNTI " << rnti << " fails to establish connection");
404  NS_TEST_ASSERT_MSG_EQ (ueRrc->GetState (), LteUeRrc::CONNECTED_NORMALLY,
405  "RNTI " << rnti << " is not at CONNECTED_NORMALLY state");
406 
407  // Verifying UE context state in eNodeB RRC.
408 
409  Ptr<LteEnbNetDevice> enbLteDevice = enbDevice->GetObject<LteEnbNetDevice> ();
410  Ptr<LteEnbRrc> enbRrc = enbLteDevice->GetRrc ();
411  const bool hasContext = enbRrc->HasUeManager (rnti);
412 
413  if (hasContext)
414  {
415  Ptr<UeManager> ueManager = enbRrc->GetUeManager (rnti);
416  NS_ASSERT (ueManager != 0);
417  NS_TEST_ASSERT_MSG_EQ (ueManager->GetState (),
418  UeManager::CONNECTED_NORMALLY,
419  "The context of RNTI " << rnti << " is in invalid state");
420  }
421  else
422  {
423  NS_LOG_WARN (this << " RNTI " << rnti << " thinks that it has"
424  << " established connection but the eNodeB thinks"
425  << " that the UE has failed on connection setup.");
426  /*
427  * The standard specifies that this case would exceed the maximum
428  * retransmission limit at UE RLC (SRB1), which will then trigger an RLF.
429  * However, this behaviour is not implemented yet.
430  */
431  }
432 
433  // Verifying other attributes on both sides.
434 
435  uint16_t ueCellId = ueRrc->GetCellId ();
436  uint16_t enbCellId = enbLteDevice->GetCellId ();
437  uint16_t ueImsi = ueLteDevice->GetImsi ();
438 
439  uint8_t ueDlBandwidth = ueRrc->GetDlBandwidth ();
440  uint8_t enbDlBandwidth = enbLteDevice->GetDlBandwidth ();
441  uint8_t ueUlBandwidth = ueRrc->GetUlBandwidth ();
442  uint8_t enbUlBandwidth = enbLteDevice->GetUlBandwidth ();
443  uint8_t ueDlEarfcn = ueRrc->GetDlEarfcn ();
444  uint8_t enbDlEarfcn = enbLteDevice->GetDlEarfcn ();
445  uint8_t ueUlEarfcn = ueRrc->GetUlEarfcn ();
446  uint8_t enbUlEarfcn = enbLteDevice->GetUlEarfcn ();
447 
448  NS_TEST_ASSERT_MSG_EQ (ueCellId, enbCellId, "inconsistent CellId");
449  NS_TEST_ASSERT_MSG_EQ (ueDlBandwidth, enbDlBandwidth, "inconsistent DlBandwidth");
450  NS_TEST_ASSERT_MSG_EQ (ueUlBandwidth, enbUlBandwidth, "inconsistent UlBandwidth");
451  NS_TEST_ASSERT_MSG_EQ (ueDlEarfcn, enbDlEarfcn, "inconsistent DlEarfcn");
452  NS_TEST_ASSERT_MSG_EQ (ueUlEarfcn, enbUlEarfcn, "inconsistent UlEarfcn");
453 
454  if (hasContext)
455  {
456  Ptr<UeManager> ueManager = enbRrc->GetUeManager (rnti);
457  NS_ASSERT (ueManager != 0);
458  UeManager::State state = ueManager->GetState ();
459  uint16_t enbImsi = ueManager->GetImsi ();
460  NS_TEST_ASSERT_MSG_EQ (ueImsi, enbImsi, "inconsistent Imsi");
461 
462  if (state == UeManager::CONNECTED_NORMALLY)
463  {
464  ObjectMapValue enbDataRadioBearerMapValue;
465  ueManager->GetAttribute ("DataRadioBearerMap", enbDataRadioBearerMapValue);
466  NS_TEST_ASSERT_MSG_EQ (enbDataRadioBearerMapValue.GetN (), m_nBearers, "wrong num bearers at eNB");
467  ObjectMapValue ueDataRadioBearerMapValue;
468  ueRrc->GetAttribute ("DataRadioBearerMap", ueDataRadioBearerMapValue);
469  NS_TEST_ASSERT_MSG_EQ (ueDataRadioBearerMapValue.GetN (), m_nBearers, "wrong num bearers at UE");
470 
471  ObjectMapValue::Iterator enbBearerIt = enbDataRadioBearerMapValue.Begin ();
472  ObjectMapValue::Iterator ueBearerIt = ueDataRadioBearerMapValue.Begin ();
473  while (enbBearerIt != enbDataRadioBearerMapValue.End ()
474  && ueBearerIt != ueDataRadioBearerMapValue.End ())
475  {
476  Ptr<LteDataRadioBearerInfo> enbDrbInfo = enbBearerIt->second->GetObject<LteDataRadioBearerInfo> ();
477  Ptr<LteDataRadioBearerInfo> ueDrbInfo = ueBearerIt->second->GetObject<LteDataRadioBearerInfo> ();
478  //NS_TEST_ASSERT_MSG_EQ (enbDrbInfo->m_epsBearer, ueDrbInfo->m_epsBearer, "epsBearer differs");
479  NS_TEST_ASSERT_MSG_EQ ((uint32_t) enbDrbInfo->m_epsBearerIdentity, (uint32_t) ueDrbInfo->m_epsBearerIdentity, "epsBearerIdentity differs");
480  NS_TEST_ASSERT_MSG_EQ ((uint32_t) enbDrbInfo->m_drbIdentity, (uint32_t) ueDrbInfo->m_drbIdentity, "drbIdentity differs");
481  //NS_TEST_ASSERT_MSG_EQ (enbDrbInfo->m_rlcConfig, ueDrbInfo->m_rlcConfig, "rlcConfig differs");
482  NS_TEST_ASSERT_MSG_EQ ((uint32_t) enbDrbInfo->m_logicalChannelIdentity, (uint32_t) ueDrbInfo->m_logicalChannelIdentity, "logicalChannelIdentity differs");
483  //NS_TEST_ASSERT_MSG_EQ (enbDrbInfo->m_logicalChannelConfig, ueDrbInfo->m_logicalChannelConfig, "logicalChannelConfig differs");
484 
485  ++enbBearerIt;
486  ++ueBearerIt;
487  }
488 
489  NS_ASSERT_MSG (enbBearerIt == enbDataRadioBearerMapValue.End (), "too many bearers at eNB");
490  NS_ASSERT_MSG (ueBearerIt == ueDataRadioBearerMapValue.End (), "too many bearers at UE");
491  }
492  }
493 }
494 
495 void
497 {
498  Ptr<LteUeNetDevice> ueLteDevice = ueDevice->GetObject<LteUeNetDevice> ();
499  Ptr<LteUeRrc> ueRrc = ueLteDevice->GetRrc ();
500  const uint64_t imsi = ueLteDevice->GetImsi ();
501  const uint16_t rnti = ueRrc->GetRnti ();
502  NS_LOG_FUNCTION (this << imsi << rnti);
504  "Invalid IMSI " << imsi);
505 
506  bool ueStateIsConnectedNormally = (LteUeRrc::CONNECTED_NORMALLY == ueRrc->GetState ());
507 
508  Ptr<LteEnbNetDevice> enbLteDevice = enbDevice->GetObject<LteEnbNetDevice> ();
509  Ptr<LteEnbRrc> enbRrc = enbLteDevice->GetRrc ();
510  const bool hasContext = enbRrc->HasUeManager (rnti);
511  bool contextStateIsConnectedNormally = false;
512  if (hasContext)
513  {
514  Ptr<UeManager> ueManager = enbRrc->GetUeManager (rnti);
515  NS_ASSERT (ueManager != 0);
516  contextStateIsConnectedNormally = (UeManager::CONNECTED_NORMALLY == ueManager->GetState ());
517  }
519  || !ueStateIsConnectedNormally
520  || !hasContext
521  || !contextStateIsConnectedNormally),
522  true,
523  "it should not happen that connection is completed both at the UE and at the eNB side");
524 }
525 
526 void
528  std::string context, uint64_t imsi, uint16_t cellId, uint16_t rnti)
529 {
530  NS_LOG_FUNCTION (this << imsi << cellId);
531  m_isConnectionEstablished[imsi] = true;
532 }
533 
534 
535 void
537  std::string context, uint64_t imsi, uint16_t cellId, uint16_t rnti)
538 {
539  NS_LOG_FUNCTION (this << imsi << cellId);
540 }
541 
542 
543 
552 {
553 public:
562  std::string description = "");
563 protected:
564  virtual void DoRun (void);
565 
566 private:
568  void JumpAway ();
570  void JumpBack ();
571 
574 };
575 
576 
578  Time jumpAwayTime, std::string description)
579  : LteRrcConnectionEstablishmentTestCase (1, 1, 0, 0, 1, true, false, true,
580  description),
581  m_jumpAwayTime (jumpAwayTime)
582 {
583  NS_LOG_FUNCTION (this << GetName ());
584 }
585 
586 
587 void
589 {
590  NS_LOG_FUNCTION (this << GetName ());
591  Config::Reset ();
592 
593  if (m_nUes < 25)
594  {
595  Config::SetDefault ("ns3::LteEnbRrc::SrsPeriodicity", UintegerValue (40));
596  }
597  else if (m_nUes < 60)
598  {
599  Config::SetDefault ("ns3::LteEnbRrc::SrsPeriodicity", UintegerValue (80));
600  }
601  else if (m_nUes < 120)
602  {
603  Config::SetDefault ("ns3::LteEnbRrc::SrsPeriodicity", UintegerValue (160));
604  }
605  else
606  {
607  Config::SetDefault ("ns3::LteEnbRrc::SrsPeriodicity", UintegerValue (320));
608  }
609 
610  // normal code
611  m_lteHelper = CreateObject<LteHelper> ();
613 
614  NodeContainer enbNodes;
615  NodeContainer ueNodes;
616 
617 
618  enbNodes.Create (4);
619  ueNodes.Create (1);
620 
622  mobility.Install (ueNodes); // UE position at (0, 0, 0)
623  m_ueMobility = ueNodes.Get (0)->GetObject<MobilityModel> ();
624 
625  Ptr<ListPositionAllocator> enbPosition = CreateObject<ListPositionAllocator> ();
626  enbPosition->Add (Vector (0, 0, 0));
627  enbPosition->Add (Vector (100.0, 0, 0));
628  enbPosition->Add (Vector (0, 100.0, 0));
629  enbPosition->Add (Vector (100.0, 100.0, 0));
630  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
631  mobility.SetPositionAllocator (enbPosition);
632  mobility.Install (enbNodes);
633 
634  int64_t stream = 1;
635  NetDeviceContainer enbDevs;
636  enbDevs = m_lteHelper->InstallEnbDevice (enbNodes);
637  stream += m_lteHelper->AssignStreams (enbDevs, stream);
638 
639  NetDeviceContainer ueDevs;
640  ueDevs = m_lteHelper->InstallUeDevice (ueNodes);
641  stream += m_lteHelper->AssignStreams (ueDevs, stream);
642 
643  // custom code used for testing purposes
644  // instead of lteHelper->Attach () and lteHelper->ActivateXxx
645 
646  // Set AdmitConnectionRequest attribute
647  for (NetDeviceContainer::Iterator it = enbDevs.Begin ();
648  it != enbDevs.End ();
649  ++it)
650  {
651  Ptr<LteEnbRrc> enbRrc = (*it)->GetObject<LteEnbNetDevice> ()->GetRrc ();
652  enbRrc->SetAttribute ("AdmitRrcConnectionRequest",
654  }
655 
656 
657  uint32_t i = 0;
658  uint32_t tmax = 0;
659  for (NetDeviceContainer::Iterator it = ueDevs.Begin (); it != ueDevs.End (); ++it)
660  {
661  Ptr<NetDevice> ueDevice = *it;
662  Ptr<NetDevice> enbDevice = enbDevs.Get (0);
663  Ptr<LteUeNetDevice> ueLteDevice = ueDevice->GetObject<LteUeNetDevice> ();
664 
665  uint32_t tc = m_tConnBase + m_tConnIncrPerUe * i; // time connection start
666  uint32_t tcc = tc + m_delayConnEnd; // time check connection completed;
667  uint32_t td = tcc + m_delayDiscStart; // time disconnect start
668  uint32_t tcd = td + m_delayDiscEnd; // time check disconnection completed
669  tmax = std::max (tmax, tcd);
670 
671  // trick to resolve overloading
672  //void (LteHelper::* overloadedAttachFunctionPointer) (Ptr<NetDevice>, Ptr<NetDevice>) = &LteHelper::Attach;
673  //Simulator::Schedule (MilliSeconds (tc), overloadedAttachFunctionPointer, lteHelper, *it, enbDevice);
674  Simulator::Schedule (MilliSeconds (tc), &LteRrcConnectionEstablishmentErrorTestCase::Connect, this, ueDevice, enbDevice);
675 
676  Simulator::Schedule (MilliSeconds (tcc), &LteRrcConnectionEstablishmentErrorTestCase::CheckConnected, this, *it, enbDevice);
677 
678  // disconnection not supported yet
679 
680  uint64_t imsi = ueLteDevice->GetImsi ();
681  m_isConnectionEstablished[imsi] = false;
682 
683  ++i;
684  }
685 
686  // Connect to trace sources in UEs
687  Config::Connect ("/NodeList/*/DeviceList/*/LteUeRrc/ConnectionEstablished",
689  this));
690  Config::Connect ("/NodeList/*/DeviceList/*/LteUeRrc/ConnectionTimeout",
692  this));
693 
694 
695  Simulator::Schedule (m_jumpAwayTime,
697  this);
698  Simulator::Schedule (m_jumpAwayTime + MilliSeconds (99),
700  this, ueDevs.Get (0), enbDevs.Get (0));
701  Simulator::Schedule (m_jumpAwayTime + MilliSeconds (100),
703  this);
704 
705  Simulator::Stop (MilliSeconds (tmax + 1));
706 
707  Simulator::Run ();
708 
709  Simulator::Destroy ();
710 
711 }
712 
713 
714 void
716 {
717  NS_LOG_FUNCTION (this);
718  // move to a really far away location so that transmission errors occur
719  m_ueMobility->SetPosition (Vector (100000.0, 100000.0, 0.0));
720 }
721 
722 
723 void
725 {
726  NS_LOG_FUNCTION (this);
727  m_ueMobility->SetPosition (Vector (0.0, 0.0, 0.0));
728 }
729 
730 
738 {
739 public:
740  LteRrcTestSuite ();
741 };
742 
743 
745  : TestSuite ("lte-rrc", SYSTEM)
746 {
747 // LogComponentEnableAll (LOG_PREFIX_ALL);
748 // LogComponentEnable ("LteRrcTest", LOG_LEVEL_ALL);
749 // LogComponentEnable ("LteEnbRrc", LOG_INFO);
750 // LogComponentEnable ("LteUeRrc", LOG_INFO);
751 
752  NS_LOG_FUNCTION (this);
753 
754  for (uint32_t useIdealRrc = 0; useIdealRrc <= 1; ++useIdealRrc)
755  {
756  // <----- all times in ms ----------------->
757 
758  // nUes tConnBase delayDiscStart useIdealRrc
759  // nBearers tConnIncrPerUe errorExpected admitRrcConnectionRequest
760  AddTestCase (new LteRrcConnectionEstablishmentTestCase ( 1, 0, 0, 0, 1, false, useIdealRrc, true), TestCase::EXTENSIVE);
761  AddTestCase (new LteRrcConnectionEstablishmentTestCase ( 1, 0, 100, 0, 1, false, useIdealRrc, true), TestCase::EXTENSIVE);
762  AddTestCase (new LteRrcConnectionEstablishmentTestCase ( 1, 1, 0, 0, 1, false, useIdealRrc, true), TestCase::EXTENSIVE);
763  AddTestCase (new LteRrcConnectionEstablishmentTestCase ( 1, 1, 100, 0, 1, false, useIdealRrc, true), TestCase::EXTENSIVE);
764  AddTestCase (new LteRrcConnectionEstablishmentTestCase ( 1, 2, 0, 0, 1, false, useIdealRrc, true), TestCase::EXTENSIVE);
765  AddTestCase (new LteRrcConnectionEstablishmentTestCase ( 1, 2, 100, 0, 1, false, useIdealRrc, true), TestCase::EXTENSIVE);
766  AddTestCase (new LteRrcConnectionEstablishmentTestCase ( 2, 0, 20, 0, 1, false, useIdealRrc, true), TestCase::EXTENSIVE);
767  AddTestCase (new LteRrcConnectionEstablishmentTestCase ( 2, 0, 20, 10, 1, false, useIdealRrc, true), TestCase::EXTENSIVE);
768  AddTestCase (new LteRrcConnectionEstablishmentTestCase ( 2, 0, 20, 100, 1, false, useIdealRrc, true), TestCase::EXTENSIVE);
769  AddTestCase (new LteRrcConnectionEstablishmentTestCase ( 2, 1, 20, 0, 1, false, useIdealRrc, true), TestCase::EXTENSIVE);
770  AddTestCase (new LteRrcConnectionEstablishmentTestCase ( 2, 1, 20, 10, 1, false, useIdealRrc, true), TestCase::EXTENSIVE);
771  AddTestCase (new LteRrcConnectionEstablishmentTestCase ( 2, 1, 20, 100, 1, false, useIdealRrc, true), TestCase::EXTENSIVE);
772  AddTestCase (new LteRrcConnectionEstablishmentTestCase ( 2, 2, 20, 0, 1, false, useIdealRrc, true), TestCase::EXTENSIVE);
773  AddTestCase (new LteRrcConnectionEstablishmentTestCase ( 2, 2, 20, 10, 1, false, useIdealRrc, true), TestCase::QUICK);
774  AddTestCase (new LteRrcConnectionEstablishmentTestCase ( 2, 2, 20, 100, 1, false, useIdealRrc, true), TestCase::EXTENSIVE);
775  AddTestCase (new LteRrcConnectionEstablishmentTestCase ( 3, 0, 20, 0, 1, false, useIdealRrc, true), TestCase::EXTENSIVE);
776  AddTestCase (new LteRrcConnectionEstablishmentTestCase ( 4, 0, 20, 0, 1, false, useIdealRrc, true), TestCase::EXTENSIVE);
777  AddTestCase (new LteRrcConnectionEstablishmentTestCase ( 4, 0, 20, 300, 1, false, useIdealRrc, true), TestCase::EXTENSIVE);
778  AddTestCase (new LteRrcConnectionEstablishmentTestCase ( 20, 0, 10, 1, 1, false, useIdealRrc, true), TestCase::EXTENSIVE);
779  AddTestCase (new LteRrcConnectionEstablishmentTestCase ( 50, 0, 0, 0, 1, false, useIdealRrc, true), TestCase::EXTENSIVE);
780 
781  // Test cases to check admitRrcConnectionRequest=false
782  // nUes tConnBase delayDiscStart useIdealRrc
783  // nBearers tConnIncrPerUe errorExpected admitRrcConnectionRequest
784  AddTestCase (new LteRrcConnectionEstablishmentTestCase ( 1, 0, 0, 0, 1, false, useIdealRrc, false), TestCase::EXTENSIVE);
785  AddTestCase (new LteRrcConnectionEstablishmentTestCase ( 1, 2, 100, 0, 1, false, useIdealRrc, false), TestCase::EXTENSIVE);
786  AddTestCase (new LteRrcConnectionEstablishmentTestCase ( 2, 0, 20, 0, 1, false, useIdealRrc, false), TestCase::EXTENSIVE);
787  AddTestCase (new LteRrcConnectionEstablishmentTestCase ( 2, 1, 20, 0, 1, false, useIdealRrc, false), TestCase::QUICK);
788  AddTestCase (new LteRrcConnectionEstablishmentTestCase ( 3, 0, 20, 0, 1, false, useIdealRrc, false), TestCase::EXTENSIVE);
789  }
790 
791  // Test cases with transmission error
793  Seconds (0.020214),
794  "failure at RRC Connection Request"),
795  TestCase::QUICK);
797  Seconds (0.025),
798  "failure at RRC Connection Setup"),
799  TestCase::QUICK);
800  /*
801  * The following test case is related to the Idle mode, which is an
802  * unsupported feature at the moment. See also Bug 1762 Comment #25.
803  */
804  // AddTestCase (new LteRrcConnectionEstablishmentErrorTestCase (
805  // Seconds (0.030),
806  // "failure at RRC Connection Setup Complete"),
807  // TestCase::QUICK);
808 
809 }
810 
uint32_t m_delayConnEnd
expected duration to perform connection establishment in ms
LteRrcConnectionEstablishmentErrorTestCase(Time jumpAwayTime, std::string description="")
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
std::map< uint64_t, bool > m_isConnectionEstablished
key: IMSI
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
uint32_t m_tConnIncrPerUe
additional connection time increment for each UE index (0...nUes-1) in ms
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)
Check connected function.
uint32_t m_delayDiscEnd
expected duration to complete disconnection in ms
State
The state of the UeManager at the eNB RRC.
Definition: lte-enb-rrc.h:84
AttributeValue implementation for Boolean.
Definition: boolean.h:36
uint32_t m_tConnBase
connection time base value for all UEs in ms
NetDeviceContainer InstallEnbDevice(NodeContainer c)
Create a set of eNodeB devices.
Definition: lte-helper.cc:474
Iterator End(void) const
Get an iterator which indicates past-the-last NetDevice in the container.
NS_ASSERT_MSG(false, "Ipv4AddressGenerator::MaskToIndex(): Impossible")
void ConnectionEstablishedCallback(std::string context, uint64_t imsi, uint16_t cellId, uint16_t rnti)
Connection established callback function.
A suite of tests to run.
Definition: test.h:1342
bool m_useIdealRrc
If set to false, real RRC protocol model will be used.
#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
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:957
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1022
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="")
State GetState() const
uint64_t GetImsi(void) const
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:1439
void ActivateDataRadioBearer(NetDeviceContainer ueDevices, EpsBearer bearer)
Activate a Data Radio Bearer on a given UE devices (for LTE-only simulation).
Definition: lte-helper.cc:1310
uint32_t m_nBearers
number of bearers to be setup in each connection
mobility
Definition: third.py:101
Keep track of the current position and velocity of an object.
uint64_t GetImsi() const
Get the IMSI.
Ptr< MobilityModel > m_ueMobility
UE mobility model.
This class contains the specification of EPS Bearers.
Definition: eps-bearer.h:71
store information on active data radio bearer instance
uint8_t m_logicalChannelIdentity
logical channel identity
#define max(a, b)
Definition: 80211b.c:43
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:299
Iterator Begin(void) const
Get an iterator which refers to the first NetDevice in the container.
Ptr< LteHelper > m_lteHelper
LTE helper.
Iterator Begin(void) const
Get an iterator to the first Object.
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:168
std::map< std::size_t, Ptr< Object > >::const_iterator Iterator
Iterator type for traversing this container.
holds a vector of ns3::NetDevice pointers
Iterator End(void) const
Get an iterator to the past-the-end Object.
bool m_admitRrcConnectionRequest
If set to false, eNb will not allow UE connections.
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
Definition: callback.h:1489
uint32_t m_delayDiscStart
delay between connection completed and disconnection request in ms
std::size_t GetN(void) const
Get the number of Objects.
void Connect(std::string path, const CallbackBase &cb)
Definition: config.cc:843
Lte Rrc Test Suite.
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Definition: object.h:459
Every class exported by the ns3 library is enclosed in the ns3 namespace.
keep track of a set of node pointers.
uint32_t m_nUes
number of UEs in the test
Definition: test-lte-rrc.cc:68
void ConnectionTimeoutCallback(std::string context, uint64_t imsi, uint16_t cellId, uint16_t rnti)
Connection timeout callback function.
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="")
Build name string function.
void SetPosition(const Vector &position)
NS_LOG_LOGIC("Net device "<< nd<< " is not bridged")
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:757
NetDeviceContainer InstallUeDevice(NodeContainer c)
Create a set of UE devices.
Definition: lte-helper.cc:489
Helper class used to assign positions and mobility models to nodes.
std::string GetName(void) const
Definition: test.cc:370
static LteRrcTestSuite g_lteRrcTestSuiteInstance
uint8_t m_drbIdentity
DRB identity.
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Definition: log.h:262
std::vector< Ptr< NetDevice > >::const_iterator Iterator
NetDevice container iterator.
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1014
void SetDefault(std::string name, const AttributeValue &value)
Definition: config.cc:782
void Connect(Ptr< NetDevice > ueDevice, Ptr< NetDevice > enbDevice)
Connect function.
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.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Lte Rrc Connection Establishment Error Test Case.
Container for a set of ns3::Object pointers.
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:185
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
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)
Check not connected function.
Test rrc connection establishment.
Definition: test-lte-rrc.cc:39
uint8_t m_epsBearerIdentity
EPS bearer identity.
virtual void DoRun(void)
Implementation to actually run this TestCase.
The LteUeNetDevice class implements the UE net device.