26 #include <ns3/object.h>
27 #include <ns3/spectrum-interference.h>
28 #include <ns3/spectrum-error-model.h>
31 #include <ns3/simulator.h>
32 #include <ns3/packet.h>
34 #include "ns3/radio-bearer-stats-calculator.h"
35 #include <ns3/constant-position-mobility-model.h>
36 #include <ns3/eps-bearer.h>
37 #include <ns3/node-container.h>
38 #include <ns3/mobility-helper.h>
39 #include <ns3/net-device-container.h>
40 #include <ns3/lte-ue-net-device.h>
41 #include <ns3/lte-enb-net-device.h>
42 #include <ns3/lte-ue-rrc.h>
43 #include <ns3/lte-helper.h>
44 #include "ns3/string.h"
45 #include "ns3/double.h"
46 #include <ns3/lte-enb-phy.h>
47 #include <ns3/lte-ue-phy.h>
48 #include <ns3/boolean.h>
51 #include "lte-test-pf-ff-mac-scheduler.h"
57 LenaTestPfFfMacSchedulerSuite::LenaTestPfFfMacSchedulerSuite ()
58 : TestSuite (
"lte-pf-ff-mac-scheduler", SYSTEM)
60 NS_LOG_INFO (
"creating LenaTestPfFfMacSchedulerSuite");
62 bool errorModel =
false;
166 std::vector<uint16_t> dist;
168 dist.push_back (4800);
169 dist.push_back (6000);
170 dist.push_back (10000);
171 dist.push_back (20000);
172 std::vector<uint32_t> estThrPfDl;
173 estThrPfDl.push_back (90000);
174 estThrPfDl.push_back (37000);
175 estThrPfDl.push_back (37000);
176 estThrPfDl.push_back (17400);
177 estThrPfDl.push_back (17400);
178 std::vector<uint32_t> estThrPfUl;
179 estThrPfUl.push_back (469000);
180 estThrPfUl.push_back (157000);
181 estThrPfUl.push_back (125000);
182 estThrPfUl.push_back (85000);
183 estThrPfUl.push_back (26000);
184 AddTestCase (
new LenaPfFfMacSchedulerTestCase2 (dist, estThrPfDl, estThrPfUl,errorModel), TestCase::QUICK);
189 static LenaTestPfFfMacSchedulerSuite lenaTestPfFfMacSchedulerSuite;
196 LenaPfFfMacSchedulerTestCase1::BuildNameString (uint16_t nUser, uint16_t dist)
198 std::ostringstream oss;
199 oss << nUser <<
" UEs, distance " << dist <<
" m";
203 LenaPfFfMacSchedulerTestCase1::LenaPfFfMacSchedulerTestCase1 (uint16_t nUser, uint16_t nLc, uint16_t dist,
double thrRefDl,
double thrRefUl,
bool errorModelEnabled)
204 : TestCase (BuildNameString (nUser, dist)),
208 m_thrRefDl (thrRefDl),
209 m_thrRefUl (thrRefUl),
210 m_errorModelEnabled (errorModelEnabled)
214 LenaPfFfMacSchedulerTestCase1::~LenaPfFfMacSchedulerTestCase1 ()
223 if (!m_errorModelEnabled)
236 lteHelper->SetAttribute (
"PathlossModel",
StringValue (
"ns3::FriisSpectrumPropagationLossModel"));
254 lteHelper->SetSchedulerType (
"ns3::PfFfMacScheduler");
255 enbDevs = lteHelper->InstallEnbDevice (enbNodes);
256 ueDevs = lteHelper->InstallUeDevice (ueNodes);
259 lteHelper->Attach (ueDevs, enbDevs.
Get (0));
264 lteHelper->ActivateDataRadioBearer (ueDevs, bearer);
269 enbPhy->SetAttribute (
"TxPower",
DoubleValue (30.0));
270 enbPhy->SetAttribute (
"NoiseFigure",
DoubleValue (5.0));
273 for (
int i = 0; i < m_nUser; i++)
276 mm->SetPosition (
Vector (m_dist, 0.0, 0.0));
279 uePhy->SetAttribute (
"TxPower",
DoubleValue (23.0));
280 uePhy->SetAttribute (
"NoiseFigure",
DoubleValue (9.0));
284 double statsStartTime = 0.300;
285 double statsDuration = 0.6;
286 double tolerance = 0.1;
289 lteHelper->EnableMacTraces ();
290 lteHelper->EnableRlcTraces ();
293 rlcStats->SetAttribute (
"EpochDuration",
TimeValue (
Seconds (statsDuration)));
301 NS_LOG_INFO (
"DL - Test with " << m_nUser <<
" user(s) at distance " << m_dist);
302 std::vector <uint64_t> dlDataRxed;
303 for (
int i = 0; i < m_nUser; i++)
308 dlDataRxed.push_back (rlcStats->GetDlRxData (imsi, lcId));
309 NS_LOG_INFO (
"\tUser " << i <<
" imsi " << imsi <<
" bytes rxed " << (
double)dlDataRxed.at (i) <<
" thr " << (double)dlDataRxed.at (i) / statsDuration <<
" ref " << m_thrRefDl);
317 for (
int i = 0; i < m_nUser; i++)
319 NS_TEST_ASSERT_MSG_EQ_TOL ((
double)dlDataRxed.at (i) / statsDuration, m_thrRefDl, m_thrRefDl * tolerance,
" Unfair Throughput!");
325 NS_LOG_INFO (
"UL - Test with " << m_nUser <<
" user(s) at distance " << m_dist);
326 std::vector <uint64_t> ulDataRxed;
327 for (
int i = 0; i < m_nUser; i++)
333 ulDataRxed.push_back (rlcStats->GetUlRxData (imsi, lcId));
334 NS_LOG_INFO (
"\tUser " << i <<
" imsi " << imsi <<
" bytes rxed " << (
double)ulDataRxed.at (i) <<
" thr " << (double)ulDataRxed.at (i) / statsDuration <<
" ref " << m_thrRefUl);
342 for (
int i = 0; i < m_nUser; i++)
344 NS_TEST_ASSERT_MSG_EQ_TOL ((
double)ulDataRxed.at (i) / statsDuration, m_thrRefUl, m_thrRefUl * tolerance,
" Unfair Throughput!");
356 LenaPfFfMacSchedulerTestCase2::BuildNameString (uint16_t nUser, std::vector<uint16_t> dist)
358 std::ostringstream oss;
359 oss <<
"distances (m) = [ " ;
360 for (std::vector<uint16_t>::iterator it = dist.begin (); it != dist.end (); ++it)
369 LenaPfFfMacSchedulerTestCase2::LenaPfFfMacSchedulerTestCase2 (std::vector<uint16_t> dist, std::vector<uint32_t> estThrPfDl, std::vector<uint32_t> estThrPfUl,
bool errorModelEnabled)
370 : TestCase (BuildNameString (dist.size (), dist)),
371 m_nUser (dist.size ()),
373 m_estThrPfDl (estThrPfDl),
374 m_estThrPfUl (estThrPfUl),
375 m_errorModelEnabled (errorModelEnabled)
379 LenaPfFfMacSchedulerTestCase2::~LenaPfFfMacSchedulerTestCase2 ()
387 if (!m_errorModelEnabled)
400 lteHelper->SetAttribute (
"PathlossModel",
StringValue (
"ns3::FriisSpectrumPropagationLossModel"));
418 lteHelper->SetSchedulerType (
"ns3::PfFfMacScheduler");
419 enbDevs = lteHelper->InstallEnbDevice (enbNodes);
420 ueDevs = lteHelper->InstallUeDevice (ueNodes);
423 lteHelper->Attach (ueDevs, enbDevs.
Get (0));
428 lteHelper->ActivateDataRadioBearer (ueDevs, bearer);
432 enbPhy->SetAttribute (
"TxPower",
DoubleValue (30.0));
433 enbPhy->SetAttribute (
"NoiseFigure",
DoubleValue (5.0));
436 for (
int i = 0; i < m_nUser; i++)
439 mm->SetPosition (
Vector (m_dist.at (i), 0.0, 0.0));
442 uePhy->SetAttribute (
"TxPower",
DoubleValue (23.0));
443 uePhy->SetAttribute (
"NoiseFigure",
DoubleValue (9.0));
446 double statsStartTime = 0.300;
447 double statsDuration = 0.4;
448 double tolerance = 0.1;
451 lteHelper->EnableRlcTraces ();
454 rlcStats->SetAttribute (
"EpochDuration",
TimeValue (
Seconds (statsDuration)));
459 NS_LOG_INFO (
"DL - Test with " << m_nUser <<
" user(s)");
460 std::vector <uint64_t> dlDataRxed;
461 double totalData = 0;
462 double totalEstThrPf = 0;
463 for (
int i = 0; i < m_nUser; i++)
469 dlDataRxed.push_back (rlcStats->GetDlRxData (imsi, lcId));
470 totalData += (double)dlDataRxed.at (i);
471 NS_LOG_INFO (
"\tUser " << i <<
" dist " << m_dist.at (i) <<
" imsi " << imsi <<
" bytes rxed " << (double)dlDataRxed.at (i) <<
" thr " << (double)dlDataRxed.at (i) / statsDuration);
472 totalEstThrPf += m_estThrPfDl.at (i);
480 for (
int i = 0; i < m_nUser; i++)
482 double thrRatio = (double)dlDataRxed.at (i) / totalData;
483 double estThrRatio = (double)m_estThrPfDl.at (i) / totalEstThrPf;
484 NS_LOG_INFO (
"\tUser " << i <<
" thrRatio " << thrRatio <<
" estThrRatio " << estThrRatio);
485 NS_TEST_ASSERT_MSG_EQ_TOL (estThrRatio, thrRatio, tolerance,
" Unfair Throughput!");
493 std::vector <uint64_t> ulDataRxed;
494 for (
int i = 0; i < m_nUser; i++)
500 ulDataRxed.push_back (rlcStats->GetUlRxData (imsi, lcId));
501 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_estThrPfUl.at (i));
502 NS_TEST_ASSERT_MSG_EQ_TOL ((
double)ulDataRxed.at (i) / statsDuration, (double)m_estThrPfUl.at (i), (double)m_estThrPfUl.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)
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.
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.
virtual void DoRun(void)
Implementation to actually run this test case.
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
virtual void DoRun(void)
Implementation to actually run this test case.