A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
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 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Nicola Baldo <nbaldo@cttc.es>
7 * Budiarto Herman <budiarto.herman@magister.fi>
8 */
9
10#include <ns3/core-module.h>
11#include <ns3/lte-module.h>
12#include <ns3/mobility-module.h>
13#include <ns3/network-module.h>
14
15#include <cmath>
16
17using namespace ns3;
18
19NS_LOG_COMPONENT_DEFINE("LteRrcTest");
20
21/**
22 * @ingroup lte-test
23 *
24 * @brief Test rrc connection establishment.
25 */
27{
28 public:
29 /**
30 *
31 *
32 * @param nUes number of UEs in the test
33 * @param nBearers number of bearers to be setup in each connection
34 * @param tConnBase connection time base value for all UEs in ms
35 * @param tConnIncrPerUe additional connection time increment for each UE index (0...nUes-1) in
36 * ms
37 * @param delayDiscStart expected duration to perform connection establishment in ms
38 * @param errorExpected if true, test case will wait a bit longer to accommodate for
39 * transmission error
40 * @param useIdealRrc If set to false, real RRC protocol model will be used
41 * @param admitRrcConnectionRequest If set to false, eNb will not allow UE connections
42 * @param description additional description of the test case
43 */
45 uint32_t nBearers,
46 uint32_t tConnBase,
47 uint32_t tConnIncrPerUe,
48 uint32_t delayDiscStart,
49 bool errorExpected,
50 bool useIdealRrc,
51 bool admitRrcConnectionRequest,
52 std::string description = "");
53
54 protected:
55 void DoRun() override;
56 uint32_t m_nUes; ///< number of UEs in the test
57
58 /**
59 * Build name string function
60 *
61 * @param nUes number of UEs in the test
62 * @param nBearers number of bearers to be setup in each connection
63 * @param tConnBase connection time base value for all UEs in ms
64 * @param tConnIncrPerUe additional connection time increment for each UE index (0...nUes-1)
65 * in ms
66 * @param delayDiscStart expected duration to perform connection establishment in ms
67 * @param useIdealRrc If set to false, real RRC protocol model will be used
68 * @param admitRrcConnectionRequest If set to false, eNb will not allow UE connections
69 * @param description additional description of the test case
70 * @returns the name string
71 */
72 static std::string BuildNameString(uint32_t nUes,
73 uint32_t nBearers,
74 uint32_t tConnBase,
75 uint32_t tConnIncrPerUe,
76 uint32_t delayDiscStart,
77 bool useIdealRrc,
78 bool admitRrcConnectionRequest,
79 std::string description = "");
80 /**
81 * Connect function
82 * @param ueDevice the UE device
83 * @param enbDevice the ENB device
84 */
85 void Connect(Ptr<NetDevice> ueDevice, Ptr<NetDevice> enbDevice);
86 /**
87 * Check connected function
88 * @param ueDevice the UE device
89 * @param enbDevice the ENB device
90 */
91 void CheckConnected(Ptr<NetDevice> ueDevice, Ptr<NetDevice> enbDevice);
92 /**
93 * Check not connected function
94 * @param ueDevice the UE device
95 * @param enbDevice the ENB device
96 */
97 void CheckNotConnected(Ptr<NetDevice> ueDevice, Ptr<NetDevice> enbDevice);
98 /**
99 * Connection established callback function
100 * @param context the context string
101 * @param imsi the IMSI
102 * @param cellId the cell ID
103 * @param rnti the RNTI
104 */
105 void ConnectionEstablishedCallback(std::string context,
106 uint64_t imsi,
107 uint16_t cellId,
108 uint16_t rnti);
109 /**
110 * Connection timeout callback function
111 * @param context the context string
112 * @param imsi the IMSI
113 * @param cellId the cell ID
114 * @param rnti the RNTI
115 * @param connEstFailCount the T300 timer expiration counter value
116 */
117 void ConnectionTimeoutCallback(std::string context,
118 uint64_t imsi,
119 uint16_t cellId,
120 uint16_t rnti,
121 uint8_t connEstFailCount);
122
123 uint32_t m_nBearers; ///< number of bearers to be setup in each connection
124 uint32_t m_tConnBase; ///< connection time base value for all UEs in ms
125 uint32_t m_tConnIncrPerUe; ///< additional connection time increment for each UE index
126 ///< (0...nUes-1) in ms
127 uint32_t m_delayConnEnd; ///< expected duration to perform connection establishment in ms
129 m_delayDiscStart; ///< delay between connection completed and disconnection request in ms
130 uint32_t m_delayDiscEnd; ///< expected duration to complete disconnection in ms
131 bool m_useIdealRrc; ///< If set to false, real RRC protocol model will be used
132 bool m_admitRrcConnectionRequest; ///< If set to false, eNb will not allow UE connections
134
135 /// key: IMSI
136 std::map<uint64_t, bool> m_isConnectionEstablished;
137};
138
139std::string
141 uint32_t nBearers,
142 uint32_t tConnBase,
143 uint32_t tConnIncrPerUe,
144 uint32_t delayDiscStart,
145 bool useIdealRrc,
146 bool admitRrcConnectionRequest,
147 std::string description)
148{
149 std::ostringstream oss;
150 oss << "nUes=" << nUes << ", nBearers=" << nBearers << ", tConnBase=" << tConnBase
151 << ", tConnIncrPerUe=" << tConnIncrPerUe << ", delayDiscStart=" << delayDiscStart;
152
153 if (useIdealRrc)
154 {
155 oss << ", ideal RRC";
156 }
157 else
158 {
159 oss << ", real RRC";
160 }
161
162 if (admitRrcConnectionRequest)
163 {
164 oss << ", admitRrcConnectionRequest = true";
165 }
166 else
167 {
168 oss << ", admitRrcConnectionRequest = false";
169 }
170
171 if (!description.empty())
172 {
173 oss << ", " << description;
174 }
175
176 return oss.str();
177}
178
180 uint32_t nUes,
181 uint32_t nBearers,
182 uint32_t tConnBase,
183 uint32_t tConnIncrPerUe,
184 uint32_t delayDiscStart,
185 bool errorExpected,
186 bool useIdealRrc,
187 bool admitRrcConnectionRequest,
188 std::string description)
189 : TestCase(BuildNameString(nUes,
190 nBearers,
191 tConnBase,
192 tConnIncrPerUe,
193 delayDiscStart,
194 useIdealRrc,
195 admitRrcConnectionRequest,
196 description)),
197 m_nUes(nUes),
198 m_nBearers(nBearers),
199 m_tConnBase(tConnBase),
200 m_tConnIncrPerUe(tConnIncrPerUe),
201
202 m_delayDiscStart(delayDiscStart),
203 m_delayDiscEnd(10),
204 m_useIdealRrc(useIdealRrc),
205 m_admitRrcConnectionRequest(admitRrcConnectionRequest)
206{
207 NS_LOG_FUNCTION(this << GetName());
208
209 // see the description of d^e in the LTE testing docs
210 double dsi = 90;
211 double nRaAttempts = 0;
212 if (nUes <= 20)
213 {
214 nRaAttempts += 5;
215 }
216 else
217 {
218 NS_ASSERT(nUes <= 50);
219 nRaAttempts += 10;
220 }
221
222 nRaAttempts += std::ceil(nUes / 4.0);
223 double dra = nRaAttempts * 7;
224 double dce = 10.0 + (2.0 * nUes) / 4.0;
225 if (errorExpected)
226 {
227 /*
228 * If transmission error happens, the UE has to repeat again from
229 * acquiring system information.
230 */
231 dce += dsi + dce;
232 }
233 double nCrs;
234 if (nUes <= 2)
235 {
236 nCrs = 0;
237 }
238 else if (nUes <= 5)
239 {
240 nCrs = 1;
241 }
242 else if (nUes <= 10)
243 {
244 nCrs = 2;
245 }
246 else if (nUes <= 20)
247 {
248 nCrs = 3;
249 }
250 else
251 {
252 nCrs = 4;
253 }
254 double dcr = (10.0 + (2.0 * nUes) / 4.0) * (m_nBearers + nCrs);
255
256 m_delayConnEnd = round(dsi + dra + dce + dcr);
257 NS_LOG_LOGIC(this << " " << GetName() << " dsi=" << dsi << " dra=" << dra << " dce=" << dce
258 << " dcr=" << dcr << " m_delayConnEnd=" << m_delayConnEnd);
259}
260
261void
263{
264 NS_LOG_FUNCTION(this << GetName());
266
267 if (m_nUes < 25)
268 {
269 Config::SetDefault("ns3::LteEnbRrc::SrsPeriodicity", UintegerValue(40));
270 }
271 else if (m_nUes < 60)
272 {
273 Config::SetDefault("ns3::LteEnbRrc::SrsPeriodicity", UintegerValue(80));
274 }
275 else if (m_nUes < 120)
276 {
277 Config::SetDefault("ns3::LteEnbRrc::SrsPeriodicity", UintegerValue(160));
278 }
279 else
280 {
281 Config::SetDefault("ns3::LteEnbRrc::SrsPeriodicity", UintegerValue(320));
282 }
283
284 // normal code
286 m_lteHelper->SetAttribute("UseIdealRrc", BooleanValue(m_useIdealRrc));
287
288 NodeContainer enbNodes;
289 NodeContainer ueNodes;
290
291 enbNodes.Create(1);
292 ueNodes.Create(m_nUes);
293
294 // the following positions all nodes at (0, 0, 0)
295 MobilityHelper mobility;
296 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
297 mobility.Install(enbNodes);
298 mobility.Install(ueNodes);
299
300 int64_t stream = 1;
301 NetDeviceContainer enbDevs;
302 enbDevs = m_lteHelper->InstallEnbDevice(enbNodes);
303 stream += m_lteHelper->AssignStreams(enbDevs, stream);
304
305 NetDeviceContainer ueDevs;
306 ueDevs = m_lteHelper->InstallUeDevice(ueNodes);
307 stream += m_lteHelper->AssignStreams(ueDevs, stream);
308
309 // custom code used for testing purposes
310 // instead of lteHelper->Attach () and lteHelper->ActivateXxx
311
312 // Set AdmitConnectionRequest attribute
313 for (auto it = enbDevs.Begin(); it != enbDevs.End(); ++it)
314 {
315 Ptr<LteEnbRrc> enbRrc = (*it)->GetObject<LteEnbNetDevice>()->GetRrc();
316 enbRrc->SetAttribute("AdmitRrcConnectionRequest",
318 }
319
320 uint32_t i = 0;
321 uint32_t tmax = 0;
322 for (auto it = ueDevs.Begin(); it != ueDevs.End(); ++it)
323 {
324 Ptr<NetDevice> ueDevice = *it;
325 Ptr<NetDevice> enbDevice = enbDevs.Get(0);
326 Ptr<LteUeNetDevice> ueLteDevice = ueDevice->GetObject<LteUeNetDevice>();
327
328 uint32_t tc = m_tConnBase + m_tConnIncrPerUe * i; // time connection start
329 uint32_t tcc = tc + m_delayConnEnd; // time check connection completed;
330 uint32_t td = tcc + m_delayDiscStart; // time disconnect start
331 uint32_t tcd = td + m_delayDiscEnd; // time check disconnection completed
332 tmax = std::max(tmax, tcd);
333
334 // trick to resolve overloading
335 // void (LteHelper::* overloadedAttachFunctionPointer) (Ptr<NetDevice>, Ptr<NetDevice>) =
336 // &LteHelper::Attach; Simulator::Schedule (MilliSeconds (tc),
337 // overloadedAttachFunctionPointer, lteHelper, *it, enbDevice);
340 this,
341 ueDevice,
342 enbDevice);
343
346 this,
347 *it,
348 enbDevice);
349
350 // disconnection not supported yet
351
352 uint64_t imsi = ueLteDevice->GetImsi();
353 m_isConnectionEstablished[imsi] = false;
354
355 ++i;
356 }
357
358 // Connect to trace sources in UEs
360 "/NodeList/*/DeviceList/*/LteUeRrc/ConnectionEstablished",
363 "/NodeList/*/DeviceList/*/LteUeRrc/ConnectionTimeout",
365
366 Simulator::Stop(MilliSeconds(tmax + 1));
367
369
371}
372
373void
375{
376 NS_LOG_FUNCTION(this);
377 m_lteHelper->Attach(ueDevice, enbDevice);
378
379 for (uint32_t b = 0; b < m_nBearers; ++b)
380 {
382 EpsBearer bearer(q);
383 m_lteHelper->ActivateDataRadioBearer(ueDevice, bearer);
384 }
385}
386
387void
389 Ptr<NetDevice> enbDevice)
390{
391 Ptr<LteUeNetDevice> ueLteDevice = ueDevice->GetObject<LteUeNetDevice>();
392 Ptr<LteUeRrc> ueRrc = ueLteDevice->GetRrc();
393 const uint64_t imsi = ueLteDevice->GetImsi();
394 const uint16_t rnti = ueRrc->GetRnti();
395 NS_LOG_FUNCTION(this << imsi << rnti);
397 "Invalid IMSI " << imsi);
398
400 {
402 false,
403 "Connection with RNTI " << rnti << " should have been rejected");
404 return;
405 }
406
407 /*
408 * Verifying UE state in UE RRC. Try to increase the test case duration if
409 * the following checks.
410 */
412 true,
413 "RNTI " << rnti << " fails to establish connection");
414 NS_TEST_ASSERT_MSG_EQ(ueRrc->GetState(),
416 "RNTI " << rnti << " is not at CONNECTED_NORMALLY state");
417
418 // Verifying UE context state in eNodeB RRC.
419
420 Ptr<LteEnbNetDevice> enbLteDevice = enbDevice->GetObject<LteEnbNetDevice>();
421 Ptr<LteEnbRrc> enbRrc = enbLteDevice->GetRrc();
422 const bool hasContext = enbRrc->HasUeManager(rnti);
423
424 if (hasContext)
425 {
426 Ptr<UeManager> ueManager = enbRrc->GetUeManager(rnti);
427 NS_ASSERT(ueManager);
428 NS_TEST_ASSERT_MSG_EQ(ueManager->GetState(),
430 "The context of RNTI " << rnti << " is in invalid state");
431 }
432 else
433 {
434 NS_LOG_WARN(this << " RNTI " << rnti << " thinks that it has"
435 << " established connection but the eNodeB thinks"
436 << " that the UE has failed on connection setup.");
437 /*
438 * The standard specifies that this case would exceed the maximum
439 * retransmission limit at UE RLC (SRB1), which will then trigger an RLF.
440 * However, this behaviour is not implemented yet.
441 */
442 }
443
444 // Verifying other attributes on both sides.
445
446 uint16_t ueCellId = ueRrc->GetCellId();
447 uint16_t enbCellId = enbLteDevice->GetCellId();
448 uint16_t ueImsi = ueLteDevice->GetImsi();
449
450 uint8_t ueDlBandwidth = ueRrc->GetDlBandwidth();
451 uint8_t enbDlBandwidth = enbLteDevice->GetDlBandwidth();
452 uint8_t ueUlBandwidth = ueRrc->GetUlBandwidth();
453 uint8_t enbUlBandwidth = enbLteDevice->GetUlBandwidth();
454 uint8_t ueDlEarfcn = ueRrc->GetDlEarfcn();
455 uint8_t enbDlEarfcn = enbLteDevice->GetDlEarfcn();
456 uint8_t ueUlEarfcn = ueRrc->GetUlEarfcn();
457 uint8_t enbUlEarfcn = enbLteDevice->GetUlEarfcn();
458
459 NS_TEST_ASSERT_MSG_EQ(ueCellId, enbCellId, "inconsistent CellId");
460 NS_TEST_ASSERT_MSG_EQ(ueDlBandwidth, enbDlBandwidth, "inconsistent DlBandwidth");
461 NS_TEST_ASSERT_MSG_EQ(ueUlBandwidth, enbUlBandwidth, "inconsistent UlBandwidth");
462 NS_TEST_ASSERT_MSG_EQ(ueDlEarfcn, enbDlEarfcn, "inconsistent DlEarfcn");
463 NS_TEST_ASSERT_MSG_EQ(ueUlEarfcn, enbUlEarfcn, "inconsistent UlEarfcn");
464
465 if (hasContext)
466 {
467 Ptr<UeManager> ueManager = enbRrc->GetUeManager(rnti);
468 NS_ASSERT(ueManager);
469 UeManager::State state = ueManager->GetState();
470 uint16_t enbImsi = ueManager->GetImsi();
471 NS_TEST_ASSERT_MSG_EQ(ueImsi, enbImsi, "inconsistent Imsi");
472
474 {
475 ObjectMapValue enbDataRadioBearerMapValue;
476 ueManager->GetAttribute("DataRadioBearerMap", enbDataRadioBearerMapValue);
477 NS_TEST_ASSERT_MSG_EQ(enbDataRadioBearerMapValue.GetN(),
479 "wrong num bearers at eNB");
480 ObjectMapValue ueDataRadioBearerMapValue;
481 ueRrc->GetAttribute("DataRadioBearerMap", ueDataRadioBearerMapValue);
482 NS_TEST_ASSERT_MSG_EQ(ueDataRadioBearerMapValue.GetN(),
484 "wrong num bearers at UE");
485
486 auto enbBearerIt = enbDataRadioBearerMapValue.Begin();
487 auto ueBearerIt = ueDataRadioBearerMapValue.Begin();
488 while (enbBearerIt != enbDataRadioBearerMapValue.End() &&
489 ueBearerIt != ueDataRadioBearerMapValue.End())
490 {
491 Ptr<LteDataRadioBearerInfo> enbDrbInfo =
492 enbBearerIt->second->GetObject<LteDataRadioBearerInfo>();
494 ueBearerIt->second->GetObject<LteDataRadioBearerInfo>();
495 // NS_TEST_ASSERT_MSG_EQ (enbDrbInfo->m_epsBearer, ueDrbInfo->m_epsBearer,
496 // "epsBearer differs");
497 NS_TEST_ASSERT_MSG_EQ((uint32_t)enbDrbInfo->m_epsBearerIdentity,
498 (uint32_t)ueDrbInfo->m_epsBearerIdentity,
499 "epsBearerIdentity differs");
500 NS_TEST_ASSERT_MSG_EQ((uint32_t)enbDrbInfo->m_drbIdentity,
501 (uint32_t)ueDrbInfo->m_drbIdentity,
502 "drbIdentity differs");
503 // NS_TEST_ASSERT_MSG_EQ (enbDrbInfo->m_rlcConfig, ueDrbInfo->m_rlcConfig,
504 // "rlcConfig differs");
505 NS_TEST_ASSERT_MSG_EQ((uint32_t)enbDrbInfo->m_logicalChannelIdentity,
506 (uint32_t)ueDrbInfo->m_logicalChannelIdentity,
507 "logicalChannelIdentity differs");
508 // NS_TEST_ASSERT_MSG_EQ (enbDrbInfo->m_logicalChannelConfig,
509 // ueDrbInfo->m_logicalChannelConfig, "logicalChannelConfig differs");
510
511 ++enbBearerIt;
512 ++ueBearerIt;
513 }
514
515 NS_ASSERT_MSG(enbBearerIt == enbDataRadioBearerMapValue.End(),
516 "too many bearers at eNB");
517 NS_ASSERT_MSG(ueBearerIt == ueDataRadioBearerMapValue.End(), "too many bearers at UE");
518 }
519 }
520}
521
522void
524 Ptr<NetDevice> enbDevice)
525{
526 Ptr<LteUeNetDevice> ueLteDevice = ueDevice->GetObject<LteUeNetDevice>();
527 Ptr<LteUeRrc> ueRrc = ueLteDevice->GetRrc();
528 const uint64_t imsi = ueLteDevice->GetImsi();
529 const uint16_t rnti = ueRrc->GetRnti();
530 NS_LOG_FUNCTION(this << imsi << rnti);
532 "Invalid IMSI " << imsi);
533
534 bool ueStateIsConnectedNormally = (LteUeRrc::CONNECTED_NORMALLY == ueRrc->GetState());
535
536 Ptr<LteEnbNetDevice> enbLteDevice = enbDevice->GetObject<LteEnbNetDevice>();
537 Ptr<LteEnbRrc> enbRrc = enbLteDevice->GetRrc();
538 const bool hasContext = enbRrc->HasUeManager(rnti);
539 bool contextStateIsConnectedNormally = false;
540 if (hasContext)
541 {
542 Ptr<UeManager> ueManager = enbRrc->GetUeManager(rnti);
543 NS_ASSERT(ueManager);
544 contextStateIsConnectedNormally = (UeManager::CONNECTED_NORMALLY == ueManager->GetState());
545 }
547 (!m_isConnectionEstablished[imsi] || !ueStateIsConnectedNormally || !hasContext ||
548 !contextStateIsConnectedNormally),
549 true,
550 "it should not happen that connection is completed both at the UE and at the eNB side");
551}
552
553void
555 uint64_t imsi,
556 uint16_t cellId,
557 uint16_t rnti)
558{
559 NS_LOG_FUNCTION(this << imsi << cellId);
560 m_isConnectionEstablished[imsi] = true;
561}
562
563void
565 uint64_t imsi,
566 uint16_t cellId,
567 uint16_t rnti,
568 uint8_t connEstFailCount)
569{
570 NS_LOG_FUNCTION(this << imsi << cellId);
571}
572
573/**
574 * @ingroup lte-test
575 *
576 * @brief Lte Rrc Connection Establishment Error Test Case
577 */
579{
580 public:
581 /**
582 *
583 *
584 * @param jumpAwayTime the time when all the UEs 'teleport' to a pre-defined
585 * high-interference position and stay there for 100 ms
586 * @param description additional description of the test case
587 */
588 LteRrcConnectionEstablishmentErrorTestCase(Time jumpAwayTime, std::string description = "");
589
590 protected:
591 void DoRun() override;
592
593 private:
594 /// Jump away function
595 void JumpAway();
596 /// Jump back function
597 void JumpBack();
598
599 Time m_jumpAwayTime; ///< jump away time
600 Ptr<MobilityModel> m_ueMobility; ///< UE mobility model
601};
602
604 Time jumpAwayTime,
605 std::string description)
606 : LteRrcConnectionEstablishmentTestCase(1, 1, 0, 0, 1, true, false, true, description),
607 m_jumpAwayTime(jumpAwayTime)
608{
609 NS_LOG_FUNCTION(this << GetName());
610}
611
612void
614{
615 NS_LOG_FUNCTION(this << GetName());
617
618 if (m_nUes < 25)
619 {
620 Config::SetDefault("ns3::LteEnbRrc::SrsPeriodicity", UintegerValue(40));
621 }
622 else if (m_nUes < 60)
623 {
624 Config::SetDefault("ns3::LteEnbRrc::SrsPeriodicity", UintegerValue(80));
625 }
626 else if (m_nUes < 120)
627 {
628 Config::SetDefault("ns3::LteEnbRrc::SrsPeriodicity", UintegerValue(160));
629 }
630 else
631 {
632 Config::SetDefault("ns3::LteEnbRrc::SrsPeriodicity", UintegerValue(320));
633 }
634
635 // normal code
637 m_lteHelper->SetAttribute("UseIdealRrc", BooleanValue(m_useIdealRrc));
638
639 NodeContainer enbNodes;
640 NodeContainer ueNodes;
641
642 enbNodes.Create(4);
643 ueNodes.Create(1);
644
645 MobilityHelper mobility;
646 mobility.Install(ueNodes); // UE position at (0, 0, 0)
647 m_ueMobility = ueNodes.Get(0)->GetObject<MobilityModel>();
648
650 enbPosition->Add(Vector(0, 0, 0));
651 enbPosition->Add(Vector(100.0, 0, 0));
652 enbPosition->Add(Vector(0, 100.0, 0));
653 enbPosition->Add(Vector(100.0, 100.0, 0));
654 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
655 mobility.SetPositionAllocator(enbPosition);
656 mobility.Install(enbNodes);
657
658 int64_t stream = 1;
659 NetDeviceContainer enbDevs;
660 enbDevs = m_lteHelper->InstallEnbDevice(enbNodes);
661 stream += m_lteHelper->AssignStreams(enbDevs, stream);
662
663 NetDeviceContainer ueDevs;
664 ueDevs = m_lteHelper->InstallUeDevice(ueNodes);
665 stream += m_lteHelper->AssignStreams(ueDevs, stream);
666
667 // custom code used for testing purposes
668 // instead of lteHelper->Attach () and lteHelper->ActivateXxx
669
670 // Set AdmitConnectionRequest attribute
671 for (auto it = enbDevs.Begin(); it != enbDevs.End(); ++it)
672 {
673 Ptr<LteEnbRrc> enbRrc = (*it)->GetObject<LteEnbNetDevice>()->GetRrc();
674 enbRrc->SetAttribute("AdmitRrcConnectionRequest",
676 }
677
678 uint32_t i = 0;
679 uint32_t tmax = 0;
680 for (auto it = ueDevs.Begin(); it != ueDevs.End(); ++it)
681 {
682 Ptr<NetDevice> ueDevice = *it;
683 Ptr<NetDevice> enbDevice = enbDevs.Get(0);
684 Ptr<LteUeNetDevice> ueLteDevice = ueDevice->GetObject<LteUeNetDevice>();
685
686 uint32_t tc = m_tConnBase + m_tConnIncrPerUe * i; // time connection start
687 uint32_t tcc = tc + m_delayConnEnd; // time check connection completed;
688 uint32_t td = tcc + m_delayDiscStart; // time disconnect start
689 uint32_t tcd = td + m_delayDiscEnd; // time check disconnection completed
690 tmax = std::max(tmax, tcd);
691
692 // trick to resolve overloading
693 // void (LteHelper::* overloadedAttachFunctionPointer) (Ptr<NetDevice>, Ptr<NetDevice>) =
694 // &LteHelper::Attach; Simulator::Schedule (MilliSeconds (tc),
695 // overloadedAttachFunctionPointer, lteHelper, *it, enbDevice);
698 this,
699 ueDevice,
700 enbDevice);
701
702 // disconnection not supported yet
703
704 uint64_t imsi = ueLteDevice->GetImsi();
705 m_isConnectionEstablished[imsi] = false;
706
707 ++i;
708 }
709
710 // Connect to trace sources in UEs
712 "/NodeList/*/DeviceList/*/LteUeRrc/ConnectionEstablished",
714 this));
716 "/NodeList/*/DeviceList/*/LteUeRrc/ConnectionTimeout",
718
721 this);
724 this,
725 ueDevs.Get(0),
726 enbDevs.Get(0));
729 this);
730
731 Simulator::Stop(MilliSeconds(tmax + 1));
732
734
736}
737
738void
740{
741 NS_LOG_FUNCTION(this);
742 // move to a really far away location so that transmission errors occur
743 m_ueMobility->SetPosition(Vector(100000.0, 100000.0, 0.0));
744}
745
746void
748{
749 NS_LOG_FUNCTION(this);
750 m_ueMobility->SetPosition(Vector(0.0, 0.0, 0.0));
751}
752
753/**
754 * @ingroup lte-test
755 *
756 * @brief Lte Rrc Test Suite
757 */
759{
760 public:
762};
763
765 : TestSuite("lte-rrc", Type::SYSTEM)
766{
767 // LogComponentEnableAll (LOG_PREFIX_ALL);
768 // LogComponentEnable ("LteRrcTest", LOG_LEVEL_ALL);
769 // LogComponentEnable ("LteEnbRrc", LOG_INFO);
770 // LogComponentEnable ("LteUeRrc", LOG_INFO);
771
772 NS_LOG_FUNCTION(this);
773
774 for (auto useIdealRrc : {false, true})
775 {
776 // <----- all times in ms ----------------->
777
778 // nUes tConnBase delayDiscStart useIdealRrc nBearers tConnIncrPerUe errorExpected
779 // admitRrcConnectionRequest
781 new LteRrcConnectionEstablishmentTestCase(1, 0, 0, 0, 1, false, useIdealRrc, true),
782 TestCase::Duration::EXTENSIVE);
784 new LteRrcConnectionEstablishmentTestCase(1, 0, 100, 0, 1, false, useIdealRrc, true),
785 TestCase::Duration::EXTENSIVE);
787 new LteRrcConnectionEstablishmentTestCase(1, 1, 0, 0, 1, false, useIdealRrc, true),
788 TestCase::Duration::EXTENSIVE);
790 new LteRrcConnectionEstablishmentTestCase(1, 1, 100, 0, 1, false, useIdealRrc, true),
791 TestCase::Duration::EXTENSIVE);
793 new LteRrcConnectionEstablishmentTestCase(1, 2, 0, 0, 1, false, useIdealRrc, true),
794 TestCase::Duration::EXTENSIVE);
796 new LteRrcConnectionEstablishmentTestCase(1, 2, 100, 0, 1, false, useIdealRrc, true),
797 TestCase::Duration::EXTENSIVE);
799 new LteRrcConnectionEstablishmentTestCase(2, 0, 20, 0, 1, false, useIdealRrc, true),
800 TestCase::Duration::EXTENSIVE);
802 new LteRrcConnectionEstablishmentTestCase(2, 0, 20, 10, 1, false, useIdealRrc, true),
803 TestCase::Duration::EXTENSIVE);
805 new LteRrcConnectionEstablishmentTestCase(2, 0, 20, 100, 1, false, useIdealRrc, true),
806 TestCase::Duration::EXTENSIVE);
808 new LteRrcConnectionEstablishmentTestCase(2, 1, 20, 0, 1, false, useIdealRrc, true),
809 TestCase::Duration::EXTENSIVE);
811 new LteRrcConnectionEstablishmentTestCase(2, 1, 20, 10, 1, false, useIdealRrc, true),
812 TestCase::Duration::EXTENSIVE);
814 new LteRrcConnectionEstablishmentTestCase(2, 1, 20, 100, 1, false, useIdealRrc, true),
815 TestCase::Duration::EXTENSIVE);
817 new LteRrcConnectionEstablishmentTestCase(2, 2, 20, 0, 1, false, useIdealRrc, true),
818 TestCase::Duration::EXTENSIVE);
820 new LteRrcConnectionEstablishmentTestCase(2, 2, 20, 10, 1, false, useIdealRrc, true),
821 TestCase::Duration::QUICK);
823 new LteRrcConnectionEstablishmentTestCase(2, 2, 20, 100, 1, false, useIdealRrc, true),
824 TestCase::Duration::EXTENSIVE);
826 new LteRrcConnectionEstablishmentTestCase(3, 0, 20, 0, 1, false, useIdealRrc, true),
827 TestCase::Duration::EXTENSIVE);
829 new LteRrcConnectionEstablishmentTestCase(4, 0, 20, 0, 1, false, useIdealRrc, true),
830 TestCase::Duration::EXTENSIVE);
832 new LteRrcConnectionEstablishmentTestCase(4, 0, 20, 300, 1, false, useIdealRrc, true),
833 TestCase::Duration::EXTENSIVE);
835 new LteRrcConnectionEstablishmentTestCase(20, 0, 10, 1, 1, false, useIdealRrc, true),
836 TestCase::Duration::EXTENSIVE);
838 new LteRrcConnectionEstablishmentTestCase(50, 0, 0, 0, 1, false, useIdealRrc, true),
839 TestCase::Duration::EXTENSIVE);
840
841 // Test cases to check admitRrcConnectionRequest=false
842 // nUes tConnBase delayDiscStart
843 // useIdealRrc
844 // nBearers tConnIncrPerUe
845 // errorExpected
846 // admitRrcConnectionRequest
848 new LteRrcConnectionEstablishmentTestCase(1, 0, 0, 0, 1, false, useIdealRrc, false),
849 TestCase::Duration::EXTENSIVE);
851 new LteRrcConnectionEstablishmentTestCase(1, 2, 100, 0, 1, false, useIdealRrc, false),
852 TestCase::Duration::EXTENSIVE);
854 new LteRrcConnectionEstablishmentTestCase(2, 0, 20, 0, 1, false, useIdealRrc, false),
855 TestCase::Duration::EXTENSIVE);
857 new LteRrcConnectionEstablishmentTestCase(2, 1, 20, 0, 1, false, useIdealRrc, false),
858 TestCase::Duration::QUICK);
860 new LteRrcConnectionEstablishmentTestCase(3, 0, 20, 0, 1, false, useIdealRrc, false),
861 TestCase::Duration::EXTENSIVE);
862 }
863
864 // Test cases with transmission error
866 "failure at RRC Connection Request"),
867 TestCase::Duration::QUICK);
869 "failure at RRC Connection Setup"),
870 TestCase::Duration::QUICK);
871 /*
872 * With RLF implementation we now do support the Idle mode,
873 * thus it solve Bug 1762 Comment #25.
874 */
877 "failure at RRC Connection Setup Complete"),
878 TestCase::Duration::QUICK);
879}
880
881/**
882 * @ingroup lte-test
883 * Static variable for test initialization
884 */
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.
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
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:26
This class contains the specification of EPS Bearers.
Definition eps-bearer.h:80
Qci
QoS Class Indicator.
Definition eps-bearer.h:95
@ NGBR_VIDEO_TCP_DEFAULT
Non-GBR TCP-based Video (Buffered Streaming, e.g., www, e-mail...)
Definition eps-bearer.h:115
store information on active data radio bearer instance
The eNodeB device implementation.
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.
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.
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
Definition object.h:511
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.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition simulator.h:560
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition simulator.cc:131
static void Run()
Run the simulation.
Definition simulator.cc:167
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Definition simulator.cc:175
encapsulates test code
Definition test.h:1050
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Definition test.cc:292
std::string GetName() const
Definition test.cc:367
A suite of tests to run.
Definition test.h:1267
Type
Type of test.
Definition test.h:1274
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
State
The state of the UeManager at the eNB RRC.
Definition lte-enb-rrc.h:67
Hold an unsigned integer type.
Definition uinteger.h:34
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition assert.h:55
#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:75
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:848
void SetDefault(std::string name, const AttributeValue &value)
Definition config.cc:883
void Connect(std::string path, const CallbackBase &cb)
Definition config.cc:967
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition log.h:271
#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:250
static LteRrcTestSuite g_lteRrcTestSuiteInstance
Static variable for test initialization.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition object.h:619
#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:134
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition nstime.h:1344
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition nstime.h:1356
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:684