From 6a5f24a6633035ec2479ef57edcbfa0591e33285 Mon Sep 17 00:00:00 2001 From: mrequena Date: Thu, 28 Apr 2011 19:16:13 +0200 Subject: [PATCH 1/3] Test 1.1 --- src/lte/test/lena-test-downlink-sinr.cc | 181 +++++++++++++++--------- src/lte/test/lena-test-downlink-sinr.h | 8 +- 2 files changed, 124 insertions(+), 65 deletions(-) diff --git a/src/lte/test/lena-test-downlink-sinr.cc b/src/lte/test/lena-test-downlink-sinr.cc index b4f42b74b..765d4f515 100644 --- a/src/lte/test/lena-test-downlink-sinr.cc +++ b/src/lte/test/lena-test-downlink-sinr.cc @@ -18,8 +18,7 @@ * Author: Manuel Requena */ -// #include "ns3/simulator.h" -// #include "ns3/test.h" +#include "ns3/simulator.h" #include "ns3/log.h" @@ -32,7 +31,7 @@ #include "ns3/lena-test-downlink-sinr.h" -NS_LOG_COMPONENT_DEFINE ("LenaTest"); +NS_LOG_COMPONENT_DEFINE ("LenaDownlinkSinrTest"); using namespace ns3; @@ -41,9 +40,29 @@ using namespace ns3; * Test 1.1 SINR calculation in downlink */ +/** + * TestSuite + */ + +LenaDownlinkSinrTestSuite::LenaDownlinkSinrTestSuite () + : TestSuite ("lena-downlink-sinr", SYSTEM) +{ + NS_LOG_INFO ("Creating LenaDownlinkSinrTestSuite"); + + AddTestCase (new LenaDownlinkSinrTestCase); +} + +static LenaDownlinkSinrTestSuite lenaDownlinkSinrTestSuite; + + +/** + * TestCase + */ + LenaDownlinkSinrTestCase::LenaDownlinkSinrTestCase () : TestCase ("SINR calculation in downlink") { + NS_LOG_INFO ("Creating LenaDownlinkSinrTestCase"); } LenaDownlinkSinrTestCase::~LenaDownlinkSinrTestCase () @@ -53,34 +72,37 @@ LenaDownlinkSinrTestCase::~LenaDownlinkSinrTestCase () void LenaDownlinkSinrTestCase::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); + LogLevel logLevel = (LogLevel)(LOG_PREFIX_FUNC | LOG_PREFIX_TIME | LOG_LEVEL_ALL); - LogComponentEnable ("LtePhy", LOG_LEVEL_ALL); - LogComponentEnable ("LteEnbPhy", LOG_LEVEL_ALL); - LogComponentEnable ("LteUePhy", LOG_LEVEL_ALL); + LogComponentEnable ("LteEnbRrc", logLevel); + LogComponentEnable ("LteUeRrc", logLevel); + LogComponentEnable ("LteEnbMac", logLevel); + LogComponentEnable ("LteUeMac", logLevel); + LogComponentEnable ("LteRlc", logLevel); + LogComponentEnable ("RrPacketScheduler", logLevel); - LogComponentEnable ("LteSpectrumPhy", LOG_LEVEL_ALL); - LogComponentEnable ("LteInterference", LOG_LEVEL_ALL); - LogComponentEnable ("LteSinrChunkProcessor", LOG_LEVEL_ALL); + LogComponentEnable ("LtePhy", logLevel); + LogComponentEnable ("LteEnbPhy", logLevel); + LogComponentEnable ("LteUePhy", logLevel); - 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 ("LteSpectrumPhy", logLevel); + LogComponentEnable ("LteInterference", logLevel); + LogComponentEnable ("LteSinrChunkProcessor", logLevel); - LogComponentEnable ("LteNetDevice", LOG_LEVEL_ALL); - LogComponentEnable ("LteUeNetDevice", LOG_LEVEL_ALL); - LogComponentEnable ("LteEnbNetDevice", LOG_LEVEL_ALL); + LogComponentEnable ("LtePropagationLossModel", logLevel); + LogComponentEnable ("LossModel", logLevel); + LogComponentEnable ("ShadowingLossModel", logLevel); + LogComponentEnable ("PenetrationLossModel", logLevel); + LogComponentEnable ("MultipathLossModel", logLevel); + LogComponentEnable ("PathLossModel", logLevel); - LogComponentEnable ("LenaTestSinrChunkProcessor", LOG_LEVEL_ALL); - LogComponentEnable ("LenaTest", LOG_LEVEL_ALL); + LogComponentEnable ("LteNetDevice", logLevel); + LogComponentEnable ("LteUeNetDevice", logLevel); + LogComponentEnable ("LteEnbNetDevice", logLevel); + + LogComponentEnable ("LenaTestSinrChunkProcessor", logLevel); + LogComponentEnable ("LenaDownlinkSinrTest", logLevel); + LogComponentEnable ("LenaUplinkSinrTest", logLevel); /** * Instantiate a single receiving LteSpectrumPhy @@ -91,8 +113,8 @@ LenaDownlinkSinrTestCase::DoRun (void) dlPhy->SetCellId (100); - Ptr p = Create (uePhy->GetObject ()); - dlPhy->AddSinrChunkProcessor (p); + Ptr chunkProcessor = Create (uePhy->GetObject ()); + dlPhy->AddSinrChunkProcessor (chunkProcessor); /** * Generate several calls to LteSpectrumPhy::StartRx corresponding to several signals. @@ -101,8 +123,8 @@ LenaDownlinkSinrTestCase::DoRun (void) * the others will have a different CellId and hence will be the interfering signals */ - // Number of packet bursts - int numOfPbs = 3; + // Number of packet bursts (1 data + 4 interferences) + int numOfPbs = 5; // Number of packets in the packet bursts int numOfPkts = 10; @@ -144,55 +166,86 @@ LenaDownlinkSinrTestCase::DoRun (void) /** * Build Spectrum Model values for signal */ - double myFreqs[] = {2.10, 2.11, 2.12, 2.13, 2.14, 2.15, 2.16, 2.17, 2.18, 2.19}; - int numOfFreqs = sizeof(myFreqs) / sizeof(double); - std::vector freqs (myFreqs, myFreqs + sizeof(myFreqs) / sizeof(double) ); + Ptr sm; - Ptr f = Create (freqs); - Ptr rxPsd = Create (f); - for ( int i = 0 ; i < numOfFreqs ; i++ ) - { - (*rxPsd)[i] = 1.11 + 0.01 * i; - } + Bands bands; + BandInfo bi; - Ptr noisePsd = Create (f); - for ( int i = 0 ; i < numOfFreqs ; i++ ) - { - (*noisePsd)[i] = 0.001; - } + bi.fl = 2.400e9; + bi.fc = 2.410e9; + bi.fh = 2.420e9; + bands.push_back (bi); - SpectrumValue saveRxPsd = *rxPsd; - SpectrumValue saveNoisePsd = *noisePsd; + bi.fl = 2.420e9; + bi.fc = 2.431e9; + bi.fh = 2.442e9; + bands.push_back (bi); + + sm = Create (bands); + + // Power Spectral Density of the signal of interest = [-46 -48] dBm and BW = [20 22] MHz + Ptr rxPsd = Create (sm); + (*rxPsd)[0] = 1.255943215755e-15; + (*rxPsd)[1] = 7.204059965732e-16; + + Ptr noisePsd = Create (sm); + Ptr i1 = Create (sm); + Ptr i2 = Create (sm); + Ptr i3 = Create (sm); + Ptr i4 = Create (sm); + + (*noisePsd)[0] = 5.000000000000e-19; + (*noisePsd)[1] = 4.545454545455e-19; + + (*i1)[0] = 5.000000000000e-18; + (*i2)[0] = 5.000000000000e-16; + (*i3)[0] = 1.581138830084e-16; + (*i4)[0] = 7.924465962306e-17; + (*i1)[1] = 1.437398936440e-18; + (*i2)[1] = 5.722388235428e-16; + (*i3)[1] = 7.204059965732e-17; + (*i4)[1] = 5.722388235428e-17; + + Time ts = Seconds (1); + Time ds = Seconds (1); + Time ti1 = Seconds (0); + Time di1 = Seconds (3); + Time ti2 = Seconds (0.7); + Time di2 = Seconds (1); + Time ti3 = Seconds (1.2); + Time di3 = Seconds (1); + Time ti4 = Seconds (1.5); + Time di4 = Seconds (0.1); dlPhy->SetNoisePowerSpectralDensity (noisePsd); - Time delay ("100ms"); - Time duration ("5ms"); - /** - * Schedule the reception of the signals + * Schedule the reception of the data signal plus the interference signals */ - for ( int pb = 0 ; pb < numOfPbs ; pb++) - { - Simulator::Schedule (delay, &LteSpectrumPhy::StartRx, dlPhy, packetBursts[pb], rxPsd, dlPhy->GetSpectrumType(), duration); - } - Simulator::Stop (Seconds (1.0)); + Simulator::Schedule (ts, &LteSpectrumPhy::StartRx, dlPhy, packetBursts[0], rxPsd, dlPhy->GetSpectrumType(), ds); + + Simulator::Schedule (ti1, &LteSpectrumPhy::StartRx, dlPhy, packetBursts[1], i1, dlPhy->GetSpectrumType(), di1); + Simulator::Schedule (ti2, &LteSpectrumPhy::StartRx, dlPhy, packetBursts[2], i2, dlPhy->GetSpectrumType(), di2); + Simulator::Schedule (ti3, &LteSpectrumPhy::StartRx, dlPhy, packetBursts[3], i3, dlPhy->GetSpectrumType(), di3); + Simulator::Schedule (ti4, &LteSpectrumPhy::StartRx, dlPhy, packetBursts[4], i4, dlPhy->GetSpectrumType(), di4); + + Simulator::Stop (Seconds (5.0)); Simulator::Run (); Simulator::Destroy (); /** - * Check that the values passed to LteSinrChunkProcessor::EvaluateSinrChunk () - * correspond to known values which have been calculated offline for the generated signals + * Check that the values passed to LteSinrChunkProcessor::EvaluateSinrChunk () correspond + * to known values which have been calculated offline (with octave) for the generated signals */ - NS_TEST_ASSERT_MSG_EQ (*rxPsd, saveRxPsd, "Data signal corrupted !"); - NS_TEST_ASSERT_MSG_EQ (*noisePsd, saveNoisePsd, "Noise signal corrupted !"); + SpectrumValue theoreticalSinr(sm); + theoreticalSinr[0] = 3.72589167251055; + theoreticalSinr[1] = 3.72255684126076; - SpectrumValue theoreticalSinr = (*rxPsd) / ( ( 2 * (*rxPsd) ) + (*noisePsd) ); - SpectrumValue calculatedSinr = p->GetSinr (); + SpectrumValue calculatedSinr = chunkProcessor->GetSinr (); -// NS_LOG_INFO ("Theoretical SINR: " << theoreticalSinr); -// NS_LOG_INFO ("Calculated SINR: " << calculatedSinr); + NS_LOG_INFO ("Theoretical SINR: " << theoreticalSinr); + NS_LOG_INFO ("Calculated SINR: " << calculatedSinr); - NS_TEST_ASSERT_MSG_EQ_TOL (calculatedSinr, theoreticalSinr, 0.000001, "Wrong SINR !"); + NS_TEST_ASSERT_MSG_EQ_TOL (calculatedSinr, theoreticalSinr, 0.0000001, "Wrong SINR !"); } diff --git a/src/lte/test/lena-test-downlink-sinr.h b/src/lte/test/lena-test-downlink-sinr.h index d003e7b21..81c7099fe 100644 --- a/src/lte/test/lena-test-downlink-sinr.h +++ b/src/lte/test/lena-test-downlink-sinr.h @@ -21,7 +21,6 @@ #ifndef LENA_TEST_DOWNLINK_SINR_H #define LENA_TEST_DOWNLINK_SINR_H -#include "ns3/simulator.h" #include "ns3/test.h" @@ -31,6 +30,13 @@ using namespace ns3; /** * Test 1.1 SINR calculation in downlink */ +class LenaDownlinkSinrTestSuite : public TestSuite +{ +public: + LenaDownlinkSinrTestSuite (); +}; + + class LenaDownlinkSinrTestCase : public TestCase { public: From e716530b9232b416c81d11b502f50ee69a682dcc Mon Sep 17 00:00:00 2001 From: Marco Miozzo Date: Fri, 29 Apr 2011 12:12:43 +0200 Subject: [PATCH 2/3] 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']): From 984ee985f83b907fffa3a750474b428af557c25c Mon Sep 17 00:00:00 2001 From: Marco Miozzo Date: Fri, 29 Apr 2011 12:24:16 +0200 Subject: [PATCH 3/3] Fix Test1.4 and 1.5 to new LenaHelper API --- src/lte/test/lena-test-pf-ff-mac-scheduler.cc | 2 +- src/lte/test/lena-test-rr-ff-mac-scheduler.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lte/test/lena-test-pf-ff-mac-scheduler.cc b/src/lte/test/lena-test-pf-ff-mac-scheduler.cc index 6fd111a80..197f6a5dc 100644 --- a/src/lte/test/lena-test-pf-ff-mac-scheduler.cc +++ b/src/lte/test/lena-test-pf-ff-mac-scheduler.cc @@ -149,7 +149,7 @@ LenaPfFfMacSchedulerTestCase::DoRun (void) // Create Devices and install them in the Nodes (eNB and UE) NetDeviceContainer enbDevs; NetDeviceContainer ueDevs; - lena.SetScheduler ("PfFfMacScheduler"); + lena.SetSchedulerType ("ns3::PfFfMacScheduler"); enbDevs = lena.InstallEnbDevice (enbNodes); ueDevs = lena.InstallUeDevice (ueNodes); diff --git a/src/lte/test/lena-test-rr-ff-mac-scheduler.cc b/src/lte/test/lena-test-rr-ff-mac-scheduler.cc index 6c65df6c3..233f05fb6 100644 --- a/src/lte/test/lena-test-rr-ff-mac-scheduler.cc +++ b/src/lte/test/lena-test-rr-ff-mac-scheduler.cc @@ -149,7 +149,7 @@ LenaRrFfMacSchedulerTestCase::DoRun (void) // Create Devices and install them in the Nodes (eNB and UE) NetDeviceContainer enbDevs; NetDeviceContainer ueDevs; - lena.SetScheduler ("RrFfMacScheduler"); + lena.SetSchedulerType ("ns3::RrFfMacScheduler"); enbDevs = lena.InstallEnbDevice (enbNodes); ueDevs = lena.InstallUeDevice (ueNodes);