A Discrete-Event Network Simulator
API
lte-test-carrier-aggregation.cc
Go to the documentation of this file.
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2016 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: Biljana Bojovic <bbojovic@cttc.es>
19  *
20  */
21 
22 #include <ns3/object.h>
23 #include <ns3/spectrum-interference.h>
24 #include <ns3/spectrum-error-model.h>
25 #include <ns3/log.h>
26 #include <ns3/test.h>
27 #include <ns3/simulator.h>
28 #include <ns3/packet.h>
29 #include <ns3/ptr.h>
30 #include <iostream>
31 #include "ns3/radio-bearer-stats-calculator.h"
32 #include <ns3/constant-position-mobility-model.h>
33 #include "ns3/ff-mac-scheduler.h"
34 #include <ns3/eps-bearer.h>
35 #include <ns3/node-container.h>
36 #include <ns3/mobility-helper.h>
37 #include <ns3/net-device-container.h>
38 #include <ns3/lte-ue-net-device.h>
39 #include <ns3/lte-enb-net-device.h>
40 #include <ns3/lte-ue-rrc.h>
41 #include <ns3/lte-helper.h>
42 #include "ns3/string.h"
43 #include "ns3/double.h"
44 #include <ns3/lte-enb-phy.h>
45 #include <ns3/lte-ue-phy.h>
46 #include <ns3/boolean.h>
47 #include <ns3/enum.h>
48 #include <ns3/config-store-module.h>
49 #include <errno.h>
50 
52 
53 using namespace ns3;
54 
55 NS_LOG_COMPONENT_DEFINE ("TestCarrierAggregation");
56 
57 bool CarrierAggregationTestCase::s_writeResults = false; // set to true to write response vectors
58 const std::string dlResultsFileName = "carrier_aggregation_results_dl.txt";
59 const std::string ulResultsFileName = "carrier_aggregation_results_ul.txt";
60 
61 
62 void
64 {
65  testcase->DlScheduling (dlInfo);
66 }
67 
68 void
70  uint32_t frameNo, uint32_t subframeNo, uint16_t rnti,
71  uint8_t mcs, uint16_t sizeTb, uint8_t ccId)
72 {
73  testcase->UlScheduling (frameNo, subframeNo, rnti, mcs, sizeTb, ccId);
74 }
75 
76 
78  : TestSuite ("lte-carrier-aggregation", SYSTEM)
79 {
80  NS_LOG_INFO ("creating CarrierAggregationTestCase");
81 
82  if (CarrierAggregationTestCase::s_writeResults) // write result vectors to file
83  {
84  std::cout<<"\n Running TestCarrierAggregationSuite with activated option to write results to files."
85  "Dl results will be written to "<<dlResultsFileName<<" and uplink results to "<<ulResultsFileName<<std::endl;
86 
87  bool abort = false;
88 
89  if (fopen(dlResultsFileName.c_str(), "r"))
90  {
91  std::cout<<"\nResults file "<<dlResultsFileName<<" already exists. Move it out of the way or specify another downlink results file name."<<std::endl;
92  abort = true;
93  }
94  if (fopen(ulResultsFileName.c_str(), "r"))
95  {
96  std::cout<<"\nResults file "<<ulResultsFileName<<" already exists. Move it out of the way or specify another uplink results file name."<<std::endl;
97  abort = true;
98  }
99 
100  if (abort)
101  return;
102 
103  AddTestCase (new CarrierAggregationTestCase (1,0, 100, 100, 1), TestCase::QUICK);
104  AddTestCase (new CarrierAggregationTestCase (3,0, 100, 100, 1), TestCase::QUICK);
105  AddTestCase (new CarrierAggregationTestCase (6,0, 100, 100, 1), TestCase::QUICK);
106  AddTestCase (new CarrierAggregationTestCase (9,0, 100, 100, 1), TestCase::QUICK);
107  AddTestCase (new CarrierAggregationTestCase (12,0, 100, 100, 1), TestCase::QUICK);
108  AddTestCase (new CarrierAggregationTestCase (15,0, 100, 100, 1), TestCase::QUICK);
109 
110  AddTestCase (new CarrierAggregationTestCase (1,0, 100, 100, 2), TestCase::QUICK);
111  AddTestCase (new CarrierAggregationTestCase (3,0, 100, 100, 2), TestCase::QUICK);
112  AddTestCase (new CarrierAggregationTestCase (6,0, 100, 100, 2), TestCase::QUICK);
113  AddTestCase (new CarrierAggregationTestCase (9,0, 100, 100, 2), TestCase::QUICK);
114  AddTestCase (new CarrierAggregationTestCase (12,0, 100, 100, 2), TestCase::QUICK);
115  AddTestCase (new CarrierAggregationTestCase (15,0, 100, 100, 2), TestCase::QUICK);
116 
117  AddTestCase (new CarrierAggregationTestCase (1,0, 100, 100, 3), TestCase::QUICK);
118  AddTestCase (new CarrierAggregationTestCase (3,0, 100, 100, 3), TestCase::QUICK);
119  AddTestCase (new CarrierAggregationTestCase (6,0, 100, 100, 3), TestCase::QUICK);
120  AddTestCase (new CarrierAggregationTestCase (9,0, 100, 100, 3), TestCase::QUICK);
121  AddTestCase (new CarrierAggregationTestCase (12,0, 100, 100, 3), TestCase::QUICK);
122  AddTestCase (new CarrierAggregationTestCase (15,0, 100, 100, 3), TestCase::QUICK);
123  }
124  else
125  {
126  // bandwidth is 25 and there are 2 carriers
127  AddTestCase (new CarrierAggregationTestCase (1,0, 25, 25, 2), TestCase::EXTENSIVE);
128  AddTestCase (new CarrierAggregationTestCase (3,0, 25, 25, 2), TestCase::EXTENSIVE);
129  AddTestCase (new CarrierAggregationTestCase (6,0, 25, 25, 2), TestCase::EXTENSIVE);
130  AddTestCase (new CarrierAggregationTestCase (9,0, 25, 25, 2), TestCase::EXTENSIVE);
131  AddTestCase (new CarrierAggregationTestCase (12,0, 25, 25, 2), TestCase::EXTENSIVE);
132  AddTestCase (new CarrierAggregationTestCase (15,0, 25, 25, 2), TestCase::EXTENSIVE);
133 
134  AddTestCase (new CarrierAggregationTestCase (1,4800, 25, 25, 2), TestCase::QUICK);
135  AddTestCase (new CarrierAggregationTestCase (3,4800, 25, 25, 2), TestCase::EXTENSIVE);
136  AddTestCase (new CarrierAggregationTestCase (6,4800, 25, 25, 2), TestCase::EXTENSIVE);
137  AddTestCase (new CarrierAggregationTestCase (9,4800, 25, 25, 2), TestCase::EXTENSIVE);
138  AddTestCase (new CarrierAggregationTestCase (12,4800, 25, 25, 2), TestCase::EXTENSIVE);
139  AddTestCase (new CarrierAggregationTestCase (15,4800, 25, 25, 2), TestCase::EXTENSIVE);
140 
141  AddTestCase (new CarrierAggregationTestCase (1,6000, 25, 25, 2), TestCase::EXTENSIVE);
142  AddTestCase (new CarrierAggregationTestCase (3,6000, 25, 25, 2), TestCase::EXTENSIVE);
143  AddTestCase (new CarrierAggregationTestCase (6,6000, 25, 25, 2), TestCase::EXTENSIVE);
144  AddTestCase (new CarrierAggregationTestCase (9,6000, 25, 25, 2), TestCase::EXTENSIVE);
145  AddTestCase (new CarrierAggregationTestCase (12,6000, 25, 25, 2), TestCase::EXTENSIVE);
146  AddTestCase (new CarrierAggregationTestCase (15,6000, 25, 25, 2), TestCase::EXTENSIVE);
147 
148  AddTestCase (new CarrierAggregationTestCase (1,20000, 25, 25, 2), TestCase::EXTENSIVE);
149  AddTestCase (new CarrierAggregationTestCase (3,20000, 25, 25, 2), TestCase::EXTENSIVE);
150  AddTestCase (new CarrierAggregationTestCase (6,20000, 25, 25, 2), TestCase::EXTENSIVE);
151  AddTestCase (new CarrierAggregationTestCase (9,20000, 25, 25, 2), TestCase::EXTENSIVE);
152  AddTestCase (new CarrierAggregationTestCase (12,20000, 25, 25, 2), TestCase::EXTENSIVE);
153  AddTestCase (new CarrierAggregationTestCase (15,20000, 25, 25, 2), TestCase::QUICK);
154 
155 
156  // bandwidth is 25 and there are 3 carriers
157  AddTestCase (new CarrierAggregationTestCase (1,0, 25, 25, 3), TestCase::EXTENSIVE);
158  AddTestCase (new CarrierAggregationTestCase (3,0, 25, 25, 3), TestCase::QUICK);
159  AddTestCase (new CarrierAggregationTestCase (6,0, 25, 25, 3), TestCase::EXTENSIVE);
160  AddTestCase (new CarrierAggregationTestCase (9,0, 25, 25, 3), TestCase::EXTENSIVE);
161  AddTestCase (new CarrierAggregationTestCase (12,0, 25, 25, 3), TestCase::EXTENSIVE);
162  AddTestCase (new CarrierAggregationTestCase (15,0, 25, 25, 3), TestCase::EXTENSIVE);
163 
164  AddTestCase (new CarrierAggregationTestCase (1,4800, 25, 25, 3), TestCase::QUICK);
165  AddTestCase (new CarrierAggregationTestCase (3,4800, 25, 25, 3), TestCase::EXTENSIVE);
166  AddTestCase (new CarrierAggregationTestCase (6,4800, 25, 25, 3), TestCase::EXTENSIVE);
167  AddTestCase (new CarrierAggregationTestCase (9,4800, 25, 25, 3), TestCase::EXTENSIVE);
168  AddTestCase (new CarrierAggregationTestCase (12,4800, 25, 25, 3), TestCase::EXTENSIVE);
169  AddTestCase (new CarrierAggregationTestCase (15,4800, 25, 25, 3), TestCase::EXTENSIVE);
170 
171  AddTestCase (new CarrierAggregationTestCase (1,6000, 25, 25, 3), TestCase::EXTENSIVE);
172  AddTestCase (new CarrierAggregationTestCase (3,6000, 25, 25, 3), TestCase::EXTENSIVE);
173  AddTestCase (new CarrierAggregationTestCase (6,6000, 25, 25, 3), TestCase::EXTENSIVE);
174  AddTestCase (new CarrierAggregationTestCase (9,6000, 25, 25, 3), TestCase::EXTENSIVE);
175  AddTestCase (new CarrierAggregationTestCase (12,6000, 25, 25, 3), TestCase::EXTENSIVE);
176  AddTestCase (new CarrierAggregationTestCase (15,6000, 25, 25, 3), TestCase::EXTENSIVE);
177 
178  AddTestCase (new CarrierAggregationTestCase (1,20000, 25, 25, 3), TestCase::EXTENSIVE);
179  AddTestCase (new CarrierAggregationTestCase (3,20000, 25, 25, 3), TestCase::EXTENSIVE);
180  AddTestCase (new CarrierAggregationTestCase (6,20000, 25, 25, 3), TestCase::EXTENSIVE);
181  AddTestCase (new CarrierAggregationTestCase (9,20000, 25, 25, 3), TestCase::EXTENSIVE);
182  AddTestCase (new CarrierAggregationTestCase (12,20000, 25, 25, 3), TestCase::EXTENSIVE);
183  AddTestCase (new CarrierAggregationTestCase (15,20000, 25, 25, 3), TestCase::EXTENSIVE);
184 
185 
186  // bandwidth = 6 RB and there are 3 carriers
187  AddTestCase (new CarrierAggregationTestCase (1,0, 6, 6, 3), TestCase::EXTENSIVE);
188  AddTestCase (new CarrierAggregationTestCase (3,0, 6, 6, 3), TestCase::EXTENSIVE);
189  AddTestCase (new CarrierAggregationTestCase (6,0, 6, 6, 3), TestCase::EXTENSIVE);
190  AddTestCase (new CarrierAggregationTestCase (9,0, 6, 6, 3), TestCase::EXTENSIVE);
191  AddTestCase (new CarrierAggregationTestCase (12,0, 6, 6, 3), TestCase::EXTENSIVE);
192  AddTestCase (new CarrierAggregationTestCase (15,0, 6, 6, 3), TestCase::EXTENSIVE);
193 
194  AddTestCase (new CarrierAggregationTestCase (1,4800, 6, 6, 3), TestCase::QUICK);
195  AddTestCase (new CarrierAggregationTestCase (3,4800, 6, 6, 3), TestCase::EXTENSIVE);
196  AddTestCase (new CarrierAggregationTestCase (6,4800, 6, 6, 3), TestCase::EXTENSIVE);
197  AddTestCase (new CarrierAggregationTestCase (9,4800, 6, 6, 3), TestCase::EXTENSIVE);
198  AddTestCase (new CarrierAggregationTestCase (12,4800, 6, 6, 3), TestCase::EXTENSIVE);
199  AddTestCase (new CarrierAggregationTestCase (15,4800, 6, 6, 3), TestCase::EXTENSIVE);
200  AddTestCase (new CarrierAggregationTestCase (1,6000, 6, 6, 3), TestCase::EXTENSIVE);
201  AddTestCase (new CarrierAggregationTestCase (3,6000, 6, 6, 3), TestCase::EXTENSIVE);
202  AddTestCase (new CarrierAggregationTestCase (6,6000, 6, 6, 3), TestCase::EXTENSIVE);
203  AddTestCase (new CarrierAggregationTestCase (9,6000, 6, 6, 3), TestCase::EXTENSIVE);
204  AddTestCase (new CarrierAggregationTestCase (12,6000, 6, 6, 3), TestCase::EXTENSIVE);
205  AddTestCase (new CarrierAggregationTestCase (15,6000, 6, 6, 3), TestCase::EXTENSIVE);
206  AddTestCase (new CarrierAggregationTestCase (1,20000, 6, 6, 3), TestCase::EXTENSIVE);
207  AddTestCase (new CarrierAggregationTestCase (3,20000, 6, 6, 3), TestCase::EXTENSIVE);
208  AddTestCase (new CarrierAggregationTestCase (6,20000, 6, 6, 3), TestCase::EXTENSIVE);
209  AddTestCase (new CarrierAggregationTestCase (9,20000, 6, 6, 3), TestCase::EXTENSIVE);
210  AddTestCase (new CarrierAggregationTestCase (12,20000, 6, 6, 3), TestCase::EXTENSIVE);
211  AddTestCase (new CarrierAggregationTestCase (15,20000, 6, 6, 3), TestCase::EXTENSIVE);
212 
213  // bandwidth = 6 RB and there are 2 carriers
214  AddTestCase (new CarrierAggregationTestCase (1,0, 6, 6, 2), TestCase::EXTENSIVE);
215  AddTestCase (new CarrierAggregationTestCase (3,0, 6, 6, 2), TestCase::EXTENSIVE);
216  AddTestCase (new CarrierAggregationTestCase (6,0, 6, 6, 2), TestCase::EXTENSIVE);
217  AddTestCase (new CarrierAggregationTestCase (9,0, 6, 6, 2), TestCase::EXTENSIVE);
218  AddTestCase (new CarrierAggregationTestCase (12,0, 6, 6, 2), TestCase::EXTENSIVE);
219  AddTestCase (new CarrierAggregationTestCase (15,0, 6, 6, 2), TestCase::EXTENSIVE);
220 
221  AddTestCase (new CarrierAggregationTestCase (1,4800, 6, 6, 2), TestCase::EXTENSIVE);
222  AddTestCase (new CarrierAggregationTestCase (3,4800, 6, 6, 2), TestCase::EXTENSIVE);
223  AddTestCase (new CarrierAggregationTestCase (6,4800, 6, 6, 2), TestCase::EXTENSIVE);
224  AddTestCase (new CarrierAggregationTestCase (9,4800, 6, 6, 2), TestCase::EXTENSIVE);
225  AddTestCase (new CarrierAggregationTestCase (12,4800, 6, 6, 2), TestCase::EXTENSIVE);
226  AddTestCase (new CarrierAggregationTestCase (15,4800, 6, 6, 2), TestCase::EXTENSIVE);
227 
228  AddTestCase (new CarrierAggregationTestCase (1,6000, 6, 6, 2), TestCase::EXTENSIVE);
229  AddTestCase (new CarrierAggregationTestCase (3,6000, 6, 6, 2), TestCase::EXTENSIVE);
230  AddTestCase (new CarrierAggregationTestCase (6,6000, 6, 6, 2), TestCase::EXTENSIVE);
231  AddTestCase (new CarrierAggregationTestCase (9,6000, 6, 6, 2), TestCase::EXTENSIVE);
232  AddTestCase (new CarrierAggregationTestCase (12,6000, 6, 6, 2), TestCase::EXTENSIVE);
233  AddTestCase (new CarrierAggregationTestCase (15,6000, 6, 6, 2), TestCase::QUICK);
234 
235  AddTestCase (new CarrierAggregationTestCase (1,20000, 6, 6, 2), TestCase::EXTENSIVE);
236  AddTestCase (new CarrierAggregationTestCase (3,20000, 6, 6, 2), TestCase::EXTENSIVE);
237  AddTestCase (new CarrierAggregationTestCase (6,20000, 6, 6, 2), TestCase::EXTENSIVE);
238  AddTestCase (new CarrierAggregationTestCase (9,20000, 6, 6, 2), TestCase::EXTENSIVE);
239  AddTestCase (new CarrierAggregationTestCase (12,20000, 6, 6, 2), TestCase::EXTENSIVE);
240  AddTestCase (new CarrierAggregationTestCase (15,20000, 6, 6, 2), TestCase::EXTENSIVE);
241  }
242 }
243 
244 
246 
247 std::string
248 CarrierAggregationTestCase::BuildNameString (uint16_t nUser, uint16_t dist, uint32_t dlBandwidth, uint32_t ulBandwidth, uint32_t numberOfComponentCarriers)
249 {
250  std::ostringstream oss;
251  oss << nUser << " UEs, distance " << dist << " m"<< " dlBandwidth "<< dlBandwidth <<" ulBandwidth "<< ulBandwidth <<" number of carriers "<<numberOfComponentCarriers;
252  return oss.str ();
253 }
254 
255 CarrierAggregationTestCase::CarrierAggregationTestCase (uint16_t nUser, uint16_t dist, uint32_t dlbandwidth, uint32_t ulBandwidth, uint32_t numberOfComponentCarriers)
256  : TestCase (BuildNameString (nUser, dist, dlbandwidth, ulBandwidth, numberOfComponentCarriers)),
257  m_nUser (nUser),
258  m_dist (dist),
259  m_dlBandwidth (dlbandwidth),
260  m_ulBandwidth (ulBandwidth),
261  m_numberOfComponentCarriers(numberOfComponentCarriers)
262 {
263  m_dlThroughput = 0;
264  m_statsDuration = 0.6;
265 }
266 
268 {
269 }
270 
271 void
273 {
275 
276  Config::SetDefault ("ns3::LteEnbNetDevice::DlEarfcn", UintegerValue (100));
277  Config::SetDefault ("ns3::LteEnbNetDevice::UlEarfcn", UintegerValue (100 + 18000));
278  Config::SetDefault ("ns3::LteEnbNetDevice::DlBandwidth", UintegerValue (m_dlBandwidth));
279  Config::SetDefault ("ns3::LteEnbNetDevice::UlBandwidth", UintegerValue (m_ulBandwidth));
280  Config::SetDefault ("ns3::LteUeNetDevice::DlEarfcn", UintegerValue (100));
281 
282  Config::SetDefault ("ns3::LteHelper::UseCa", BooleanValue (true));
283  Config::SetDefault ("ns3::LteHelper::NumberOfComponentCarriers", UintegerValue (m_numberOfComponentCarriers));
284  Config::SetDefault ("ns3::LteHelper::EnbComponentCarrierManager", StringValue ("ns3::RrComponentCarrierManager"));
285  Config::SetDefault ("ns3::LteSpectrumPhy::CtrlErrorModelEnabled", BooleanValue (false));
286  Config::SetDefault ("ns3::LteSpectrumPhy::DataErrorModelEnabled", BooleanValue (false));
287  Config::SetDefault ("ns3::LteHelper::UseIdealRrc", BooleanValue (true));
288 
289  Config::SetDefault ("ns3::MacStatsCalculator::DlOutputFilename", StringValue (CreateTempDirFilename ("DlMacStats.txt")));
290  Config::SetDefault ("ns3::MacStatsCalculator::UlOutputFilename", StringValue (CreateTempDirFilename ("UlMacStats.txt")));
291  Config::SetDefault ("ns3::RadioBearerStatsCalculator::DlRlcOutputFilename", StringValue (CreateTempDirFilename ("DlRlcStats.txt")));
292  Config::SetDefault ("ns3::RadioBearerStatsCalculator::UlRlcOutputFilename", StringValue (CreateTempDirFilename ("UlRlcStats.txt")));
293  Config::SetDefault ("ns3::RadioBearerStatsCalculator::DlPdcpOutputFilename", StringValue (CreateTempDirFilename ("DlPdcpStats.txt")));
294  Config::SetDefault ("ns3::RadioBearerStatsCalculator::UlPdcpOutputFilename", StringValue (CreateTempDirFilename ("UlPdcpStats.txt")));
295  Config::SetDefault ("ns3::PhyStatsCalculator::DlRsrpSinrFilename", StringValue (CreateTempDirFilename ("DlRsrpSinrStats.txt")));
296  Config::SetDefault ("ns3::PhyStatsCalculator::UlSinrFilename", StringValue (CreateTempDirFilename ("UlSinrStats.txt")));
297  Config::SetDefault ("ns3::PhyStatsCalculator::UlInterferenceFilename", StringValue (CreateTempDirFilename ("UlInterferenceStats.txt")));
298  Config::SetDefault ("ns3::PhyRxStatsCalculator::DlRxOutputFilename", StringValue (CreateTempDirFilename ("DlRxPhyStats.txt")));
299  Config::SetDefault ("ns3::PhyRxStatsCalculator::UlRxOutputFilename", StringValue (CreateTempDirFilename ("UlRxPhyStats.txt")));
300  Config::SetDefault ("ns3::PhyTxStatsCalculator::DlTxOutputFilename", StringValue (CreateTempDirFilename ("DlTxPhyStats.txt")));
301  Config::SetDefault ("ns3::PhyTxStatsCalculator::UlTxOutputFilename", StringValue (CreateTempDirFilename ("UlTxPhyStats.txt")));
302 
307  Ptr<LteHelper> lteHelper = CreateObject<LteHelper> ();
308 
309  lteHelper->SetAttribute ("PathlossModel", StringValue ("ns3::FriisSpectrumPropagationLossModel"));
310 
311  // Create Nodes: eNodeB and UE
312  NodeContainer enbNodes;
313  NodeContainer ueNodes;
314  enbNodes.Create (1);
315  ueNodes.Create (m_nUser);
316 
317  // Install Mobility Model
319  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
320  mobility.Install (enbNodes);
321  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
322  mobility.Install (ueNodes);
323 
324  // Create Devices and install them in the Nodes (eNB and UE)
325  NetDeviceContainer enbDevs;
326  NetDeviceContainer ueDevs;
327  lteHelper->SetSchedulerType ("ns3::PfFfMacScheduler");
328  lteHelper->SetSchedulerAttribute ("UlCqiFilter", EnumValue (FfMacScheduler::SRS_UL_CQI));
329  enbDevs = lteHelper->InstallEnbDevice (enbNodes);
330  ueDevs = lteHelper->InstallUeDevice (ueNodes);
331 
332  // Attach a UE to a eNB
333  lteHelper->Attach (ueDevs, enbDevs.Get (0));
334 
335  // Activate an EPS bearer
336  enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE;
337  EpsBearer bearer (q);
338  lteHelper->ActivateDataRadioBearer (ueDevs, bearer);
339 
340 
341  Ptr<LteEnbNetDevice> lteEnbDev = enbDevs.Get (0)->GetObject<LteEnbNetDevice> ();
342  Ptr<LteEnbPhy> enbPhy = lteEnbDev->GetPhy ();
343  enbPhy->SetAttribute ("TxPower", DoubleValue (30.0));
344  enbPhy->SetAttribute ("NoiseFigure", DoubleValue (5.0));
345 
346  // Set UEs' position and power
347  for (int i = 0; i < m_nUser; i++)
348  {
350  mm->SetPosition (Vector (m_dist, 0.0, 0.0));
351  Ptr<LteUeNetDevice> lteUeDev = ueDevs.Get (i)->GetObject<LteUeNetDevice> ();
352  Ptr<LteUePhy> uePhy = lteUeDev->GetPhy ();
353  uePhy->SetAttribute ("TxPower", DoubleValue (23.0));
354  uePhy->SetAttribute ("NoiseFigure", DoubleValue (9.0));
355  }
356 
357 
358  double statsStartTime = 0.300; // need to allow for RRC connection establishment + SRS
359 
360  Simulator::Stop (Seconds (statsStartTime + m_statsDuration - 0.0001));
361 
362  Config::Connect ("/NodeList/*/DeviceList/*/ComponentCarrierMap/*/LteEnbMac/DlScheduling",
364 
365  Config::Connect ("/NodeList/*/DeviceList/*/ComponentCarrierMap/*/LteEnbMac/UlScheduling",
367 
368  lteHelper->EnableTraces();
369 
370  Simulator::Run ();
371 
375  NS_LOG_INFO ("DL - Test with " << m_nUser << " user(s) at distance " << m_dist);
376  std::vector <uint64_t> dlDataRxed;
377 
378  // tolerance increases with the number of users because the lc 0 and lc 1 will go always over primary carrier, so as the number of users increases the difference between primary and secondary
379  //carrier will increase
380 
381  bool testDownlinkShare = true;
382 
383  for (std::map <uint8_t, uint32_t>::iterator itDownlink = m_ccDownlinkTraffic.begin(); itDownlink!=m_ccDownlinkTraffic.end(); itDownlink++)
384  {
385 
386  if (itDownlink == m_ccDownlinkTraffic.begin())
387  {
388  NS_LOG_INFO ("Downlink traffic per carrier:"<<itDownlink->second);
389  }
390  else
391  {
392  if (itDownlink->second != m_ccDownlinkTraffic.begin()->second)
393  {
394  testDownlinkShare = false;
395  break;
396  }
397  }
398  }
399 
400  bool testUplinkShare = true;
401 
402  for (std::map <uint8_t, uint32_t>::iterator itUplink = m_ccUplinkTraffic.begin(); itUplink!=m_ccUplinkTraffic.end(); itUplink++)
403  {
404  if (itUplink == m_ccUplinkTraffic.begin())
405  {
406  NS_LOG_INFO ("Uplink traffic per carrier:"<<itUplink->second);
407  }
408  else
409  {
410  if (itUplink->second != m_ccUplinkTraffic.begin()->second)
411  {
412  testUplinkShare = false;
413  break;
414  }
415  }
416  }
417 
418  NS_TEST_ASSERT_MSG_EQ (m_ccUplinkTraffic.size(), m_numberOfComponentCarriers, "Number of carriers in uplink does not correspond to number of carriers being configured in test.");
419  NS_TEST_ASSERT_MSG_EQ (m_ccDownlinkTraffic.size(), m_numberOfComponentCarriers, "Number of carriers in downlink does not correspond to number of carriers being configured in test.");
420 
421  NS_TEST_ASSERT_MSG_EQ (testDownlinkShare, true, " Downlink traffic not split equally between carriers!");
422  NS_TEST_ASSERT_MSG_EQ (testUplinkShare, true , " Uplink traffic not split equally between carriers");
423 
424  if (s_writeResults)
426 
427  Simulator::Destroy ();
428 }
429 
430 void
432 {
433  //NS_LOG_FUNCTION (dlInfo.frameNo << dlInfo.subframeNo << dlInfo.rnti << (uint32_t) dlInfo.mcsTb1 << dlInfo.sizeTb1 << (uint32_t) dlInfo.mcsTb2 << dlInfo.sizeTb2<<(uint16_t)dlInfo.componentCarrierId);
434  // need to allow for RRC connection establishment + CQI feedback reception + persistent data transmission
435  if (Simulator::Now () > MilliSeconds (300))
436  {
438  {
439  m_ccDownlinkTraffic.insert (std::pair<uint8_t, uint32_t> (dlInfo.componentCarrierId, dlInfo.sizeTb1 + dlInfo.sizeTb2));
440  }
441  else
442  {
443  m_ccDownlinkTraffic[dlInfo.componentCarrierId]+= (dlInfo.sizeTb1 + dlInfo.sizeTb2);
444  }
445 
446  m_dlThroughput += dlInfo.sizeTb1 + dlInfo.sizeTb2;
447  }
448 }
449 
450 void
451 CarrierAggregationTestCase::UlScheduling (uint32_t frameNo, uint32_t subframeNo, uint16_t rnti,
452  uint8_t mcs, uint16_t sizeTb, uint8_t componentCarrierId)
453 {
454  //NS_LOG_FUNCTION (frameNo << subframeNo << rnti << (uint32_t) mcs << sizeTb);
455  // need to allow for RRC connection establishment + SRS transmission
456  if (Simulator::Now () > MilliSeconds (300))
457  {
458  if (m_ccUplinkTraffic.find(componentCarrierId) == m_ccUplinkTraffic.end())
459  {
460  m_ccUplinkTraffic.insert (std::pair<uint8_t, uint32_t> (componentCarrierId, sizeTb));
461  }
462  else
463  {
464  m_ccUplinkTraffic[componentCarrierId] += sizeTb;
465  }
466 
467  m_ulThroughput += sizeTb;
468  }
469 }
470 
471 void
473 {
474  std::ofstream dlOutFile;
475  dlOutFile.open (dlResultsFileName.c_str(), std::ofstream::out | std::ofstream::app);
476  dlOutFile.setf (std::ios_base::fixed);
477 
478  if (!dlOutFile.is_open ())
479  {
480  NS_LOG_ERROR ("Can't open file "<<dlResultsFileName);
481  return;
482  }
483  dlOutFile << m_nUser <<" "<<m_numberOfComponentCarriers <<" "<< ((m_dlThroughput*8)/m_statsDuration)/m_nUser<<std::endl;
484  dlOutFile.close ();
485 
486  std::ofstream ulOutFile;
487  ulOutFile.open (ulResultsFileName.c_str(), std::ofstream::out | std::ofstream::app);
488  ulOutFile.setf (std::ios_base::fixed);
489 
490  if (!ulOutFile.is_open ())
491  {
492  NS_LOG_ERROR ("Can't open file "<<ulResultsFileName);
493  return;
494  }
495  ulOutFile << m_nUser <<" "<<m_numberOfComponentCarriers <<" "<< ((m_ulThroughput*8)/m_statsDuration)/m_nUser<<std::endl;
496  ulOutFile.close ();
497 }
498 
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
#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:36
NetDeviceContainer InstallEnbDevice(NodeContainer c)
Create a set of eNodeB devices.
Definition: lte-helper.cc:474
uint16_t sizeTb2
size TB2
Definition: lte-common.h:247
Hold variables of type string.
Definition: string.h:41
std::map< uint8_t, uint32_t > m_ccDownlinkTraffic
CC DL traffic.
A suite of tests to run.
Definition: test.h:1342
Callback< R > MakeBoundCallback(R(*fnPtr)(TX), ARG a1)
Make Callbacks with one bound argument.
Definition: callback.h:1686
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:961
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:204
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1070
virtual void DoRun(void)
Implementation to actually run this TestCase.
static std::string BuildNameString(uint16_t nUser, uint16_t dist, uint32_t dlBandwidth, uint32_t ulBandwidth, uint32_t numberOfComponentCarriers)
Builds the test name string based on provided parameter values.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:280
void LteTestDlSchedulingCallback(CarrierAggregationTestCase *testcase, std::string path, DlSchedulingCallbackInfo dlInfo)
encapsulates test code
Definition: test.h:1155
void ActivateDataRadioBearer(NetDeviceContainer ueDevices, EpsBearer bearer)
Activate a Data Radio Bearer on a given UE devices (for LTE-only simulation).
Definition: lte-helper.cc:1314
uint16_t sizeTb1
size TB1
Definition: lte-common.h:245
uint32_t m_numberOfComponentCarriers
number of component carriers
uint8_t componentCarrierId
component carrier ID
Definition: lte-common.h:248
void SetSchedulerType(std::string type)
Set the type of scheduler to be used by eNodeB devices.
Definition: lte-helper.cc:279
mobility
Definition: third.py:108
CarrierAggregationTestCase(uint16_t nUser, uint16_t dist, uint32_t dlbandwidth, uint32_t ulBandwidth, uint32_t numberOfComponentCarriers)
Constructor of test case.
static TestCarrierAggregationSuite lenaTestRrFfMacSchedulerSuite
Hold variables of type enum.
Definition: enum.h:54
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:299
void LteTestUlSchedulingCallback(CarrierAggregationTestCase *testcase, std::string path, uint32_t frameNo, uint32_t subframeNo, uint16_t rnti, uint8_t mcs, uint16_t sizeTb, uint8_t ccId)
void EnableTraces(void)
Enables trace sinks for PHY, MAC, RLC and PDCP.
Definition: lte-helper.cc:1427
Hold an unsigned integer type.
Definition: uinteger.h:44
void DlScheduling(DlSchedulingCallbackInfo dlInfo)
DL Scheduling function that is used in this test as callback function of DL scheduling trace...
void SetSchedulerAttribute(std::string n, const AttributeValue &v)
Set an attribute for the scheduler to be created.
Definition: lte-helper.cc:293
#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:168
void UlScheduling(uint32_t frameNo, uint32_t subframeNo, uint16_t rnti, uint8_t mcs, uint16_t sizeTb, uint8_t componentCarrierId)
UL Scheduling function that is used in this test as callback function of UL sceduling trace...
holds a vector of ns3::NetDevice pointers
Ptr< LteEnbPhy > GetPhy(void) const
void Connect(std::string path, const CallbackBase &cb)
Definition: config.cc:871
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Definition: object.h:459
Every class exported by the ns3 library is enclosed in the ns3 namespace.
keep track of a set of node pointers.
Ptr< LteUePhy > GetPhy(void) const
Get the Phy.
This system test program creates different test cases with a single eNB and several UEs...
This class contains the specification of EPS Bearers.
Definition: eps-bearer.h:91
const std::string dlResultsFileName
void SetPosition(const Vector &position)
const std::string ulResultsFileName
NetDeviceContainer InstallUeDevice(NodeContainer c)
Create a set of UE devices.
Definition: lte-helper.cc:489
uint16_t m_nUser
the number of users
Helper class used to assign positions and mobility models to nodes.
std::string CreateTempDirFilename(std::string filename)
Construct the full path to a file in a temporary directory.
Definition: test.cc:430
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1062
void SetDefault(std::string name, const AttributeValue &value)
Definition: config.cc:810
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
static bool s_writeResults
write results flag, determines whether to write results to outoput files
Qci
QoS Class Indicator.
Definition: eps-bearer.h:106
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
Definition: simulator.cc:309
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
Definition: log.h:256
void WriteResultToFile()
Write result to file function.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
DlSchedulingCallbackInfo structure.
Definition: lte-common.h:239
Test Carrier Aggregation Suite.
This class can be used to hold variables of floating point type such as &#39;double&#39; or &#39;float&#39;...
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:185
The eNodeB device implementation.
std::map< uint8_t, uint32_t > m_ccUplinkTraffic
CC UL traffic.
The LteUeNetDevice class implements the UE net device.