This commit is contained in:
Nicola Baldo
2011-05-11 12:10:17 +02:00
6 changed files with 128 additions and 53 deletions

View File

@@ -79,9 +79,9 @@ LteEarfcnDlTestCase::LteEarfcnDlTestCase (const char* str, uint16_t earfcn, doub
void
LteEarfcnDlTestCase::DoRun (void)
{
LogLevel logLevel = (LogLevel)(LOG_PREFIX_FUNC | LOG_PREFIX_TIME | LOG_LEVEL_ALL);
LogComponentEnable ("LteSpectrumValueHelper", logLevel);
LogComponentEnable ("LteTestEarfcn", logLevel);
// LogLevel logLevel = (LogLevel)(LOG_PREFIX_FUNC | LOG_PREFIX_TIME | LOG_LEVEL_ALL);
// LogComponentEnable ("LteSpectrumValueHelper", logLevel);
// LogComponentEnable ("LteTestEarfcn", logLevel);
double f = LteSpectrumValueHelper::GetDownlinkCarrierFrequency (m_earfcn);
NS_TEST_ASSERT_MSG_EQ_TOL (f, m_f, 0.0000001, "wrong frequency");

View File

@@ -34,6 +34,11 @@ using namespace ns3;
uint32_t LteLinkAdaptationTestCase::m_runId = 0;
bool LteLinkAdaptationTestCase::m_lastTestCase = false;
// GnuplotCollection LteLinkAdaptationTestCase::gnuplots("link-adaptation.ps");
// Gnuplot LteLinkAdaptationTestCase::plot;
// Gnuplot2dDataset LteLinkAdaptationTestCase::data;
/**
@@ -41,24 +46,11 @@ uint32_t LteLinkAdaptationTestCase::m_runId = 0;
*/
void
LteTestDlSchedulingCallback (std::string path,
LteTestDlSchedulingCallback (LteLinkAdaptationTestCase *testcase, std::string path,
uint32_t frameNo, uint32_t subframeNo, uint16_t rnti,
uint8_t mcsTb1, uint16_t sizeTb1, uint8_t mcsTb2, uint16_t sizeTb2)
{
static bool firstTime = true;
if ( firstTime )
{
NS_LOG_UNCOND ("frame\tsbframe\trnti\tmcsTb1\tsizeTb1\tmcsTb2\tsizeTb2");
firstTime = false;
}
if ( subframeNo == 10 )
{
NS_LOG_UNCOND (" " << frameNo << "\t" << subframeNo << "\t" << rnti << "\t"
<< (uint16_t)mcsTb1 << "\t" << sizeTb1 << "\t"
<< (uint16_t)mcsTb2 << "\t" << sizeTb2);
}
testcase->DlScheduling(frameNo, subframeNo, rnti, mcsTb1, sizeTb1, mcsTb2, sizeTb2);
}
/**
@@ -75,15 +67,20 @@ LteLinkAdaptationTestSuite::LteLinkAdaptationTestSuite ()
NS_LOG_INFO ("Creating LteLinkAdaptionTestSuite");
int distanceMin = 1;
int distanceMax = 100000;
int distanceStep = 10000;
int distanceMin = 10;
int distanceMax = 25000;
int distanceStep = 500;
bool logStep = false;
int distance;
for ( int distance = distanceMin ; distance <= distanceMax ; logStep ? ( distance *= distanceStep) : ( distance += distanceStep ) )
double lossLinear, lossDb;
for ( distance = distanceMin ;
distance < distanceMax ;
logStep ? ( distance *= distanceStep) : ( distance += distanceStep ) )
{
/**
* Propagation Loss
* Propagation Loss (in W/Hz)
*
* ( 4 * PI * distance * frequency ) 2
* Loss = ( ------------------------------- )
@@ -93,12 +90,27 @@ LteLinkAdaptationTestSuite::LteLinkAdaptationTestSuite ()
* distance in (m)
* frequency in (Hz)
*/
double myLoss = ( ( 4 * M_PI * distance * 1.92e9 ) / 3e8 );
myLoss = myLoss * myLoss;
// double myLoss = ( ( 4.0 * M_PI * distance * 1.92e9 ) / 3e8 );
lossLinear = ( ( 4.0 * M_PI * distance * 2.160e9 ) / 3e8 );
lossLinear = lossLinear * lossLinear;
lossDb = 10 * log10(lossLinear);
AddTestCase (new LteLinkAdaptationTestCase (myLoss));
AddTestCase (new LteLinkAdaptationTestCase (lossDb, distance));
}
LteLinkAdaptationTestCase::m_lastTestCase = true;
distance = distanceMax;
lossLinear = ( ( 4.0 * M_PI * distance * 2.160e9 ) / 3e8 );
lossLinear = lossLinear * lossLinear;
lossDb = 10 * log10(lossLinear);
AddTestCase (new LteLinkAdaptationTestCase (lossDb, distance));
// SINR = XXX
// AddTestCase (new LteLinkAdaptationTestCase (myLoss));
// SINR = YYY
// AddTestCase (new LteLinkAdaptationTestCase (myLoss));
}
static LteLinkAdaptationTestSuite lteLinkAdaptationTestSuite;
@@ -108,9 +120,10 @@ static LteLinkAdaptationTestSuite lteLinkAdaptationTestSuite;
* TestCase
*/
LteLinkAdaptationTestCase::LteLinkAdaptationTestCase (double loss)
LteLinkAdaptationTestCase::LteLinkAdaptationTestCase (double loss, double distance)
: TestCase ("Link Adaptation"),
m_loss (loss)
m_loss (loss),
m_distance (distance)
{
std::ostringstream sstream1, sstream2;
sstream1 << loss;
@@ -193,13 +206,6 @@ LteLinkAdaptationTestCase::DoRun (void)
* 1000 6.46814e+09
*/
// for ( int i = 0 ; i <= 10 ; i++ )
// {
// double myLoss = ( ( 4 * M_PI * ( i * 100.0 ) * 1.92e9 ) / 3e8 );
// myLoss = myLoss * myLoss;
// NS_LOG_INFO ("i = " << i << "\tLoss = " << myLoss);
// }
// Create Nodes: eNodeB and UE
NodeContainer enbNodes;
NodeContainer ueNodes;
@@ -235,9 +241,8 @@ LteLinkAdaptationTestCase::DoRun (void)
Config::Connect ("/NodeList/0/DeviceList/0/LteEnbMac/DlScheduling",
MakeCallback(&LteTestDlSchedulingCallback));
MakeBoundCallback(&LteTestDlSchedulingCallback, this));
// Simulator::Stop (Seconds (0.005));
Simulator::Stop (Seconds (0.01));
Simulator::Run ();
@@ -248,3 +253,45 @@ LteLinkAdaptationTestCase::DoRun (void)
NS_TEST_ASSERT_MSG_EQ_TOL (1.0, 1.0, 0.0000001, "Wrong Test !");
}
void
LteLinkAdaptationTestCase::DlScheduling (uint32_t frameNo, uint32_t subframeNo, uint16_t rnti,
uint8_t mcsTb1, uint16_t sizeTb1, uint8_t mcsTb2, uint16_t sizeTb2)
{
static bool firstTime = true;
if ( firstTime )
{
firstTime = false;
// NS_LOG_UNCOND ("frame\tsbframe\trnti\tmcsTb1\tsizeTb1\tmcsTb2\tsizeTb2");
NS_LOG_UNCOND ("dist\tmcsTb1\tsizeTb1");
// NS_LOG_UNCOND ("dist, mcsTb1, sizeTb1");
// gnuplots.SetTerminal("ps color");
// plot.SetTitle("UniformVariable");
// plot.AppendExtra("set yrange [0:]");
// data.SetTitle("MCS");
}
if ( subframeNo == 10 )
{
// NS_LOG_UNCOND (" " << frameNo << "\t" << subframeNo << "\t" << rnti << "\t"
// << (uint16_t)mcsTb1 << "\t" << sizeTb1 << "\t"
// << (uint16_t)mcsTb2 << "\t" << sizeTb2);
NS_LOG_UNCOND (m_distance << "\t" << (uint16_t)mcsTb1 << "\t" << sizeTb1);
// data.Add(m_distance, mcsTb1);
}
// if ( LteLinkAdaptationTestCase::m_lastTestCase )
// {
// plot.AddDataset(data);
// gnuplots.AddPlot(plot);
// gnuplots.GenerateOutput(std::cout);
// }
}

