A Discrete-Event Network Simulator
API
test-lte-rrc.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation;
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  *
17  * Author: Nicola Baldo <nbaldo@cttc.es>
18  * Budiarto Herman <budiarto.herman@magister.fi>
19  */
20 
21 #include <ns3/core-module.h>
22 #include <ns3/lte-module.h>
23 #include <ns3/mobility-module.h>
24 #include <ns3/network-module.h>
25 
26 #include <cmath>
27 
28 using namespace ns3;
29 
30 NS_LOG_COMPONENT_DEFINE("LteRrcTest");
31 
38 {
39  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  void DoRun() override;
67  uint32_t m_nUes;
68 
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,
117  uint64_t imsi,
118  uint16_t cellId,
119  uint16_t rnti);
128  void ConnectionTimeoutCallback(std::string context,
129  uint64_t imsi,
130  uint16_t cellId,
131  uint16_t rnti,
132  uint8_t connEstFailCount);
133 
134  uint32_t m_nBearers;
135  uint32_t m_tConnBase;
136  uint32_t m_tConnIncrPerUe;
138  uint32_t m_delayConnEnd;
139  uint32_t
141  uint32_t m_delayDiscEnd;
145 
147  std::map<uint64_t, bool> m_isConnectionEstablished;
148 };
149 
150 std::string
152  uint32_t nBearers,
153  uint32_t tConnBase,
154  uint32_t tConnIncrPerUe,
155  uint32_t delayDiscStart,
156  bool useIdealRrc,
157  bool admitRrcConnectionRequest,
158  std::string description)
159 {
160  std::ostringstream oss;
161  oss << "nUes=" << nUes << ", nBearers=" << nBearers << ", tConnBase=" << tConnBase
162  << ", tConnIncrPerUe=" << tConnIncrPerUe << ", delayDiscStart=" << delayDiscStart;
163 
164  if (useIdealRrc)
165  {
166  oss << ", ideal RRC";
167  }
168  else
169  {
170  oss << ", real RRC";
171  }
172 
173  if (admitRrcConnectionRequest)
174  {
175  oss << ", admitRrcConnectionRequest = true";
176  }
177  else
178  {
179  oss << ", admitRrcConnectionRequest = false";
180  }
181 
182  if (!description.empty())
183  {
184  oss << ", " << description;
185  }
186 
187  return oss.str();
188 }
189 
191  uint32_t nUes,
192  uint32_t nBearers,
193  uint32_t tConnBase,
194  uint32_t tConnIncrPerUe,
195  uint32_t delayDiscStart,
196  bool errorExpected,
197  bool useIdealRrc,
198  bool admitRrcConnectionRequest,
199  std::string description)
200  : TestCase(BuildNameString(nUes,
201  nBearers,
202  tConnBase,
203  tConnIncrPerUe,
204  delayDiscStart,
205  useIdealRrc,
206  admitRrcConnectionRequest,
207  description)),
208  m_nUes(nUes),
209  m_nBearers(nBearers),
210  m_tConnBase(tConnBase),
211  m_tConnIncrPerUe(tConnIncrPerUe),
212 
213  m_delayDiscStart(delayDiscStart),
214  m_delayDiscEnd(10),
215  m_useIdealRrc(useIdealRrc),
216  m_admitRrcConnectionRequest(admitRrcConnectionRequest)
217 {
218  NS_LOG_FUNCTION(this << GetName());
219 
220  // see the description of d^e in the LTE testing docs
221  double dsi = 90;
222  double nRaAttempts = 0;
223  if (nUes <= 20)
224  {
225  nRaAttempts += 5;
226  }
227  else
228  {
229  NS_ASSERT(nUes <= 50);
230  nRaAttempts += 10;
231  }
232 
233  nRaAttempts += std::ceil(nUes / 4.0);
234  double dra = nRaAttempts * 7;
235  double dce = 10.0 + (2.0 * nUes) / 4.0;
236  if (errorExpected)
237  {
238  /*
239  * If transmission error happens, the UE has to repeat again from
240  * acquiring system information.
241  */
242  dce += dsi + dce;
243  }
244  double nCrs;
245  if (nUes <= 2)
246  {
247  nCrs = 0;
248  }
249  else if (nUes <= 5)
250  {
251  nCrs = 1;
252  }
253  else if (nUes <= 10)
254  {
255  nCrs = 2;
256  }
257  else if (nUes <= 20)
258  {
259  nCrs = 3;
260  }
261  else
262  {
263  nCrs = 4;
264  }
265  double dcr = (10.0 + (2.0 * nUes) / 4.0) * (m_nBearers + nCrs);
266 
267  m_delayConnEnd = round(dsi + dra + dce + dcr);
268  NS_LOG_LOGIC(this << " " << GetName() << " dsi=" << dsi << " dra=" << dra << " dce=" << dce
269  << " dcr=" << dcr << " m_delayConnEnd=" << m_delayConnEnd);
270 }
271 
272 void
274 {
275  NS_LOG_FUNCTION(this << GetName());
276  Config::Reset();
277 
278  if (m_nUes < 25)
279  {
280  Config::SetDefault("ns3::LteEnbRrc::SrsPeriodicity", UintegerValue(40));
281  }
282  else if (m_nUes < 60)
283  {
284  Config::SetDefault("ns3::LteEnbRrc::SrsPeriodicity", UintegerValue(80));
285  }
286  else if (m_nUes < 120)
287  {
288  Config::SetDefault("ns3::LteEnbRrc::SrsPeriodicity", UintegerValue(160));
289  }
290  else
291  {
292  Config::SetDefault("ns3::LteEnbRrc::SrsPeriodicity", UintegerValue(320));
293  }
294 
295  // normal code
296  m_lteHelper = CreateObject<LteHelper>();
298 
299  NodeContainer enbNodes;
300  NodeContainer ueNodes;
301 
302  enbNodes.Create(1);
303  ueNodes.Create(m_nUes);
304 
305  // the following positions all nodes at (0, 0, 0)
307  mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
308  mobility.Install(enbNodes);
309  mobility.Install(ueNodes);
310 
311  int64_t stream = 1;
312  NetDeviceContainer enbDevs;
313  enbDevs = m_lteHelper->InstallEnbDevice(enbNodes);
314  stream += m_lteHelper->AssignStreams(enbDevs, stream);
315 
316  NetDeviceContainer ueDevs;
317  ueDevs = m_lteHelper->InstallUeDevice(ueNodes);
318  stream += m_lteHelper->AssignStreams(ueDevs, stream);
319 
320  // custom code used for testing purposes
321  // instead of lteHelper->Attach () and lteHelper->ActivateXxx
322 
323  // Set AdmitConnectionRequest attribute
324  for (auto it = enbDevs.Begin(); it != enbDevs.End(); ++it)
325  {
326  Ptr<LteEnbRrc> enbRrc = (*it)->GetObject<LteEnbNetDevice>()->GetRrc();
327  enbRrc->SetAttribute("AdmitRrcConnectionRequest",
329  }
330 
331  uint32_t i = 0;
332  uint32_t tmax = 0;
333  for (auto it = ueDevs.Begin(); it != ueDevs.End(); ++it)
334  {
335  Ptr<NetDevice> ueDevice = *it;
336  Ptr<NetDevice> enbDevice = enbDevs.Get(0);
337  Ptr<LteUeNetDevice> ueLteDevice = ueDevice->GetObject<LteUeNetDevice>();
338 
339  uint32_t tc = m_tConnBase + m_tConnIncrPerUe * i; // time connection start
340  uint32_t tcc = tc + m_delayConnEnd; // time check connection completed;
341  uint32_t td = tcc + m_delayDiscStart; // time disconnect start
342  uint32_t tcd = td + m_delayDiscEnd; // time check disconnection completed
343  tmax = std::max(tmax, tcd);
344 
345  // trick to resolve overloading
346  // void (LteHelper::* overloadedAttachFunctionPointer) (Ptr<NetDevice>, Ptr<NetDevice>) =
347  // &LteHelper::Attach; Simulator::Schedule (MilliSeconds (tc),
348  // overloadedAttachFunctionPointer, lteHelper, *it, enbDevice);
349  Simulator::Schedule(MilliSeconds(tc),
351  this,
352  ueDevice,
353  enbDevice);
354 
355  Simulator::Schedule(MilliSeconds(tcc),
357  this,
358  *it,
359  enbDevice);
360 
361  // disconnection not supported yet
362 
363  uint64_t imsi = ueLteDevice->GetImsi();
364  m_isConnectionEstablished[imsi] = false;
365 
366  ++i;
367  }
368 
369  // Connect to trace sources in UEs
371  "/NodeList/*/DeviceList/*/LteUeRrc/ConnectionEstablished",
374  "/NodeList/*/DeviceList/*/LteUeRrc/ConnectionTimeout",
376 
377  Simulator::Stop(MilliSeconds(tmax + 1));
378 
379  Simulator::Run();
380 
381  Simulator::Destroy();
382 }
383 
384 void
386 {
387  NS_LOG_FUNCTION(this);
388  m_lteHelper->Attach(ueDevice, enbDevice);
389 
390  for (uint32_t b = 0; b < m_nBearers; ++b)
391  {
392  EpsBearer::Qci q = EpsBearer::NGBR_VIDEO_TCP_DEFAULT;
393  EpsBearer bearer(q);
394  m_lteHelper->ActivateDataRadioBearer(ueDevice, bearer);
395  }
396 }
397 
398 void
400  Ptr<NetDevice> enbDevice)
401 {
402  Ptr<LteUeNetDevice> ueLteDevice = ueDevice->GetObject<LteUeNetDevice>();
403  Ptr<LteUeRrc> ueRrc = ueLteDevice->GetRrc();
404  const uint64_t imsi = ueLteDevice->GetImsi();
405  const uint16_t rnti = ueRrc->GetRnti();
406  NS_LOG_FUNCTION(this << imsi << rnti);
408  "Invalid IMSI " << imsi);
409 
411  {
413  false,
414  "Connection with RNTI " << rnti << " should have been rejected");
415  return;
416  }
417 
418  /*
419  * Verifying UE state in UE RRC. Try to increase the test case duration if
420  * the following checks.
421  */
423  true,
424  "RNTI " << rnti << " fails to establish connection");
425  NS_TEST_ASSERT_MSG_EQ(ueRrc->GetState(),
426  LteUeRrc::CONNECTED_NORMALLY,
427  "RNTI " << rnti << " is not at CONNECTED_NORMALLY state");
428 
429  // Verifying UE context state in eNodeB RRC.
430 
431  Ptr<LteEnbNetDevice> enbLteDevice = enbDevice->GetObject<LteEnbNetDevice>();
432  Ptr<LteEnbRrc> enbRrc = enbLteDevice->GetRrc();
433  const bool hasContext = enbRrc->HasUeManager(rnti);
434 
435  if (hasContext)
436  {
437  Ptr<UeManager> ueManager = enbRrc->GetUeManager(rnti);
438  NS_ASSERT(ueManager);
439  NS_TEST_ASSERT_MSG_EQ(ueManager->GetState(),
440  UeManager::CONNECTED_NORMALLY,
441  "The context of RNTI " << rnti << " is in invalid state");
442  }
443  else
444  {
445  NS_LOG_WARN(this << " RNTI " << rnti << " thinks that it has"
446  << " established connection but the eNodeB thinks"
447  << " that the UE has failed on connection setup.");
448  /*
449  * The standard specifies that this case would exceed the maximum
450  * retransmission limit at UE RLC (SRB1), which will then trigger an RLF.
451  * However, this behaviour is not implemented yet.
452  */
453  }
454 
455  // Verifying other attributes on both sides.
456 
457  uint16_t ueCellId = ueRrc->GetCellId();
458  uint16_t enbCellId = enbLteDevice->GetCellId();
459  uint16_t ueImsi = ueLteDevice->GetImsi();
460 
461  uint8_t ueDlBandwidth = ueRrc->GetDlBandwidth();
462  uint8_t enbDlBandwidth = enbLteDevice->GetDlBandwidth();
463  uint8_t ueUlBandwidth = ueRrc->GetUlBandwidth();
464  uint8_t enbUlBandwidth = enbLteDevice->GetUlBandwidth();
465  uint8_t ueDlEarfcn = ueRrc->GetDlEarfcn();
466  uint8_t enbDlEarfcn = enbLteDevice->GetDlEarfcn();
467  uint8_t ueUlEarfcn = ueRrc->GetUlEarfcn();
468  uint8_t enbUlEarfcn = enbLteDevice->GetUlEarfcn();
469 
470  NS_TEST_ASSERT_MSG_EQ(ueCellId, enbCellId, "inconsistent CellId");
471  NS_TEST_ASSERT_MSG_EQ(ueDlBandwidth, enbDlBandwidth, "inconsistent DlBandwidth");
472  NS_TEST_ASSERT_MSG_EQ(ueUlBandwidth, enbUlBandwidth, "inconsistent UlBandwidth");
473  NS_TEST_ASSERT_MSG_EQ(ueDlEarfcn, enbDlEarfcn, "inconsistent DlEarfcn");
474  NS_TEST_ASSERT_MSG_EQ(ueUlEarfcn, enbUlEarfcn, "inconsistent UlEarfcn");
475 
476  if (hasContext)
477  {
478  Ptr<UeManager> ueManager = enbRrc->GetUeManager(rnti);
479  NS_ASSERT(ueManager);
480  UeManager::State state = ueManager->GetState();
481  uint16_t enbImsi = ueManager->GetImsi();
482  NS_TEST_ASSERT_MSG_EQ(ueImsi, enbImsi, "inconsistent Imsi");
483 
484  if (state == UeManager::CONNECTED_NORMALLY)
485  {
486  ObjectMapValue enbDataRadioBearerMapValue;
487  ueManager->GetAttribute("DataRadioBearerMap", enbDataRadioBearerMapValue);
488  NS_TEST_ASSERT_MSG_EQ(enbDataRadioBearerMapValue.GetN(),
489  m_nBearers,
490  "wrong num bearers at eNB");
491  ObjectMapValue ueDataRadioBearerMapValue;
492  ueRrc->GetAttribute("DataRadioBearerMap", ueDataRadioBearerMapValue);
493  NS_TEST_ASSERT_MSG_EQ(ueDataRadioBearerMapValue.GetN(),
494  m_nBearers,
495  "wrong num bearers at UE");
496 
497  auto enbBearerIt = enbDataRadioBearerMapValue.Begin();
498  auto ueBearerIt = ueDataRadioBearerMapValue.Begin();
499  while (enbBearerIt != enbDataRadioBearerMapValue.End() &&
500  ueBearerIt != ueDataRadioBearerMapValue.End())
501  {
502  Ptr<LteDataRadioBearerInfo> enbDrbInfo =
503  enbBearerIt->second->GetObject<LteDataRadioBearerInfo>();
504  Ptr<LteDataRadioBearerInfo> ueDrbInfo =
505  ueBearerIt->second->GetObject<LteDataRadioBearerInfo>();
506  // NS_TEST_ASSERT_MSG_EQ (enbDrbInfo->m_epsBearer, ueDrbInfo->m_epsBearer,
507  // "epsBearer differs");
508  NS_TEST_ASSERT_MSG_EQ((uint32_t)enbDrbInfo->m_epsBearerIdentity,
509  (uint32_t)ueDrbInfo->m_epsBearerIdentity,
510  "epsBearerIdentity differs");
511  NS_TEST_ASSERT_MSG_EQ((uint32_t)enbDrbInfo->m_drbIdentity,
512  (uint32_t)ueDrbInfo->m_drbIdentity,
513  "drbIdentity differs");
514  // NS_TEST_ASSERT_MSG_EQ (enbDrbInfo->m_rlcConfig, ueDrbInfo->m_rlcConfig,
515  // "rlcConfig differs");
516  NS_TEST_ASSERT_MSG_EQ((uint32_t)enbDrbInfo->m_logicalChannelIdentity,
517  (uint32_t)ueDrbInfo->m_logicalChannelIdentity,
518  "logicalChannelIdentity differs");
519  // NS_TEST_ASSERT_MSG_EQ (enbDrbInfo->m_logicalChannelConfig,
520  // ueDrbInfo->m_logicalChannelConfig, "logicalChannelConfig differs");
521 
522  ++enbBearerIt;
523  ++ueBearerIt;
524  }
525 
526  NS_ASSERT_MSG(enbBearerIt == enbDataRadioBearerMapValue.End(),
527  "too many bearers at eNB");
528  NS_ASSERT_MSG(ueBearerIt == ueDataRadioBearerMapValue.End(), "too many bearers at UE");
529  }
530  }
531 }
532 
533 void
535  Ptr<NetDevice> enbDevice)
536 {
537  Ptr<LteUeNetDevice> ueLteDevice = ueDevice->GetObject<LteUeNetDevice>();
538  Ptr<LteUeRrc> ueRrc = ueLteDevice->GetRrc();
539  const uint64_t imsi = ueLteDevice->GetImsi();
540  const uint16_t rnti = ueRrc->GetRnti();
541  NS_LOG_FUNCTION(this << imsi << rnti);
543  "Invalid IMSI " << imsi);
544 
545  bool ueStateIsConnectedNormally = (LteUeRrc::CONNECTED_NORMALLY == ueRrc->GetState());
546 
547  Ptr<LteEnbNetDevice> enbLteDevice = enbDevice->GetObject<LteEnbNetDevice>();
548  Ptr<LteEnbRrc> enbRrc = enbLteDevice->GetRrc();
549  const bool hasContext = enbRrc->HasUeManager(rnti);
550  bool contextStateIsConnectedNormally = false;
551  if (hasContext)
552  {
553  Ptr<UeManager> ueManager = enbRrc->GetUeManager(rnti);
554  NS_ASSERT(ueManager);
555  contextStateIsConnectedNormally = (UeManager::CONNECTED_NORMALLY == ueManager->GetState());
556  }
558  (!m_isConnectionEstablished[imsi] || !ueStateIsConnectedNormally || !hasContext ||
559  !contextStateIsConnectedNormally),
560  true,
561  "it should not happen that connection is completed both at the UE and at the eNB side");
562 }
563 
564 void
566  uint64_t imsi,
567  uint16_t cellId,
568  uint16_t rnti)
569 {
570  NS_LOG_FUNCTION(this << imsi << cellId);
571  m_isConnectionEstablished[imsi] = true;
572 }
573 
574 void
576  uint64_t imsi,
577  uint16_t cellId,
578  uint16_t rnti,
579  uint8_t connEstFailCount)
580 {
581  NS_LOG_FUNCTION(this << imsi << cellId);
582 }
583 
590 {
591  public:
599  LteRrcConnectionEstablishmentErrorTestCase(Time jumpAwayTime, std::string description = "");
600 
601  protected:
602  void DoRun() override;
603 
604  private:
606  void JumpAway();
608  void JumpBack();
609 
612 };
613 
615  Time jumpAwayTime,
616  std::string description)
617  : LteRrcConnectionEstablishmentTestCase(1, 1, 0, 0, 1, true, false, true, description),
618  m_jumpAwayTime(jumpAwayTime)
619 {
620  NS_LOG_FUNCTION(this << GetName());
621 }
622 
623 void
625 {
626  NS_LOG_FUNCTION(this << GetName());
627  Config::Reset();
628 
629  if (m_nUes < 25)
630  {
631  Config::SetDefault("ns3::LteEnbRrc::SrsPeriodicity", UintegerValue(40));
632  }
633  else if (m_nUes < 60)
634  {
635  Config::SetDefault("ns3::LteEnbRrc::SrsPeriodicity", UintegerValue(80));
636  }
637  else if (m_nUes < 120)
638  {
639  Config::SetDefault("ns3::LteEnbRrc::SrsPeriodicity", UintegerValue(160));
640  }
641  else
642  {
643  Config::SetDefault("ns3::LteEnbRrc::SrsPeriodicity", UintegerValue(320));
644  }
645 
646  // normal code
647  m_lteHelper = CreateObject<LteHelper>();
649 
650  NodeContainer enbNodes;
651  NodeContainer ueNodes;
652 
653  enbNodes.Create(4);
654  ueNodes.Create(1);
655 
657  mobility.Install(ueNodes); // UE position at (0, 0, 0)
658  m_ueMobility = ueNodes.Get(0)->GetObject<MobilityModel>();
659 
660  Ptr<ListPositionAllocator> enbPosition = CreateObject<ListPositionAllocator>();
661  enbPosition->Add(Vector(0, 0, 0));
662  enbPosition->Add(Vector(100.0, 0, 0));
663  enbPosition->Add(Vector(0, 100.0, 0));
664  enbPosition->Add(Vector(100.0, 100.0, 0));
665  mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
666  mobility.SetPositionAllocator(enbPosition);
667  mobility.Install(enbNodes);
668 
669  int64_t stream = 1;
670  NetDeviceContainer enbDevs;
671  enbDevs = m_lteHelper->InstallEnbDevice(enbNodes);
672  stream += m_lteHelper->AssignStreams(enbDevs, stream);
673 
674  NetDeviceContainer ueDevs;
675  ueDevs = m_lteHelper->InstallUeDevice(ueNodes);
676  stream += m_lteHelper->AssignStreams(ueDevs, stream);
677 
678  // custom code used for testing purposes
679  // instead of lteHelper->Attach () and lteHelper->ActivateXxx
680 
681  // Set AdmitConnectionRequest attribute
682  for (auto it = enbDevs.Begin(); it != enbDevs.End(); ++it)
683  {
684  Ptr<LteEnbRrc> enbRrc = (*it)->GetObject<LteEnbNetDevice>()->GetRrc();
685  enbRrc->SetAttribute("AdmitRrcConnectionRequest",
687  }
688 
689  uint32_t i = 0;
690  uint32_t tmax = 0;
691  for (auto it = ueDevs.Begin(); it != ueDevs.End(); ++it)
692  {
693  Ptr<NetDevice> ueDevice = *it;
694  Ptr<NetDevice> enbDevice = enbDevs.Get(0);
695  Ptr<LteUeNetDevice> ueLteDevice = ueDevice->GetObject<LteUeNetDevice>();
696 
697  uint32_t tc = m_tConnBase + m_tConnIncrPerUe * i; // time connection start
698  uint32_t tcc = tc + m_delayConnEnd; // time check connection completed;
699  uint32_t td = tcc + m_delayDiscStart; // time disconnect start
700  uint32_t tcd = td + m_delayDiscEnd; // time check disconnection completed
701  tmax = std::max(tmax, tcd);
702 
703  // trick to resolve overloading
704  // void (LteHelper::* overloadedAttachFunctionPointer) (Ptr<NetDevice>, Ptr<NetDevice>) =
705  // &LteHelper::Attach; Simulator::Schedule (MilliSeconds (tc),
706  // overloadedAttachFunctionPointer, lteHelper, *it, enbDevice);
707  Simulator::Schedule(MilliSeconds(tc),
709  this,
710  ueDevice,
711  enbDevice);
712 
713  // disconnection not supported yet
714 
715  uint64_t imsi = ueLteDevice->GetImsi();
716  m_isConnectionEstablished[imsi] = false;
717 
718  ++i;
719  }
720 
721  // Connect to trace sources in UEs
723  "/NodeList/*/DeviceList/*/LteUeRrc/ConnectionEstablished",
725  this));
727  "/NodeList/*/DeviceList/*/LteUeRrc/ConnectionTimeout",
729 
730  Simulator::Schedule(m_jumpAwayTime,
732  this);
733  Simulator::Schedule(m_jumpAwayTime + MilliSeconds(99),
735  this,
736  ueDevs.Get(0),
737  enbDevs.Get(0));
738  Simulator::Schedule(m_jumpAwayTime + MilliSeconds(100),
740  this);
741 
742  Simulator::Stop(MilliSeconds(tmax + 1));
743 
744  Simulator::Run();
745 
746  Simulator::Destroy();
747 }
748 
749 void
751 {
752  NS_LOG_FUNCTION(this);
753  // move to a really far away location so that transmission errors occur
754  m_ueMobility->SetPosition(Vector(100000.0, 100000.0, 0.0));
755 }
756 
757 void
759 {
760  NS_LOG_FUNCTION(this);
761  m_ueMobility->SetPosition(Vector(0.0, 0.0, 0.0));
762 }
763 
770 {
771  public:
772  LteRrcTestSuite();
773 };
774 
776  : TestSuite("lte-rrc", SYSTEM)
777 {
778  // LogComponentEnableAll (LOG_PREFIX_ALL);
779  // LogComponentEnable ("LteRrcTest", LOG_LEVEL_ALL);
780  // LogComponentEnable ("LteEnbRrc", LOG_INFO);
781  // LogComponentEnable ("LteUeRrc", LOG_INFO);
782 
783  NS_LOG_FUNCTION(this);
784 
785  for (auto useIdealRrc : {false, true})
786  {
787  // <----- all times in ms ----------------->
788 
789  // nUes tConnBase delayDiscStart useIdealRrc nBearers tConnIncrPerUe errorExpected
790  // admitRrcConnectionRequest
791  AddTestCase(
792  new LteRrcConnectionEstablishmentTestCase(1, 0, 0, 0, 1, false, useIdealRrc, true),
793  TestCase::EXTENSIVE);
794  AddTestCase(
795  new LteRrcConnectionEstablishmentTestCase(1, 0, 100, 0, 1, false, useIdealRrc, true),
796  TestCase::EXTENSIVE);
797  AddTestCase(
798  new LteRrcConnectionEstablishmentTestCase(1, 1, 0, 0, 1, false, useIdealRrc, true),
799  TestCase::EXTENSIVE);
800  AddTestCase(
801  new LteRrcConnectionEstablishmentTestCase(1, 1, 100, 0, 1, false, useIdealRrc, true),
802  TestCase::EXTENSIVE);
803  AddTestCase(
804  new LteRrcConnectionEstablishmentTestCase(1, 2, 0, 0, 1, false, useIdealRrc, true),
805  TestCase::EXTENSIVE);
806  AddTestCase(
807  new LteRrcConnectionEstablishmentTestCase(1, 2, 100, 0, 1, false, useIdealRrc, true),
808  TestCase::EXTENSIVE);
809  AddTestCase(
810  new LteRrcConnectionEstablishmentTestCase(2, 0, 20, 0, 1, false, useIdealRrc, true),
811  TestCase::EXTENSIVE);
812  AddTestCase(
813  new LteRrcConnectionEstablishmentTestCase(2, 0, 20, 10, 1, false, useIdealRrc, true),
814  TestCase::EXTENSIVE);
815  AddTestCase(
816  new LteRrcConnectionEstablishmentTestCase(2, 0, 20, 100, 1, false, useIdealRrc, true),
817  TestCase::EXTENSIVE);
818  AddTestCase(
819  new LteRrcConnectionEstablishmentTestCase(2, 1, 20, 0, 1, false, useIdealRrc, true),
820  TestCase::EXTENSIVE);
821  AddTestCase(
822  new LteRrcConnectionEstablishmentTestCase(2, 1, 20, 10, 1, false, useIdealRrc, true),
823  TestCase::EXTENSIVE);
824  AddTestCase(
825  new LteRrcConnectionEstablishmentTestCase(2, 1, 20, 100, 1, false, useIdealRrc, true),
826  TestCase::EXTENSIVE);
827  AddTestCase(
828  new LteRrcConnectionEstablishmentTestCase(2, 2, 20, 0, 1, false, useIdealRrc, true),
829  TestCase::EXTENSIVE);
830  AddTestCase(
831  new LteRrcConnectionEstablishmentTestCase(2, 2, 20, 10, 1, false, useIdealRrc, true),
832  TestCase::QUICK);
833  AddTestCase(
834  new LteRrcConnectionEstablishmentTestCase(2, 2, 20, 100, 1, false, useIdealRrc, true),
835  TestCase::EXTENSIVE);
836  AddTestCase(
837  new LteRrcConnectionEstablishmentTestCase(3, 0, 20, 0, 1, false, useIdealRrc, true),
838  TestCase::EXTENSIVE);
839  AddTestCase(
840  new LteRrcConnectionEstablishmentTestCase(4, 0, 20, 0, 1, false, useIdealRrc, true),
841  TestCase::EXTENSIVE);
842  AddTestCase(
843  new LteRrcConnectionEstablishmentTestCase(4, 0, 20, 300, 1, false, useIdealRrc, true),
844  TestCase::EXTENSIVE);
845  AddTestCase(
846  new LteRrcConnectionEstablishmentTestCase(20, 0, 10, 1, 1, false, useIdealRrc, true),
847  TestCase::EXTENSIVE);
848  AddTestCase(
849  new LteRrcConnectionEstablishmentTestCase(50, 0, 0, 0, 1, false, useIdealRrc, true),
850  TestCase::EXTENSIVE);
851 
852  // Test cases to check admitRrcConnectionRequest=false
853  // nUes tConnBase delayDiscStart
854  // useIdealRrc
855  // nBearers tConnIncrPerUe
856  // errorExpected
857  // admitRrcConnectionRequest
858  AddTestCase(
859  new LteRrcConnectionEstablishmentTestCase(1, 0, 0, 0, 1, false, useIdealRrc, false),
860  TestCase::EXTENSIVE);
861  AddTestCase(
862  new LteRrcConnectionEstablishmentTestCase(1, 2, 100, 0, 1, false, useIdealRrc, false),
863  TestCase::EXTENSIVE);
864  AddTestCase(
865  new LteRrcConnectionEstablishmentTestCase(2, 0, 20, 0, 1, false, useIdealRrc, false),
866  TestCase::EXTENSIVE);
867  AddTestCase(
868  new LteRrcConnectionEstablishmentTestCase(2, 1, 20, 0, 1, false, useIdealRrc, false),
869  TestCase::QUICK);
870  AddTestCase(
871  new LteRrcConnectionEstablishmentTestCase(3, 0, 20, 0, 1, false, useIdealRrc, false),
872  TestCase::EXTENSIVE);
873  }
874 
875  // Test cases with transmission error
877  "failure at RRC Connection Request"),
878  TestCase::QUICK);
880  "failure at RRC Connection Setup"),
881  TestCase::QUICK);
882  /*
883  * With RLF implementation we now do support the Idle mode,
884  * thus it solve Bug 1762 Comment #25.
885  */
886  AddTestCase(
888  "failure at RRC Connection Setup Complete"),
889  TestCase::QUICK);
890 }
891 
#define max(a, b)
Definition: 80211b.c:42
Lte Rrc Connection Establishment Error Test Case.
void DoRun() override
Implementation to actually run this TestCase.
LteRrcConnectionEstablishmentErrorTestCase(Time jumpAwayTime, std::string description="")
Ptr< MobilityModel > m_ueMobility
UE mobility model.
Test rrc connection establishment.
Definition: test-lte-rrc.cc:38
void DoRun() override
Implementation to actually run this TestCase.
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.
std::map< uint64_t, bool > m_isConnectionEstablished
key: IMSI
void CheckNotConnected(Ptr< NetDevice > ueDevice, Ptr< NetDevice > enbDevice)
Check not connected function.
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="")
bool m_admitRrcConnectionRequest
If set to false, eNb will not allow UE connections.
void ConnectionEstablishedCallback(std::string context, uint64_t imsi, uint16_t cellId, uint16_t rnti)
Connection established callback function.
uint32_t m_nUes
number of UEs in the test
Definition: test-lte-rrc.cc:67
void CheckConnected(Ptr< NetDevice > ueDevice, Ptr< NetDevice > enbDevice)
Check connected function.
bool m_useIdealRrc
If set to false, real RRC protocol model will be used.
uint32_t m_delayConnEnd
expected duration to perform connection establishment in ms
uint32_t m_tConnBase
connection time base value for all UEs in ms
Ptr< LteHelper > m_lteHelper
LTE helper.
void ConnectionTimeoutCallback(std::string context, uint64_t imsi, uint16_t cellId, uint16_t rnti, uint8_t connEstFailCount)
Connection timeout callback function.
uint32_t m_delayDiscStart
delay between connection completed and disconnection request in ms
uint32_t m_tConnIncrPerUe
additional connection time increment for each UE index (0...nUes-1) in ms
void Connect(Ptr< NetDevice > ueDevice, Ptr< NetDevice > enbDevice)
Connect function.
uint32_t m_delayDiscEnd
expected duration to complete disconnection in ms
uint32_t m_nBearers
number of bearers to be setup in each connection
Lte Rrc Test Suite.
This class contains the specification of EPS Bearers.
Definition: eps-bearer.h:91
Qci
QoS Class Indicator.
Definition: eps-bearer.h:106
store information on active data radio bearer instance
The eNodeB device implementation.
uint16_t GetDlBandwidth() const
uint32_t GetUlEarfcn() const
uint32_t GetDlEarfcn() const
Ptr< LteEnbRrc > GetRrc() const
uint16_t GetUlBandwidth() const
uint16_t GetCellId() const
NetDeviceContainer InstallEnbDevice(NodeContainer c)
Create a set of eNodeB devices.
Definition: lte-helper.cc:485
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:1039
void ActivateDataRadioBearer(NetDeviceContainer ueDevices, EpsBearer bearer)
Activate a Data Radio Bearer on a given UE devices (for LTE-only simulation).
Definition: lte-helper.cc:1436
NetDeviceContainer InstallUeDevice(NodeContainer c)
Create a set of UE devices.
Definition: lte-helper.cc:500
int64_t AssignStreams(NetDeviceContainer c, int64_t stream)
Assign a fixed random variable stream number to the random variables used.
Definition: lte-helper.cc:1567
The LteUeNetDevice class implements the UE net device.
Helper class used to assign positions and mobility models to nodes.
Keep track of the current position and velocity of an object.
void SetPosition(const Vector &position)
holds a vector of ns3::NetDevice pointers
Iterator Begin() const
Get an iterator which refers to the first NetDevice in the container.
Iterator End() const
Get an iterator which indicates past-the-last NetDevice in the container.
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
keep track of a set of node pointers.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:204
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
Definition: object.h:471
Container for a set of ns3::Object pointers.
std::size_t GetN() const
Get the number of Objects.
Iterator End() const
Get an iterator to the past-the-end Object.
Iterator Begin() const
Get an iterator to the first Object.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
encapsulates test code
Definition: test.h:1060
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:301
std::string GetName() const
Definition: test.cc:373
A suite of tests to run.
Definition: test.h:1256
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
State
The state of the UeManager at the eNB RRC.
Definition: lte-enb-rrc.h:78
Hold an unsigned integer type.
Definition: uinteger.h:45
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition: assert.h:66
#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:86
void Reset()
Reset the initial value of every attribute as well as the value of every global to what they were bef...
Definition: config.cc:855
void SetDefault(std::string name, const AttributeValue &value)
Definition: config.cc:890
void Connect(std::string path, const CallbackBase &cb)
Definition: config.cc:974
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:282
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Definition: log.h:261
static LteRrcTestSuite g_lteRrcTestSuiteInstance
Static variable for test initialization.
#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:144
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1326
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1338
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Definition: callback.h:704
mobility
Definition: third.py:105