Add TestSuite for UE Measurements: on-going work, test does not pass

This commit is contained in:
Marco Miozzo
2013-03-06 11:58:54 +01:00
parent c5350bf3a6
commit 34ef42a780
5 changed files with 416 additions and 0 deletions

View File

@@ -325,6 +325,12 @@ private:
uint16_t m_rsrpSinrSamplePeriod;
uint16_t m_rsrpSinrSampleCounter;
/**
* Trace information regarding RSRP and RSRQ (see TS 36.214)
* uint16_t rnti, uint16_t cellId, double rsrp, double sinr, bool servingCell
*/
TracedCallback<uint16_t, uint16_t, double, double, bool> m_reportUeMeasurements;
EventId m_sendSrsEvent;
/**

View File

@@ -0,0 +1,236 @@
/* -*- 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: Manuel Requena <manuel.requena@cttc.es>
* Nicola Baldo <nbaldo@cttc.es>
* Marco Miozzo <mmiozzo@cttc.es>
*/
#include "ns3/simulator.h"
#include "ns3/log.h"
#include "ns3/string.h"
#include "ns3/double.h"
#include <ns3/enum.h>
#include "ns3/boolean.h"
#include "ns3/mobility-helper.h"
#include "ns3/lte-helper.h"
#include "ns3/ff-mac-scheduler.h"
#include "ns3/lte-enb-phy.h"
#include "ns3/lte-enb-net-device.h"
#include "ns3/lte-ue-phy.h"
#include "ns3/lte-ue-net-device.h"
#include "lte-test-ue-measurements.h"
#include "lte-test-sinr-chunk-processor.h"
NS_LOG_COMPONENT_DEFINE ("LteUeMeasurementsTest");
namespace ns3 {
void
ReportUeMeasurementsCallback (LteUeMeasurementsTestCase *testcase, std::string path,
uint16_t rnti, uint16_t cellId, double rsrp, double rsrq, bool servingCell)
{
testcase->ReportUeMeasurements (rnti, cellId, rsrp, rsrq, servingCell);
}
/**
* TestSuite
*/
LteUeMeasurementsTestSuite::LteUeMeasurementsTestSuite ()
: TestSuite ("lte-ue-measurements", SYSTEM)
{
AddTestCase (new LteUeMeasurementsTestCase ("d1=50, d2=10", 50.000000, 10.000000, -42.947889, -42.947889, -14.149733, -14.149733));
// AddTestCase (new LteUeMeasurementsTestCase ("d1=50, d2=20", 50.000000, 20.000000, -42.947889, -42.947889, -8.603380, -8.603380));
// AddTestCase (new LteUeMeasurementsTestCase ("d1=50, d2=50", 50.000000, 50.000000, -42.947889, -42.947889, -3.010300, -3.010300));
// AddTestCase (new LteUeMeasurementsTestCase ("d1=50, d2=100", 50.000000, 100.000000, -42.947889, -42.947889, -0.969101, -0.969101));
// AddTestCase (new LteUeMeasurementsTestCase ("d1=50, d2=200", 50.000000, 200.000000, -42.947889, -42.947889, -0.263290, -0.263290));
// AddTestCase (new LteUeMeasurementsTestCase ("d1=50, d2=500", 50.000000, 500.000000, -42.947889, -42.947889, -0.043214, -0.043214));
// AddTestCase (new LteUeMeasurementsTestCase ("d1=50, d2=1000", 50.000000, 1000.000000, -42.947889, -42.947889, -0.010844, -0.010844));
// AddTestCase (new LteUeMeasurementsTestCase ("d1=50, d2=10000", 50.000000, 10000.000000, -42.947889, -42.947889, -0.000109, -0.000109));
// AddTestCase (new LteUeMeasurementsTestCase ("d1=50, d2=100000", 50.000000, 100000.000000, -42.947889, -42.947889, -0.000002, -0.000002));
// AddTestCase (new LteUeMeasurementsTestCase ("d1=50, d2=1000000", 50.000000, 1000000.000000, -42.947889, -42.947889, -0.000000, -0.000000));
// AddTestCase (new LteUeMeasurementsTestCase ("d1=50, d2=10", 50.000000, 10.000000, 0.040000, 0.040000, 0.010399, 0.010399, 0, 0));
// AddTestCase (new LteUeMeasurementsTestCase ("d1=50, d2=20", 50.000000, 20.000000, 0.160000, 0.159998, 0.041154, 0.041153, 0, 0));
// AddTestCase (new LteUeMeasurementsTestCase ("d1=50, d2=50", 50.000000, 50.000000, 0.999997, 0.999907, 0.239828, 0.239808, 2, 2));
// AddTestCase (new LteUeMeasurementsTestCase ("d1=50, d2=100", 50.000000, 100.000000, 3.999955, 3.998520, 0.785259, 0.785042, 6, 6));
// AddTestCase (new LteUeMeasurementsTestCase ("d1=50, d2=200", 50.000000, 200.000000, 15.999282, 15.976339, 1.961072, 1.959533, 14, 14));
// AddTestCase (new LteUeMeasurementsTestCase ("d1=50, d2=500", 50.000000, 500.000000, 99.971953, 99.082845, 4.254003, 4.241793, 22, 22));
// AddTestCase (new LteUeMeasurementsTestCase ("d1=50, d2=1000", 50.000000, 1000.000000, 399.551632, 385.718468, 6.194952, 6.144825, 28, 28));
// AddTestCase (new LteUeMeasurementsTestCase ("d1=50, d2=10000", 50.000000, 10000.000000, 35964.181431, 8505.970614, 12.667381, 10.588084, 28, 28));
// AddTestCase (new LteUeMeasurementsTestCase ("d1=50, d2=100000", 50.000000, 100000.000000, 327284.773828, 10774.181090, 15.853097, 10.928917, 28, 28));
// AddTestCase (new LteUeMeasurementsTestCase ("d1=50, d2=1000000", 50.000000, 1000000.000000, 356132.574152, 10802.988445, 15.974963, 10.932767, 28, 28));
// AddTestCase (new LteUeMeasurementsTestCase ("d1=4500, d2=12600", 4500.000000, 12600.000000, 6.654462, 1.139831, 1.139781, 0.270399, 8, 2));
// AddTestCase (new LteUeMeasurementsTestCase ("d1=5400, d2=12600", 5400.000000, 12600.000000, 4.621154, 0.791549, 0.876368, 0.193019, 6, 0));
}
static LteUeMeasurementsTestSuite lteUeMeasurementsTestSuite;
/**
* TestCase
*/
LteUeMeasurementsTestCase::LteUeMeasurementsTestCase (std::string name, double d1, double d2, double rsrpDbmUe1, double rsrpDbmUe2, double rsrqDbUe1, double rsrqDbUe2)
: TestCase (name),
m_d1 (d1),
m_d2 (d2),
m_rsrpDbmUe1 (rsrpDbmUe1),
m_rsrpDbmUe2 (rsrpDbmUe2),
m_rsrqDbUe1 (rsrqDbUe1),
m_rsrqDbUe2 (rsrqDbUe2)
{
NS_LOG_INFO ("Test UE Measurements d1 = " << d1 << " m. and d2 = " << d2 << " m.");
}
LteUeMeasurementsTestCase::~LteUeMeasurementsTestCase ()
{
}
void
LteUeMeasurementsTestCase::DoRun (void)
{
NS_LOG_INFO (this << GetName ());
Config::SetDefault ("ns3::LteSpectrumPhy::CtrlErrorModelEnabled", BooleanValue (false));
Config::SetDefault ("ns3::LteSpectrumPhy::DataErrorModelEnabled", BooleanValue (false));
Config::SetDefault ("ns3::LteAmc::AmcModel", EnumValue (LteAmc::PiroEW2010));
Config::SetDefault ("ns3::LteAmc::Ber", DoubleValue (0.00005));
Ptr<LteHelper> lteHelper = CreateObject<LteHelper> ();
lteHelper->SetAttribute ("PathlossModel", StringValue ("ns3::FriisSpectrumPropagationLossModel"));
lteHelper->SetAttribute ("UseIdealRrc", BooleanValue (false));
LogComponentEnable ("LteUeMeasurementsTest", LOG_LEVEL_ALL);
LogComponentEnable ("LteUePhy", LOG_LEVEL_ALL);
// Create Nodes: eNodeB and UE
NodeContainer enbNodes;
NodeContainer ueNodes1;
NodeContainer ueNodes2;
enbNodes.Create (2);
ueNodes1.Create (1);
ueNodes2.Create (1);
NodeContainer allNodes = NodeContainer ( enbNodes, ueNodes1, ueNodes2);
// the topology is the following:
// d2
// UE1-----------eNB2
// | |
// d1| |d1
// | d2 |
// eNB1----------UE2
//
Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
positionAlloc->Add (Vector (0.0, 0.0, 0.0)); // eNB1
positionAlloc->Add (Vector (m_d2, m_d1, 0.0)); // eNB2
positionAlloc->Add (Vector (0.0, m_d1, 0.0)); // UE1
positionAlloc->Add (Vector (m_d2, 0.0, 0.0)); // UE2
MobilityHelper mobility;
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
mobility.SetPositionAllocator (positionAlloc);
mobility.Install (allNodes);
// Create Devices and install them in the Nodes (eNB and UE)
NetDeviceContainer enbDevs;
NetDeviceContainer ueDevs1;
NetDeviceContainer ueDevs2;
lteHelper->SetSchedulerType ("ns3::RrFfMacScheduler");
lteHelper->SetSchedulerAttribute ("UlCqiFilter", EnumValue (FfMacScheduler::PUSCH_UL_CQI));
enbDevs = lteHelper->InstallEnbDevice (enbNodes);
ueDevs1 = lteHelper->InstallUeDevice (ueNodes1);
ueDevs2 = lteHelper->InstallUeDevice (ueNodes2);
lteHelper->Attach (ueDevs1, enbDevs.Get (0));
lteHelper->Attach (ueDevs2, enbDevs.Get (1));
// Activate an EPS bearer
enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE;
EpsBearer bearer (q);
lteHelper->ActivateDataRadioBearer (ueDevs1, bearer);
lteHelper->ActivateDataRadioBearer (ueDevs2, bearer);
// Use testing chunk processor in the PHY layer
// It will be used to test that the SNR is as intended
// we plug in two instances, one for DL and one for UL
Ptr<LtePhy> ue1Phy = ueDevs1.Get (0)->GetObject<LteUeNetDevice> ()->GetPhy ()->GetObject<LtePhy> ();
Ptr<LteTestSinrChunkProcessor> testDlSinr1 = Create<LteTestSinrChunkProcessor> (ue1Phy);
ue1Phy->GetDownlinkSpectrumPhy ()->AddDataSinrChunkProcessor (testDlSinr1);
Ptr<LtePhy> enb1phy = enbDevs.Get (0)->GetObject<LteEnbNetDevice> ()->GetPhy ()->GetObject<LtePhy> ();
Ptr<LteTestSinrChunkProcessor> testUlSinr1 = Create<LteTestSinrChunkProcessor> (enb1phy);
enb1phy->GetUplinkSpectrumPhy ()->AddDataSinrChunkProcessor (testUlSinr1);
Config::Connect ("/NodeList/2/DeviceList/0/LteUePhy/ReportUeMeasurements",
MakeBoundCallback (&ReportUeMeasurementsCallback, this));
// same as above for eNB2 and UE2
Ptr<LtePhy> ue2Phy = ueDevs2.Get (0)->GetObject<LteUeNetDevice> ()->GetPhy ()->GetObject<LtePhy> ();
Ptr<LteTestSinrChunkProcessor> testDlSinr2 = Create<LteTestSinrChunkProcessor> (ue2Phy);
ue2Phy->GetDownlinkSpectrumPhy ()->AddDataSinrChunkProcessor (testDlSinr2);
Ptr<LtePhy> enb2phy = enbDevs.Get (1)->GetObject<LteEnbNetDevice> ()->GetPhy ()->GetObject<LtePhy> ();
Ptr<LteTestSinrChunkProcessor> testUlSinr2 = Create<LteTestSinrChunkProcessor> (enb2phy);
enb1phy->GetUplinkSpectrumPhy ()->AddDataSinrChunkProcessor (testUlSinr2);
Config::Connect ("/NodeList/3/DeviceList/0/LteUePhy/ReportUeMeasurements",
MakeBoundCallback (&ReportUeMeasurementsCallback, this));
// need to allow for RRC connection establishment + SRS
Simulator::Stop (Seconds (0.100));
Simulator::Run ();
Simulator::Destroy ();
}
void
LteUeMeasurementsTestCase::ReportUeMeasurements (uint16_t rnti, uint16_t cellId, double rsrp, double rsrq, bool servingCell)
{
// need to allow for RRC connection establishment + CQI feedback reception + UE measurements filtering (200 ms)
if (Simulator::Now () > MilliSeconds (400))
{
if (cellId == 1)
{
NS_LOG_DEBUG ("UE 1 Rxed RSRP " << rsrp << " thr " << m_rsrpDbmUe1 << " RSRQ " << rsrq << " thr " << m_rsrqDbUe1);
NS_TEST_ASSERT_MSG_EQ_TOL (m_rsrpDbmUe1, rsrp, 0.1, "Wrong RSRP UE 1");
NS_TEST_ASSERT_MSG_EQ_TOL (m_rsrqDbUe1, rsrq, 0.1 , "Wrong RSRQ UE 1");
}
else
{
NS_LOG_DEBUG ("UE 2 Rxed RSRP " << rsrp << " thr " << m_rsrpDbmUe2 << " RSRQ " << rsrq << " thr " << m_rsrqDbUe2);
NS_TEST_ASSERT_MSG_EQ_TOL (m_rsrpDbmUe2, rsrp, 0.1 , "Wrong RSRP UE 2");
NS_TEST_ASSERT_MSG_EQ_TOL (m_rsrqDbUe2, rsrq, 0.1 , "Wrong RSRQ UE ");
}
}
}
} // namespace ns3