View File

@@ -22,13 +22,12 @@
#define LTE_TEST_LINK_ADAPTATION_H
#include "ns3/test.h"
#include "ns3/gnuplot.h"
using namespace ns3;
/**
* Test 1.3 Link adaptation
*/
@@ -42,20 +41,24 @@ public:
class LteLinkAdaptationTestCase : public TestCase
{
public:
// LteLinkAdaptationTestCase (Ptr<SpectrumValue> sv, Ptr<SpectrumValue> sinr, std::string name);
LteLinkAdaptationTestCase (double loss);
LteLinkAdaptationTestCase (double loss, double distance);
LteLinkAdaptationTestCase ();
virtual ~LteLinkAdaptationTestCase ();
void DlScheduling (uint32_t frameNo, uint32_t subframeNo, uint16_t rnti,
uint8_t mcsTb1, uint16_t sizeTb1, uint8_t mcsTb2, uint16_t sizeTb2);
static bool m_lastTestCase;
// static GnuplotCollection gnuplots;
// static Gnuplot plot;
// static Gnuplot2dDataset data;
private:
virtual void DoRun (void);
Ptr<MacStatsCalculator> macStats;
double m_loss;
// Ptr<SpectrumValue> m_sv;
// Ptr<const SpectrumModel> m_sm;
// Ptr<SpectrumValue> m_sinr;
double m_distance;
static uint32_t m_runId;
};

