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
28using namespace ns3;
29
30NS_LOG_COMPONENT_DEFINE("LteRrcTest");
31
39{
40 public:
57 uint32_t nBearers,
58 uint32_t tConnBase,
59 uint32_t tConnIncrPerUe,
60 uint32_t delayDiscStart,
61 bool errorExpected,
62 bool useIdealRrc,
63 bool admitRrcConnectionRequest,
64 std::string description = "");
65
66 protected:
67 void DoRun() override;
69
84 static std::string BuildNameString(uint32_t nUes,
85 uint32_t nBearers,
86 uint32_t tConnBase,
87 uint32_t tConnIncrPerUe,
88 uint32_t delayDiscStart,
89 bool useIdealRrc,
90 bool admitRrcConnectionRequest,
91 std::string description = "");
97 void Connect(Ptr<NetDevice> ueDevice, Ptr<NetDevice> enbDevice);
103 void CheckConnected(Ptr<NetDevice> ueDevice, Ptr<NetDevice> enbDevice);
109 void CheckNotConnected(Ptr<NetDevice> ueDevice, Ptr<NetDevice> enbDevice);
117 void ConnectionEstablishedCallback(std::string context,
118 uint64_t imsi,
119 uint16_t cellId,
120 uint16_t rnti);
129 void ConnectionTimeoutCallback(std::string context,
130 uint64_t imsi,
131 uint16_t cellId,
132 uint16_t rnti,
133 uint8_t connEstFailCount);
134
146
148 std::map<uint64_t, bool> m_isConnectionEstablished;
149};
150
151std::string
153 uint32_t nBearers,
154 uint32_t tConnBase,
155 uint32_t tConnIncrPerUe,
156 uint32_t delayDiscStart,
157 bool useIdealRrc,
158 bool admitRrcConnectionRequest,
159 std::string description)
160{
161 std::ostringstream oss;
162 oss << "nUes=" << nUes << ", nBearers=" << nBearers << ", tConnBase=" << tConnBase
163 << ", tConnIncrPerUe=" << tConnIncrPerUe << ", delayDiscStart=" << delayDiscStart;
164
165 if (useIdealRrc)
166 {
167 oss << ", ideal RRC";
168 }
169 else
170 {
171 oss << ", real RRC";
172 }
173
174 if (admitRrcConnectionRequest)
175 {
176 oss << ", admitRrcConnectionRequest = true";
177 }
178 else
179 {
180 oss << ", admitRrcConnectionRequest = false";
181 }
182
183 if (!description.empty())
184 {
185 oss << ", " << description;
186 }
187
188 return oss.str();
189}
190
192 uint32_t nUes,
193 uint32_t nBearers,
194 uint32_t tConnBase,
195 uint32_t tConnIncrPerUe,
196 uint32_t delayDiscStart,
197 bool errorExpected,
198 bool useIdealRrc,
199 bool admitRrcConnectionRequest,
200 std::string description)
201 : TestCase(BuildNameString(nUes,
202 nBearers,
203 tConnBase,
204 tConnIncrPerUe,
205 delayDiscStart,
206 useIdealRrc,
207 admitRrcConnectionRequest,
208 description)),
209 m_nUes(nUes),
210 m_nBearers(nBearers),
211 m_tConnBase(tConnBase),
212 m_tConnIncrPerUe(tConnIncrPerUe),
213
214 m_delayDiscStart(delayDiscStart),
215 m_delayDiscEnd(10),
216 m_useIdealRrc(useIdealRrc),
217 m_admitRrcConnectionRequest(admitRrcConnectionRequest)
218{
219 NS_LOG_FUNCTION(this << GetName());
220
221 // see the description of d^e in the LTE testing docs
222 double dsi = 90;
223 double nRaAttempts = 0;
224 if (nUes <= 20)
225 {
226 nRaAttempts += 5;
227 }
228 else
229 {
230 NS_ASSERT(nUes <= 50);
231 nRaAttempts += 10;
232 }
233
234 nRaAttempts += std::ceil(nUes / 4.0);
235 double dra = nRaAttempts * 7;
236 double dce = 10.0 + (2.0 * nUes) / 4.0;
237 if (errorExpected)
238 {
239 /*
240 * If transmission error happens, the UE has to repeat again from
241 * acquiring system information.
242 */
243 dce += dsi + dce;
244 }
245 double nCrs;
246 if (nUes <= 2)
247 {
248 nCrs = 0;
249 }
250 else if (nUes <= 5)
251 {
252 nCrs = 1;
253 }
254 else if (nUes <= 10)
255 {
256 nCrs = 2;
257 }
258 else if (nUes <= 20)
259 {
260 nCrs = 3;
261 }
262 else
263 {
264 nCrs = 4;
265 }
266 double dcr = (10.0 + (2.0 * nUes) / 4.0) * (m_nBearers + nCrs);
267
268 m_delayConnEnd = round(dsi + dra + dce + dcr);
269 NS_LOG_LOGIC(this << " " << GetName() << " dsi=" << dsi << " dra=" << dra << " dce=" << dce
270 << " dcr=" << dcr << " m_delayConnEnd=" << m_delayConnEnd);
271}
272
273void
275{
276 NS_LOG_FUNCTION(this << GetName());
278
279 if (m_nUes < 25)
280 {
281 Config::SetDefault("ns3::LteEnbRrc::SrsPeriodicity", UintegerValue(40));
282 }
283 else if (m_nUes < 60)
284 {
285 Config::SetDefault("ns3::LteEnbRrc::SrsPeriodicity", UintegerValue(80));
286 }
287 else if (m_nUes < 120)
288 {
289 Config::SetDefault("ns3::LteEnbRrc::SrsPeriodicity", UintegerValue(160));
290 }
291 else
292 {
293 Config::SetDefault("ns3::LteEnbRrc::SrsPeriodicity", UintegerValue(320));
294 }
295
296 // normal code
297 m_lteHelper = CreateObject<LteHelper>();
299
300 NodeContainer enbNodes;
301 NodeContainer ueNodes;
302
303 enbNodes.Create(1);
304 ueNodes.Create(m_nUes);
305
306 // the following positions all nodes at (0, 0, 0)
308 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
309 mobility.Install(enbNodes);
310 mobility.Install(ueNodes);
311
312 int64_t stream = 1;
313 NetDeviceContainer enbDevs;
314 enbDevs = m_lteHelper->InstallEnbDevice(enbNodes);
315 stream += m_lteHelper->AssignStreams(enbDevs, stream);
316
317 NetDeviceContainer ueDevs;
318 ueDevs = m_lteHelper->InstallUeDevice(ueNodes);
319 stream += m_lteHelper->AssignStreams(ueDevs, stream);
320
321 // custom code used for testing purposes
322 // instead of lteHelper->Attach () and lteHelper->ActivateXxx
323
324 // Set AdmitConnectionRequest attribute
325 for (NetDeviceContainer::Iterator it = enbDevs.Begin(); it != enbDevs.End(); ++it)
326 {
327 Ptr<LteEnbRrc> enbRrc = (*it)->GetObject<LteEnbNetDevice>()->GetRrc();
328 enbRrc->SetAttribute("AdmitRrcConnectionRequest",
330 }
331
332 uint32_t i = 0;
333 uint32_t tmax = 0;
334 for (NetDeviceContainer::Iterator it = ueDevs.Begin(); it != ueDevs.End(); ++it)
335 {
336 Ptr<NetDevice> ueDevice = *it;
337 Ptr<NetDevice> enbDevice = enbDevs.Get(0);
338 Ptr<LteUeNetDevice> ueLteDevice = ueDevice->GetObject<LteUeNetDevice>();
339
340 uint32_t tc = m_tConnBase + m_tConnIncrPerUe * i; // time connection start
341 uint32_t tcc = tc + m_delayConnEnd; // time check connection completed;
342 uint32_t td = tcc + m_delayDiscStart; // time disconnect start
343 uint32_t tcd = td + m_delayDiscEnd; // time check disconnection completed
344 tmax = std::max(tmax, tcd);
345
346 // trick to resolve overloading
347 // void (LteHelper::* overloadedAttachFunctionPointer) (Ptr<NetDevice>, Ptr<NetDevice>) =
348 // &LteHelper::Attach; Simulator::Schedule (MilliSeconds (tc),
349 // overloadedAttachFunctionPointer, lteHelper, *it, enbDevice);
350 Simulator::Schedule(MilliSeconds(tc),
352 this,
353 ueDevice,
354 enbDevice);
355
356 Simulator::Schedule(MilliSeconds(tcc),
358 this,
359 *it,
360 enbDevice);
361
362 // disconnection not supported yet
363
364 uint64_t imsi = ueLteDevice->GetImsi();
365 m_isConnectionEstablished[imsi] = false;
366
367 ++i;
368 }
369
370 // Connect to trace sources in UEs
372 "/NodeList/*/DeviceList/*/LteUeRrc/ConnectionEstablished",
375 "/NodeList/*/DeviceList/*/LteUeRrc/ConnectionTimeout",
377
378 Simulator::Stop(MilliSeconds(tmax + 1));
379
380 Simulator::Run();
381
382 Simulator::Destroy();
383}
384
385void
387{
388 NS_LOG_FUNCTION(this);
389 m_lteHelper->Attach(ueDevice, enbDevice);
390
391 for (uint32_t b = 0; b < m_nBearers; ++b)
392 {
393 enum EpsBearer::Qci q = EpsBearer::NGBR_VIDEO_TCP_DEFAULT;
394 EpsBearer bearer(q);
395 m_lteHelper->ActivateDataRadioBearer(ueDevice, bearer);
396 }
397}
398
399void
401 Ptr<NetDevice> enbDevice)
402{
403 Ptr<LteUeNetDevice> ueLteDevice = ueDevice->GetObject<LteUeNetDevice>();
404 Ptr<LteUeRrc> ueRrc = ueLteDevice->GetRrc();
405 const uint64_t imsi = ueLteDevice->GetImsi();
406 const uint16_t rnti = ueRrc->GetRnti();
407 NS_LOG_FUNCTION(this << imsi << rnti);
409 "Invalid IMSI " << imsi);
410
412 {
414 false,
415 "Connection with RNTI " << rnti << " should have been rejected");
416 return;
417 }
418
419 /*
420 * Verifying UE state in UE RRC. Try to increase the test case duration if
421 * the following checks.
422 */
424 true,
425 "RNTI " << rnti << " fails to establish connection");
426 NS_TEST_ASSERT_MSG_EQ(ueRrc->GetState(),
427 LteUeRrc::CONNECTED_NORMALLY,
428 "RNTI " << rnti << " is not at CONNECTED_NORMALLY state");
429
430 // Verifying UE context state in eNodeB RRC.
431
432 Ptr<LteEnbNetDevice> enbLteDevice = enbDevice->GetObject<LteEnbNetDevice>();
433 Ptr<LteEnbRrc> enbRrc = enbLteDevice->GetRrc();
434 const bool hasContext = enbRrc->HasUeManager(rnti);
435
436 if (hasContext)
437 {
438 Ptr<UeManager> ueManager = enbRrc->GetUeManager(rnti);
439 NS_ASSERT(ueManager);
440 NS_TEST_ASSERT_MSG_EQ(ueManager->GetState(),
441 UeManager::CONNECTED_NORMALLY,
442 "The context of RNTI " << rnti << " is in invalid state");
443 }
444 else
445 {
446 NS_LOG_WARN(this << " RNTI " << rnti << " thinks that it has"
447 << " established connection but the eNodeB thinks"
448 << " that the UE has failed on connection setup.");
449 /*
450 * The standard specifies that this case would exceed the maximum
451 * retransmission limit at UE RLC (SRB1), which will then trigger an RLF.
452 * However, this behaviour is not implemented yet.
453 */
454 }
455
456 // Verifying other attributes on both sides.
457
458 uint16_t ueCellId = ueRrc->GetCellId();
459 uint16_t enbCellId = enbLteDevice->GetCellId();
460 uint16_t ueImsi = ueLteDevice->GetImsi();
461
462 uint8_t ueDlBandwidth = ueRrc->GetDlBandwidth();
463 uint8_t enbDlBandwidth = enbLteDevice->GetDlBandwidth();
464 uint8_t ueUlBandwidth = ueRrc->GetUlBandwidth();
465 uint8_t enbUlBandwidth = enbLteDevice->GetUlBandwidth();
466 uint8_t ueDlEarfcn = ueRrc->GetDlEarfcn();
467 uint8_t enbDlEarfcn = enbLteDevice->GetDlEarfcn();
468 uint8_t ueUlEarfcn = ueRrc->GetUlEarfcn();
469 uint8_t enbUlEarfcn = enbLteDevice->GetUlEarfcn();
470
471 NS_TEST_ASSERT_MSG_EQ(ueCellId, enbCellId, "inconsistent CellId");
472 NS_TEST_ASSERT_MSG_EQ(ueDlBandwidth, enbDlBandwidth, "inconsistent DlBandwidth");
473 NS_TEST_ASSERT_MSG_EQ(ueUlBandwidth, enbUlBandwidth, "inconsistent UlBandwidth");
474 NS_TEST_ASSERT_MSG_EQ(ueDlEarfcn, enbDlEarfcn, "inconsistent DlEarfcn");
475 NS_TEST_ASSERT_MSG_EQ(ueUlEarfcn, enbUlEarfcn, "inconsistent UlEarfcn");
476
477 if (hasContext)
478 {
479 Ptr<UeManager> ueManager = enbRrc->GetUeManager(rnti);
480 NS_ASSERT(ueManager);
481 UeManager::State state = ueManager->GetState();
482 uint16_t enbImsi = ueManager->GetImsi();
483 NS_TEST_ASSERT_MSG_EQ(ueImsi, enbImsi, "inconsistent Imsi");
484
485 if (state == UeManager::CONNECTED_NORMALLY)
486 {
487 ObjectMapValue enbDataRadioBearerMapValue;
488 ueManager->GetAttribute("DataRadioBearerMap", enbDataRadioBearerMapValue);
489 NS_TEST_ASSERT_MSG_EQ(enbDataRadioBearerMapValue.GetN(),
491 "wrong num bearers at eNB");
492 ObjectMapValue ueDataRadioBearerMapValue;
493 ueRrc->GetAttribute("DataRadioBearerMap", ueDataRadioBearerMapValue);
494 NS_TEST_ASSERT_MSG_EQ(ueDataRadioBearerMapValue.GetN(),
496 "wrong num bearers at UE");
497
498 ObjectMapValue::Iterator enbBearerIt = enbDataRadioBearerMapValue.Begin();
499 ObjectMapValue::Iterator ueBearerIt = ueDataRadioBearerMapValue.Begin();
500 while (enbBearerIt != enbDataRadioBearerMapValue.End() &&
501 ueBearerIt != ueDataRadioBearerMapValue.End())
502 {
503 Ptr<LteDataRadioBearerInfo> enbDrbInfo =
504 enbBearerIt->second->GetObject<LteDataRadioBearerInfo>();
506 ueBearerIt->second->GetObject<LteDataRadioBearerInfo>();
507 // NS_TEST_ASSERT_MSG_EQ (enbDrbInfo->m_epsBearer, ueDrbInfo->m_epsBearer,
508 // "epsBearer differs");
509 NS_TEST_ASSERT_MSG_EQ((uint32_t)enbDrbInfo->m_epsBearerIdentity,
510 (uint32_t)ueDrbInfo->m_epsBearerIdentity,
511 "epsBearerIdentity differs");
512 NS_TEST_ASSERT_MSG_EQ((uint32_t)enbDrbInfo->m_drbIdentity,
513 (uint32_t)ueDrbInfo->m_drbIdentity,
514 "drbIdentity differs");
515 // NS_TEST_ASSERT_MSG_EQ (enbDrbInfo->m_rlcConfig, ueDrbInfo->m_rlcConfig,
516 // "rlcConfig differs");
517 NS_TEST_ASSERT_MSG_EQ((uint32_t)enbDrbInfo->m_logicalChannelIdentity,
518 (uint32_t)ueDrbInfo->m_logicalChannelIdentity,
519 "logicalChannelIdentity differs");
520 // NS_TEST_ASSERT_MSG_EQ (enbDrbInfo->m_logicalChannelConfig,
521 // ueDrbInfo->m_logicalChannelConfig, "logicalChannelConfig differs");
522
523 ++enbBearerIt;
524 ++ueBearerIt;
525 }
526
527 NS_ASSERT_MSG(enbBearerIt == enbDataRadioBearerMapValue.End(),
528 "too many bearers at eNB");
529 NS_ASSERT_MSG(ueBearerIt == ueDataRadioBearerMapValue.End(), "too many bearers at UE");
530 }
531 }
532}
533
534void
536 Ptr<NetDevice> enbDevice)
537{
538 Ptr<LteUeNetDevice> ueLteDevice = ueDevice->GetObject<LteUeNetDevice>();
539 Ptr<LteUeRrc> ueRrc = ueLteDevice->GetRrc();
540 const uint64_t imsi = ueLteDevice->GetImsi();
541 const uint16_t rnti = ueRrc->GetRnti();
542 NS_LOG_FUNCTION(this << imsi << rnti);
544 "Invalid IMSI " << imsi);
545
546 bool ueStateIsConnectedNormally = (LteUeRrc::CONNECTED_NORMALLY == ueRrc->GetState());
547
548 Ptr<LteEnbNetDevice> enbLteDevice = enbDevice->GetObject<LteEnbNetDevice>();
549 Ptr<LteEnbRrc> enbRrc = enbLteDevice->GetRrc();
550 const bool hasContext = enbRrc->HasUeManager(rnti);
551 bool contextStateIsConnectedNormally = false;
552 if (hasContext)
553 {
554 Ptr<UeManager> ueManager = enbRrc->GetUeManager(rnti);
555 NS_ASSERT(ueManager);
556 contextStateIsConnectedNormally = (UeManager::CONNECTED_NORMALLY == ueManager->GetState());
557 }
559 (!m_isConnectionEstablished[imsi] || !ueStateIsConnectedNormally || !hasContext ||
560 !contextStateIsConnectedNormally),
561 true,
562 "it should not happen that connection is completed both at the UE and at the eNB side");
563}
564
565void
567 uint64_t imsi,
568 uint16_t cellId,
569 uint16_t rnti)
570{
571 NS_LOG_FUNCTION(this << imsi << cellId);
572 m_isConnectionEstablished[imsi] = true;
573}
574
575void
577 uint64_t imsi,
578 uint16_t cellId,
579 uint16_t rnti,
580 uint8_t connEstFailCount)
581{
582 NS_LOG_FUNCTION(this << imsi << cellId);
583}
584
592{
593 public:
601 LteRrcConnectionEstablishmentErrorTestCase(Time jumpAwayTime, std::string description = "");
602
603 protected:
604 void DoRun() override;
605
606 private:
608 void JumpAway();
610 void JumpBack();
611
614};
615
617 Time jumpAwayTime,
618 std::string description)
619 : LteRrcConnectionEstablishmentTestCase(1, 1, 0, 0, 1, true, false, true, description),
620 m_jumpAwayTime(jumpAwayTime)
621{
622 NS_LOG_FUNCTION(this << GetName());
623}
624
625void
627{
628 NS_LOG_FUNCTION(this << GetName());
630
631 if (m_nUes < 25)
632 {
633 Config::SetDefault("ns3::LteEnbRrc::SrsPeriodicity", UintegerValue(40));
634 }
635 else if (m_nUes < 60)
636 {
637 Config::SetDefault("ns3::LteEnbRrc::SrsPeriodicity", UintegerValue(80));
638 }
639 else if (m_nUes < 120)
640 {
641 Config::SetDefault("ns3::LteEnbRrc::SrsPeriodicity", UintegerValue(160));
642 }
643 else
644 {
645 Config::SetDefault("ns3::LteEnbRrc::SrsPeriodicity", UintegerValue(320));
646 }
647
648 // normal code
649 m_lteHelper = CreateObject<LteHelper>();
651
652 NodeContainer enbNodes;
653 NodeContainer ueNodes;
654
655 enbNodes.Create(4);
656 ueNodes.Create(1);
657
659 mobility.Install(ueNodes); // UE position at (0, 0, 0)
660 m_ueMobility = ueNodes.Get(0)->GetObject<MobilityModel>();
661
662 Ptr<ListPositionAllocator> enbPosition = CreateObject<ListPositionAllocator>();
663 enbPosition->Add(Vector(0, 0, 0));
664 enbPosition->Add(Vector(100.0, 0, 0));
665 enbPosition->Add(Vector(0, 100.0, 0));
666 enbPosition->Add(Vector(100.0, 100.0, 0));
667 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
668 mobility.SetPositionAllocator(enbPosition);
669 mobility.Install(enbNodes);
670
671 int64_t stream = 1;
672 NetDeviceContainer enbDevs;
673 enbDevs = m_lteHelper->InstallEnbDevice(enbNodes);
674 stream += m_lteHelper->AssignStreams(enbDevs, stream);
675
676 NetDeviceContainer ueDevs;
677 ueDevs = m_lteHelper->InstallUeDevice(ueNodes);
678 stream += m_lteHelper->AssignStreams(ueDevs, stream);
679
680 // custom code used for testing purposes
681 // instead of lteHelper->Attach () and lteHelper->ActivateXxx
682
683 // Set AdmitConnectionRequest attribute
684 for (NetDeviceContainer::Iterator it = enbDevs.Begin(); it != enbDevs.End(); ++it)
685 {
686 Ptr<LteEnbRrc> enbRrc = (*it)->GetObject<LteEnbNetDevice>()->GetRrc();
687 enbRrc->SetAttribute("AdmitRrcConnectionRequest",
689 }
690
691 uint32_t i = 0;
692 uint32_t tmax = 0;
693 for (NetDeviceContainer::Iterator it = ueDevs.Begin(); it != ueDevs.End(); ++it)
694 {
695 Ptr<NetDevice> ueDevice = *it;
696 Ptr<NetDevice> enbDevice = enbDevs.Get(0);
697 Ptr<LteUeNetDevice> ueLteDevice = ueDevice->GetObject<LteUeNetDevice>();
698
699 uint32_t tc = m_tConnBase + m_tConnIncrPerUe * i; // time connection start
700 uint32_t tcc = tc + m_delayConnEnd; // time check connection completed;
701 uint32_t td = tcc + m_delayDiscStart; // time disconnect start
702 uint32_t tcd = td + m_delayDiscEnd; // time check disconnection completed
703 tmax = std::max(tmax, tcd);
704
705 // trick to resolve overloading
706 // void (LteHelper::* overloadedAttachFunctionPointer) (Ptr<NetDevice>, Ptr<NetDevice>) =
707 // &LteHelper::Attach; Simulator::Schedule (MilliSeconds (tc),
708 // overloadedAttachFunctionPointer, lteHelper, *it, enbDevice);
709 Simulator::Schedule(MilliSeconds(tc),
711 this,
712 ueDevice,
713 enbDevice);
714
715 // disconnection not supported yet
716
717 uint64_t imsi = ueLteDevice->GetImsi();
718 m_isConnectionEstablished[imsi] = false;
719
720 ++i;
721 }
722
723 // Connect to trace sources in UEs
725 "/NodeList/*/DeviceList/*/LteUeRrc/ConnectionEstablished",
727 this));
729 "/NodeList/*/DeviceList/*/LteUeRrc/ConnectionTimeout",
731
732 Simulator::Schedule(m_jumpAwayTime,
734 this);
735 Simulator::Schedule(m_jumpAwayTime + MilliSeconds(99),
737 this,
738 ueDevs.Get(0),
739 enbDevs.Get(0));
740 Simulator::Schedule(m_jumpAwayTime + MilliSeconds(100),
742 this);
743
744 Simulator::Stop(MilliSeconds(tmax + 1));
745
746 Simulator::Run();
747
748 Simulator::Destroy();
749}
750
751void
753{
754 NS_LOG_FUNCTION(this);
755 // move to a really far away location so that transmission errors occur
756 m_ueMobility->SetPosition(Vector(100000.0, 100000.0, 0.0));
757}
758
759void
761{
762 NS_LOG_FUNCTION(this);
763 m_ueMobility->SetPosition(Vector(0.0, 0.0, 0.0));
764}
765
773{
774 public:
776};
777
779 : TestSuite("lte-rrc", SYSTEM)
780{
781 // LogComponentEnableAll (LOG_PREFIX_ALL);
782 // LogComponentEnable ("LteRrcTest", LOG_LEVEL_ALL);
783 // LogComponentEnable ("LteEnbRrc", LOG_INFO);
784 // LogComponentEnable ("LteUeRrc", LOG_INFO);
785
786 NS_LOG_FUNCTION(this);
787
788 for (uint32_t useIdealRrc = 0; useIdealRrc <= 1; ++useIdealRrc)
789 {
790 // <----- all times in ms ----------------->
791
792 // nUes tConnBase delayDiscStart
793 // useIdealRrc
794 // nBearers tConnIncrPerUe
795 // errorExpected
796 // admitRrcConnectionRequest
798 new LteRrcConnectionEstablishmentTestCase(1, 0, 0, 0, 1, false, useIdealRrc, true),
799 TestCase::EXTENSIVE);
801 new LteRrcConnectionEstablishmentTestCase(1, 0, 100, 0, 1, false, useIdealRrc, true),
802 TestCase::EXTENSIVE);
804 new LteRrcConnectionEstablishmentTestCase(1, 1, 0, 0, 1, false, useIdealRrc, true),
805 TestCase::EXTENSIVE);
807 new LteRrcConnectionEstablishmentTestCase(1, 1, 100, 0, 1, false, useIdealRrc, true),
808 TestCase::EXTENSIVE);
810 new LteRrcConnectionEstablishmentTestCase(1, 2, 0, 0, 1, false, useIdealRrc, true),
811 TestCase::EXTENSIVE);
813 new LteRrcConnectionEstablishmentTestCase(1, 2, 100, 0, 1, false, useIdealRrc, true),
814 TestCase::EXTENSIVE);
816 new LteRrcConnectionEstablishmentTestCase(2, 0, 20, 0, 1, false, useIdealRrc, true),
817 TestCase::EXTENSIVE);
819 new LteRrcConnectionEstablishmentTestCase(2, 0, 20, 10, 1, false, useIdealRrc, true),
820 TestCase::EXTENSIVE);
822 new LteRrcConnectionEstablishmentTestCase(2, 0, 20, 100, 1, false, useIdealRrc, true),
823 TestCase::EXTENSIVE);
825 new LteRrcConnectionEstablishmentTestCase(2, 1, 20, 0, 1, false, useIdealRrc, true),
826 TestCase::EXTENSIVE);
828 new LteRrcConnectionEstablishmentTestCase(2, 1, 20, 10, 1, false, useIdealRrc, true),
829 TestCase::EXTENSIVE);
831 new LteRrcConnectionEstablishmentTestCase(2, 1, 20, 100, 1, false, useIdealRrc, true),
832 TestCase::EXTENSIVE);
834 new LteRrcConnectionEstablishmentTestCase(2, 2, 20, 0, 1, false, useIdealRrc, true),
835 TestCase::EXTENSIVE);
837 new LteRrcConnectionEstablishmentTestCase(2, 2, 20, 10, 1, false, useIdealRrc, true),
838 TestCase::QUICK);
840 new LteRrcConnectionEstablishmentTestCase(2, 2, 20, 100, 1, false, useIdealRrc, true),
841 TestCase::EXTENSIVE);
843 new LteRrcConnectionEstablishmentTestCase(3, 0, 20, 0, 1, false, useIdealRrc, true),
844 TestCase::EXTENSIVE);
846 new LteRrcConnectionEstablishmentTestCase(4, 0, 20, 0, 1, false, useIdealRrc, true),
847 TestCase::EXTENSIVE);
849 new LteRrcConnectionEstablishmentTestCase(4, 0, 20, 300, 1, false, useIdealRrc, true),
850 TestCase::EXTENSIVE);
852 new LteRrcConnectionEstablishmentTestCase(20, 0, 10, 1, 1, false, useIdealRrc, true),
853 TestCase::EXTENSIVE);
855 new LteRrcConnectionEstablishmentTestCase(50, 0, 0, 0, 1, false, useIdealRrc, true),
856 TestCase::EXTENSIVE);
857
858 // Test cases to check admitRrcConnectionRequest=false
859 // nUes tConnBase delayDiscStart
860 // useIdealRrc
861 // nBearers tConnIncrPerUe
862 // errorExpected
863 // admitRrcConnectionRequest
865 new LteRrcConnectionEstablishmentTestCase(1, 0, 0, 0, 1, false, useIdealRrc, false),
866 TestCase::EXTENSIVE);
868 new LteRrcConnectionEstablishmentTestCase(1, 2, 100, 0, 1, false, useIdealRrc, false),
869 TestCase::EXTENSIVE);
871 new LteRrcConnectionEstablishmentTestCase(2, 0, 20, 0, 1, false, useIdealRrc, false),
872 TestCase::EXTENSIVE);
874 new LteRrcConnectionEstablishmentTestCase(2, 1, 20, 0, 1, false, useIdealRrc, false),
875 TestCase::QUICK);
877 new LteRrcConnectionEstablishmentTestCase(3, 0, 20, 0, 1, false, useIdealRrc, false),
878 TestCase::EXTENSIVE);
879 }
880
881 // Test cases with transmission error
883 "failure at RRC Connection Request"),
884 TestCase::QUICK);
886 "failure at RRC Connection Setup"),
887 TestCase::QUICK);
888 /*
889 * With RLF implementation we now do support the Idle mode,
890 * thus it solve Bug 1762 Comment #25.
891 */
894 "failure at RRC Connection Setup Complete"),
895 TestCase::QUICK);
896}
897
#define max(a, b)
Definition: 80211b.c:43
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:39
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:68
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.
AttributeValue implementation for Boolean.
Definition: boolean.h:37
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:482
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:1044
void ActivateDataRadioBearer(NetDeviceContainer ueDevices, EpsBearer bearer)
Activate a Data Radio Bearer on a given UE devices (for LTE-only simulation).
Definition: lte-helper.cc:1441
NetDeviceContainer InstallUeDevice(NodeContainer c)
Create a set of UE devices.
Definition: lte-helper.cc:497
int64_t AssignStreams(NetDeviceContainer c, int64_t stream)
Assign a fixed random variable stream number to the random variables used.
Definition: lte-helper.cc:1572
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
std::vector< Ptr< NetDevice > >::const_iterator Iterator
NetDevice container iterator.
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:258
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.
std::map< std::size_t, Ptr< Object > >::const_iterator Iterator
Iterator type for traversing this container.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:78
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:305
std::string GetName() const
Definition: test.cc:377
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:82
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:856
void SetDefault(std::string name, const AttributeValue &value)
Definition: config.cc:891
void Connect(std::string path, const CallbackBase &cb)
Definition: config.cc:975
#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
#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:1338
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1350
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:691
mobility
Definition: third.py:96
static LteRrcTestSuite g_lteRrcTestSuiteInstance