View File

@@ -0,0 +1,69 @@
/* -*- 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: Manuel Requena <manuel.requena@cttc.es>
* Nicola Baldo <nbaldo@cttc.es>
* Marco Miozzo <mmiozzo@cttc.es>
* adapt lte-test-interference.cc to lte-ue-measurements.cc
*/
#ifndef LTE_TEST_UE_MEASUREMENTS_H
#define LTE_TEST_UE_MEASUREMENTS_H
#include "ns3/test.h"
namespace ns3 {
/**
* Test that UE Measurements (see 36.214) calculation works fine in a
* multi-cell interference scenario.
*/
class LteUeMeasurementsTestSuite : public TestSuite
{
public:
LteUeMeasurementsTestSuite ();
};
class LteUeMeasurementsTestCase : public TestCase
{
public:
LteUeMeasurementsTestCase (std::string name, double d1, double d2, double rsrpDbmUe1, double rsrpDbmUe2, double rsrqDbUe1, double rsrqDbUe2);
virtual ~LteUeMeasurementsTestCase ();
void ReportUeMeasurements (uint16_t rnti, uint16_t cellId, double rsrp, double rsrq, bool servingCell);
private:
virtual void DoRun (void);
double m_d1;
double m_d2;
double m_rsrpDbmUe1;
double m_rsrpDbmUe2;
double m_rsrqDbUe1;
double m_rsrqDbUe2;
};
} // namespace ns3
#endif /* LTE_TEST_UE_MEASUREMENTS_H */

