Merge with 4b3d17addd8758a883dd7e4205fab02419f34ac7

This commit is contained in:
jnin
2011-04-29 17:33:06 +02:00
7 changed files with 633 additions and 65 deletions

View File

@@ -18,8 +18,7 @@
* Author: Manuel Requena <manuel.requena@cttc.es>
*/
// #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<LenaTestSinrChunkProcessor> p = Create<LenaTestSinrChunkProcessor> (uePhy->GetObject<LtePhy> ());
dlPhy->AddSinrChunkProcessor (p);
Ptr<LenaTestSinrChunkProcessor> chunkProcessor = Create<LenaTestSinrChunkProcessor> (uePhy->GetObject<LtePhy> ());
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<double> freqs (myFreqs, myFreqs + sizeof(myFreqs) / sizeof(double) );
Ptr<SpectrumModel> sm;
Ptr<SpectrumModel> f = Create<SpectrumModel> (freqs);
Ptr<SpectrumValue> rxPsd = Create<SpectrumValue> (f);
for ( int i = 0 ; i < numOfFreqs ; i++ )
{
(*rxPsd)[i] = 1.11 + 0.01 * i;
}
Bands bands;
BandInfo bi;
Ptr<SpectrumValue> noisePsd = Create<SpectrumValue> (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<SpectrumModel> (bands);
// Power Spectral Density of the signal of interest = [-46 -48] dBm and BW = [20 22] MHz
Ptr<SpectrumValue> rxPsd = Create<SpectrumValue> (sm);
(*rxPsd)[0] = 1.255943215755e-15;
(*rxPsd)[1] = 7.204059965732e-16;
Ptr<SpectrumValue> noisePsd = Create<SpectrumValue> (sm);
Ptr<SpectrumValue> i1 = Create<SpectrumValue> (sm);
Ptr<SpectrumValue> i2 = Create<SpectrumValue> (sm);
Ptr<SpectrumValue> i3 = Create<SpectrumValue> (sm);
Ptr<SpectrumValue> i4 = Create<SpectrumValue> (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 <numOfPbs> 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 !");
}

View File

@@ -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:

View File

@@ -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 <marco.miozzo@cttc.es>
*/
#include <ns3/object.h>
#include <ns3/spectrum-interference.h>
#include <ns3/spectrum-error-model.h>
#include <ns3/log.h>
#include <ns3/test.h>
#include <ns3/simulator.h>
#include <ns3/packet.h>
#include <ns3/ptr.h>
#include <iostream>
#include "ns3/rlc-stats-calculator.h"
#include "ns3/lena-test-pf-ff-mac-scheduler.h"
#include <ns3/eps-bearer.h>
#include <ns3/node-container.h>
#include <ns3/mobility-helper.h>
#include <ns3/net-device-container.h>
#include <ns3/lena-helper.h>
NS_LOG_COMPONENT_DEFINE ("LenaTestPfFfMacCheduler");
using namespace ns3;
// void
// UlTxPduCallback(Ptr<RlcStatsCalculator> rlcStats, std::string path,
// uint16_t rnti, uint8_t lcid, uint32_t packetSize)
// {
// rlcStats->UlTxPdu(rnti, lcid, packetSize);
// }
//
// void
// UlRxPduCallback(Ptr<RlcStatsCalculator> 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<RlcStatsCalculator> rlcStats, std::string path,
// uint16_t rnti, uint8_t lcid, uint32_t packetSize)
// {
// rlcStats->DlTxPdu(rnti, lcid, packetSize);
// }
//
// void
// DlRxPduCallback(Ptr<RlcStatsCalculator> 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.SetSchedulerType ("ns3::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<RlcStatsCalculator> rlcStats = CreateObject<RlcStatsCalculator> ();
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 !");
}

View File

@@ -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 <marco.miozzo@cttc.es>
*/
#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 */

View File

@@ -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 <marco.miozzo@cttc.es>
*/
#include <ns3/object.h>
#include <ns3/spectrum-interference.h>
#include <ns3/spectrum-error-model.h>
#include <ns3/log.h>
#include <ns3/test.h>
#include <ns3/simulator.h>
#include <ns3/packet.h>
#include <ns3/ptr.h>
#include <iostream>
#include "ns3/rlc-stats-calculator.h"
#include "ns3/lena-test-rr-ff-mac-scheduler.h"
#include <ns3/eps-bearer.h>
#include <ns3/node-container.h>
#include <ns3/mobility-helper.h>
#include <ns3/net-device-container.h>
#include <ns3/lena-helper.h>
NS_LOG_COMPONENT_DEFINE ("LenaTestRrFfMacCheduler");
using namespace ns3;
// void
// UlTxPduCallback(Ptr<RlcStatsCalculator> rlcStats, std::string path,
// uint16_t rnti, uint8_t lcid, uint32_t packetSize)
// {
// rlcStats->UlTxPdu(rnti, lcid, packetSize);
// }
//
// void
// UlRxPduCallback(Ptr<RlcStatsCalculator> 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<RlcStatsCalculator> rlcStats, std::string path,
// uint16_t rnti, uint8_t lcid, uint32_t packetSize)
// {
// rlcStats->DlTxPdu(rnti, lcid, packetSize);
// }
//
// void
// DlRxPduCallback(Ptr<RlcStatsCalculator> 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.SetSchedulerType ("ns3::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<RlcStatsCalculator> rlcStats = CreateObject<RlcStatsCalculator> ();
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;

View File

@@ -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 <marco.miozzo@cttc.es>
*/
#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 */

View File

@@ -49,6 +49,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')
@@ -99,6 +101,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']):