View File

@@ -150,10 +150,10 @@ static LteSpectrumValueHelperTestSuite g_lteSpectrumValueHelperTestSuite;
LteSpectrumValueHelperTestSuite::LteSpectrumValueHelperTestSuite ()
: TestSuite ("lte-spectrum-value-helper", UNIT)
{
//LogLevel logLevel = (LogLevel)(LOG_PREFIX_FUNC | LOG_PREFIX_TIME | LOG_LEVEL_ALL);
//LogComponentEnable ("LteSpectrumModelTestCase", logLevel);
//LogComponentEnable ("LteSpectrumValueHelperTestSuite", logLevel);
//LogComponentEnable ("LteSpectrumValueHelper", logLevel);
// LogLevel logLevel = (LogLevel)(LOG_PREFIX_FUNC | LOG_PREFIX_TIME | LOG_LEVEL_ALL);
// LogComponentEnable ("LteSpectrumModelTestCase", logLevel);
// LogComponentEnable ("LteSpectrumValueHelperTestSuite", logLevel);
// LogComponentEnable ("LteSpectrumValueHelper", logLevel);
NS_LOG_INFO ("Creating LteSpectrumValueHelperTestSuite");

View File

@@ -18,6 +18,8 @@
* Author: Manuel Requena <manuel.requena@cttc.es>
*/
#include <math.h>
#include "ns3/log.h"
#include "ns3/constant-spectrum-propagation-loss.h"
@@ -50,13 +52,31 @@ ConstantSpectrumPropagationLossModel::GetTypeId (void)
.AddAttribute ("Loss",
"Path loss (dB) between transmitter and receiver",
DoubleValue (1.0),
MakeDoubleAccessor (&ConstantSpectrumPropagationLossModel::m_loss),
MakeDoubleAccessor (&ConstantSpectrumPropagationLossModel::SetLossDb,
&ConstantSpectrumPropagationLossModel::GetLossDb),
MakeDoubleChecker<double> ())
;
return tid;
}
void
ConstantSpectrumPropagationLossModel::SetLossDb (double lossDb)
{
NS_LOG_FUNCTION (this);
m_lossDb = lossDb;
m_lossLinear = pow (10, m_lossDb / 10);
}
double
ConstantSpectrumPropagationLossModel::GetLossDb () const
{
NS_LOG_FUNCTION (this);
return m_lossDb;
}
Ptr<SpectrumValue>
ConstantSpectrumPropagationLossModel::DoCalcRxPowerSpectralDensity (Ptr<const SpectrumValue> txPsd,
Ptr<const MobilityModel> a,
@@ -73,7 +93,7 @@ ConstantSpectrumPropagationLossModel::DoCalcRxPowerSpectralDensity (Ptr<const Sp
{
NS_ASSERT (fit != rxPsd->ConstBandsEnd ());
// NS_LOG_INFO ("Ptx = " << *vit);
*vit /= m_loss; // Prx = Ptx / loss
*vit /= m_lossLinear; // Prx = Ptx / loss
// NS_LOG_INFO ("Prx = " << *vit);
++vit;
++fit;

View File

@@ -38,8 +38,13 @@ public:
Ptr<const MobilityModel> a,
Ptr<const MobilityModel> b) const;
void SetLossDb (double lossDb);
double GetLossDb () const;
protected:
double m_lossDb;
double m_lossLinear;
private:
double m_loss;
};