27 #include <ns3/object.h>
28 #include <ns3/spectrum-interference.h>
29 #include <ns3/spectrum-error-model.h>
32 #include <ns3/simulator.h>
33 #include <ns3/packet.h>
35 #include "ns3/radio-bearer-stats-calculator.h"
36 #include <ns3/constant-position-mobility-model.h>
37 #include <ns3/eps-bearer.h>
38 #include <ns3/node-container.h>
39 #include <ns3/mobility-helper.h>
40 #include <ns3/net-device-container.h>
41 #include <ns3/lte-ue-net-device.h>
42 #include <ns3/lte-enb-net-device.h>
43 #include <ns3/lte-ue-rrc.h>
44 #include <ns3/lte-helper.h>
45 #include "ns3/string.h"
46 #include "ns3/double.h"
47 #include <ns3/lte-enb-phy.h>
48 #include <ns3/lte-ue-phy.h>
49 #include <ns3/boolean.h>
52 #include "lte-test-fdbet-ff-mac-scheduler.h"
58 LenaTestFdBetFfMacSchedulerSuite::LenaTestFdBetFfMacSchedulerSuite ()
59 : TestSuite (
"lte-fdbet-ff-mac-scheduler", SYSTEM)
61 NS_LOG_INFO (
"creating LenaTestFdBetFfMacSchedulerSuite");
63 bool errorModel =
false;
150 std::vector<uint16_t> dist;
152 dist.push_back (4800);
153 dist.push_back (6000);
154 dist.push_back (10000);
155 dist.push_back (20000);
156 std::vector<uint32_t> estAchievableRateDl;
157 estAchievableRateDl.push_back (2196000);
158 estAchievableRateDl.push_back (1383000);
159 estAchievableRateDl.push_back (775000);
160 estAchievableRateDl.push_back (421000);
161 estAchievableRateDl.push_back (421000);
162 std::vector<uint32_t> estThrFdBetUl;
163 estThrFdBetUl.push_back (469000);
164 estThrFdBetUl.push_back (157000);
165 estThrFdBetUl.push_back (125000);
166 estThrFdBetUl.push_back (85000);
167 estThrFdBetUl.push_back (26000);
168 AddTestCase (
new LenaFdBetFfMacSchedulerTestCase2 (dist, estAchievableRateDl, estThrFdBetUl, errorModel), TestCase::QUICK);
171 static LenaTestFdBetFfMacSchedulerSuite lenaTestFdBetFfMacSchedulerSuite;
178 LenaFdBetFfMacSchedulerTestCase1::BuildNameString (uint16_t nUser, uint16_t dist)
180 std::ostringstream oss;
181 oss << nUser <<
" UEs, distance " << dist <<
" m";
185 LenaFdBetFfMacSchedulerTestCase1::LenaFdBetFfMacSchedulerTestCase1 (uint16_t nUser, uint16_t nLc, uint16_t dist,
double thrRefDl,
double thrRefUl,
bool errorModelEnabled)
186 : TestCase (BuildNameString (nUser, dist)),
190 m_thrRefDl (thrRefDl),
191 m_thrRefUl (thrRefUl),
192 m_errorModelEnabled (errorModelEnabled)
196 LenaFdBetFfMacSchedulerTestCase1::~LenaFdBetFfMacSchedulerTestCase1 ()
203 if (!m_errorModelEnabled)
217 lteHelper->SetAttribute (
"PathlossModel",
StringValue (
"ns3::FriisSpectrumPropagationLossModel"));
235 lteHelper->SetSchedulerType (
"ns3::FdBetFfMacScheduler");
236 enbDevs = lteHelper->InstallEnbDevice (enbNodes);
237 ueDevs = lteHelper->InstallUeDevice (ueNodes);
240 lteHelper->Attach (ueDevs, enbDevs.
Get (0));
245 lteHelper->ActivateDataRadioBearer (ueDevs, bearer);
249 enbPhy->SetAttribute (
"TxPower",
DoubleValue (30.0));
250 enbPhy->SetAttribute (
"NoiseFigure",
DoubleValue (5.0));
253 for (
int i = 0; i < m_nUser; i++)
256 mm->SetPosition (
Vector (m_dist, 0.0, 0.0));
259 uePhy->SetAttribute (
"TxPower",
DoubleValue (23.0));
260 uePhy->SetAttribute (
"NoiseFigure",
DoubleValue (9.0));
263 double statsStartTime = 0.300;
264 double statsDuration = 0.6;
265 double tolerance = 0.1;
268 lteHelper->EnableMacTraces ();
269 lteHelper->EnableRlcTraces ();
272 rlcStats->SetAttribute (
"EpochDuration",
TimeValue (
Seconds (statsDuration)));
279 NS_LOG_INFO (
"DL - Test with " << m_nUser <<
" user(s) at distance " << m_dist);
280 std::vector <uint64_t> dlDataRxed;
281 for (
int i = 0; i < m_nUser; i++)
287 dlDataRxed.push_back (rlcStats->GetDlRxData (imsi, lcId));
288 NS_LOG_INFO (
"\tUser " << i <<
" imsi " << imsi <<
" bytes rxed " << (
double)dlDataRxed.at (i) <<
" thr " << (double)dlDataRxed.at (i) / statsDuration <<
" ref " << m_thrRefDl);
296 for (
int i = 0; i < m_nUser; i++)
298 NS_TEST_ASSERT_MSG_EQ_TOL ((
double)dlDataRxed.at (i) / statsDuration, m_thrRefDl, m_thrRefDl * tolerance,
" Unfair Throughput!");
304 NS_LOG_INFO (
"UL - Test with " << m_nUser <<
" user(s) at distance " << m_dist);
305 std::vector <uint64_t> ulDataRxed;
306 for (
int i = 0; i < m_nUser; i++)
312 ulDataRxed.push_back (rlcStats->GetUlRxData (imsi, lcId));
313 NS_LOG_INFO (
"\tUser " << i <<
" imsi " << imsi <<
" bytes rxed " << (
double)ulDataRxed.at (i) <<
" thr " << (double)ulDataRxed.at (i) / statsDuration <<
" ref " << m_thrRefUl);
321 for (
int i = 0; i < m_nUser; i++)
323 NS_TEST_ASSERT_MSG_EQ_TOL ((
double)ulDataRxed.at (i) / statsDuration, m_thrRefUl, m_thrRefUl * tolerance,
" Unfair Throughput!");
335 LenaFdBetFfMacSchedulerTestCase2::BuildNameString (uint16_t nUser, std::vector<uint16_t> dist)
337 std::ostringstream oss;
338 oss <<
"distances (m) = [ " ;
339 for (std::vector<uint16_t>::iterator it = dist.begin (); it != dist.end (); ++it)
348 LenaFdBetFfMacSchedulerTestCase2::LenaFdBetFfMacSchedulerTestCase2 (std::vector<uint16_t> dist, std::vector<uint32_t> estAchievableRateDl, std::vector<uint32_t> estThrFdBetUl,
bool errorModelEnabled)
349 : TestCase (BuildNameString (dist.size (), dist)),
350 m_nUser (dist.size ()),
352 m_achievableRateDl (estAchievableRateDl),
353 m_estThrFdBetUl (estThrFdBetUl),
354 m_errorModelEnabled (errorModelEnabled)
358 LenaFdBetFfMacSchedulerTestCase2::~LenaFdBetFfMacSchedulerTestCase2 ()
368 if (!m_errorModelEnabled)
381 lteHelper->SetAttribute (
"PathlossModel",
StringValue (
"ns3::FriisSpectrumPropagationLossModel"));
399 lteHelper->SetSchedulerType (
"ns3::FdBetFfMacScheduler");
400 enbDevs = lteHelper->InstallEnbDevice (enbNodes);
401 ueDevs = lteHelper->InstallUeDevice (ueNodes);
404 lteHelper->Attach (ueDevs, enbDevs.
Get (0));
409 lteHelper->ActivateDataRadioBearer (ueDevs, bearer);
413 enbPhy->SetAttribute (
"TxPower",
DoubleValue (30.0));
414 enbPhy->SetAttribute (
"NoiseFigure",
DoubleValue (5.0));
417 for (
int i = 0; i < m_nUser; i++)
420 mm->SetPosition (
Vector (m_dist.at (i), 0.0, 0.0));
423 uePhy->SetAttribute (
"TxPower",
DoubleValue (23.0));
424 uePhy->SetAttribute (
"NoiseFigure",
DoubleValue (9.0));
428 double statsStartTime = 0.300;
429 double statsDuration = 0.4;
430 double tolerance = 0.1;
433 lteHelper->EnableMacTraces ();
434 lteHelper->EnableRlcTraces ();
437 rlcStats->SetAttribute (
"EpochDuration",
TimeValue (
Seconds (statsDuration)));
441 NS_LOG_INFO (
"DL - Test with " << m_nUser <<
" user(s)");
442 std::vector <uint64_t> dlDataRxed;
443 double totalData = 0;
444 double estTotalThr = 0;
446 for (
int i = 0; i < m_nUser; i++)
452 dlDataRxed.push_back (rlcStats->GetDlRxData (imsi, lcId));
453 totalData += (double)dlDataRxed.at (i);
454 estTotalThr += 1 / m_achievableRateDl.at (i);
455 NS_LOG_INFO (
"\tUser " << i <<
" dist " << m_dist.at (i) <<
" imsi " << imsi <<
" bytes rxed " << (double)dlDataRxed.at (i) <<
" thr " << (double)dlDataRxed.at (i) / statsDuration <<
" ref " << m_nUser);
458 estTotalThr = m_nUser * (1 / estTotalThr);
459 estUeThr = estTotalThr / m_nUser;
464 for (
int i = 0; i < m_nUser; i++)
466 double thrRatio = (double) 1 / m_nUser;
467 double estThrRatio = (double)dlDataRxed.at (i) / totalData;
468 NS_LOG_INFO (
"\tUser " << i <<
" thrRatio " << thrRatio <<
" estThrRatio " << estThrRatio);
469 NS_TEST_ASSERT_MSG_EQ_TOL (estThrRatio, thrRatio, tolerance,
" Unfair Throughput!");
470 NS_TEST_ASSERT_MSG_EQ_TOL ((
double)dlDataRxed.at (i) / statsDuration, estUeThr, estUeThr * tolerance,
" Unfair Throughput!");
479 std::vector <uint64_t> ulDataRxed;
480 for (
int i = 0; i < m_nUser; i++)
486 ulDataRxed.push_back (rlcStats->GetUlRxData (imsi, lcId));
487 NS_LOG_INFO (
"\tUser " << i <<
" dist " << m_dist.at (i) <<
" bytes rxed " << (double)ulDataRxed.at (i) <<
" thr " << (double)ulDataRxed.at (i) / statsDuration <<
" ref " << (double)m_estThrFdBetUl.at (i));
488 NS_TEST_ASSERT_MSG_EQ_TOL ((
double)ulDataRxed.at (i) / statsDuration, (double)m_estThrFdBetUl.at (i), (double)m_estThrFdBetUl.at (i) * tolerance,
" Unfair Throughput!");
smart pointer class similar to boost::intrusive_ptr
#define NS_LOG_FUNCTION(parameters)
hold variables of type string
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
Mobility model for which the current position does not change once it has been set and until it is se...
#define NS_LOG_COMPONENT_DEFINE(name)
virtual void DoRun(void)
Implementation to actually run this test case.
void Install(Ptr< Node > node) const
"Layout" a single node according to the current position allocator type.
hold objects of type ns3::Time
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.
virtual void DoRun(void)
Implementation to actually run this test case.
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