21 #include <ns3/object.h>
22 #include <ns3/spectrum-interference.h>
23 #include <ns3/spectrum-error-model.h>
26 #include <ns3/simulator.h>
27 #include <ns3/packet.h>
30 #include <ns3/radio-bearer-stats-calculator.h>
31 #include <ns3/buildings-mobility-model.h>
32 #include <ns3/hybrid-buildings-propagation-loss-model.h>
33 #include <ns3/eps-bearer.h>
34 #include <ns3/node-container.h>
35 #include <ns3/mobility-helper.h>
36 #include <ns3/net-device-container.h>
37 #include <ns3/lte-ue-net-device.h>
38 #include <ns3/lte-enb-net-device.h>
39 #include <ns3/lte-ue-rrc.h>
40 #include <ns3/lte-helper.h>
41 #include <ns3/string.h>
42 #include <ns3/double.h>
43 #include <ns3/lte-enb-phy.h>
44 #include <ns3/lte-ue-phy.h>
45 #include <ns3/config.h>
46 #include <ns3/boolean.h>
48 #include <ns3/unused.h>
49 #include <ns3/ff-mac-scheduler.h>
51 #include "lte-test-phy-error-model.h"
58 LenaTestPhyErrorModelrSuite::LenaTestPhyErrorModelrSuite ()
59 : TestSuite (
"lte-phy-error-model", SYSTEM)
61 NS_LOG_INFO (
"creating LenaTestPhyErrorModelTestCase");
66 AddTestCase (
new LenaDlCtrlPhyErrorModelTestCase (2, 1078, 217, 0.007), TestCase::QUICK);
76 AddTestCase (
new LenaDataPhyErrorModelTestCase (4, 1800, 32, 0.33, 50), TestCase::QUICK);
93 static LenaTestPhyErrorModelrSuite lenaTestPhyErrorModelrSuite;
96 LenaDataPhyErrorModelTestCase::BuildNameString (uint16_t nUser, uint16_t dist)
98 std::ostringstream oss;
99 oss << nUser <<
" UEs, distance " << dist <<
" m";
103 LenaDataPhyErrorModelTestCase::LenaDataPhyErrorModelTestCase (uint16_t nUser, uint16_t dist, uint16_t tbSize,
double berRef, uint16_t bernQuantile)
104 : TestCase (BuildNameString (nUser, dist)),
109 m_bernQuantile (bernQuantile)
113 LenaDataPhyErrorModelTestCase::~LenaDataPhyErrorModelTestCase ()
192 lena->SetAttribute (
"PathlossModel",
StringValue (
"ns3::HybridBuildingsPropagationLossModel"));
193 lena->SetPathlossModelAttribute (
"ShadowSigmaOutdoor",
DoubleValue (0.0));
194 lena->SetPathlossModelAttribute (
"ShadowSigmaIndoor",
DoubleValue (0.0));
195 lena->SetPathlossModelAttribute (
"ShadowSigmaExtWalls",
DoubleValue (0.0));
200 lena->SetSchedulerType (
"ns3::RrFfMacScheduler");
201 lena->SetSchedulerAttribute (
"UlCqiFilter",
EnumValue (FfMacScheduler::PUSCH_UL_CQI));
203 enbDevs = lena->InstallEnbDevice (enbNodes);
204 ueDevs = lena->InstallUeDevice (ueNodes);
207 lena->Attach (ueDevs, enbDevs.
Get (0));
212 lena->ActivateDataRadioBearer (ueDevs, bearer);
217 enbPhy->SetAttribute (
"TxPower",
DoubleValue (43.0));
218 enbPhy->SetAttribute (
"NoiseFigure",
DoubleValue (5.0));
221 mm->SetPosition (
Vector (0.0, 0.0, 30.0));
224 for (
int i = 0; i < m_nUser; i++)
227 mm->SetPosition (
Vector (m_dist, 0.0, 1.0));
230 uePhy->SetAttribute (
"TxPower",
DoubleValue (23.0));
231 uePhy->SetAttribute (
"NoiseFigure",
DoubleValue (9.0));
234 lena->EnableRlcTraces ();
235 double simulationTime = 1.000;
240 rlcStats->SetAttribute (
"EpochDuration",
TimeValue (
Seconds (simulationTime)));
248 NS_LOG_INFO (
"\tTest downlink/uplink data shared channels (PDSCH and PUSCH)");
249 NS_LOG_INFO (
"Test with " << m_nUser <<
" user(s) at distance " << m_dist <<
" expected BER " << m_berRef);
250 std::vector <uint64_t> dlDataRxed;
251 for (
int i = 0; i < m_nUser; i++)
257 dlDataRxed.push_back (rlcStats->GetDlRxData (imsi, lcId));
258 double txed = rlcStats->GetDlTxData (imsi, lcId);
259 int n = txed / m_tbSize;
260 int lambda = (double)dlDataRxed.at (i) / m_tbSize;
261 double ber = 1.0 - ((double)dlDataRxed.at (i)/txed);
262 double np = n-n*m_berRef;
263 NS_LOG_INFO (
"\tUser " << i <<
" imsi " << imsi <<
" bytes rxed " << (
double)dlDataRxed.at (i) <<
" txed " << txed
264 <<
" BER " << ber <<
" Err " << std::fabs (m_berRef - ber) <<
" lambda " << lambda
265 <<
" np " << np <<
" difference " << std::abs (lambda - np) <<
" quantile " << m_bernQuantile);
270 NS_TEST_ASSERT_MSG_EQ_TOL (lambda, np, m_bernQuantile,
" Unexpected BER distribution!");
281 LenaDlCtrlPhyErrorModelTestCase::BuildNameString (uint16_t nEnb, uint16_t dist)
283 std::ostringstream oss;
284 oss << nEnb <<
" eNBs, distance " << dist <<
" m";
289 LenaDlCtrlPhyErrorModelTestCase::LenaDlCtrlPhyErrorModelTestCase (uint16_t nEnb, uint16_t dist, uint16_t tbSize,
double berRef)
290 : TestCase (BuildNameString (nEnb, dist)),
298 LenaDlCtrlPhyErrorModelTestCase::~LenaDlCtrlPhyErrorModelTestCase ()
377 lena->SetAttribute (
"PathlossModel",
StringValue (
"ns3::HybridBuildingsPropagationLossModel"));
378 lena->SetPathlossModelAttribute (
"ShadowSigmaOutdoor",
DoubleValue (0.0));
379 lena->SetPathlossModelAttribute (
"ShadowSigmaIndoor",
DoubleValue (0.0));
380 lena->SetPathlossModelAttribute (
"ShadowSigmaExtWalls",
DoubleValue (0.0));
385 lena->SetSchedulerType (
"ns3::RrFfMacScheduler");
386 lena->SetSchedulerAttribute (
"UlCqiFilter",
EnumValue (FfMacScheduler::PUSCH_UL_CQI));
388 enbDevs = lena->InstallEnbDevice (enbNodes);
389 ueDevs = lena->InstallUeDevice (ueNodes);
392 lena->Attach (ueDevs, enbDevs.
Get (0));
397 lena->ActivateDataRadioBearer (ueDevs, bearer);
400 for (
int i = 0; i < m_nEnb; i++)
404 mm->SetPosition (
Vector (0.0, 0.0, 30.0));
407 enbPhy->SetAttribute (
"TxPower",
DoubleValue (43.0));
408 enbPhy->SetAttribute (
"NoiseFigure",
DoubleValue (5.0));
413 mm->SetPosition (
Vector (m_dist, 0.0, 1.0));
416 uePhy->SetAttribute (
"TxPower",
DoubleValue (23.0));
417 uePhy->SetAttribute (
"NoiseFigure",
DoubleValue (9.0));
420 lena->EnableRlcTraces ();
421 double simulationTime = 1.000;
426 rlcStats->SetAttribute (
"EpochDuration",
TimeValue (
Seconds (simulationTime)));
434 NS_LOG_INFO (
"\tTest downlink control channels (PCFICH+PDCCH)");
435 NS_LOG_INFO (
"Test with " << m_nEnb <<
" eNB(s) at distance " << m_dist <<
" expected BER " << m_berRef);
436 std::vector <uint64_t> dlDataRxed;
438 for (
int i = 0; i < nUser; i++)
444 dlDataRxed.push_back (rlcStats->GetDlRxData (imsi, lcId));
445 double txed = rlcStats->GetDlTxData (imsi, lcId);
446 double ber = 1.0 - ((double)dlDataRxed.at (i)/txed);
447 NS_LOG_INFO (
"\tUser " << i <<
" imsi " << imsi <<
" bytes rxed " << (
double)dlDataRxed.at (i) <<
" txed " << txed
448 <<
" BER " << ber <<
" Err " << fabs (m_berRef - ber));
450 NS_TEST_ASSERT_MSG_EQ_TOL (ber, m_berRef, 0.1,
" Unexpected BER distribution!");
smart pointer class similar to boost::intrusive_ptr
virtual void DoRun(void)
Implementation to actually run this test case.
hold variables of type string
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
#define NS_LOG_COMPONENT_DEFINE(name)
void Install(Ptr< Node > node) const
"Layout" a single node according to the current position allocator type.
hold variables of type 'enum'
hold objects of type ns3::Time
virtual void DoRun(void)
Implementation to actually run this test case.
Buildings mobility model.
holds a vector of ns3::NetDevice pointers
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.
Helper class used to assign positions and mobility models to nodes.
Time Seconds(double seconds)
create ns3::Time instances in units of seconds.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Hold an floating point type.
Ptr< T > GetObject(void) const
void LogComponentEnable(char const *name, enum LogLevel level)