24 #include <ns3/boolean.h> 25 #include <ns3/double.h> 26 #include <ns3/integer.h> 28 #include <ns3/simulator.h> 30 #include <ns3/internet-stack-helper.h> 31 #include <ns3/ipv4-address-helper.h> 32 #include <ns3/ipv4-interface-container.h> 33 #include <ns3/friis-spectrum-propagation-loss.h> 34 #include <ns3/ipv4-static-routing-helper.h> 35 #include <ns3/lte-enb-net-device.h> 36 #include <ns3/lte-helper.h> 37 #include <ns3/lte-ue-net-device.h> 38 #include <ns3/lte-ue-rrc.h> 39 #include <ns3/mobility-helper.h> 40 #include <ns3/net-device-container.h> 41 #include <ns3/node-container.h> 42 #include <ns3/point-to-point-epc-helper.h> 43 #include <ns3/point-to-point-helper.h> 54 :
TestSuite (
"lte-secondary-cell-selection", SYSTEM)
75 std::string name,
bool isIdealRrc, uint64_t rngRun, uint8_t numberOfComponentCarriers)
77 m_isIdealRrc (isIdealRrc),
79 m_numberOfComponentCarriers (numberOfComponentCarriers)
98 auto lteHelper = CreateObject<LteHelper> ();
103 auto epcHelper = CreateObject<PointToPointEpcHelper> ();
104 lteHelper->SetEpcHelper (epcHelper);
107 auto enbNode = CreateObject<Node> ();
112 mobility.SetMobilityModel (
"ns3::ConstantPositionMobilityModel");
117 auto enbDev = DynamicCast<LteEnbNetDevice> (lteHelper->InstallEnbDevice (enbNode).Get (0));
118 auto ueDevs = lteHelper->InstallUeDevice (ueNodes);
123 epcHelper->AssignUeIpv4Address (ueDevs);
125 auto ueDev = DynamicCast<LteUeNetDevice> (ueDevs.Get (0));
126 std::map< uint8_t, Ptr<ComponentCarrierUe> > ueCcMap = ueDev->GetCcMap ();
127 for (
auto it: ueCcMap)
129 std::cerr <<
"Assign " << it.second->GetDlEarfcn() << std::endl;
130 DynamicCast<LteUeNetDevice> (ueDevs.Get (it.first))->SetDlEarfcn (it.second->GetDlEarfcn());
134 lteHelper->Attach (ueDevs);
140 Config::Connect (
"/NodeList/*/DeviceList/*/LteUeRrc/InitialSecondaryCellSelectionEndOk",
143 Config::Connect (
"/NodeList/*/DeviceList/*/LteUeRrc/ConnectionEstablished",
148 Simulator::Stop (
Seconds (2.0));
151 for (
auto &it: enbDev->GetCcMap ())
153 ueDev = DynamicCast<LteUeNetDevice> (ueDevs.Get (it.first));
154 uint16_t expectedCellId = it.second->GetCellId ();
155 uint16_t actualCellId = ueDev->GetRrc ()->GetCellId ();
156 NS_TEST_ASSERT_MSG_EQ (expectedCellId, actualCellId,
"IMSI " << ueDev->GetImsi () <<
" has attached to an unexpected cell");
159 LteUeRrc::CONNECTED_NORMALLY,
160 "UE " << ueDev->GetImsi ()
161 <<
" is not at CONNECTED_NORMALLY state");
165 Simulator::Destroy ();
171 std::string context, uint64_t imsi, uint16_t cellId, uint16_t rnti,
174 NS_LOG_FUNCTION (
this << imsi << cellId << rnti << oldState << newState);
181 std::string context, uint64_t imsi, uint16_t cellId)
188 std::string context, uint64_t imsi, uint16_t cellId, uint16_t rnti)
Test suite for executing the secondary cell selection test cases.
uint8_t m_numberOfComponentCarriers
number of component carriers
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
AttributeValue implementation for Boolean.
std::map< uint64_t, LteUeRrc::State > m_lastState
The current UE RRC state.
static TypeId GetTypeId()
Get the type ID.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
aggregate IP/TCP/UDP functionality to existing Nodes.
virtual ~LteSecondaryCellSelectionTestCase()
void StateTransitionCallback(std::string context, uint64_t imsi, uint16_t cellId, uint16_t rnti, LteUeRrc::State oldState, LteUeRrc::State newState)
State transition callback function.
Testing the initial cell selection procedure by UE at IDLE state in the beginning of simulation with ...
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Hold an unsigned integer type.
#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.
LteSecondaryCellSelectionTestCase(std::string name, bool isIdealRrc, uint64_t rngRun, uint8_t numberOfComponentCarriers)
Creates an instance of the initial cell selection test case.
AttributeValue implementation for TypeId.
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
bool m_isIdealRrc
whether the LTE is configured to use ideal RRC
void Connect(std::string path, const CallbackBase &cb)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
keep track of a set of node pointers.
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
State
The states of the UE RRC entity.
Helper class used to assign positions and mobility models to nodes.
void ConnectionEstablishedCallback(std::string context, uint64_t imsi, uint16_t cellId, uint16_t rnti)
Connection established callback function.
std::string GetName(void) const
virtual void DoRun()
Setup the simulation according to the configuration set by the class constructor, run it...
void SetGlobal(std::string name, const AttributeValue &value)
Time Seconds(double value)
Construct a Time in the indicated unit.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
static LteSecondaryCellSelectionTestSuite g_lteSecondaryCellSelectionTestSuite
void InitialSecondaryCellSelectionEndOkCallback(std::string context, uint64_t imsi, uint16_t cellId)
Initial cell selection end ok callback function.
LteSecondaryCellSelectionTestSuite()