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 
40 #include "lte-test-interference.h"
41 
42 
43 using namespace ns3;
44 
45 NS_LOG_COMPONENT_DEFINE ("LteInterferenceTest");
46 
47 void
49  uint32_t frameNo, uint32_t subframeNo, uint16_t rnti,
50  uint8_t mcsTb1, uint16_t sizeTb1, uint8_t mcsTb2, uint16_t sizeTb2)
51 {
52  testcase->DlScheduling (frameNo, subframeNo, rnti, mcsTb1, sizeTb1, mcsTb2, sizeTb2);
53 }
54 
55 void
57  uint32_t frameNo, uint32_t subframeNo, uint16_t rnti,
58  uint8_t mcs, uint16_t sizeTb)
59 {
60  testcase->UlScheduling (frameNo, subframeNo, rnti, mcs, sizeTb);
61 }
62 
63 
69  : TestSuite ("lte-interference", SYSTEM)
70 {
71  // these two first test cases have a spectral efficiency that corresponds to CQI=0 (out of range)
72  // TODO: update the test conditions to handle out-of-range correctly
73  // AddTestCase (new LteInterferenceTestCase ("d1=50, d2=10", 50.000000, 10.000000, 0.040000, 0.040000, 0.010399, 0.010399, 0, 0), TestCase::QUICK);
74  // AddTestCase (new LteInterferenceTestCase ("d1=50, d2=20", 50.000000, 20.000000, 0.160000, 0.159998, 0.041154, 0.041153, 0, 0), TestCase::QUICK);
75 
76  AddTestCase (new LteInterferenceTestCase ("d1=3000, d2=6000", 3000.000000, 6000.000000, 3.844681, 1.714583, 0.761558, 0.389662, 6, 4), TestCase::QUICK);
77  AddTestCase (new LteInterferenceTestCase ("d1=50, d2=50", 50.000000, 50.000000, 0.999997, 0.999907, 0.239828, 0.239808, 2, 2), TestCase::QUICK);
78  AddTestCase (new LteInterferenceTestCase ("d1=50, d2=100", 50.000000, 100.000000, 3.999955, 3.998520, 0.785259, 0.785042, 6, 6), TestCase::QUICK);
79  AddTestCase (new LteInterferenceTestCase ("d1=50, d2=200", 50.000000, 200.000000, 15.999282, 15.976339, 1.961072, 1.959533, 14, 14), TestCase::QUICK);
80  AddTestCase (new LteInterferenceTestCase ("d1=50, d2=500", 50.000000, 500.000000, 99.971953, 99.082845, 4.254003, 4.241793, 22, 22), TestCase::QUICK);
81  AddTestCase (new LteInterferenceTestCase ("d1=50, d2=1000", 50.000000, 1000.000000, 399.551632, 385.718468, 6.194952, 6.144825, 28, 28), TestCase::QUICK);
82  AddTestCase (new LteInterferenceTestCase ("d1=50, d2=10000", 50.000000, 10000.000000, 35964.181431, 8505.970614, 12.667381, 10.588084, 28, 28), TestCase::QUICK);
83  AddTestCase (new LteInterferenceTestCase ("d1=50, d2=100000", 50.000000, 100000.000000, 327284.773828, 10774.181090, 15.853097, 10.928917, 28, 28), TestCase::QUICK);
84  AddTestCase (new LteInterferenceTestCase ("d1=50, d2=1000000", 50.000000, 1000000.000000, 356132.574152, 10802.988445, 15.974963, 10.932767, 28, 28), TestCase::QUICK);
85  AddTestCase (new LteInterferenceTestCase ("d1=4500, d2=12600", 4500.000000, 12600.000000, 6.654462, 1.139831, 1.139781, 0.270399, 8, 2), TestCase::QUICK);
86  AddTestCase (new LteInterferenceTestCase ("d1=5400, d2=12600", 5400.000000, 12600.000000, 4.621154, 0.791549, 0.876368, 0.193019, 6, 0), TestCase::QUICK);
87 
88 
89 }
90 
92 
93 
98 LteInterferenceTestCase::LteInterferenceTestCase (std::string name, double d1, double d2, double dlSinr, double ulSinr, double dlSe, double ulSe, uint16_t dlMcs, uint16_t ulMcs)
99  : TestCase (name),
100  m_d1 (d1),
101  m_d2 (d2),
102  m_expectedDlSinrDb (10 * std::log10 (dlSinr)),
103  m_expectedUlSinrDb (10 * std::log10 (ulSinr)),
104  m_dlMcs (dlMcs),
105  m_ulMcs (ulMcs)
106 {
107 }
108 
110 {
111 }
112 
113 void
115 {
116  NS_LOG_INFO (this << GetName ());
117 
118  Config::SetDefault ("ns3::LteSpectrumPhy::CtrlErrorModelEnabled", BooleanValue (false));
119  Config::SetDefault ("ns3::LteSpectrumPhy::DataErrorModelEnabled", BooleanValue (false));
120  Config::SetDefault ("ns3::LteAmc::AmcModel", EnumValue (LteAmc::PiroEW2010));
121  Config::SetDefault ("ns3::LteAmc::Ber", DoubleValue (0.00005));
122  Ptr<LteHelper> lteHelper = CreateObject<LteHelper> ();
123  lteHelper->SetAttribute ("PathlossModel", StringValue ("ns3::FriisSpectrumPropagationLossModel"));
124  lteHelper->SetAttribute ("UseIdealRrc", BooleanValue (false));
125  lteHelper->SetAttribute ("UsePdschForCqiGeneration", BooleanValue (true));
126 
127  //Disable Uplink Power Control
128  Config::SetDefault ("ns3::LteUePhy::EnableUplinkPowerControl", BooleanValue (false));
129 
130  // Create Nodes: eNodeB and UE
131  NodeContainer enbNodes;
132  NodeContainer ueNodes1;
133  NodeContainer ueNodes2;
134  enbNodes.Create (2);
135  ueNodes1.Create (1);
136  ueNodes2.Create (1);
137  NodeContainer allNodes = NodeContainer ( enbNodes, ueNodes1, ueNodes2);
138 
139  // the topology is the following:
140  // d2
141  // UE1-----------eNB2
142  // | |
143  // d1| |d1
144  // | d2 |
145  // eNB1----------UE2
146  //
147  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
148  positionAlloc->Add (Vector (0.0, 0.0, 0.0)); // eNB1
149  positionAlloc->Add (Vector (m_d2, m_d1, 0.0)); // eNB2
150  positionAlloc->Add (Vector (0.0, m_d1, 0.0)); // UE1
151  positionAlloc->Add (Vector (m_d2, 0.0, 0.0)); // UE2
153  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
154  mobility.SetPositionAllocator (positionAlloc);
155  mobility.Install (allNodes);
156 
157  // Create Devices and install them in the Nodes (eNB and UE)
158  NetDeviceContainer enbDevs;
159  NetDeviceContainer ueDevs1;
160  NetDeviceContainer ueDevs2;
161  lteHelper->SetSchedulerType ("ns3::RrFfMacScheduler");
162  lteHelper->SetSchedulerAttribute ("UlCqiFilter", EnumValue (FfMacScheduler::PUSCH_UL_CQI));
163  enbDevs = lteHelper->InstallEnbDevice (enbNodes);
164  ueDevs1 = lteHelper->InstallUeDevice (ueNodes1);
165  ueDevs2 = lteHelper->InstallUeDevice (ueNodes2);
166 
167  lteHelper->Attach (ueDevs1, enbDevs.Get (0));
168  lteHelper->Attach (ueDevs2, enbDevs.Get (1));
169 
170  // Activate an EPS bearer
171  enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE;
172  EpsBearer bearer (q);
173  lteHelper->ActivateDataRadioBearer (ueDevs1, bearer);
174  lteHelper->ActivateDataRadioBearer (ueDevs2, bearer);
175 
176  // Use testing chunk processor in the PHY layer
177  // It will be used to test that the SNR is as intended
178  // we plug in two instances, one for DL and one for UL
179 
180  Ptr<LtePhy> ue1Phy = ueDevs1.Get (0)->GetObject<LteUeNetDevice> ()->GetPhy ()->GetObject<LtePhy> ();
181  Ptr<LteChunkProcessor> testDlSinr1 = Create<LteChunkProcessor> ();
182  LteSpectrumValueCatcher dlSinr1Catcher;
183  testDlSinr1->AddCallback (MakeCallback (&LteSpectrumValueCatcher::ReportValue, &dlSinr1Catcher));
184  ue1Phy->GetDownlinkSpectrumPhy ()->AddDataSinrChunkProcessor (testDlSinr1);
185 
186  Ptr<LtePhy> enb1phy = enbDevs.Get (0)->GetObject<LteEnbNetDevice> ()->GetPhy ()->GetObject<LtePhy> ();
187  Ptr<LteChunkProcessor> testUlSinr1 = Create<LteChunkProcessor> ();
188  LteSpectrumValueCatcher ulSinr1Catcher;
189  testUlSinr1->AddCallback (MakeCallback (&LteSpectrumValueCatcher::ReportValue, &ulSinr1Catcher));
190  enb1phy->GetUplinkSpectrumPhy ()->AddDataSinrChunkProcessor (testUlSinr1);
191 
192  Config::Connect ("/NodeList/0/DeviceList/0/LteEnbMac/DlScheduling",
194 
195  Config::Connect ("/NodeList/0/DeviceList/0/LteEnbMac/UlScheduling",
197 
198 
199  // same as above for eNB2 and UE2
200 
201  Ptr<LtePhy> ue2Phy = ueDevs2.Get (0)->GetObject<LteUeNetDevice> ()->GetPhy ()->GetObject<LtePhy> ();
202  Ptr<LteChunkProcessor> testDlSinr2 = Create<LteChunkProcessor> ();
203  LteSpectrumValueCatcher dlSinr2Catcher;
204  testDlSinr2->AddCallback (MakeCallback (&LteSpectrumValueCatcher::ReportValue, &dlSinr2Catcher));
205  ue2Phy->GetDownlinkSpectrumPhy ()->AddDataSinrChunkProcessor (testDlSinr2);
206 
207  Ptr<LtePhy> enb2phy = enbDevs.Get (1)->GetObject<LteEnbNetDevice> ()->GetPhy ()->GetObject<LtePhy> ();
208  Ptr<LteChunkProcessor> testUlSinr2 = Create<LteChunkProcessor> ();
209  LteSpectrumValueCatcher ulSinr2Catcher;
210  testUlSinr2->AddCallback (MakeCallback (&LteSpectrumValueCatcher::ReportValue, &ulSinr2Catcher));
211  enb1phy->GetUplinkSpectrumPhy ()->AddDataSinrChunkProcessor (testUlSinr2);
212 
213  Config::Connect ("/NodeList/1/DeviceList/0/LteEnbMac/DlScheduling",
215 
216  Config::Connect ("/NodeList/1/DeviceList/0/LteEnbMac/UlScheduling",
218 
219 // need to allow for RRC connection establishment + SRS
220  Simulator::Stop (Seconds (0.100));
221  Simulator::Run ();
222 
223  if (m_dlMcs > 0)
224  {
225  double dlSinr1Db = 10.0 * std::log10 (dlSinr1Catcher.GetValue ()->operator[] (0));
226  NS_TEST_ASSERT_MSG_EQ_TOL (dlSinr1Db, m_expectedDlSinrDb, 0.01, "Wrong SINR in DL! (eNB1 --> UE1)");
227 
228  double dlSinr2Db = 10.0 * std::log10 (dlSinr2Catcher.GetValue ()->operator[] (0));
229  NS_TEST_ASSERT_MSG_EQ_TOL (dlSinr2Db, m_expectedDlSinrDb, 0.01, "Wrong SINR in DL! (eNB2 --> UE2)");
230  }
231  if (m_ulMcs > 0)
232  {
233  double ulSinr1Db = 10.0 * std::log10 (ulSinr1Catcher.GetValue ()->operator[] (0));
234  NS_TEST_ASSERT_MSG_EQ_TOL (ulSinr1Db, m_expectedUlSinrDb, 0.01, "Wrong SINR in UL! (UE1 --> eNB1)");
235 
236  double ulSinr2Db = 10.0 * std::log10 (ulSinr2Catcher.GetValue ()->operator[] (0));
237  NS_TEST_ASSERT_MSG_EQ_TOL (ulSinr2Db, m_expectedUlSinrDb, 0.01, "Wrong SINR in UL! (UE2 --> eNB2)");
238  }
239 
240  Simulator::Destroy ();
241 
242 }
243 
244 
245 void
246 LteInterferenceTestCase::DlScheduling (uint32_t frameNo, uint32_t subframeNo, uint16_t rnti,
247  uint8_t mcsTb1, uint16_t sizeTb1, uint8_t mcsTb2, uint16_t sizeTb2)
248 {
249  NS_LOG_FUNCTION (frameNo << subframeNo << rnti << (uint32_t) mcsTb1 << sizeTb1 << (uint32_t) mcsTb2 << sizeTb2);
250  // need to allow for RRC connection establishment + CQI feedback reception + persistent data transmission
251  if (Simulator::Now () > MilliSeconds (65))
252  {
253  NS_TEST_ASSERT_MSG_EQ ((uint32_t)mcsTb1, (uint32_t)m_dlMcs, "Wrong DL MCS ");
254  }
255 }
256 
257 void
258 LteInterferenceTestCase::UlScheduling (uint32_t frameNo, uint32_t subframeNo, uint16_t rnti,
259  uint8_t mcs, uint16_t sizeTb)
260 {
261  NS_LOG_FUNCTION (frameNo << subframeNo << rnti << (uint32_t) mcs << sizeTb);
262  // need to allow for RRC connection establishment + SRS transmission
263  if (Simulator::Now () > MilliSeconds (50))
264  {
265  NS_TEST_ASSERT_MSG_EQ ((uint32_t)mcs, (uint32_t)m_ulMcs, "Wrong UL MCS");
266  }
267 }
virtual void DoRun(void)
Implementation to actually run this TestCase.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
AttributeValue implementation for Boolean.
Definition: boolean.h:34
NetDeviceContainer InstallEnbDevice(NodeContainer c)
Create a set of eNodeB devices.
Definition: lte-helper.cc:382
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Definition: object.h:462
Hold variables of type string.
Definition: string.h:41
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr stored in this container at a given index.
static LteInterferenceTestSuite lteLinkAdaptationWithInterferenceTestSuite
A suite of tests to run.
Definition: test.h:1333
Callback< R > MakeBoundCallback(R(*fnPtr)(TX), ARG a1)
Make Callbacks with one bound argument.
Definition: callback.h:1686
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:716
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:201
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:903
Ptr< LteSpectrumPhy > GetUplinkSpectrumPhy()
Definition: lte-phy.cc:110
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:244
encapsulates test code
Definition: test.h:1147
void ActivateDataRadioBearer(NetDeviceContainer ueDevices, EpsBearer bearer)
Activate a Data Radio Bearer on a given UE devices (for LTE-only simulation).
Definition: lte-helper.cc:1046
STL namespace.
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)
void SetSchedulerType(std::string type)
Set the type of scheduler to be used by eNodeB devices.
Definition: lte-helper.cc:225
void LteTestUlSchedulingCallback(LteInterferenceTestCase *testcase, std::string path, uint32_t frameNo, uint32_t subframeNo, uint16_t rnti, uint8_t mcs, uint16_t sizeTb)
This class contains the specification of EPS Bearers.
Definition: eps-bearer.h:71
void Install(Ptr< Node > node) const
"Layout" a single node according to the current position allocator type.
tuple mobility
Definition: third.py:101
Hold variables of type enum.
Definition: enum.h:54
void AddTestCase(TestCase *testCase, enum TestDuration duration)
Add an individual child TestCase to this test suite.
Definition: test.cc:298
void UlScheduling(uint32_t frameNo, uint32_t subframeNo, uint16_t rnti, uint8_t mcs, uint16_t sizeTb)
void SetSchedulerAttribute(std::string n, const AttributeValue &v)
Set an attribute for the scheduler to be created.
Definition: lte-helper.cc:239
#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:161
holds a vector of ns3::NetDevice pointers
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
Definition: callback.h:1489
A sink to be plugged to the callback of LteChunkProcessor allowing to save and later retrieve the lat...
Ptr< LteSpectrumPhy > GetDownlinkSpectrumPhy()
Definition: lte-phy.cc:104
#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:373
void Connect(std::string path, const CallbackBase &cb)
Definition: config.cc:835
Every class exported by the ns3 library is enclosed in the ns3 namespace.
keep track of a set of node pointers.
void SetMobilityModel(std::string type, std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue(), std::string n8="", const AttributeValue &v8=EmptyAttributeValue(), std::string n9="", const AttributeValue &v9=EmptyAttributeValue())
void DlScheduling(uint32_t frameNo, uint32_t subframeNo, uint16_t rnti, uint8_t mcsTb1, uint16_t sizeTb1, uint8_t mcsTb2, uint16_t sizeTb2)
NetDeviceContainer InstallUeDevice(NodeContainer c)
Create a set of UE devices.
Definition: lte-helper.cc:397
Helper class used to assign positions and mobility models to nodes.
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:895
void SetDefault(std::string name, const AttributeValue &value)
Definition: config.cc:774
void Add(Vector v)
Add a position to the list of positions.
Test that SINR calculation and MCS selection works fine in a multi-cell interference scenario...
std::string GetName(void) const
Definition: test.cc:369
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
Definition: simulator.cc:340
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
void SetPositionAllocator(Ptr< PositionAllocator > allocator)
Set the position allocator which will be used to allocate the initial position of every node initiali...
LteInterferenceTestCase(std::string name, double d1, double d2, double dlSinr, double ulSinr, double dlSe, double ulSe, uint16_t dlMcs, uint16_t ulMcs)
TestCase.
This class can be used to hold variables of floating point type such as 'double' or 'float'...
Definition: double.h:41
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:191
The eNodeB device implementation.
Qci
QoS Class Indicator.
Definition: eps-bearer.h:77
The LtePhy models the physical layer of LTE.
Definition: lte-phy.h:52
The LteUeNetDevice class implements the UE net device.