diff --git a/src/lte/doc/source/index.rst b/src/lte/doc/source/index.rst index 3dcc51f39..7d9084000 100644 --- a/src/lte/doc/source/index.rst +++ b/src/lte/doc/source/index.rst @@ -9,7 +9,6 @@ This is the stand-alone version of the ns-3 LTE module documentation. :maxdepth: 2 lte-design - ff-api lte-user lte-testing diff --git a/src/lte/doc/source/lte.rst b/src/lte/doc/source/lte.rst index b0cd86d5b..448603be5 100644 --- a/src/lte/doc/source/lte.rst +++ b/src/lte/doc/source/lte.rst @@ -15,4 +15,3 @@ LTE Simulator Documentation - diff --git a/src/lte/examples/lena-rlc-calculator.cc b/src/lte/examples/lena-rlc-calculator.cc index 73fdc7e68..0ce202371 100644 --- a/src/lte/examples/lena-rlc-calculator.cc +++ b/src/lte/examples/lena-rlc-calculator.cc @@ -73,11 +73,21 @@ int main (int argc, char *argv[]) EpsBearer bearer (q); lena->ActivateEpsBearer (ueDevs, bearer); - Simulator::Stop (Seconds (35)); + Simulator::Stop (Seconds (2)); lena->EnableMacTraces (); lena->EnableRlcTraces (); + + double distance_temp [] = {10000,10000,10000}; //{10000, 10000, 10000}; + std::vector userDistance; + userDistance.assign(distance_temp, distance_temp+3); + for (int i = 0; i < 3; i++) + { + Ptr mm = ueNodes.Get (i)->GetObject (); + mm->SetPosition (Vector (userDistance[i], 0.0, 0.0)); + } // rkwan + Simulator::Run (); // Uncomment to show available paths diff --git a/src/lte/model/lte-enb-mac.h b/src/lte/model/lte-enb-mac.h index 47466f6be..9483df6ad 100644 --- a/src/lte/model/lte-enb-mac.h +++ b/src/lte/model/lte-enb-mac.h @@ -216,13 +216,13 @@ private: uint32_t m_subframeNo; /** * Trace information regarding DL scheduling - * Simulation time, Frame number, Subframe number, RNTI, MCS of TB1, size of TB1, + * Frame number, Subframe number, RNTI, MCS of TB1, size of TB1, * MCS of TB2 (0 if not present), size of TB2 (0 if not present) */ TracedCallback m_dlScheduling; /** * Trace information regarding UL scheduling - * Simulation time, Frame number, Subframe number, RNTI, MCS of TB, size of TB + * Frame number, Subframe number, RNTI, MCS of TB, size of TB */ TracedCallback m_ulScheduling; diff --git a/src/lte/model/pf-ff-mac-scheduler.cc b/src/lte/model/pf-ff-mac-scheduler.cc index 3cd1889fa..95bc42816 100644 --- a/src/lte/model/pf-ff-mac-scheduler.cc +++ b/src/lte/model/pf-ff-mac-scheduler.cc @@ -833,7 +833,7 @@ PfFfMacScheduler::DoSchedUlTriggerReq (const struct FfMacSchedSapProvider::Sched // Update global UE stats // update UEs stats - for (itStats = m_flowStatsDl.begin (); itStats != m_flowStatsDl.end (); itStats++) + for (itStats = m_flowStatsUl.begin (); itStats != m_flowStatsUl.end (); itStats++) { (*itStats).second.totalBytesTransmitted += (*itStats).second.lastTtiBytesTrasmitted; // update average throughput (see eq. 12.3 of Sec 12.3.1.2 of LTE – The UMTS Long Term Evolution, Ed Wiley) diff --git a/src/lte/test/lte-test-interference.cc b/src/lte/test/lte-test-interference.cc new file mode 100644 index 000000000..da5c1d2cf --- /dev/null +++ b/src/lte/test/lte-test-interference.cc @@ -0,0 +1,228 @@ +/* -*- 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 + * Nicola Baldo + */ + +#include "ns3/simulator.h" +#include "ns3/log.h" +#include "ns3/string.h" +#include "ns3/double.h" + +#include "ns3/mobility-helper.h" +#include "ns3/lena-helper.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 "ns3/lte-test-interference.h" + +#include "lte-test-sinr-chunk-processor.h" + +NS_LOG_COMPONENT_DEFINE ("LteInterferenceTest"); + +using namespace ns3; + + +void +LteTestDlSchedulingCallback (LteInterferenceTestCase *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) +{ + testcase->DlScheduling(frameNo, subframeNo, rnti, mcsTb1, sizeTb1, mcsTb2, sizeTb2); +} + +void +LteTestUlSchedulingCallback (LteInterferenceTestCase *testcase, std::string path, + uint32_t frameNo, uint32_t subframeNo, uint16_t rnti, + uint8_t mcs, uint16_t sizeTb) +{ + testcase->UlScheduling(frameNo, subframeNo, rnti, mcs, sizeTb); +} + + +/** + * TestSuite + */ + +LteInterferenceTestSuite::LteInterferenceTestSuite () + : TestSuite ("lte-interference", SYSTEM) +{ + NS_LOG_INFO ("Creating LteInterferenceTestSuite"); + + AddTestCase (new LteInterferenceTestCase ("d1=3000, d2=6000", 3000.000000, 6000.000000, 3.844681, 1.714583, 0.761558, 0.389662, 6, 4)); + AddTestCase (new LteInterferenceTestCase ("d1=50, d2=10", 50.000000, 10.000000, 0.040000, 0.040000, 0.010399, 0.010399, 0, 0)); + AddTestCase (new LteInterferenceTestCase ("d1=50, d2=20", 50.000000, 20.000000, 0.160000, 0.159998, 0.041154, 0.041153, 0, 0)); + AddTestCase (new LteInterferenceTestCase ("d1=50, d2=50", 50.000000, 50.000000, 0.999997, 0.999907, 0.239828, 0.239808, 2, 2)); + AddTestCase (new LteInterferenceTestCase ("d1=50, d2=100", 50.000000, 100.000000, 3.999955, 3.998520, 0.785259, 0.785042, 6, 6)); + AddTestCase (new LteInterferenceTestCase ("d1=50, d2=200", 50.000000, 200.000000, 15.999282, 15.976339, 1.961072, 1.959533, 14, 14)); + AddTestCase (new LteInterferenceTestCase ("d1=50, d2=500", 50.000000, 500.000000, 99.971953, 99.082845, 4.254003, 4.241793, 22, 22)); + AddTestCase (new LteInterferenceTestCase ("d1=50, d2=1000", 50.000000, 1000.000000, 399.551632, 385.718468, 6.194952, 6.144825, 28, 28)); + AddTestCase (new LteInterferenceTestCase ("d1=50, d2=10000", 50.000000, 10000.000000, 35964.181431, 8505.970614, 12.667381, 10.588084, 28, 28)); + AddTestCase (new LteInterferenceTestCase ("d1=50, d2=100000", 50.000000, 100000.000000, 327284.773828, 10774.181090, 15.853097, 10.928917, 28, 28)); + AddTestCase (new LteInterferenceTestCase ("d1=50, d2=1000000", 50.000000, 1000000.000000, 356132.574152, 10802.988445, 15.974963, 10.932767, 28, 28)); + +} + +static LteInterferenceTestSuite lteLinkAdaptationWithInterferenceTestSuite; + + +/** + * TestCase + */ + +LteInterferenceTestCase::LteInterferenceTestCase (std::string name, double d1, double d2, double dlSinr, double ulSinr, double dlSe, double ulSe, uint16_t dlMcs, uint16_t ulMcs) + : TestCase (name), + m_d1 (d1), + m_d2 (d2), + m_dlSinrDb (10*log10(dlSinr)), + m_ulSinrDb (10*log10(ulSinr)), + m_dlSe (dlSe), + m_ulSe (ulSe), + m_dlMcs (dlMcs), + m_ulMcs (ulMcs) +{ +} + +LteInterferenceTestCase::~LteInterferenceTestCase () +{ +} + +void +LteInterferenceTestCase::DoRun (void) +{ + /** + * Simulation Topology + */ + + Ptr lena = CreateObject (); +// lena->EnableLogComponents (); + lena->EnableMacTraces (); + lena->EnableRlcTraces (); + lena->SetAttribute ("PropagationModel", StringValue ("ns3::FriisSpectrumPropagationLossModel")); + + // 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 positionAlloc = CreateObject (); + 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; + lena->SetSchedulerType ("ns3::RrFfMacScheduler"); + enbDevs = lena->InstallEnbDevice (enbNodes); + ueDevs1 = lena->InstallUeDevice (ueNodes1); + ueDevs2 = lena->InstallUeDevice (ueNodes2); + + lena->Attach (ueDevs1, enbDevs.Get (0)); + lena->Attach (ueDevs2, enbDevs.Get (1)); + + // Activate an EPS bearer + enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; + EpsBearer bearer (q); + lena->ActivateEpsBearer (ueDevs1, bearer); + lena->ActivateEpsBearer (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 uePhy = ueDevs1.Get (0)->GetObject ()->GetPhy ()->GetObject (); + Ptr testDlSinr = Create (uePhy); + uePhy->GetDownlinkSpectrumPhy ()->AddSinrChunkProcessor (testDlSinr); + + Ptr enbPhy = enbDevs.Get (0)->GetObject ()->GetPhy ()->GetObject (); + Ptr testUlSinr = Create (enbPhy); + enbPhy->GetUplinkSpectrumPhy ()->AddSinrChunkProcessor (testUlSinr); + + Config::Connect ("/NodeList/0/DeviceList/0/LteEnbMac/DlScheduling", + MakeBoundCallback(&LteTestDlSchedulingCallback, this)); + + Config::Connect ("/NodeList/0/DeviceList/0/LteEnbMac/UlScheduling", + MakeBoundCallback(&LteTestUlSchedulingCallback, this)); + + + Simulator::Stop (Seconds (0.005)); + Simulator::Run (); + + double dlSinrDb = 10.0 * log10 (testDlSinr->GetSinr ()[0]); + NS_TEST_ASSERT_MSG_EQ_TOL (dlSinrDb, m_dlSinrDb, 0.01, "Wrong SINR in DL!"); + + double ulSinrDb = 10.0 * log10 (testUlSinr->GetSinr ()[0]); + NS_TEST_ASSERT_MSG_EQ_TOL (ulSinrDb, m_ulSinrDb, 0.01, "Wrong SINR in UL!"); + + Simulator::Destroy (); +} + + +void +LteInterferenceTestCase::DlScheduling (uint32_t frameNo, uint32_t subframeNo, uint16_t rnti, + uint8_t mcsTb1, uint16_t sizeTb1, uint8_t mcsTb2, uint16_t sizeTb2) +{ + /** + * Note: + * For first 4 subframeNo in the first frameNo, the MCS cannot be properly evaluated, + * because CQI feedback is still not available at the eNB. + */ + if ( (frameNo > 1) || (subframeNo > 4) ) + { + NS_TEST_ASSERT_MSG_EQ ((uint16_t)mcsTb1, m_dlMcs, "Wrong DL MCS "); + } +} + +void +LteInterferenceTestCase::UlScheduling (uint32_t frameNo, uint32_t subframeNo, uint16_t rnti, + uint8_t mcs, uint16_t sizeTb) +{ + /** + * Note: + * For first 4 subframeNo in the first frameNo, the MCS cannot be properly evaluated, + * because CQI feedback is still not available at the eNB. + */ + if ( (frameNo > 1) || (subframeNo > 4) ) + { + NS_TEST_ASSERT_MSG_EQ ((uint16_t)mcs, m_ulMcs, "Wrong UL MCS"); + } +} diff --git a/src/lte/test/lte-test-interference.h b/src/lte/test/lte-test-interference.h new file mode 100644 index 000000000..21fa36f83 --- /dev/null +++ b/src/lte/test/lte-test-interference.h @@ -0,0 +1,68 @@ +/* -*- 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 + * Nicola Baldo + */ + +#ifndef LTE_TEST_INTERFERENCE_H +#define LTE_TEST_INTERFERENCE_H + +#include "ns3/test.h" + + +using namespace ns3; + + +/** + * Test that SINR calculation and MCS selection works fine in a multi-cell interference scenario. + */ +class LteInterferenceTestSuite : public TestSuite +{ +public: + LteInterferenceTestSuite (); +}; + + +class LteInterferenceTestCase : public TestCase +{ +public: + LteInterferenceTestCase (std::string name, double d1, double d2, double dlSinr, double ulSinr, double dlSe, double ulSe, uint16_t dlMcs, uint16_t ulMcs); + virtual ~LteInterferenceTestCase (); + + void DlScheduling (uint32_t frameNo, uint32_t subframeNo, uint16_t rnti, + uint8_t mcsTb1, uint16_t sizeTb1, uint8_t mcsTb2, uint16_t sizeTb2); + + void UlScheduling (uint32_t frameNo, uint32_t subframeNo, uint16_t rnti, + uint8_t mcs, uint16_t sizeTb); + +private: + virtual void DoRun (void); + + + double m_d1; + double m_d2; + double m_dlSinrDb; + double m_ulSinrDb; + double m_dlSe; + double m_ulSe; + uint16_t m_dlMcs; + uint16_t m_ulMcs; +}; + + +#endif /* LTE_TEST_INTERFERENCE_H */ diff --git a/src/lte/test/lte-test-link-adaptation.cc b/src/lte/test/lte-test-link-adaptation.cc index cfdbab2da..4a153e006 100644 --- a/src/lte/test/lte-test-link-adaptation.cc +++ b/src/lte/test/lte-test-link-adaptation.cc @@ -144,7 +144,7 @@ LteLinkAdaptationTestCase::LteLinkAdaptationTestCase (std::string name, double s sstream1 << " snr=" << snrDb << " mcs=" << mcsIndex; - NS_LOG_UNCOND ("Creating LteLinkAdaptationTestCase: " + sstream1.str ()); + NS_LOG_INFO ("Creating LteLinkAdaptationTestCase: " + sstream1.str ()); } LteLinkAdaptationTestCase::~LteLinkAdaptationTestCase () @@ -213,14 +213,14 @@ LteLinkAdaptationTestCase::DoRun (void) void LteLinkAdaptationTestCase::DlScheduling (uint32_t frameNo, uint32_t subframeNo, uint16_t rnti, - uint8_t mcsTb1, uint16_t sizeTb1, uint8_t mcsTb2, uint16_t sizeTb2) + uint8_t mcsTb1, uint16_t sizeTb1, uint8_t mcsTb2, uint16_t sizeTb2) { static bool firstTime = true; if ( firstTime ) { firstTime = false; - NS_LOG_UNCOND ("SNR\tRef_MCS\tCalc_MCS"); + NS_LOG_INFO ("SNR\tRef_MCS\tCalc_MCS"); } /** @@ -230,7 +230,7 @@ LteLinkAdaptationTestCase::DlScheduling (uint32_t frameNo, uint32_t subframeNo, */ if ( (frameNo > 1) || (subframeNo > 4) ) { - NS_LOG_UNCOND (m_snrDb << "\t" << m_mcsIndex << "\t" << (uint16_t)mcsTb1); + NS_LOG_INFO (m_snrDb << "\t" << m_mcsIndex << "\t" << (uint16_t)mcsTb1); NS_TEST_ASSERT_MSG_EQ ((uint16_t)mcsTb1, m_mcsIndex, "Wrong MCS index"); } diff --git a/src/lte/test/reference/lte_link_budget_interference.m b/src/lte/test/reference/lte_link_budget_interference.m new file mode 100644 index 000000000..362e18399 --- /dev/null +++ b/src/lte/test/reference/lte_link_budget_interference.m @@ -0,0 +1,79 @@ +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 = nrbs * 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 +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); %% 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 = [20 50 200 500] + + %% 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); + + %% 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 LteInterferenceTestCase (\"d1=%d, d2=%d\", % f, %f, % f, %f, % f, %f, , ));\n", \ + d1, d2, d1, d2, dlsinr, ulsinr, dlse, ulse) + + +endfor diff --git a/src/lte/wscript b/src/lte/wscript index 4baa278f2..1fe49fa1b 100644 --- a/src/lte/wscript +++ b/src/lte/wscript @@ -53,6 +53,7 @@ def build(bld): 'test/lte-test-downlink-sinr.cc', 'test/lte-test-uplink-sinr.cc', 'test/lte-test-link-adaptation.cc', + 'test/lte-test-interference.cc', 'test/lte-test-sinr-chunk-processor.cc', 'test/lte-test-ue-phy.cc', 'test/lte-test-rr-ff-mac-scheduler.cc', @@ -110,6 +111,7 @@ def build(bld): 'test/lte-test-downlink-sinr.h', 'test/lte-test-uplink-sinr.h', 'test/lte-test-link-adaptation.h', + 'test/lte-test-interference.h', 'test/lte-test-sinr-chunk-processor.h', 'test/lte-test-ue-phy.h', 'test/lte-test-rr-ff-mac-scheduler.h',