23 #include <ns3/boolean.h>
24 #include <ns3/double.h>
25 #include <ns3/friis-spectrum-propagation-loss.h>
26 #include <ns3/integer.h>
27 #include <ns3/internet-stack-helper.h>
28 #include <ns3/ipv4-address-helper.h>
29 #include <ns3/ipv4-interface-container.h>
30 #include <ns3/ipv4-static-routing-helper.h>
32 #include <ns3/lte-enb-net-device.h>
33 #include <ns3/lte-helper.h>
34 #include <ns3/lte-ue-net-device.h>
35 #include <ns3/lte-ue-rrc.h>
36 #include <ns3/mobility-helper.h>
37 #include <ns3/net-device-container.h>
38 #include <ns3/node-container.h>
39 #include <ns3/point-to-point-epc-helper.h>
40 #include <ns3/point-to-point-helper.h>
41 #include <ns3/simulator.h>
52 :
TestSuite(
"lte-secondary-cell-selection", SYSTEM)
84 uint8_t numberOfComponentCarriers)
86 m_isIdealRrc(isIdealRrc),
88 m_numberOfComponentCarriers(numberOfComponentCarriers)
106 auto lteHelper = CreateObject<LteHelper>();
107 lteHelper->SetAttribute(
"PathlossModel",
110 lteHelper->SetAttribute(
"NumberOfComponentCarriers",
113 auto epcHelper = CreateObject<PointToPointEpcHelper>();
114 lteHelper->SetEpcHelper(epcHelper);
117 auto enbNode = CreateObject<Node>();
122 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
127 auto enbDev = DynamicCast<LteEnbNetDevice>(lteHelper->InstallEnbDevice(enbNode).Get(0));
128 auto ueDevs = lteHelper->InstallUeDevice(ueNodes);
133 epcHelper->AssignUeIpv4Address(ueDevs);
135 auto ueDev = DynamicCast<LteUeNetDevice>(ueDevs.Get(0));
136 std::map<uint8_t, Ptr<ComponentCarrierUe>> ueCcMap = ueDev->GetCcMap();
137 for (
auto it : ueCcMap)
139 NS_LOG_DEBUG(
"Assign DL EARFCN " << it.second->GetDlEarfcn() <<
" to UE "
140 << ueDevs.Get(it.first)->GetNode()->GetId());
141 DynamicCast<LteUeNetDevice>(ueDevs.Get(it.first))->SetDlEarfcn(it.second->GetDlEarfcn());
145 lteHelper->Attach(ueDevs);
149 "/NodeList/*/DeviceList/*/LteUeRrc/StateTransition",
152 "/NodeList/*/DeviceList/*/LteUeRrc/ConnectionEstablished",
159 for (
auto& it : enbDev->GetCcMap())
161 ueDev = DynamicCast<LteUeNetDevice>(ueDevs.Get(it.first));
162 uint16_t expectedCellId = it.second->GetCellId();
163 uint16_t actualCellId = ueDev->GetRrc()->GetCellId();
165 <<
" attached to cell ID: " << actualCellId);
168 "IMSI " << ueDev->GetImsi() <<
" has attached to an unexpected cell");
171 LteUeRrc::CONNECTED_NORMALLY,
172 "UE " << ueDev->GetImsi() <<
" is not at CONNECTED_NORMALLY state");
176 Simulator::Destroy();
Testing the initial cell selection procedure by UE at IDLE state in the beginning of simulation with ...
void StateTransitionCallback(std::string context, uint64_t imsi, uint16_t cellId, uint16_t rnti, LteUeRrc::State oldState, LteUeRrc::State newState)
State transition callback function.
bool m_isIdealRrc
whether the LTE is configured to use ideal RRC
uint8_t m_numberOfComponentCarriers
number of component carriers
std::map< uint64_t, LteUeRrc::State > m_lastState
The current UE RRC state.
void ConnectionEstablishedCallback(std::string context, uint64_t imsi, uint16_t cellId, uint16_t rnti)
Connection established callback function.
~LteSecondaryCellSelectionTestCase() override
LteSecondaryCellSelectionTestCase(std::string name, bool isIdealRrc, uint64_t rngRun, uint8_t numberOfComponentCarriers)
Creates an instance of the initial cell selection test case.
void DoRun() override
Setup the simulation according to the configuration set by the class constructor, run it,...
Test suite for executing the secondary cell selection test cases.
LteSecondaryCellSelectionTestSuite()
static TypeId GetTypeId()
Get the type ID.
aggregate IP/TCP/UDP functionality to existing Nodes.
State
The states of the UE RRC entity.
Helper class used to assign positions and mobility models to nodes.
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.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
std::string GetName() const
Hold an unsigned integer type.
void SetGlobal(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_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
static LteSecondaryCellSelectionTestSuite g_lteSecondaryCellSelectionTestSuite
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.
static const std::string & ToString(LteUeRrc::State s)
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...