22 #include <ns3/core-module.h>
23 #include <ns3/network-module.h>
24 #include <ns3/mobility-module.h>
25 #include <ns3/lte-module.h>
44 LteRrcConnectionEstablishmentTestCase (uint32_t nUes, uint32_t nBearers, uint32_t tc, uint32_t tConnIncrPerUe, uint32_t delayDiscStart,
bool useIdealRrc,
bool admitRrcConnectionRequest);
47 static std::string BuildNameString (uint32_t nUes, uint32_t nBearers, uint32_t tc, uint32_t tConnIncrPerUe, uint32_t delayDiscStart,
bool useIdealRrc,
bool admitRrcConnectionRequest);
48 virtual void DoRun (
void);
56 uint32_t m_tConnIncrPerUe;
57 uint32_t m_delayConnEnd;
58 uint32_t m_delayDiscStart;
59 uint32_t m_delayDiscEnd;
61 bool m_admitRrcConnectionRequest;
67 std::string LteRrcConnectionEstablishmentTestCase::BuildNameString (uint32_t nUes, uint32_t nBearers, uint32_t tConnBase, uint32_t tConnIncrPerUe, uint32_t delayDiscStart,
bool useIdealRrc,
bool admitRrcConnectionRequest)
69 std::ostringstream oss;
70 oss <<
"nUes=" << nUes
71 <<
", nBearers=" << nBearers
72 <<
", tConnBase=" << tConnBase
73 <<
", tConnIncrPerUe=" << tConnIncrPerUe
74 <<
", delayDiscStart=" << delayDiscStart;
83 if (admitRrcConnectionRequest)
85 oss <<
", admitRrcConnectionRequest = true";
89 oss <<
", admitRrcConnectionRequest = false";
95 :
TestCase (BuildNameString (nUes, nBearers, tConnBase, tConnIncrPerUe, delayDiscStart, useIdealRrc, admitRrcConnectionRequest)),
97 m_nBearers (nBearers),
98 m_tConnBase (tConnBase),
99 m_tConnIncrPerUe (tConnIncrPerUe),
101 m_delayDiscStart (delayDiscStart),
103 m_useIdealRrc (useIdealRrc),
104 m_admitRrcConnectionRequest (admitRrcConnectionRequest)
108 double nRaAttempts = 0;
118 nRaAttempts += std::ceil (nUes / 4.0);
119 double dra = nRaAttempts * 7;
120 double dce = 10.0 + (2.0 * nUes) / 4.0;
142 double dcr = (10.0 + (2.0 * nUes) / 4.0) * (m_nBearers + nCrs);
144 m_delayConnEnd = round (dsi + dra + dce + dcr);
145 NS_LOG_LOGIC (
this <<
GetName () <<
" dsi=" << dsi <<
" dra=" << dra <<
" dce=" << dce <<
" dcr=" << dcr <<
" m_delayConnEnd=" << m_delayConnEnd);
158 else if (m_nUes < 60)
162 else if (m_nUes < 120)
172 m_lteHelper = CreateObject<LteHelper> ();
173 m_lteHelper->SetAttribute (
"UseIdealRrc",
BooleanValue (m_useIdealRrc));
187 enbDevs = m_lteHelper->InstallEnbDevice (enbNodes);
190 ueDevs = m_lteHelper->InstallUeDevice (ueNodes);
196 for (NetDeviceContainer::Iterator it = enbDevs.
Begin ();
197 it != enbDevs.
End ();
201 enbRrc->SetAttribute (
"AdmitRrcConnectionRequest",
BooleanValue (m_admitRrcConnectionRequest));
207 for (NetDeviceContainer::Iterator it = ueDevs.
Begin (); it != ueDevs.
End (); ++it)
213 uint32_t tc = m_tConnBase + m_tConnIncrPerUe * i;
214 uint32_t tcc = tc + m_delayConnEnd;
215 uint32_t td = tcc + m_delayDiscStart;
216 uint32_t tcd = td + m_delayDiscEnd;
217 tmax = std::max (tmax, tcd);
243 m_lteHelper->Attach (ueDevice, enbDevice);
245 for (uint32_t b = 0; b < m_nBearers; ++b)
249 m_lteHelper->ActivateDataRadioBearer (ueDevice, bearer);
253 LteRrcConnectionEstablishmentTestCase::CheckConnected (Ptr<NetDevice> ueDevice, Ptr<NetDevice> enbDevice)
255 Ptr<LteUeNetDevice> ueLteDevice = ueDevice->GetObject<LteUeNetDevice> ();
256 Ptr<LteUeRrc> ueRrc = ueLteDevice->GetRrc ();
258 if (!m_admitRrcConnectionRequest)
260 NS_TEST_ASSERT_MSG_EQ (ueRrc->GetState (), LteUeRrc::IDLE_CAMPED_NORMALLY,
"Wrong LteUeRrc state!");
264 NS_TEST_ASSERT_MSG_EQ (ueRrc->GetState (), LteUeRrc::CONNECTED_NORMALLY,
"Wrong LteUeRrc state!");
266 Ptr<LteEnbNetDevice> enbLteDevice = enbDevice->GetObject<LteEnbNetDevice> ();
267 Ptr<LteEnbRrc> enbRrc = enbLteDevice->GetRrc ();
268 uint16_t rnti = ueRrc->GetRnti ();
269 Ptr<UeManager> ueManager = enbRrc->GetUeManager (rnti);
270 NS_TEST_ASSERT_MSG_NE (ueManager, 0,
"RNTI " << rnti <<
" not found in eNB");
272 NS_TEST_ASSERT_MSG_EQ (ueManager->GetState (), UeManager::CONNECTED_NORMALLY,
"Wrong UeManager state!");
274 uint16_t ueCellId = ueRrc->GetCellId ();
275 uint16_t enbCellId = enbLteDevice->GetCellId ();
276 uint16_t ueImsi = ueLteDevice->GetImsi ();
277 uint16_t enbImsi = ueManager->GetImsi ();
278 uint8_t ueDlBandwidth = ueRrc->GetDlBandwidth ();
279 uint8_t enbDlBandwidth = enbLteDevice->GetDlBandwidth ();
280 uint8_t ueUlBandwidth = ueRrc->GetUlBandwidth ();
281 uint8_t enbUlBandwidth = enbLteDevice->GetUlBandwidth ();
282 uint8_t ueDlEarfcn = ueRrc->GetDlEarfcn ();
283 uint8_t enbDlEarfcn = enbLteDevice->GetDlEarfcn ();
284 uint8_t ueUlEarfcn = ueRrc->GetUlEarfcn ();
285 uint8_t enbUlEarfcn = enbLteDevice->GetUlEarfcn ();
288 NS_TEST_ASSERT_MSG_EQ (ueCellId, enbCellId,
"inconsistent CellId");
289 NS_TEST_ASSERT_MSG_EQ (ueImsi, enbImsi,
"inconsistent Imsi");
290 NS_TEST_ASSERT_MSG_EQ (ueDlBandwidth, enbDlBandwidth,
"inconsistent DlBandwidth");
291 NS_TEST_ASSERT_MSG_EQ (ueUlBandwidth, enbUlBandwidth,
"inconsistent UlBandwidth");
292 NS_TEST_ASSERT_MSG_EQ (ueDlEarfcn, enbDlEarfcn,
"inconsistent DlEarfcn");
293 NS_TEST_ASSERT_MSG_EQ (ueUlEarfcn, enbUlEarfcn,
"inconsistent UlEarfcn");
295 ObjectMapValue enbDataRadioBearerMapValue;
296 ueManager->GetAttribute (
"DataRadioBearerMap", enbDataRadioBearerMapValue);
297 NS_TEST_ASSERT_MSG_EQ (enbDataRadioBearerMapValue.GetN (), m_nBearers,
"wrong num bearers at eNB");
299 ObjectMapValue ueDataRadioBearerMapValue;
300 ueRrc->GetAttribute (
"DataRadioBearerMap", ueDataRadioBearerMapValue);
301 NS_TEST_ASSERT_MSG_EQ (ueDataRadioBearerMapValue.GetN (), m_nBearers,
"wrong num bearers at UE");
303 ObjectMapValue::Iterator enbBearerIt = enbDataRadioBearerMapValue.Begin ();
304 ObjectMapValue::Iterator ueBearerIt = ueDataRadioBearerMapValue.Begin ();
305 while (enbBearerIt != enbDataRadioBearerMapValue.End ()
306 && ueBearerIt != ueDataRadioBearerMapValue.End ())
308 Ptr<LteDataRadioBearerInfo> enbDrbInfo = enbBearerIt->second->GetObject<LteDataRadioBearerInfo> ();
309 Ptr<LteDataRadioBearerInfo> ueDrbInfo = ueBearerIt->second->GetObject<LteDataRadioBearerInfo> ();
311 NS_TEST_ASSERT_MSG_EQ ((uint32_t) enbDrbInfo->m_epsBearerIdentity, (uint32_t) ueDrbInfo->m_epsBearerIdentity,
"epsBearerIdentity differs");
312 NS_TEST_ASSERT_MSG_EQ ((uint32_t) enbDrbInfo->m_drbIdentity, (uint32_t) ueDrbInfo->m_drbIdentity,
"drbIdentity differs");
314 NS_TEST_ASSERT_MSG_EQ ((uint32_t) enbDrbInfo->m_logicalChannelIdentity, (uint32_t) ueDrbInfo->m_logicalChannelIdentity,
"logicalChannelIdentity differs");
320 NS_ASSERT_MSG (enbBearerIt == enbDataRadioBearerMapValue.End (),
"too many bearers at eNB");
321 NS_ASSERT_MSG (ueBearerIt == ueDataRadioBearerMapValue.End (),
"too many bearers at UE");
334 LteRrcTestSuite::LteRrcTestSuite ()
339 for (uint32_t useIdealRrc = 0; useIdealRrc <= 1; ++useIdealRrc)
380 static LteRrcTestSuite g_lteRrcTestSuiteInstance;
Iterator Begin(void) const
Get an iterator which refers to the first NetDevice in the container.
virtual void DoRun(void)
Implementation to actually run this test case.
smart pointer class similar to boost::intrusive_ptr
#define NS_LOG_FUNCTION(parameters)
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
#define NS_ASSERT(condition)
#define NS_LOG_COMPONENT_DEFINE(name)
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
void Install(Ptr< Node > node) const
"Layout" a single node according to the current position allocator type.
Hold an unsigned integer type.
holds a vector of ns3::NetDevice pointers
#define NS_LOG_LOGIC(msg)
static void Destroy(void)
void SetDefault(std::string name, const AttributeValue &value)
keep track of a set of node pointers.
void SetMobilityModel(std::string type, std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue(), std::string n8="", const AttributeValue &v8=EmptyAttributeValue(), std::string n9="", const AttributeValue &v9=EmptyAttributeValue())
void AddTestCase(TestCase *testCase) NS_DEPRECATED
Add an individual test case to this test suite.
#define NS_ASSERT_MSG(condition, message)
Helper class used to assign positions and mobility models to nodes.
Time MilliSeconds(uint64_t ms)
create ns3::Time instances in units of milliseconds.
std::string GetName(void) const
LteRrcConnectionEstablishmentTestCase(uint32_t nUes, uint32_t nBearers, uint32_t tc, uint32_t tConnIncrPerUe, uint32_t delayDiscStart, bool useIdealRrc, bool admitRrcConnectionRequest)
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Iterator End(void) const
Get an iterator which indicates past-the-last NetDevice in the container.