A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
lte-test-tdmt-ff-mac-scheduler.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: Marco Miozzo <marco.miozzo@cttc.es>,
19  * Nicola Baldo <nbaldo@cttc.es>
20  * Dizhi Zhou <dizhi.zhou@gmail.com>
21  */
22 
23 #include <iostream>
24 #include <sstream>
25 #include <string>
26 
27 #include <ns3/object.h>
28 #include <ns3/spectrum-interference.h>
29 #include <ns3/spectrum-error-model.h>
30 #include <ns3/log.h>
31 #include <ns3/test.h>
32 #include <ns3/simulator.h>
33 #include <ns3/packet.h>
34 #include <ns3/ptr.h>
35 #include "ns3/radio-bearer-stats-calculator.h"
36 #include <ns3/constant-position-mobility-model.h>
38 #include <ns3/eps-bearer.h>
39 #include <ns3/node-container.h>
40 #include <ns3/mobility-helper.h>
41 #include <ns3/net-device-container.h>
42 #include <ns3/lte-ue-net-device.h>
43 #include <ns3/lte-enb-net-device.h>
44 #include <ns3/lte-ue-rrc.h>
45 #include <ns3/lte-helper.h>
46 #include "ns3/string.h"
47 #include "ns3/double.h"
48 #include <ns3/lte-enb-phy.h>
49 #include <ns3/lte-ue-phy.h>
50 #include <ns3/boolean.h>
51 #include <ns3/enum.h>
52 
53 
55 
56 NS_LOG_COMPONENT_DEFINE ("LenaTestTdMtFfMacScheduler");
57 
58 using namespace ns3;
59 
61  : TestSuite ("lte-tdmt-ff-mac-scheduler", SYSTEM)
62 {
63  NS_LOG_INFO ("creating LenaTestTdMtFfMacSchedulerSuite");
64 
65  bool errorModel = false;
66 
67  //Test Case : AMC works in TDMT
68 
69  //Note: here the MCS is calculated by the wideband CQI
70 
71  // DOWNLINK - DISTANCE 0 -> MCS 28 -> Itbs 26 (from table 7.1.7.2.1-1 of 36.213)
72  // 1 user -> 24 PRB at Itbs 26 -> 2196 -> 2196000 bytes/sec for one UE; 0 bytes/sec for other UEs
73  // 3 users -> 2196000 among 3 users -> 2196000 bytes/sec for one UE; 0 bytes/sec for other UEs
74  // 6 users -> 2196000 among 6 users -> 2196000 bytes/sec for one UE; 0 bytes/sec for other UEs
75  // 12 users -> 2196000 among 12 users -> 2196000 bytes/sec for one UE; 0 bytes/sec for other UEs
76  // UPLINK- DISTANCE 0 -> MCS 28 -> Itbs 26 (from table 7.1.7.2.1-1 of 36.213)
77  // 1 user -> 25 PRB at Itbs 26 -> 2292 -> 2292000 bytes/sec
78  // 3 users -> 8 PRB at Itbs 26 -> 749 -> 749000 bytes/sec
79  // 6 users -> 4 PRB at Itbs 26 -> 373 -> 373000 bytes/sec
80  // after the patch enforcing min 3 PRBs per UE:
81  // 12 users -> 3 PRB at Itbs 26 -> 277 bytes * 8/12 UE/TTI -> 184670 bytes/sec
82  AddTestCase (new LenaTdMtFfMacSchedulerTestCase (1,0,2196000,2292000, errorModel), TestCase::EXTENSIVE);
83  AddTestCase (new LenaTdMtFfMacSchedulerTestCase (3,0,2196000,749000,errorModel), TestCase::QUICK);
84  AddTestCase (new LenaTdMtFfMacSchedulerTestCase (6,0,2196000,373000, errorModel), TestCase::EXTENSIVE);
85  AddTestCase (new LenaTdMtFfMacSchedulerTestCase (12,0,2196000,184670, errorModel), TestCase::EXTENSIVE);
86 
87  // DOWNLINK - DISTANCE 4800 -> MCS 22 -> Itbs 20 (from table 7.1.7.2.1-1 of 36.213)
88  // 1 user -> 24 PRB at Itbs 20 -> 1383 -> 1383000 bytes/sec for one UE; 0 bytes/sec for other UEs
89  // 3 users -> 1383000 among 3 users -> 1383000 bytes/sec for one UE; 0 bytes/sec for other UEs
90  // 6 users -> 1383000 among 6 users -> 1383000 bytes/sec for one UE; 0 bytes/sec for other UEs
91  // 12 users -> 1383000 among 12 users -> 1383000 bytes/sec for one UE; 0 bytes/sec for other UEs
92  // UPLINK - DISTANCE 4800 -> MCS 14 -> Itbs 13 (from table 7.1.7.2.1-1 of 36.213)
93  // 1 user -> 25 PRB at Itbs 13 -> 807 -> 807000 bytes/sec
94  // 3 users -> 8 PRB at Itbs 13 -> 253 -> 253000 bytes/sec
95  // 6 users -> 4 PRB at Itbs 13 -> 125 -> 125000 bytes/sec
96  // after the patch enforcing min 3 PRBs per UE:
97  // 12 users -> 3 PRB at Itbs 13 -> 93 bytes * 8/12 UE/TTI -> 62000 bytes/sec
98  AddTestCase (new LenaTdMtFfMacSchedulerTestCase (1,4800,1383000,807000,errorModel), TestCase::EXTENSIVE);
99  AddTestCase (new LenaTdMtFfMacSchedulerTestCase (3,4800,1383000,253000,errorModel), TestCase::EXTENSIVE);
100  AddTestCase (new LenaTdMtFfMacSchedulerTestCase (6,4800,1383000,125000,errorModel), TestCase::EXTENSIVE);
101  AddTestCase (new LenaTdMtFfMacSchedulerTestCase (12,4800,1383000,62000,errorModel), TestCase::EXTENSIVE);
102 
103  // DOWNLINK - DISTANCE 6000 -> MCS 20 -> Itbs 18 (from table 7.1.7.2.1-1 of 36.213)
104  // 1 user -> 24 PRB at Itbs 18 -> 1191 -> 1191000 byte/sec for one UE; 0 bytes/sec for other UEs
105  // 3 users -> 1191000 among 3 users -> 1191000 bytes/sec for one UE; 0 bytes/sec for other UEs
106  // 6 users -> 1191000 among 6 users -> 1191000 bytes/sec for one UE; 0 bytes/sec for other UEs
107  // 12 users ->1191000 among 12 users -> 1191000 bytes/sec for one UE; 0 bytes/sec for other UEs
108  // UPLINK - DISTANCE 6000 -> MCS 12 -> Itbs 11 (from table 7.1.7.2.1-1 of 36.213)
109  // 1 user -> 25 PRB at Itbs 11 -> 621 -> 621000 bytes/sec
110  // 3 users -> 8 PRB at Itbs 11 -> 201 -> 201000 bytes/sec
111  // 6 users -> 4 PRB at Itbs 11 -> 97 -> 97000 bytes/sec
112  // after the patch enforcing min 3 PRBs per UE:
113  // 12 users -> 3 PRB at Itbs 11 -> 73 bytes * 8/12 UE/TTI -> 48667 bytes/sec
114  AddTestCase (new LenaTdMtFfMacSchedulerTestCase (1,6000,1191000,621000, errorModel), TestCase::EXTENSIVE);
115  AddTestCase (new LenaTdMtFfMacSchedulerTestCase (3,6000,1191000,201000, errorModel), TestCase::EXTENSIVE);
116  AddTestCase (new LenaTdMtFfMacSchedulerTestCase (6,6000,1191000,97000, errorModel), TestCase::EXTENSIVE);
117  AddTestCase (new LenaTdMtFfMacSchedulerTestCase (12,6000,1191000,48667, errorModel), TestCase::EXTENSIVE);
118 
119  // DOWNLINK - DISTANCE 10000 -> MCS 14 -> Itbs 13 (from table 7.1.7.2.1-1 of 36.213)
120  // 1 user -> 24 PRB at Itbs 13 -> 775 -> 775000 byte/sec for one UE; 0 bytes/sec for other UEs
121  // 3 users -> 775000 among 3 users -> 775000 bytes/sec for one UE; 0 bytes/sec for other UEs
122  // 6 users -> 775000 among 6 users -> 775000 bytes/sec for one UE; 0 bytes/sec for other UEs
123  // 12 users -> 775000 among 12 users -> 775000 bytes/sec for one UE; 0 bytes/sec for other UEs
124  // UPLINK - DISTANCE 10000 -> MCS 8 -> Itbs 8 (from table 7.1.7.2.1-1 of 36.213)
125  // 1 user -> 24 PRB at Itbs 8 -> 437 -> 437000 bytes/sec
126  // 3 users -> 8 PRB at Itbs 8 -> 137 -> 137000 bytes/sec
127  // 6 users -> 4 PRB at Itbs 8 -> 67 -> 67000 bytes/sec
128  // after the patch enforcing min 3 PRBs per UE:
129  // 12 users -> 3 PRB at Itbs 8 -> 49 bytes * 8/12 UE/TTI -> 32667 bytes/sec
130  AddTestCase (new LenaTdMtFfMacSchedulerTestCase (1,10000,775000,437000,errorModel), TestCase::EXTENSIVE);
131  AddTestCase (new LenaTdMtFfMacSchedulerTestCase (3,10000,775000,137000,errorModel), TestCase::EXTENSIVE);
132  AddTestCase (new LenaTdMtFfMacSchedulerTestCase (6,10000,775000,67000,errorModel), TestCase::EXTENSIVE);
133  AddTestCase (new LenaTdMtFfMacSchedulerTestCase (12,10000,775000,32667,errorModel), TestCase::EXTENSIVE);
134 
135  // DONWLINK - DISTANCE 20000 -> MCS 8 -> Itbs 8 (from table 7.1.7.2.1-1 of 36.213)
136  // 1 user -> 24 PRB at Itbs 8 -> 421 -> 421000 bytes/sec for one UE; 0 bytes/sec for other UEs
137  // 3 users -> 421000 among 3 users -> 421000 bytes/sec for one UE; 0 bytes/sec for other UEs
138  // 6 users -> 421000 among 6 users -> 421000 bytes/sec for one UE; 0 bytes/sec for other UEs
139  // 12 users -> 421000 among 12 users -> 421000 bytes/sec for one UE; 0 bytes/sec for other UEs
140  // UPLINK - DISTANCE 20000 -> MCS 2 -> Itbs 2 (from table 7.1.7.2.1-1 of 36.213)
141  // 1 user -> 25 PRB at Itbs 2 -> 233 -> 137000 bytes/sec
142  // 3 users -> 8 PRB at Itbs 2 -> 69 -> 41000 bytes/sec
143  // 6 users -> 4 PRB at Itbs 2 -> 32 -> 22000 bytes/sec
144  // after the patch enforcing min 3 PRBs per UE:
145  // 12 users -> 3 PRB at Itbs 2 -> 26 bytes * 8/12 UE/TTI -> 12000 bytes/sec
146  AddTestCase (new LenaTdMtFfMacSchedulerTestCase (1,20000,421000,137000,errorModel), TestCase::EXTENSIVE);
147  AddTestCase (new LenaTdMtFfMacSchedulerTestCase (3,20000,421000,41000,errorModel), TestCase::EXTENSIVE);
148  AddTestCase (new LenaTdMtFfMacSchedulerTestCase (6,20000,421000,22000,errorModel), TestCase::EXTENSIVE);
149  AddTestCase (new LenaTdMtFfMacSchedulerTestCase (12,20000,421000,12000,errorModel), TestCase::EXTENSIVE);
150 
151 }
152 
154 
155 
156 // --------------- T E S T - C A S E ------------------------------
157 
158 std::string
159 LenaTdMtFfMacSchedulerTestCase::BuildNameString (uint16_t nUser, uint16_t dist)
160 {
161  std::ostringstream oss;
162  oss << nUser << " UEs, distance " << dist << " m";
163  return oss.str ();
164 }
165 
166 LenaTdMtFfMacSchedulerTestCase::LenaTdMtFfMacSchedulerTestCase (uint16_t nUser, uint16_t dist, double thrRefDl, double thrRefUl, bool errorModelEnabled)
167  : TestCase (BuildNameString (nUser, dist)),
168  m_nUser (nUser),
169  m_dist (dist),
170  m_thrRefDl (thrRefDl),
171  m_thrRefUl (thrRefUl),
172  m_errorModelEnabled (errorModelEnabled)
173 {
174 }
175 
177 {
178 }
179 
180 
181 void
183 {
184 
185  NS_LOG_FUNCTION (this << m_nUser << m_dist);
186 
187  if (!m_errorModelEnabled)
188  {
189  Config::SetDefault ("ns3::LteSpectrumPhy::CtrlErrorModelEnabled", BooleanValue (false));
190  Config::SetDefault ("ns3::LteSpectrumPhy::DataErrorModelEnabled", BooleanValue (false));
191  }
192 
193  Config::SetDefault ("ns3::LteHelper::UseIdealRrc", BooleanValue (true));
194 
199  Ptr<LteHelper> lteHelper = CreateObject<LteHelper> ();
200  lteHelper->SetAttribute ("PathlossModel", StringValue ("ns3::FriisSpectrumPropagationLossModel"));
201 
202  // Create Nodes: eNodeB and UE
203  NodeContainer enbNodes;
204  NodeContainer ueNodes;
205  enbNodes.Create (1);
206  ueNodes.Create (m_nUser);
207 
208  // Install Mobility Model
209  MobilityHelper mobility;
210  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
211  mobility.Install (enbNodes);
212  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
213  mobility.Install (ueNodes);
214 
215  // Create Devices and install them in the Nodes (eNB and UE)
216  NetDeviceContainer enbDevs;
217  NetDeviceContainer ueDevs;
218  lteHelper->SetSchedulerType ("ns3::TdMtFfMacScheduler");
219  enbDevs = lteHelper->InstallEnbDevice (enbNodes);
220  ueDevs = lteHelper->InstallUeDevice (ueNodes);
221 
222  // Attach a UE to a eNB
223  lteHelper->Attach (ueDevs, enbDevs.Get (0));
224 
225  // Activate an EPS bearer
226  enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE;
227  EpsBearer bearer (q);
228  lteHelper->ActivateDataRadioBearer (ueDevs, bearer);
229 
230 
231  Ptr<LteEnbNetDevice> lteEnbDev = enbDevs.Get (0)->GetObject<LteEnbNetDevice> ();
232  Ptr<LteEnbPhy> enbPhy = lteEnbDev->GetPhy ();
233  enbPhy->SetAttribute ("TxPower", DoubleValue (30.0));
234  enbPhy->SetAttribute ("NoiseFigure", DoubleValue (5.0));
235 
236  // Set UEs' position and power
237  for (int i = 0; i < m_nUser; i++)
238  {
240  mm->SetPosition (Vector (m_dist, 0.0, 0.0));
241  Ptr<LteUeNetDevice> lteUeDev = ueDevs.Get (i)->GetObject<LteUeNetDevice> ();
242  Ptr<LteUePhy> uePhy = lteUeDev->GetPhy ();
243  uePhy->SetAttribute ("TxPower", DoubleValue (23.0));
244  uePhy->SetAttribute ("NoiseFigure", DoubleValue (9.0));
245  }
246 
247 
248  double statsStartTime = 0.300; // need to allow for RRC connection establishment + SRS
249  double statsDuration = 0.6;
250  double tolerance = 0.1;
251  Simulator::Stop (Seconds (statsStartTime + statsDuration - 0.000001));
252 
253  lteHelper->EnableMacTraces ();
254  lteHelper->EnableRlcTraces ();
255  Ptr<RadioBearerStatsCalculator> rlcStats = lteHelper->GetRlcStats ();
256  rlcStats->SetAttribute ("StartTime", TimeValue (Seconds (statsStartTime)));
257  rlcStats->SetAttribute ("EpochDuration", TimeValue (Seconds (statsDuration)));
258 
259 
260  Simulator::Run ();
261 
265  NS_LOG_INFO ("DL - Test with " << m_nUser << " user(s) at distance " << m_dist);
266  std::vector <uint64_t> dlDataRxed;
267  for (int i = 0; i < m_nUser; i++)
268  {
269  // get the imsi
270  uint64_t imsi = ueDevs.Get (i)->GetObject<LteUeNetDevice> ()->GetImsi ();
271  uint8_t lcId = 3;
272  dlDataRxed.push_back (rlcStats->GetDlRxData (imsi, lcId));
273  NS_LOG_INFO ("\tUser " << i << " imsi " << imsi << " bytes rxed " << (double)dlDataRxed.at (i) << " thr " << (double)dlDataRxed.at (i) / statsDuration << " ref " << m_thrRefDl);
274  }
275 
281  uint8_t found = 0;
282  for (int i = 0; i < m_nUser; i++)
283  {
284  double throughput = (double)dlDataRxed.at (i) / statsDuration;
285  if (throughput != 0 && found == 0)
286  {
287  NS_TEST_ASSERT_MSG_EQ_TOL (throughput, m_thrRefDl, m_thrRefDl * tolerance, " Unfair Throughput!");
288  found = 1;
289  }
290  else if (throughput != 0 && found == 1)
291  {
292  NS_TEST_ASSERT_MSG_EQ_TOL (0, m_thrRefDl, m_thrRefDl * tolerance, " Unfair Throughput!");
293  }
294  else
295  NS_TEST_ASSERT_MSG_EQ_TOL (throughput, 0, 0, " Unfair Throughput!");
296  }
297 
301  NS_LOG_INFO ("UL - Test with " << m_nUser << " user(s) at distance " << m_dist);
302  std::vector <uint64_t> ulDataRxed;
303  for (int i = 0; i < m_nUser; i++)
304  {
305  // get the imsi
306  uint64_t imsi = ueDevs.Get (i)->GetObject<LteUeNetDevice> ()->GetImsi ();
307  // get the lcId
308  uint8_t lcId = 3;
309  ulDataRxed.push_back (rlcStats->GetUlRxData (imsi, lcId));
310  NS_LOG_INFO ("\tUser " << i << " imsi " << imsi << " bytes rxed " << (double)ulDataRxed.at (i) << " thr " << (double)ulDataRxed.at (i) / statsDuration << " ref " << m_thrRefUl);
311  }
318  for (int i = 0; i < m_nUser; i++)
319  {
320  NS_TEST_ASSERT_MSG_EQ_TOL ((double)ulDataRxed.at (i) / statsDuration, m_thrRefUl, m_thrRefUl * tolerance, " Unfair Throughput!");
321  }
322  Simulator::Destroy ();
323 
324 }
325 
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:59
#define NS_LOG_FUNCTION(parameters)
Definition: log.h:345
Hold a bool native type.
Definition: boolean.h:38
NetDeviceContainer InstallEnbDevice(NodeContainer c)
create a set of eNB devices
Definition: lte-helper.cc:347
hold variables of type string
Definition: string.h:19
NS_LOG_COMPONENT_DEFINE("LenaTestTdMtFfMacScheduler")
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr stored in this container at a given index.
#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:326
A suite of tests to run.
Definition: test.h:1025
Ptr< LteEnbPhy > GetPhy(void) const
Mobility model for which the current position does not change once it has been set and until it is se...
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:647
void EnableRlcTraces(void)
Enable trace sinks for RLC layer.
Definition: lte-helper.cc:957
static std::string BuildNameString(uint16_t nUser, uint16_t dist)
#define NS_LOG_INFO(msg)
Definition: log.h:298
encapsulates test code
Definition: test.h:849
void ActivateDataRadioBearer(NetDeviceContainer ueDevices, EpsBearer bearer)
Call ActivateDataRadioBearer (ueDevice, bearer) for each UE device in a given set.
Definition: lte-helper.cc:901
a 3d vector
Definition: vector.h:31
void SetSchedulerType(std::string type)
Definition: lte-helper.cc:211
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.
hold objects of type ns3::Time
Definition: nstime.h:961
LenaTdMtFfMacSchedulerTestCase(uint16_t nUser, uint16_t dist, double thrRefDl, double thrRefUl, bool errorModelEnabled)
uint64_t GetDlRxData(uint64_t imsi, uint8_t lcid)
Gets the number of received downlink data bytes.
holds a vector of ns3::NetDevice pointers
void SetDefault(std::string name, const AttributeValue &value)
Definition: config.cc:667
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 AddTestCase(TestCase *testCase) NS_DEPRECATED
Add an individual child TestCase case to this TestCase.
Definition: test.cc:173
void SetPosition(const Vector &position)
static LenaTestTdMtFfMacSchedulerSuite lenaTestTdMtFfMacSchedulerSuite
Ptr< RadioBearerStatsCalculator > GetRlcStats(void)
Definition: lte-helper.cc:1088
NetDeviceContainer InstallUeDevice(NodeContainer c)
create a set of UE devices
Definition: lte-helper.cc:362
Helper class used to assign positions and mobility models to nodes.
uint64_t GetUlRxData(uint64_t imsi, uint8_t lcid)
Gets the number of received uplink data bytes.
double throughput
Ptr< Node > Get(uint32_t i) const
Get the Ptr stored in this container at a given index.
This system test program creates different test cases with a single eNB and several UEs...
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
void EnableMacTraces(void)
Enable trace sinks for MAC layer.
Definition: lte-helper.cc:1045
virtual void DoRun(void)
Implementation to actually run this TestCase.
Ptr< LteUePhy > GetPhy(void) const
Hold a floating point type.
Definition: double.h:41
void SetAttribute(std::string name, const AttributeValue &value)
Definition: object-base.cc:161
The eNodeB device implementation.
Ptr< T > GetObject(void) const
Definition: object.h:361
Qci
QoS Class Indicator.
Definition: eps-bearer.h:77
The LteUeNetDevice class implements the UE net device.