From e716530b9232b416c81d11b502f50ee69a682dcc Mon Sep 17 00:00:00 2001 From: Marco Miozzo Date: Fri, 29 Apr 2011 12:12:43 +0200 Subject: [PATCH] Lena Test 1.4 (RR Scheduler) and Test 1.5 (PF Scheduler) draft versions --- src/lte/test/lena-test-pf-ff-mac-scheduler.cc | 189 ++++++++++++++++ src/lte/test/lena-test-pf-ff-mac-scheduler.h | 55 +++++ src/lte/test/lena-test-rr-ff-mac-scheduler.cc | 206 ++++++++++++++++++ src/lte/test/lena-test-rr-ff-mac-scheduler.h | 55 +++++ src/lte/wscript | 4 + 5 files changed, 509 insertions(+) create mode 100644 src/lte/test/lena-test-pf-ff-mac-scheduler.cc create mode 100644 src/lte/test/lena-test-pf-ff-mac-scheduler.h create mode 100644 src/lte/test/lena-test-rr-ff-mac-scheduler.cc create mode 100644 src/lte/test/lena-test-rr-ff-mac-scheduler.h diff --git a/src/lte/test/lena-test-pf-ff-mac-scheduler.cc b/src/lte/test/lena-test-pf-ff-mac-scheduler.cc new file mode 100644 index 000000000..6fd111a80 --- /dev/null +++ b/src/lte/test/lena-test-pf-ff-mac-scheduler.cc @@ -0,0 +1,189 @@ +/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Marco Miozzo + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "ns3/rlc-stats-calculator.h" + +#include "ns3/lena-test-pf-ff-mac-scheduler.h" +#include +#include +#include +#include +#include + +NS_LOG_COMPONENT_DEFINE ("LenaTestPfFfMacCheduler"); + +using namespace ns3; + + +// void +// UlTxPduCallback(Ptr rlcStats, std::string path, +// uint16_t rnti, uint8_t lcid, uint32_t packetSize) +// { +// rlcStats->UlTxPdu(rnti, lcid, packetSize); +// } +// +// void +// UlRxPduCallback(Ptr rlcStats, std::string path, +// uint16_t rnti, uint8_t lcid, uint32_t packetSize, uint64_t delay) +// { +// rlcStats->UlRxPdu(rnti, lcid, packetSize, delay); +// } +// +// void +// DlTxPduCallback(Ptr rlcStats, std::string path, +// uint16_t rnti, uint8_t lcid, uint32_t packetSize) +// { +// rlcStats->DlTxPdu(rnti, lcid, packetSize); +// } +// +// void +// DlRxPduCallback(Ptr rlcStats, std::string path, +// uint16_t rnti, uint8_t lcid, uint32_t packetSize, uint64_t delay) +// { +// rlcStats->DlRxPdu(rnti, lcid, packetSize, delay); +// } + + +/** + * Test 1.5 Proportional Fair (PF) MAC Scheduler + */ + + +LenaTest1_5Suite::LenaTest1_5Suite () +: TestSuite ("lenaTest1.5", SYSTEM) +{ + SetVerbose (true); + NS_LOG_INFO ("creating LenaPfFfMacSchedulerTestCase"); + AddTestCase (new LenaPfFfMacSchedulerTestCase); +} + +static LenaTest1_5Suite lenaTest1_5Suite; + +LenaPfFfMacSchedulerTestCase::LenaPfFfMacSchedulerTestCase () + : TestCase ("Round Robin (RR) Mac Scheduler Test Case") +{ +} + +LenaPfFfMacSchedulerTestCase::~LenaPfFfMacSchedulerTestCase () +{ +} + +void +LenaPfFfMacSchedulerTestCase::DoRun (void) +{ + LogComponentEnable ("LteEnbRrc", LOG_LEVEL_ALL); + LogComponentEnable ("LteUeRrc", LOG_LEVEL_ALL); + LogComponentEnable ("LteEnbMac", LOG_LEVEL_ALL); + LogComponentEnable ("LteUeMac", LOG_LEVEL_ALL); + LogComponentEnable ("LteRlc", LOG_LEVEL_ALL); + LogComponentEnable ("RrPacketScheduler", LOG_LEVEL_ALL); + + LogComponentEnable ("LtePhy", LOG_LEVEL_ALL); + LogComponentEnable ("LteEnbPhy", LOG_LEVEL_ALL); + LogComponentEnable ("LteUePhy", LOG_LEVEL_ALL); + + LogComponentEnable ("LteSpectrumPhy", LOG_LEVEL_ALL); + LogComponentEnable ("LteInterference", LOG_LEVEL_ALL); + LogComponentEnable ("LteSinrChunkProcessor", LOG_LEVEL_ALL); + + LogComponentEnable ("LtePropagationLossModel", LOG_LEVEL_ALL); + LogComponentEnable ("LossModel", LOG_LEVEL_ALL); + LogComponentEnable ("ShadowingLossModel", LOG_LEVEL_ALL); + LogComponentEnable ("PenetrationLossModel", LOG_LEVEL_ALL); + LogComponentEnable ("MultipathLossModel", LOG_LEVEL_ALL); + LogComponentEnable ("PathLossModel", LOG_LEVEL_ALL); + + LogComponentEnable ("LteNetDevice", LOG_LEVEL_ALL); + LogComponentEnable ("LteUeNetDevice", LOG_LEVEL_ALL); + LogComponentEnable ("LteEnbNetDevice", LOG_LEVEL_ALL); + + LogComponentEnable ("LenaTestSinrChunkProcessor", LOG_LEVEL_ALL); + LogComponentEnable ("LenaTest", LOG_LEVEL_ALL); + + /** + * Initialize Simulation Scenario: 1 eNB and 2 UEs + */ + + SetVerbose (true); + + LenaHelper lena; + // Create Nodes: eNodeB and UE + NodeContainer enbNodes; + NodeContainer ueNodes; + enbNodes.Create (1); + ueNodes.Create (2); + + // Install Mobility Model + MobilityHelper mobility; + mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); + mobility.Install (enbNodes); + mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); + mobility.Install (ueNodes); + + // Create Devices and install them in the Nodes (eNB and UE) + NetDeviceContainer enbDevs; + NetDeviceContainer ueDevs; + lena.SetScheduler ("PfFfMacScheduler"); + enbDevs = lena.InstallEnbDevice (enbNodes); + ueDevs = lena.InstallUeDevice (ueNodes); + + // Attach a UE to a eNB + lena.Attach (ueDevs, enbDevs.Get (0)); + + // Activate an EPS bearer + enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; + EpsBearer bearer (q); + lena.ActivateEpsBearer (ueDevs, bearer); + + + Simulator::Stop (Seconds (0.005)); + + Ptr rlcStats = CreateObject (); + + Simulator::Run (); + + Simulator::Destroy (); + + /** + * Check that the assignation is done in a "proportional fair" manner + */ + //NS_TEST_ASSERT_MSG_EQ (*rxPsd, saveRxPsd, "Data signal corrupted !"); + //NS_TEST_ASSERT_MSG_EQ (*noisePsd, saveNoisePsd, "Noise signal corrupted !"); + + //SpectrumValue theoreticalSinr = (*rxPsd) / ( ( 2 * (*rxPsd) ) + (*noisePsd) ); + //SpectrumValue calculatedSinr = p->GetSinr (); + + NS_LOG_INFO ("User 1 Rx Data: " << rlcStats->GetDlRxData (1,1)); + NS_LOG_INFO ("User 2 Rx Data: " << rlcStats->GetDlRxData (2,1)); + NS_TEST_ASSERT_MSG_EQ_TOL (rlcStats->GetDlRxData (1,1), rlcStats->GetDlRxData (2,1), 0.01, " Unfair Throughput!"); + + //NS_TEST_ASSERT_MSG_EQ_TOL (calculatedSinr, theoreticalSinr, 0.000001, "Wrong SINR !"); +} + + diff --git a/src/lte/test/lena-test-pf-ff-mac-scheduler.h b/src/lte/test/lena-test-pf-ff-mac-scheduler.h new file mode 100644 index 000000000..5c4651831 --- /dev/null +++ b/src/lte/test/lena-test-pf-ff-mac-scheduler.h @@ -0,0 +1,55 @@ +/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Marco Miozzo + */ + +#ifndef LENA_TEST_PF_FF_MAC_SCHEDULER_H +#define LENA_TEST_PF_FF_MAC_SCHEDULER_H + +#include "ns3/simulator.h" +#include "ns3/test.h" + + +using namespace ns3; + + +/** + * Test 1.5 Proportional Fair MAC Scheduler + */ +class LenaPfFfMacSchedulerTestCase : public TestCase +{ + public: + LenaPfFfMacSchedulerTestCase (); + virtual ~LenaPfFfMacSchedulerTestCase (); + + private: + virtual void DoRun (void); +}; + + + +class LenaTest1_5Suite : public TestSuite +{ + public: + LenaTest1_5Suite (); +}; + + + + +#endif /* LENA_TEST_RR_FF_MAC_SCHEDULER_H */ diff --git a/src/lte/test/lena-test-rr-ff-mac-scheduler.cc b/src/lte/test/lena-test-rr-ff-mac-scheduler.cc new file mode 100644 index 000000000..6c65df6c3 --- /dev/null +++ b/src/lte/test/lena-test-rr-ff-mac-scheduler.cc @@ -0,0 +1,206 @@ +/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Marco Miozzo + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "ns3/rlc-stats-calculator.h" + +#include "ns3/lena-test-rr-ff-mac-scheduler.h" +#include +#include +#include +#include +#include + +NS_LOG_COMPONENT_DEFINE ("LenaTestRrFfMacCheduler"); + +using namespace ns3; + + +// void +// UlTxPduCallback(Ptr rlcStats, std::string path, +// uint16_t rnti, uint8_t lcid, uint32_t packetSize) +// { +// rlcStats->UlTxPdu(rnti, lcid, packetSize); +// } +// +// void +// UlRxPduCallback(Ptr rlcStats, std::string path, +// uint16_t rnti, uint8_t lcid, uint32_t packetSize, uint64_t delay) +// { +// rlcStats->UlRxPdu(rnti, lcid, packetSize, delay); +// } +// +// void +// DlTxPduCallback(Ptr rlcStats, std::string path, +// uint16_t rnti, uint8_t lcid, uint32_t packetSize) +// { +// rlcStats->DlTxPdu(rnti, lcid, packetSize); +// } +// +// void +// DlRxPduCallback(Ptr rlcStats, std::string path, +// uint16_t rnti, uint8_t lcid, uint32_t packetSize, uint64_t delay) +// { +// rlcStats->DlRxPdu(rnti, lcid, packetSize, delay); +// } + + +/** + * Test 1.4 Round Robin (RR) MAC Scheduler + */ + + +LenaTest1_4Suite::LenaTest1_4Suite () +: TestSuite ("lenaTest1.4", SYSTEM) +{ + SetVerbose (true); + NS_LOG_INFO ("creating LenaRrFfMacSchedulerTestCase"); + AddTestCase (new LenaRrFfMacSchedulerTestCase); +} + +static LenaTest1_4Suite lenaTest1_4Suite; + +LenaRrFfMacSchedulerTestCase::LenaRrFfMacSchedulerTestCase () + : TestCase ("Round Robin (RR) Mac Scheduler Test Case") +{ +} + +LenaRrFfMacSchedulerTestCase::~LenaRrFfMacSchedulerTestCase () +{ +} + +void +LenaRrFfMacSchedulerTestCase::DoRun (void) +{ + LogComponentEnable ("LteEnbRrc", LOG_LEVEL_ALL); + LogComponentEnable ("LteUeRrc", LOG_LEVEL_ALL); + LogComponentEnable ("LteEnbMac", LOG_LEVEL_ALL); + LogComponentEnable ("LteUeMac", LOG_LEVEL_ALL); + LogComponentEnable ("LteRlc", LOG_LEVEL_ALL); + LogComponentEnable ("RrPacketScheduler", LOG_LEVEL_ALL); + + LogComponentEnable ("LtePhy", LOG_LEVEL_ALL); + LogComponentEnable ("LteEnbPhy", LOG_LEVEL_ALL); + LogComponentEnable ("LteUePhy", LOG_LEVEL_ALL); + + LogComponentEnable ("LteSpectrumPhy", LOG_LEVEL_ALL); + LogComponentEnable ("LteInterference", LOG_LEVEL_ALL); + LogComponentEnable ("LteSinrChunkProcessor", LOG_LEVEL_ALL); + + LogComponentEnable ("LtePropagationLossModel", LOG_LEVEL_ALL); + LogComponentEnable ("LossModel", LOG_LEVEL_ALL); + LogComponentEnable ("ShadowingLossModel", LOG_LEVEL_ALL); + LogComponentEnable ("PenetrationLossModel", LOG_LEVEL_ALL); + LogComponentEnable ("MultipathLossModel", LOG_LEVEL_ALL); + LogComponentEnable ("PathLossModel", LOG_LEVEL_ALL); + + LogComponentEnable ("LteNetDevice", LOG_LEVEL_ALL); + LogComponentEnable ("LteUeNetDevice", LOG_LEVEL_ALL); + LogComponentEnable ("LteEnbNetDevice", LOG_LEVEL_ALL); + + LogComponentEnable ("LenaTestSinrChunkProcessor", LOG_LEVEL_ALL); + LogComponentEnable ("LenaTest", LOG_LEVEL_ALL); + + /** + * Initialize Simulation Scenario: 1 eNB and 2 UEs + */ + + SetVerbose (true); + + LenaHelper lena; + // Create Nodes: eNodeB and UE + NodeContainer enbNodes; + NodeContainer ueNodes; + enbNodes.Create (1); + ueNodes.Create (2); + + // Install Mobility Model + MobilityHelper mobility; + mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); + mobility.Install (enbNodes); + mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); + mobility.Install (ueNodes); + + // Create Devices and install them in the Nodes (eNB and UE) + NetDeviceContainer enbDevs; + NetDeviceContainer ueDevs; + lena.SetScheduler ("RrFfMacScheduler"); + enbDevs = lena.InstallEnbDevice (enbNodes); + ueDevs = lena.InstallUeDevice (ueNodes); + + // Attach a UE to a eNB + lena.Attach (ueDevs, enbDevs.Get (0)); + + // Activate an EPS bearer + enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; + EpsBearer bearer (q); + lena.ActivateEpsBearer (ueDevs, bearer); + + + Simulator::Stop (Seconds (0.005)); + + Ptr rlcStats = CreateObject (); + + Simulator::Run (); + + Simulator::Destroy (); + + /** + * Check that the assignation is done in a RR fashion + */ + //NS_TEST_ASSERT_MSG_EQ (*rxPsd, saveRxPsd, "Data signal corrupted !"); + //NS_TEST_ASSERT_MSG_EQ (*noisePsd, saveNoisePsd, "Noise signal corrupted !"); + + //SpectrumValue theoreticalSinr = (*rxPsd) / ( ( 2 * (*rxPsd) ) + (*noisePsd) ); + //SpectrumValue calculatedSinr = p->GetSinr (); + + NS_LOG_INFO ("User 1 Rx Data: " << rlcStats->GetDlRxData (1,1)); + NS_LOG_INFO ("User 2 Rx Data: " << rlcStats->GetDlRxData (2,1)); + NS_TEST_ASSERT_MSG_EQ_TOL (rlcStats->GetDlRxData (1,1), rlcStats->GetDlRxData (2,1), 0.0000001, " Unfair Throughput!"); + + //NS_TEST_ASSERT_MSG_EQ_TOL (calculatedSinr, theoreticalSinr, 0.000001, "Wrong SINR !"); +} + + + + +// class LenaTest1_4Suite : public TestSuite +// { +// public: +// LenaTest1_4Suite (); +// }; +// +// LenaTest1_4Suite::LenaTest1_4Suite () +// : TestSuite ("lenaTest1.4", SYSTEM) +// { +// AddTestCase (new LenaRrFfMacSchedulerTestCase ()); +// } +// +// static LenaTest1_4Suite lenaTest1_4Suite; + + diff --git a/src/lte/test/lena-test-rr-ff-mac-scheduler.h b/src/lte/test/lena-test-rr-ff-mac-scheduler.h new file mode 100644 index 000000000..d191b4daf --- /dev/null +++ b/src/lte/test/lena-test-rr-ff-mac-scheduler.h @@ -0,0 +1,55 @@ +/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Marco Miozzo + */ + +#ifndef LENA_TEST_RR_FF_MAC_SCHEDULER_H +#define LENA_TEST_RR_FF_MAC_SCHEDULER_H + +#include "ns3/simulator.h" +#include "ns3/test.h" + + +using namespace ns3; + + +/** + * Test 1.4 Round Robin (RR) MAC Scheduler + */ +class LenaRrFfMacSchedulerTestCase : public TestCase +{ + public: + LenaRrFfMacSchedulerTestCase (); + virtual ~LenaRrFfMacSchedulerTestCase (); + + private: + virtual void DoRun (void); +}; + + + +class LenaTest1_4Suite : public TestSuite +{ + public: + LenaTest1_4Suite (); +}; + + + + +#endif /* LENA_TEST_RR_FF_MAC_SCHEDULER_H */ diff --git a/src/lte/wscript b/src/lte/wscript index c0a6493dc..a4e5c3537 100644 --- a/src/lte/wscript +++ b/src/lte/wscript @@ -48,6 +48,8 @@ def build(bld): 'test/lena-test-suite.cc', 'test/lena-test-downlink-sinr.cc', 'test/lena-test-sinr-chunk-processor.cc', + 'test/lena-test-rr-ff-mac-scheduler.cc', + 'test/lena-test-pf-ff-mac-scheduler.cc', ] headers = bld.new_task_gen('ns3header') @@ -97,6 +99,8 @@ def build(bld): 'model/pf-ff-mac-scheduler.h', 'test/lena-test-downlink-sinr.h', 'test/lena-test-sinr-chunk-processor.h', + 'test/lena-test-rr-ff-mac-scheduler.h', + 'test/lena-test-pf-ff-mac-scheduler.h', ] if (bld.env['ENABLE_EXAMPLES']):