21 #include <ns3/core-module.h>
22 #include <ns3/lte-module.h>
23 #include <ns3/mobility-module.h>
24 #include <ns3/network-module.h>
58 uint32_t tConnIncrPerUe,
59 uint32_t delayDiscStart,
62 bool admitRrcConnectionRequest,
63 std::string description =
"");
66 void DoRun()
override;
83 static std::string BuildNameString(uint32_t nUes,
86 uint32_t tConnIncrPerUe,
87 uint32_t delayDiscStart,
89 bool admitRrcConnectionRequest,
90 std::string description =
"");
116 void ConnectionEstablishedCallback(std::string context,
128 void ConnectionTimeoutCallback(std::string context,
132 uint8_t connEstFailCount);
154 uint32_t tConnIncrPerUe,
155 uint32_t delayDiscStart,
157 bool admitRrcConnectionRequest,
158 std::string description)
160 std::ostringstream oss;
161 oss <<
"nUes=" << nUes <<
", nBearers=" << nBearers <<
", tConnBase=" << tConnBase
162 <<
", tConnIncrPerUe=" << tConnIncrPerUe <<
", delayDiscStart=" << delayDiscStart;
166 oss <<
", ideal RRC";
173 if (admitRrcConnectionRequest)
175 oss <<
", admitRrcConnectionRequest = true";
179 oss <<
", admitRrcConnectionRequest = false";
182 if (!description.empty())
184 oss <<
", " << description;
194 uint32_t tConnIncrPerUe,
195 uint32_t delayDiscStart,
198 bool admitRrcConnectionRequest,
199 std::string description)
206 admitRrcConnectionRequest,
209 m_nBearers(nBearers),
210 m_tConnBase(tConnBase),
211 m_tConnIncrPerUe(tConnIncrPerUe),
213 m_delayDiscStart(delayDiscStart),
215 m_useIdealRrc(useIdealRrc),
216 m_admitRrcConnectionRequest(admitRrcConnectionRequest)
222 double nRaAttempts = 0;
233 nRaAttempts += std::ceil(nUes / 4.0);
234 double dra = nRaAttempts * 7;
235 double dce = 10.0 + (2.0 * nUes) / 4.0;
265 double dcr = (10.0 + (2.0 * nUes) / 4.0) * (
m_nBearers + nCrs);
268 NS_LOG_LOGIC(
this <<
" " <<
GetName() <<
" dsi=" << dsi <<
" dra=" << dra <<
" dce=" << dce
307 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
324 for (
auto it = enbDevs.
Begin(); it != enbDevs.
End(); ++it)
327 enbRrc->SetAttribute(
"AdmitRrcConnectionRequest",
333 for (
auto it = ueDevs.
Begin(); it != ueDevs.
End(); ++it)
363 uint64_t imsi = ueLteDevice->GetImsi();
371 "/NodeList/*/DeviceList/*/LteUeRrc/ConnectionEstablished",
374 "/NodeList/*/DeviceList/*/LteUeRrc/ConnectionTimeout",
381 Simulator::Destroy();
404 const uint64_t imsi = ueLteDevice->GetImsi();
405 const uint16_t rnti = ueRrc->GetRnti();
408 "Invalid IMSI " << imsi);
414 "Connection with RNTI " << rnti <<
" should have been rejected");
424 "RNTI " << rnti <<
" fails to establish connection");
426 LteUeRrc::CONNECTED_NORMALLY,
427 "RNTI " << rnti <<
" is not at CONNECTED_NORMALLY state");
433 const bool hasContext = enbRrc->HasUeManager(rnti);
440 UeManager::CONNECTED_NORMALLY,
441 "The context of RNTI " << rnti <<
" is in invalid state");
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.");
457 uint16_t ueCellId = ueRrc->GetCellId();
458 uint16_t enbCellId = enbLteDevice->
GetCellId();
459 uint16_t ueImsi = ueLteDevice->GetImsi();
461 uint8_t ueDlBandwidth = ueRrc->GetDlBandwidth();
463 uint8_t ueUlBandwidth = ueRrc->GetUlBandwidth();
465 uint8_t ueDlEarfcn = ueRrc->GetDlEarfcn();
467 uint8_t ueUlEarfcn = ueRrc->GetUlEarfcn();
481 uint16_t enbImsi = ueManager->GetImsi();
484 if (state == UeManager::CONNECTED_NORMALLY)
487 ueManager->GetAttribute(
"DataRadioBearerMap", enbDataRadioBearerMapValue);
490 "wrong num bearers at eNB");
492 ueRrc->GetAttribute(
"DataRadioBearerMap", ueDataRadioBearerMapValue);
495 "wrong num bearers at UE");
497 auto enbBearerIt = enbDataRadioBearerMapValue.
Begin();
498 auto ueBearerIt = ueDataRadioBearerMapValue.
Begin();
499 while (enbBearerIt != enbDataRadioBearerMapValue.
End() &&
500 ueBearerIt != ueDataRadioBearerMapValue.
End())
509 (uint32_t)ueDrbInfo->m_epsBearerIdentity,
510 "epsBearerIdentity differs");
512 (uint32_t)ueDrbInfo->m_drbIdentity,
513 "drbIdentity differs");
517 (uint32_t)ueDrbInfo->m_logicalChannelIdentity,
518 "logicalChannelIdentity differs");
527 "too many bearers at eNB");
528 NS_ASSERT_MSG(ueBearerIt == ueDataRadioBearerMapValue.
End(),
"too many bearers at UE");
539 const uint64_t imsi = ueLteDevice->GetImsi();
540 const uint16_t rnti = ueRrc->GetRnti();
543 "Invalid IMSI " << imsi);
545 bool ueStateIsConnectedNormally = (LteUeRrc::CONNECTED_NORMALLY == ueRrc->GetState());
549 const bool hasContext = enbRrc->HasUeManager(rnti);
550 bool contextStateIsConnectedNormally =
false;
555 contextStateIsConnectedNormally = (UeManager::CONNECTED_NORMALLY == ueManager->GetState());
559 !contextStateIsConnectedNormally),
561 "it should not happen that connection is completed both at the UE and at the eNB side");
579 uint8_t connEstFailCount)
602 void DoRun()
override;
616 std::string description)
618 m_jumpAwayTime(jumpAwayTime)
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);
682 for (
auto it = enbDevs.
Begin(); it != enbDevs.
End(); ++it)
685 enbRrc->SetAttribute(
"AdmitRrcConnectionRequest",
691 for (
auto it = ueDevs.
Begin(); it != ueDevs.
End(); ++it)
715 uint64_t imsi = ueLteDevice->GetImsi();
723 "/NodeList/*/DeviceList/*/LteUeRrc/ConnectionEstablished",
727 "/NodeList/*/DeviceList/*/LteUeRrc/ConnectionTimeout",
746 Simulator::Destroy();
785 for (
auto useIdealRrc : {
false,
true})
793 TestCase::EXTENSIVE);
796 TestCase::EXTENSIVE);
799 TestCase::EXTENSIVE);
802 TestCase::EXTENSIVE);
805 TestCase::EXTENSIVE);
808 TestCase::EXTENSIVE);
811 TestCase::EXTENSIVE);
814 TestCase::EXTENSIVE);
817 TestCase::EXTENSIVE);
820 TestCase::EXTENSIVE);
823 TestCase::EXTENSIVE);
826 TestCase::EXTENSIVE);
829 TestCase::EXTENSIVE);
835 TestCase::EXTENSIVE);
838 TestCase::EXTENSIVE);
841 TestCase::EXTENSIVE);
844 TestCase::EXTENSIVE);
847 TestCase::EXTENSIVE);
850 TestCase::EXTENSIVE);
860 TestCase::EXTENSIVE);
863 TestCase::EXTENSIVE);
866 TestCase::EXTENSIVE);
872 TestCase::EXTENSIVE);
877 "failure at RRC Connection Request"),
880 "failure at RRC Connection Setup"),
888 "failure at RRC Connection Setup Complete"),
Lte Rrc Connection Establishment Error Test Case.
void DoRun() override
Implementation to actually run this TestCase.
void JumpBack()
Jump back function.
void JumpAway()
Jump away function.
Time m_jumpAwayTime
jump away time
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
This class contains the specification of EPS Bearers.
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.
void Attach(NetDeviceContainer ueDevices)
Enables automatic attachment of a set of UE devices to a suitable cell using Idle mode initial cell s...
void ActivateDataRadioBearer(NetDeviceContainer ueDevices, EpsBearer bearer)
Activate a Data Radio Bearer on a given UE devices (for LTE-only simulation).
NetDeviceContainer InstallUeDevice(NodeContainer c)
Create a set of UE devices.
int64_t AssignStreams(NetDeviceContainer c, int64_t stream)
Assign a fixed random variable stream number to the random variables used.
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.
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
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.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
std::string GetName() const
Simulation virtual time values and global simulation resolution.
State
The state of the UeManager at the eNB RRC.
Hold an unsigned integer type.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
void Reset()
Reset the initial value of every attribute as well as the value of every global to what they were bef...
void SetDefault(std::string name, const AttributeValue &value)
void Connect(std::string path, const CallbackBase &cb)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
#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.
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.
Time Seconds(double value)
Construct a Time in the indicated unit.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
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...