View File

@@ -0,0 +1,104 @@
clear all;
close all;
%% LTE from theory to practice
%% Table 22.7 Reference sensitivity.
fdl = 2120e6; % DL carrier freq Hz, EARFCN = 100
ful = 1930e6; % UL carrier freq Hz, EARFCN = 18100
nrbs = 25; % tx bandwdith configuration in number of RBs
bw = 180000; % bandwidth in Hz, note that this is smaller than
% the nominal Channel Bandwdith, see TS 36.101 fig 5.6-1
kT = -174; % noise PSD in dBm / Hz
ndBm = kT + 10*log10(bw); % noise power dBm
dlpdBm = 30; % tx power dBm in DL
dlpdBm = 30.*ones(1,nrbs); % tx power dBm in DL
dlp = 10.^((dlpdBm - 30)/10); %% tx pow in W in DL
dlnf = 9; % receiver noise figure in dB in DL
dln = 10.^((ndBm-30+dlnf)/10); %% noise in W in DL
ulpdBm = 10; % tx power dBm in UL
ulp = 10.^((ulpdBm - 30)/10); %% tx pow in W in UL
ulnf = 5; % receiver noise figure in dB in UL
uln = (10.^((ndBm-30+ulnf)/10)).*ones(1,nrbs); %% noise in W in UL
ber = 0.00005;
gamma = -log (5*ber)./1.5;
%% distances
%% d2
%% UE1-----------eNB2
%% | |
%% d1| |d1
%% | d2 |
%% eNB1----------UE2
%%
d1 = 50;
%% for d2 = [10 100 1000 10000 100000 1000000]
%for d2 = [10 20 50 100 200 500 1000 10000 100000 1000000]
for d2 = [10]
%% propagation gains (linear)
%% g21dl
%% UE1<----------eNB2
%% ^ |
%%g11dl1| |g11ul
%% | v
%% eNB1<---------UE2
%% g21ul
g11dl = gain_freespace (d1, fdl);
g11ul = gain_freespace (d1, ful);
g21dl = gain_freespace (d2, fdl);
g21ul = gain_freespace (d2, ful);
dlpdBm
dlp
g11dl
%% RSRP (linear)
rsrp1 = (sum (g11dl.*dlp)) / nrbs;
rsrp2 = (sum (g11dl.*dlp)) / nrbs;
%% RSRP (dBm)
rsrp1dBm = 10.*log10(1000*rsrp1);
rsrp2dBm = 10.*log10(1000*rsrp2);
%% RSSI (linear)
rssi1 = sum (dlp*g11dl + dlp*g21dl + dln);
rssi2 = sum (dlp*g11dl + dlp*g21dl + dln);
%% RSRQ (linear)
rsrq1 = (nrbs * rsrp1) / rssi1;
rsrq2 = (nrbs * rsrp2) / rssi2;
%% RSRQ (dB)
rsrq1dB = 10.*log10(rsrq1);
rsrq2dB = 10.*log10(rsrq2);
%% SINR (linear)
% dlsinr = dlp*g11dl / (dlp*g21dl + dln);
% ulsinr = ulp*g11ul / (ulp*g21ul + uln);
%% SINR (dB)
% dlsinrdB = 10.*log10(dlsinr);
% ulsinrdB = 10.*log10(ulsinr);
%% Spectal Efficiency
% dlse = log2(1 + dlsinr./gamma);
% ulse = log2(1 + ulsinr./gamma);
%% to get the MCS, you need to do a manual lookup into 3GPP R1-081483
%% starting from the spectral efficiency value.
%% See the Testing section in the LTE module documentation for more info
%% on how this is done. You might as well look into lte_amc.m
printf("AddTestCase (new LteUeMeasurementsTestCase (\"d1=%d, d2=%d\", % f, %f, % f, %f, % f, %f));\n", \
d1, d2, d1, d2, rsrp1dBm, rsrp2dBm, rsrq1dB, rsrq2dB)
endfor

View File

@@ -124,6 +124,7 @@ def build(bld):
'test/test-lte-rrc.cc',
'test/test-lte-x2-handover.cc',
'test/test-asn1-encoding.cc',
'test/lte-test-ue-measurements.cc',
]
headers = bld.new_task_gen(features=['ns3header'])