A Discrete-Event Network Simulator
API
lte-test-interference.cc
Go to the documentation of this file.
1/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Author: Manuel Requena <manuel.requena@cttc.es>
19 * Nicola Baldo <nbaldo@cttc.es>
20 */
21
22#include "ns3/simulator.h"
23#include "ns3/log.h"
24#include "ns3/string.h"
25#include "ns3/double.h"
26#include <ns3/enum.h>
27#include "ns3/boolean.h"
28#include "ns3/mobility-helper.h"
29#include "ns3/lte-helper.h"
30#include "ns3/ff-mac-scheduler.h"
31
32#include "ns3/lte-enb-phy.h"
33#include "ns3/lte-enb-net-device.h"
34
35#include "ns3/lte-ue-phy.h"
36#include "ns3/lte-ue-net-device.h"
37
38#include <ns3/lte-chunk-processor.h>
39
41
42
43using namespace ns3;
44
45NS_LOG_COMPONENT_DEFINE ("LteInterferenceTest");
46
47void
50{
51 testcase->DlScheduling (dlInfo);
52}
53
54void
56 uint32_t frameNo, uint32_t subframeNo, uint16_t rnti,
57 uint8_t mcs, uint16_t sizeTb, uint8_t ccId)
58{
59 testcase->UlScheduling (frameNo, subframeNo, rnti, mcs, sizeTb);
60}
61
62
68 : TestSuite ("lte-interference", SYSTEM)
69{
70 // these two first test cases have a spectral efficiency that corresponds to CQI=0 (out of range)
71 // TODO: update the test conditions to handle out-of-range correctly
72 // AddTestCase (new LteInterferenceTestCase ("d1=50, d2=10", 50.000000, 10.000000, 0.040000, 0.040000, 0.010399, 0.010399, 0, 0), TestCase::QUICK);
73 // AddTestCase (new LteInterferenceTestCase ("d1=50, d2=20", 50.000000, 20.000000, 0.160000, 0.159998, 0.041154, 0.041153, 0, 0), TestCase::QUICK);
74
75 AddTestCase (new LteInterferenceTestCase ("d1=3000, d2=6000", 3000.000000, 6000.000000, 3.844681, 1.714583, 0.761558, 0.389662, 6, 4), TestCase::QUICK);
76 AddTestCase (new LteInterferenceTestCase ("d1=50, d2=50", 50.000000, 50.000000, 0.999997, 0.999907, 0.239828, 0.239808, 2, 2), TestCase::QUICK);
77 AddTestCase (new LteInterferenceTestCase ("d1=50, d2=100", 50.000000, 100.000000, 3.999955, 3.998520, 0.785259, 0.785042, 6, 6), TestCase::QUICK);
78 AddTestCase (new LteInterferenceTestCase ("d1=50, d2=200", 50.000000, 200.000000, 15.999282, 15.976339, 1.961072, 1.959533, 14, 14), TestCase::QUICK);
79 AddTestCase (new LteInterferenceTestCase ("d1=50, d2=500", 50.000000, 500.000000, 99.971953, 99.082845, 4.254003, 4.241793, 22, 22), TestCase::QUICK);
80 AddTestCase (new LteInterferenceTestCase ("d1=50, d2=1000", 50.000000, 1000.000000, 399.551632, 385.718468, 6.194952, 6.144825, 28, 28), TestCase::QUICK);
81 AddTestCase (new LteInterferenceTestCase ("d1=50, d2=10000", 50.000000, 10000.000000, 35964.181431, 8505.970614, 12.667381, 10.588084, 28, 28), TestCase::QUICK);
82 AddTestCase (new LteInterferenceTestCase ("d1=50, d2=100000", 50.000000, 100000.000000, 327284.773828, 10774.181090, 15.853097, 10.928917, 28, 28), TestCase::QUICK);
83 AddTestCase (new LteInterferenceTestCase ("d1=50, d2=1000000", 50.000000, 1000000.000000, 356132.574152, 10802.988445, 15.974963, 10.932767, 28, 28), TestCase::QUICK);
84 AddTestCase (new LteInterferenceTestCase ("d1=4500, d2=12600", 4500.000000, 12600.000000, 6.654462, 1.139831, 1.139781, 0.270399, 8, 2), TestCase::QUICK);
85 AddTestCase (new LteInterferenceTestCase ("d1=5400, d2=12600", 5400.000000, 12600.000000, 4.621154, 0.791549, 0.876368, 0.193019, 6, 0), TestCase::QUICK);
86
87
88}
89
91
92
97LteInterferenceTestCase::LteInterferenceTestCase (std::string name, double d1, double d2, double dlSinr, double ulSinr, double dlSe, double ulSe, uint16_t dlMcs, uint16_t ulMcs)
98 : TestCase (name),
99 m_d1 (d1),
100 m_d2 (d2),
101 m_expectedDlSinrDb (10 * std::log10 (dlSinr)),
102 m_expectedUlSinrDb (10 * std::log10 (ulSinr)),
103 m_dlMcs (dlMcs),
104 m_ulMcs (ulMcs)
105{
106}
107
109{
110}
111
112void
114{
115 NS_LOG_INFO (this << GetName ());
116
117 Config::SetDefault ("ns3::LteSpectrumPhy::CtrlErrorModelEnabled", BooleanValue (false));
118 Config::SetDefault ("ns3::LteSpectrumPhy::DataErrorModelEnabled", BooleanValue (false));
119 Config::SetDefault ("ns3::LteAmc::AmcModel", EnumValue (LteAmc::PiroEW2010));
120 Config::SetDefault ("ns3::LteAmc::Ber", DoubleValue (0.00005));
121 Ptr<LteHelper> lteHelper = CreateObject<LteHelper> ();
122 lteHelper->SetAttribute ("PathlossModel", StringValue ("ns3::FriisSpectrumPropagationLossModel"));
123 lteHelper->SetAttribute ("UseIdealRrc", BooleanValue (false));
124 lteHelper->SetAttribute ("UsePdschForCqiGeneration", BooleanValue (true));
125
126 //Disable Uplink Power Control
127 Config::SetDefault ("ns3::LteUePhy::EnableUplinkPowerControl", BooleanValue (false));
128
129 // Create Nodes: eNodeB and UE
130 NodeContainer enbNodes;
131 NodeContainer ueNodes1;
132 NodeContainer ueNodes2;
133 enbNodes.Create (2);
134 ueNodes1.Create (1);
135 ueNodes2.Create (1);
136 NodeContainer allNodes = NodeContainer ( enbNodes, ueNodes1, ueNodes2);
137
138 // the topology is the following:
139 // d2
140 // UE1-----------eNB2
141 // | |
142 // d1| |d1
143 // | d2 |
144 // eNB1----------UE2
145 //
146 Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
147 positionAlloc->Add (Vector (0.0, 0.0, 0.0)); // eNB1
148 positionAlloc->Add (Vector (m_d2, m_d1, 0.0)); // eNB2
149 positionAlloc->Add (Vector (0.0, m_d1, 0.0)); // UE1
150 positionAlloc->Add (Vector (m_d2, 0.0, 0.0)); // UE2
152 mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
153 mobility.SetPositionAllocator (positionAlloc);
154 mobility.Install (allNodes);
155
156 // Create Devices and install them in the Nodes (eNB and UE)
157 NetDeviceContainer enbDevs;
158 NetDeviceContainer ueDevs1;
159 NetDeviceContainer ueDevs2;
160 lteHelper->SetSchedulerType ("ns3::RrFfMacScheduler");
161 lteHelper->SetSchedulerAttribute ("UlCqiFilter", EnumValue (FfMacScheduler::PUSCH_UL_CQI));
162 enbDevs = lteHelper->InstallEnbDevice (enbNodes);
163 ueDevs1 = lteHelper->InstallUeDevice (ueNodes1);
164 ueDevs2 = lteHelper->InstallUeDevice (ueNodes2);
165
166 lteHelper->Attach (ueDevs1, enbDevs.Get (0));
167 lteHelper->Attach (ueDevs2, enbDevs.Get (1));
168
169 // Activate an EPS bearer
170 enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE;
171 EpsBearer bearer (q);
172 lteHelper->ActivateDataRadioBearer (ueDevs1, bearer);
173 lteHelper->ActivateDataRadioBearer (ueDevs2, bearer);
174
175 // Use testing chunk processor in the PHY layer
176 // It will be used to test that the SNR is as intended
177 // we plug in two instances, one for DL and one for UL
178
179 Ptr<LtePhy> ue1Phy = ueDevs1.Get (0)->GetObject<LteUeNetDevice> ()->GetPhy ()->GetObject<LtePhy> ();
180 Ptr<LteChunkProcessor> testDlSinr1 = Create<LteChunkProcessor> ();
181 LteSpectrumValueCatcher dlSinr1Catcher;
182 testDlSinr1->AddCallback (MakeCallback (&LteSpectrumValueCatcher::ReportValue, &dlSinr1Catcher));
183 ue1Phy->GetDownlinkSpectrumPhy ()->AddDataSinrChunkProcessor (testDlSinr1);
184
185 Ptr<LtePhy> enb1phy = enbDevs.Get (0)->GetObject<LteEnbNetDevice> ()->GetPhy ()->GetObject<LtePhy> ();
186 Ptr<LteChunkProcessor> testUlSinr1 = Create<LteChunkProcessor> ();
187 LteSpectrumValueCatcher ulSinr1Catcher;
188 testUlSinr1->AddCallback (MakeCallback (&LteSpectrumValueCatcher::ReportValue, &ulSinr1Catcher));
189 enb1phy->GetUplinkSpectrumPhy ()->AddDataSinrChunkProcessor (testUlSinr1);
190
191 Config::Connect ("/NodeList/0/DeviceList/0/ComponentCarrierMap/*/LteEnbMac/DlScheduling",
193
194 Config::Connect ("/NodeList/0/DeviceList/0/ComponentCarrierMap/*/LteEnbMac/UlScheduling",
196
197
198 // same as above for eNB2 and UE2
199
200 Ptr<LtePhy> ue2Phy = ueDevs2.Get (0)->GetObject<LteUeNetDevice> ()->GetPhy ()->GetObject<LtePhy> ();
201 Ptr<LteChunkProcessor> testDlSinr2 = Create<LteChunkProcessor> ();
202 LteSpectrumValueCatcher dlSinr2Catcher;
203 testDlSinr2->AddCallback (MakeCallback (&LteSpectrumValueCatcher::ReportValue, &dlSinr2Catcher));
204 ue2Phy->GetDownlinkSpectrumPhy ()->AddDataSinrChunkProcessor (testDlSinr2);
205
206 Ptr<LtePhy> enb2phy = enbDevs.Get (1)->GetObject<LteEnbNetDevice> ()->GetPhy ()->GetObject<LtePhy> ();
207 Ptr<LteChunkProcessor> testUlSinr2 = Create<LteChunkProcessor> ();
208 LteSpectrumValueCatcher ulSinr2Catcher;
209 testUlSinr2->AddCallback (MakeCallback (&LteSpectrumValueCatcher::ReportValue, &ulSinr2Catcher));
210 enb1phy->GetUplinkSpectrumPhy ()->AddDataSinrChunkProcessor (testUlSinr2);
211
212 Config::Connect ("/NodeList/1/DeviceList/0/ComponentCarrierMap/*/LteEnbMac/DlScheduling",
214
215 Config::Connect ("/NodeList/1/DeviceList/0/ComponentCarrierMap/*/LteEnbMac/UlScheduling",
217
218// need to allow for RRC connection establishment + SRS
219 Simulator::Stop (Seconds (0.100));
220 Simulator::Run ();
221
222 if (m_dlMcs > 0)
223 {
224 double dlSinr1Db = 10.0 * std::log10 (dlSinr1Catcher.GetValue ()->operator[] (0));
225 NS_TEST_ASSERT_MSG_EQ_TOL (dlSinr1Db, m_expectedDlSinrDb, 0.01, "Wrong SINR in DL! (eNB1 --> UE1)");
226
227 double dlSinr2Db = 10.0 * std::log10 (dlSinr2Catcher.GetValue ()->operator[] (0));
228 NS_TEST_ASSERT_MSG_EQ_TOL (dlSinr2Db, m_expectedDlSinrDb, 0.01, "Wrong SINR in DL! (eNB2 --> UE2)");
229 }
230 if (m_ulMcs > 0)
231 {
232 double ulSinr1Db = 10.0 * std::log10 (ulSinr1Catcher.GetValue ()->operator[] (0));
233 NS_TEST_ASSERT_MSG_EQ_TOL (ulSinr1Db, m_expectedUlSinrDb, 0.01, "Wrong SINR in UL! (UE1 --> eNB1)");
234
235 double ulSinr2Db = 10.0 * std::log10 (ulSinr2Catcher.GetValue ()->operator[] (0));
236 NS_TEST_ASSERT_MSG_EQ_TOL (ulSinr2Db, m_expectedUlSinrDb, 0.01, "Wrong SINR in UL! (UE2 --> eNB2)");
237 }
238
239 Simulator::Destroy ();
240
241}
242
243
244void
246{
247 NS_LOG_FUNCTION (dlInfo.frameNo << dlInfo.subframeNo << dlInfo.rnti << (uint32_t) dlInfo.mcsTb1 << dlInfo.sizeTb1 << (uint32_t) dlInfo.mcsTb2 << dlInfo.sizeTb2);
248 // need to allow for RRC connection establishment + CQI feedback reception + persistent data transmission
249 if (Simulator::Now () > MilliSeconds (65))
250 {
251 NS_TEST_ASSERT_MSG_EQ ((uint32_t)dlInfo.mcsTb1, (uint32_t)m_dlMcs, "Wrong DL MCS ");
252 }
253}
254
255void
256LteInterferenceTestCase::UlScheduling (uint32_t frameNo, uint32_t subframeNo, uint16_t rnti,
257 uint8_t mcs, uint16_t sizeTb)
258{
259 NS_LOG_FUNCTION (frameNo << subframeNo << rnti << (uint32_t) mcs << sizeTb);
260 // need to allow for RRC connection establishment + SRS transmission
261 if (Simulator::Now () > MilliSeconds (50))
262 {
263 NS_TEST_ASSERT_MSG_EQ ((uint32_t)mcs, (uint32_t)m_ulMcs, "Wrong UL MCS");
264 }
265}
Test that SINR calculation and MCS selection works fine in a multi-cell interference scenario.
LteInterferenceTestCase(std::string name, double d1, double d2, double dlSinr, double ulSinr, double dlSe, double ulSe, uint16_t dlMcs, uint16_t ulMcs)
Constructor.
double m_expectedDlSinrDb
expected DL SINR in dB
void UlScheduling(uint32_t frameNo, uint32_t subframeNo, uint16_t rnti, uint8_t mcs, uint16_t sizeTb)
UL scheduling function.
double m_expectedUlSinrDb
expected UL SINR in dB
void DlScheduling(DlSchedulingCallbackInfo dlInfo)
DL scheduling function.
double m_d2
distance between UE and other ENB
virtual void DoRun(void)
Implementation to actually run this TestCase.
double m_d1
distance between UE and ENB
Test suite for interference test.
AttributeValue implementation for Boolean.
Definition: boolean.h:37
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition: double.h:41
Hold variables of type enum.
Definition: enum.h:55
This class contains the specification of EPS Bearers.
Definition: eps-bearer.h:92
Qci
QoS Class Indicator.
Definition: eps-bearer.h:107
The eNodeB device implementation.
void SetSchedulerAttribute(std::string n, const AttributeValue &v)
Set an attribute for the scheduler to be created.
Definition: lte-helper.cc:293
NetDeviceContainer InstallEnbDevice(NodeContainer c)
Create a set of eNodeB devices.
Definition: lte-helper.cc:474
void SetSchedulerType(std::string type)
Set the type of scheduler to be used by eNodeB devices.
Definition: lte-helper.cc:279
void Attach(NetDeviceContainer ueDevices)
Enables automatic attachment of a set of UE devices to a suitable cell using Idle mode initial cell s...
Definition: lte-helper.cc:959
void ActivateDataRadioBearer(NetDeviceContainer ueDevices, EpsBearer bearer)
Activate a Data Radio Bearer on a given UE devices (for LTE-only simulation).
Definition: lte-helper.cc:1313
NetDeviceContainer InstallUeDevice(NodeContainer c)
Create a set of UE devices.
Definition: lte-helper.cc:489
The LtePhy models the physical layer of LTE.
Definition: lte-phy.h:53
A sink to be plugged to the callback of LteChunkProcessor allowing to save and later retrieve the lat...
Ptr< SpectrumValue > GetValue()
The LteUeNetDevice class implements the UE net device.
Helper class used to assign positions and mobility models to nodes.
holds a vector of ns3::NetDevice pointers
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
keep track of a set of node pointers.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:256
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Definition: object.h:470
Hold variables of type string.
Definition: string.h:41
encapsulates test code
Definition: test.h:994
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:299
std::string GetName(void) const
Definition: test.cc:370
A suite of tests to run.
Definition: test.h:1188
void SetDefault(std::string name, const AttributeValue &value)
Definition: config.cc:849
void Connect(std::string path, const CallbackBase &cb)
Definition: config.cc:920
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:281
Callback< R > MakeBoundCallback(R(*fnPtr)(TX), ARG a1)
Make Callbacks with one bound argument.
Definition: callback.h:1709
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
Definition: simulator.cc:287
#define NS_TEST_ASSERT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report and abort if not.
Definition: test.h:141
#define NS_TEST_ASSERT_MSG_EQ_TOL(actual, limit, tol, msg)
Test that actual and expected (limit) values are equal to plus or minus some tolerance and report and...
Definition: test.h:323
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1244
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1252
void LteTestDlSchedulingCallback(LteInterferenceTestCase *testcase, std::string path, DlSchedulingCallbackInfo dlInfo)
static LteInterferenceTestSuite lteLinkAdaptationWithInterferenceTestSuite
void LteTestUlSchedulingCallback(LteInterferenceTestCase *testcase, std::string path, uint32_t frameNo, uint32_t subframeNo, uint16_t rnti, uint8_t mcs, uint16_t sizeTb, uint8_t ccId)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Definition: callback.h:1648
STL namespace.
mobility
Definition: third.py:107
DlSchedulingCallbackInfo structure.
Definition: lte-common.h:240
uint32_t subframeNo
subframe number
Definition: lte-common.h:242
uint16_t sizeTb2
size TB2
Definition: lte-common.h:247
uint16_t sizeTb1
size TB1
Definition: lte-common.h:245
uint32_t frameNo
frame number
Definition: lte-common.h:241