A Discrete-Event Network Simulator
API
lte-test-frequency-reuse.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014 Piotr Gawlowicz
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation;
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  *
17  * Author: Piotr Gawlowicz <gawlowicz.p@gmail.com>
18  *
19  */
20 
22 
23 #include "lte-ffr-simple.h"
25 
26 #include "ns3/internet-module.h"
27 #include "ns3/lte-helper.h"
28 #include "ns3/mobility-helper.h"
29 #include "ns3/packet-sink-helper.h"
30 #include "ns3/point-to-point-epc-helper.h"
31 #include "ns3/point-to-point-module.h"
32 #include "ns3/udp-client-server-helper.h"
33 #include <ns3/boolean.h>
34 #include <ns3/callback.h>
35 #include <ns3/config.h>
36 #include <ns3/double.h>
37 #include <ns3/enum.h>
38 #include <ns3/ff-mac-scheduler.h>
39 #include <ns3/log.h>
40 #include <ns3/lte-common.h>
41 #include <ns3/lte-enb-net-device.h>
42 #include <ns3/lte-enb-phy.h>
43 #include <ns3/lte-enb-rrc.h>
44 #include <ns3/lte-ue-net-device.h>
45 #include <ns3/lte-ue-phy.h>
46 #include <ns3/lte-ue-rrc.h>
47 #include <ns3/pointer.h>
48 #include <ns3/simulator.h>
49 #include <ns3/string.h>
50 
51 using namespace ns3;
52 
53 NS_LOG_COMPONENT_DEFINE("LteFrequencyReuseTest");
54 
60  : TestSuite("lte-frequency-reuse", SYSTEM)
61 {
62  // LogLevel logLevel = (LogLevel)(LOG_PREFIX_FUNC | LOG_PREFIX_TIME | LOG_LEVEL_DEBUG);
63  // LogComponentEnable ("LteFrequencyReuseTest", logLevel);
64 
65  std::vector<bool> availableDlRb;
66  std::vector<bool> availableUlRb;
67  for (uint32_t i = 0; i < 12; i++)
68  {
69  availableDlRb.push_back(true);
70  availableUlRb.push_back(true);
71  }
72  for (uint32_t i = 12; i < 25; i++)
73  {
74  availableDlRb.push_back(false);
75  availableUlRb.push_back(false);
76  }
77 
78  AddTestCase(new LteHardFrTestCase("DownlinkHardFrPf1",
79  1,
80  "ns3::PfFfMacScheduler",
81  25,
82  25,
83  0,
84  12,
85  0,
86  12,
87  availableDlRb,
88  availableUlRb),
89  TestCase::QUICK);
90  AddTestCase(new LteHardFrTestCase("DownlinkHardFrPf2",
91  5,
92  "ns3::PfFfMacScheduler",
93  25,
94  25,
95  0,
96  12,
97  0,
98  12,
99  availableDlRb,
100  availableUlRb),
101  TestCase::QUICK);
102  AddTestCase(new LteHardFrTestCase("DownlinkHardFrPss1",
103  1,
104  "ns3::PssFfMacScheduler",
105  25,
106  25,
107  0,
108  12,
109  0,
110  12,
111  availableDlRb,
112  availableUlRb),
113  TestCase::QUICK);
114  AddTestCase(new LteHardFrTestCase("DownlinkHardFrPss2",
115  5,
116  "ns3::PssFfMacScheduler",
117  25,
118  25,
119  0,
120  12,
121  0,
122  12,
123  availableDlRb,
124  availableUlRb),
125  TestCase::QUICK);
126  AddTestCase(new LteHardFrTestCase("DownlinkHardFrCqa1",
127  1,
128  "ns3::CqaFfMacScheduler",
129  25,
130  25,
131  0,
132  12,
133  0,
134  12,
135  availableDlRb,
136  availableUlRb),
137  TestCase::QUICK);
138  AddTestCase(new LteHardFrTestCase("DownlinkHardFrCqa2",
139  5,
140  "ns3::CqaFfMacScheduler",
141  25,
142  25,
143  0,
144  12,
145  0,
146  12,
147  availableDlRb,
148  availableUlRb),
149  TestCase::QUICK);
150  AddTestCase(new LteHardFrTestCase("DownlinkHardFrFdTbfq1",
151  1,
152  "ns3::FdTbfqFfMacScheduler",
153  25,
154  25,
155  0,
156  12,
157  0,
158  12,
159  availableDlRb,
160  availableUlRb),
161  TestCase::QUICK);
162  AddTestCase(new LteHardFrTestCase("DownlinkHardFrFdTbfq2",
163  5,
164  "ns3::FdTbfqFfMacScheduler",
165  25,
166  25,
167  0,
168  12,
169  0,
170  12,
171  availableDlRb,
172  availableUlRb),
173  TestCase::QUICK);
174  AddTestCase(new LteHardFrTestCase("DownlinkHardFrTdTbfq1",
175  1,
176  "ns3::TdTbfqFfMacScheduler",
177  25,
178  25,
179  0,
180  12,
181  0,
182  12,
183  availableDlRb,
184  availableUlRb),
185  TestCase::QUICK);
186  AddTestCase(new LteHardFrTestCase("DownlinkHardFrTdTbfq2",
187  5,
188  "ns3::TdTbfqFfMacScheduler",
189  25,
190  25,
191  0,
192  12,
193  0,
194  12,
195  availableDlRb,
196  availableUlRb),
197  TestCase::QUICK);
198 
199  availableDlRb.clear();
200  availableUlRb.clear();
201  for (uint32_t i = 0; i < 6; i++)
202  {
203  availableDlRb.push_back(true);
204  availableUlRb.push_back(true);
205  }
206  for (uint32_t i = 6; i < 12; i++)
207  {
208  availableDlRb.push_back(false);
209  availableUlRb.push_back(false);
210  }
211  for (uint32_t i = 12; i < 18; i++)
212  {
213  availableDlRb.push_back(true);
214  availableUlRb.push_back(true);
215  }
216  for (uint32_t i = 18; i < 25; i++)
217  {
218  availableDlRb.push_back(false);
219  availableUlRb.push_back(false);
220  }
221 
222  AddTestCase(new LteStrictFrTestCase("DownlinkStrictFrPf1",
223  1,
224  "ns3::PfFfMacScheduler",
225  25,
226  25,
227  6,
228  6,
229  6,
230  6,
231  6,
232  6,
233  availableDlRb,
234  availableUlRb),
235  TestCase::QUICK);
236  AddTestCase(new LteStrictFrTestCase("DownlinkStrictFrPf2",
237  5,
238  "ns3::PfFfMacScheduler",
239  25,
240  25,
241  6,
242  6,
243  6,
244  6,
245  6,
246  6,
247  availableDlRb,
248  availableUlRb),
249  TestCase::QUICK);
250  AddTestCase(new LteStrictFrTestCase("DownlinkStrictFrPss1",
251  1,
252  "ns3::PssFfMacScheduler",
253  25,
254  25,
255  6,
256  6,
257  6,
258  6,
259  6,
260  6,
261  availableDlRb,
262  availableUlRb),
263  TestCase::QUICK);
264  AddTestCase(new LteStrictFrTestCase("DownlinkStrictFrPss2",
265  5,
266  "ns3::PssFfMacScheduler",
267  25,
268  25,
269  6,
270  6,
271  6,
272  6,
273  6,
274  6,
275  availableDlRb,
276  availableUlRb),
277  TestCase::QUICK);
278  AddTestCase(new LteStrictFrTestCase("DownlinkStrictFrCqa1",
279  1,
280  "ns3::CqaFfMacScheduler",
281  25,
282  25,
283  6,
284  6,
285  6,
286  6,
287  6,
288  6,
289  availableDlRb,
290  availableUlRb),
291  TestCase::QUICK);
292  AddTestCase(new LteStrictFrTestCase("DownlinkStrictFrCqa2",
293  5,
294  "ns3::CqaFfMacScheduler",
295  25,
296  25,
297  6,
298  6,
299  6,
300  6,
301  6,
302  6,
303  availableDlRb,
304  availableUlRb),
305  TestCase::QUICK);
306  AddTestCase(new LteStrictFrTestCase("DownlinkStrictFrCqaFdTbfq1",
307  1,
308  "ns3::FdTbfqFfMacScheduler",
309  25,
310  25,
311  6,
312  6,
313  6,
314  6,
315  6,
316  6,
317  availableDlRb,
318  availableUlRb),
319  TestCase::QUICK);
320  AddTestCase(new LteStrictFrTestCase("DownlinkStrictFrCqaFdTbfq2",
321  5,
322  "ns3::FdTbfqFfMacScheduler",
323  25,
324  25,
325  6,
326  6,
327  6,
328  6,
329  6,
330  6,
331  availableDlRb,
332  availableUlRb),
333  TestCase::QUICK);
334  AddTestCase(new LteStrictFrTestCase("DownlinkStrictFrCqaTdTbfq1",
335  1,
336  "ns3::TdTbfqFfMacScheduler",
337  25,
338  25,
339  6,
340  6,
341  6,
342  6,
343  6,
344  6,
345  availableDlRb,
346  availableUlRb),
347  TestCase::QUICK);
348  AddTestCase(new LteStrictFrTestCase("DownlinkStrictFrCqaTdTbfq2",
349  5,
350  "ns3::TdTbfqFfMacScheduler",
351  25,
352  25,
353  6,
354  6,
355  6,
356  6,
357  6,
358  6,
359  availableDlRb,
360  availableUlRb),
361  TestCase::QUICK);
362 
363  AddTestCase(new LteStrictFrAreaTestCase("LteStrictFrAreaTestCasePf1", "ns3::PfFfMacScheduler"),
364  TestCase::QUICK);
365  AddTestCase(
366  new LteStrictFrAreaTestCase("LteStrictFrAreaTestCasePss1", "ns3::PssFfMacScheduler"),
367  TestCase::QUICK);
368  AddTestCase(
369  new LteStrictFrAreaTestCase("LteStrictFrAreaTestCaseCqa1", "ns3::CqaFfMacScheduler"),
370  TestCase::QUICK);
371  AddTestCase(
372  new LteStrictFrAreaTestCase("LteStrictFrAreaTestCaseFdTbfq1", "ns3::FdTbfqFfMacScheduler"),
373  TestCase::QUICK);
374  AddTestCase(
375  new LteStrictFrAreaTestCase("LteStrictFrAreaTestCaseTdTbfq1", "ns3::TdTbfqFfMacScheduler"),
376  TestCase::QUICK);
377 
378  AddTestCase(new LteSoftFrAreaTestCase("LteSoftFrAreaTestCasePf1", "ns3::PfFfMacScheduler"),
379  TestCase::QUICK);
380  AddTestCase(new LteSoftFrAreaTestCase("LteSoftFrAreaTestCasePss1", "ns3::PssFfMacScheduler"),
381  TestCase::QUICK);
382  AddTestCase(new LteSoftFrAreaTestCase("LteSoftFrAreaTestCaseCqa1", "ns3::CqaFfMacScheduler"),
383  TestCase::QUICK);
384  AddTestCase(
385  new LteSoftFrAreaTestCase("LteSoftFrAreaTestCaseFdTbfq1", "ns3::FdTbfqFfMacScheduler"),
386  TestCase::QUICK);
387  AddTestCase(
388  new LteSoftFrAreaTestCase("LteSoftFrAreaTestCaseTdTbfq1", "ns3::TdTbfqFfMacScheduler"),
389  TestCase::QUICK);
390 
391  AddTestCase(new LteSoftFfrAreaTestCase("LteSoftFfrAreaTestCasePf1", "ns3::PfFfMacScheduler"),
392  TestCase::QUICK);
393  AddTestCase(new LteSoftFfrAreaTestCase("LteSoftFfrAreaTestCasePss1", "ns3::PssFfMacScheduler"),
394  TestCase::QUICK);
395  AddTestCase(new LteSoftFfrAreaTestCase("LteSoftFfrAreaTestCaseCqa1", "ns3::CqaFfMacScheduler"),
396  TestCase::QUICK);
397  AddTestCase(
398  new LteSoftFfrAreaTestCase("LteSoftFfrAreaTestCaseFdTbfq1", "ns3::FdTbfqFfMacScheduler"),
399  TestCase::QUICK);
400  AddTestCase(
401  new LteSoftFfrAreaTestCase("LteSoftFfrAreaTestCaseTdTbfq1", "ns3::TdTbfqFfMacScheduler"),
402  TestCase::QUICK);
403 
404  AddTestCase(
405  new LteEnhancedFfrAreaTestCase("LteEnhancedFfrAreaTestCasePf1", "ns3::PfFfMacScheduler"),
406  TestCase::QUICK);
407  AddTestCase(
408  new LteEnhancedFfrAreaTestCase("LteEnhancedFfrAreaTestCasePss1", "ns3::PssFfMacScheduler"),
409  TestCase::QUICK);
410  AddTestCase(
411  new LteEnhancedFfrAreaTestCase("LteEnhancedFfrAreaTestCaseCqa1", "ns3::CqaFfMacScheduler"),
412  TestCase::QUICK);
413  AddTestCase(new LteEnhancedFfrAreaTestCase("LteEnhancedFfrAreaTestCaseFdTbfq1",
414  "ns3::FdTbfqFfMacScheduler"),
415  TestCase::QUICK);
416  AddTestCase(new LteEnhancedFfrAreaTestCase("LteEnhancedFfrAreaTestCaseTdTbfq1",
417  "ns3::TdTbfqFfMacScheduler"),
418  TestCase::QUICK);
419 
420  AddTestCase(new LteDistributedFfrAreaTestCase("LteDistributedFfrAreaTestCasePf1",
421  "ns3::PfFfMacScheduler"),
422  TestCase::QUICK);
423  AddTestCase(new LteDistributedFfrAreaTestCase("LteDistributedFfrAreaTestCasePss1",
424  "ns3::PssFfMacScheduler"),
425  TestCase::QUICK);
426  AddTestCase(new LteDistributedFfrAreaTestCase("LteDistributedFfrAreaTestCaseCqa1",
427  "ns3::CqaFfMacScheduler"),
428  TestCase::QUICK);
429  AddTestCase(new LteDistributedFfrAreaTestCase("LteDistributedFfrAreaTestCaseFdTbfq1",
430  "ns3::FdTbfqFfMacScheduler"),
431  TestCase::QUICK);
432  AddTestCase(new LteDistributedFfrAreaTestCase("LteDistributedFfrAreaTestCaseTdTbfq1",
433  "ns3::TdTbfqFfMacScheduler"),
434  TestCase::QUICK);
435 }
436 
442 
446 void
448 {
449  testcase->DlDataRxStart(spectrumValue);
450 }
451 
452 void
454 {
455  testcase->UlDataRxStart(spectrumValue);
456 }
457 
459  uint32_t userNum,
460  uint16_t dlBandwidth,
461  uint16_t ulBandwidth,
462  std::vector<bool> availableDlRb,
463  std::vector<bool> availableUlRb)
464  : TestCase("Test: " + name),
465  m_userNum(userNum),
466  m_dlBandwidth(dlBandwidth),
467  m_ulBandwidth(ulBandwidth),
468  m_availableDlRb(availableDlRb),
469  m_usedMutedDlRbg(false),
470  m_availableUlRb(availableUlRb),
471  m_usedMutedUlRbg(false)
472 {
473 }
474 
476 {
477 }
478 
479 void
481 {
482  NS_LOG_DEBUG("DL DATA Power allocation :");
483  uint32_t i = 0;
484  for (auto it = spectrumValue->ConstValuesBegin(); it != spectrumValue->ConstValuesEnd(); it++)
485  {
486  double power = (*it) * (m_dlBandwidth * 180000);
487  NS_LOG_DEBUG("RB " << i << " POWER: "
488  << " " << power << " isAvailable: " << m_availableDlRb[i]);
489 
490  if (!m_availableDlRb[i] && power > 0)
491  {
492  m_usedMutedDlRbg = true;
493  }
494  i++;
495  }
496 }
497 
498 void
500 {
501  NS_LOG_DEBUG("UL DATA Power allocation :");
502  uint32_t i = 0;
503  for (auto it = spectrumValue->ConstValuesBegin(); it != spectrumValue->ConstValuesEnd(); it++)
504  {
505  double power = (*it) * (m_ulBandwidth * 180000);
506  NS_LOG_DEBUG("RB " << i << " POWER: "
507  << " " << power << " isAvailable: " << m_availableUlRb[i]);
508 
509  if (!m_availableUlRb[i] && power > 0)
510  {
511  m_usedMutedUlRbg = true;
512  }
513  i++;
514  }
515 }
516 
517 void
519 {
520 }
521 
523  uint32_t userNum,
524  std::string schedulerType,
525  uint16_t dlBandwidth,
526  uint16_t ulBandwidth,
527  uint8_t dlSubBandOffset,
528  uint16_t dlSubBandwidth,
529  uint8_t ulSubBandOffset,
530  uint16_t ulSubBandwidth,
531  std::vector<bool> availableDlRb,
532  std::vector<bool> availableUlRb)
533  : LteFrTestCase(name, userNum, dlBandwidth, ulBandwidth, availableDlRb, availableUlRb),
534  m_schedulerType(schedulerType),
535  m_dlSubBandOffset(dlSubBandOffset),
536  m_dlSubBandwidth(dlSubBandwidth),
537  m_ulSubBandOffset(ulSubBandOffset),
538  m_ulSubBandwidth(ulSubBandwidth)
539 {
540  NS_LOG_INFO("Creating LteDownlinkFrTestCase");
541 }
542 
544 {
545 }
546 
547 void
549 {
550  NS_LOG_DEBUG("LteFrTestCase");
551 
552  Config::Reset();
553  Config::SetDefault("ns3::LteHelper::UseIdealRrc", BooleanValue(false));
554 
559  Ptr<LteHelper> lteHelper = CreateObject<LteHelper>();
560  lteHelper->SetFfrAlgorithmType("ns3::LteFrHardAlgorithm");
561 
562  lteHelper->SetFfrAlgorithmAttribute("DlSubBandOffset", UintegerValue(m_dlSubBandOffset));
563  lteHelper->SetFfrAlgorithmAttribute("DlSubBandwidth", UintegerValue(m_dlSubBandwidth));
564 
565  lteHelper->SetFfrAlgorithmAttribute("UlSubBandOffset", UintegerValue(m_ulSubBandOffset));
566  lteHelper->SetFfrAlgorithmAttribute("UlSubBandwidth", UintegerValue(m_ulSubBandwidth));
567 
568  // Create Nodes: eNodeB and UE
569  NodeContainer enbNodes;
570  NodeContainer ueNodes;
571  enbNodes.Create(1);
572  ueNodes.Create(m_userNum);
573  NodeContainer allNodes = NodeContainer(enbNodes, ueNodes);
574 
575  // Install Mobility Model
577  mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
578  mobility.Install(allNodes);
579 
580  // Create Devices and install them in the Nodes (eNB and UE)
581  NetDeviceContainer enbDevs;
582  NetDeviceContainer ueDevs;
583  lteHelper->SetSchedulerType(m_schedulerType);
584  enbDevs = lteHelper->InstallEnbDevice(enbNodes);
585  ueDevs = lteHelper->InstallUeDevice(ueNodes);
586 
587  // Attach a UE to a eNB
588  lteHelper->Attach(ueDevs, enbDevs.Get(0));
589 
590  // Activate the default EPS bearer
591  // Since this test includes the Token Bank Fair Queue Scheduler
592  //(ns3::FdTbfqFfMacScheduler) we have to treat the default
593  // bearer as the dedicated bearer with QoS.
594  GbrQosInformation qos;
595  qos.mbrUl = 1e6;
596  qos.mbrDl = 1e6;
597  qos.gbrUl = 1e4;
598  qos.gbrDl = 1e4;
599 
600  EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE;
601  EpsBearer bearer(q, qos);
602  lteHelper->ActivateDataRadioBearer(ueDevs, bearer);
603 
604  // Test SpectrumPhy to get signals form DL channel
605  Ptr<LteSpectrumPhy> enbDlSpectrumPhy = enbDevs.Get(0)
606  ->GetObject<LteEnbNetDevice>()
607  ->GetPhy()
608  ->GetDownlinkSpectrumPhy()
610  Ptr<SpectrumChannel> dlChannel = enbDlSpectrumPhy->GetChannel();
611 
612  Ptr<LteSimpleSpectrumPhy> testDlSpectrumPhy = CreateObject<LteSimpleSpectrumPhy>();
613  Ptr<LteEnbNetDevice> eNbDev = enbDevs.Get(0)->GetObject<LteEnbNetDevice>();
614  testDlSpectrumPhy->SetRxSpectrumModel(
615  LteSpectrumValueHelper::GetSpectrumModel(eNbDev->GetDlEarfcn(), m_dlBandwidth));
616  dlChannel->AddRx(testDlSpectrumPhy);
617 
618  testDlSpectrumPhy->TraceConnectWithoutContext(
619  "RxStart",
621 
622  // Test SpectrumPhy to get signals form UL channel
623  Ptr<LteSpectrumPhy> ueUlSpectrumPhy = ueDevs.Get(0)
624  ->GetObject<LteUeNetDevice>()
625  ->GetPhy()
626  ->GetUplinkSpectrumPhy()
628  Ptr<SpectrumChannel> ulChannel = ueUlSpectrumPhy->GetChannel();
629 
630  Ptr<LteSimpleSpectrumPhy> testUlSpectrumPhy = CreateObject<LteSimpleSpectrumPhy>();
631  testUlSpectrumPhy->SetRxSpectrumModel(
632  LteSpectrumValueHelper::GetSpectrumModel(eNbDev->GetUlEarfcn(), m_ulBandwidth));
633  ulChannel->AddRx(testUlSpectrumPhy);
634 
635  testUlSpectrumPhy->TraceConnectWithoutContext(
636  "RxStart",
638 
639  Simulator::Stop(Seconds(0.500));
640  Simulator::Run();
641 
642  NS_TEST_ASSERT_MSG_EQ(m_usedMutedDlRbg, false, "Scheduler used DL RBG muted by FFR Algorithm");
643 
644  NS_TEST_ASSERT_MSG_EQ(m_usedMutedUlRbg, false, "Scheduler used UL RBG muted by FFR Algorithm");
645 
646  Simulator::Destroy();
647 }
648 
650  uint32_t userNum,
651  std::string schedulerType,
652  uint16_t dlBandwidth,
653  uint16_t ulBandwidth,
654  uint16_t dlCommonSubBandwidth,
655  uint8_t dlEdgeSubBandOffset,
656  uint16_t dlEdgeSubBandwidth,
657  uint16_t ulCommonSubBandwidth,
658  uint8_t ulEdgeSubBandOffset,
659  uint16_t ulEdgeSubBandwidth,
660  std::vector<bool> availableDlRb,
661  std::vector<bool> availableUlRb)
662  : LteFrTestCase(name, userNum, dlBandwidth, ulBandwidth, availableDlRb, availableUlRb),
663  m_schedulerType(schedulerType),
664  m_dlCommonSubBandwidth(dlCommonSubBandwidth),
665  m_dlEdgeSubBandOffset(dlEdgeSubBandOffset),
666  m_dlEdgeSubBandwidth(dlEdgeSubBandwidth),
667  m_ulCommonSubBandwidth(ulCommonSubBandwidth),
668  m_ulEdgeSubBandOffset(ulEdgeSubBandOffset),
669  m_ulEdgeSubBandwidth(ulEdgeSubBandwidth)
670 {
671  NS_LOG_INFO("Creating LteFrTestCase");
672 }
673 
675 {
676 }
677 
678 void
680 {
681  NS_LOG_DEBUG("LteFrTestCase");
682 
683  Config::Reset();
684  Config::SetDefault("ns3::LteHelper::UseIdealRrc", BooleanValue(false));
685 
690  Ptr<LteHelper> lteHelper = CreateObject<LteHelper>();
691  lteHelper->SetFfrAlgorithmType("ns3::LteFrStrictAlgorithm");
692 
693  lteHelper->SetFfrAlgorithmAttribute("DlCommonSubBandwidth",
695  lteHelper->SetFfrAlgorithmAttribute("DlEdgeSubBandOffset",
697  lteHelper->SetFfrAlgorithmAttribute("DlEdgeSubBandwidth", UintegerValue(m_dlEdgeSubBandwidth));
698 
699  lteHelper->SetFfrAlgorithmAttribute("UlCommonSubBandwidth",
701  lteHelper->SetFfrAlgorithmAttribute("UlEdgeSubBandOffset",
703  lteHelper->SetFfrAlgorithmAttribute("UlEdgeSubBandwidth", UintegerValue(m_ulEdgeSubBandwidth));
704 
705  // Create Nodes: eNodeB and UE
706  NodeContainer enbNodes;
707  NodeContainer ueNodes;
708  enbNodes.Create(1);
709  ueNodes.Create(m_userNum);
710  NodeContainer allNodes = NodeContainer(enbNodes, ueNodes);
711 
712  // Install Mobility Model
714  mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
715  mobility.Install(allNodes);
716 
717  // Create Devices and install them in the Nodes (eNB and UE)
718  NetDeviceContainer enbDevs;
719  NetDeviceContainer ueDevs;
720  lteHelper->SetSchedulerType(m_schedulerType);
721  enbDevs = lteHelper->InstallEnbDevice(enbNodes);
722  ueDevs = lteHelper->InstallUeDevice(ueNodes);
723 
724  // Attach a UE to a eNB
725  lteHelper->Attach(ueDevs, enbDevs.Get(0));
726 
727  // Activate the default EPS bearer
728  // Since this test includes the Token Bank Fair Queue Scheduler
729  //(ns3::FdTbfqFfMacScheduler) we have to treat the default
730  // bearer as the dedicated bearer with QoS.
731 
732  GbrQosInformation qos;
733  qos.mbrUl = 1e6;
734  qos.mbrDl = 1e6;
735  qos.gbrUl = 1e4;
736  qos.gbrDl = 1e4;
737 
738  EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE;
739  EpsBearer bearer(q, qos);
740  lteHelper->ActivateDataRadioBearer(ueDevs, bearer);
741 
742  // Test SpectrumPhy to get signals form DL channel
743  Ptr<LteSpectrumPhy> enbDlSpectrumPhy = enbDevs.Get(0)
744  ->GetObject<LteEnbNetDevice>()
745  ->GetPhy()
746  ->GetDownlinkSpectrumPhy()
748  Ptr<SpectrumChannel> dlChannel = enbDlSpectrumPhy->GetChannel();
749 
750  Ptr<LteSimpleSpectrumPhy> testDlSpectrumPhy = CreateObject<LteSimpleSpectrumPhy>();
751  Ptr<LteEnbNetDevice> eNbDev = enbDevs.Get(0)->GetObject<LteEnbNetDevice>();
752  testDlSpectrumPhy->SetRxSpectrumModel(
753  LteSpectrumValueHelper::GetSpectrumModel(eNbDev->GetDlEarfcn(), m_dlBandwidth));
754  dlChannel->AddRx(testDlSpectrumPhy);
755 
756  testDlSpectrumPhy->TraceConnectWithoutContext(
757  "RxStart",
759 
760  // Test SpectrumPhy to get signals form UL channel
761  Ptr<LteSpectrumPhy> ueUlSpectrumPhy = ueDevs.Get(0)
762  ->GetObject<LteUeNetDevice>()
763  ->GetPhy()
764  ->GetUplinkSpectrumPhy()
766  Ptr<SpectrumChannel> ulChannel = ueUlSpectrumPhy->GetChannel();
767 
768  Ptr<LteSimpleSpectrumPhy> testUlSpectrumPhy = CreateObject<LteSimpleSpectrumPhy>();
769  testUlSpectrumPhy->SetRxSpectrumModel(
770  LteSpectrumValueHelper::GetSpectrumModel(eNbDev->GetUlEarfcn(), m_ulBandwidth));
771  ulChannel->AddRx(testUlSpectrumPhy);
772 
773  testUlSpectrumPhy->TraceConnectWithoutContext(
774  "RxStart",
776 
777  Simulator::Stop(Seconds(0.500));
778  Simulator::Run();
779 
780  NS_TEST_ASSERT_MSG_EQ(m_usedMutedDlRbg, false, "Scheduler used DL RBG muted by FFR Algorithm");
781 
782  NS_TEST_ASSERT_MSG_EQ(m_usedMutedUlRbg, false, "Scheduler used UL RBG muted by FFR Algorithm");
783 
784  Simulator::Destroy();
785 }
786 
787 void
789 {
790  testcase->DlDataRxStart(spectrumValue);
791 }
792 
793 void
795 {
796  testcase->UlDataRxStart(spectrumValue);
797 }
798 
799 LteFrAreaTestCase::LteFrAreaTestCase(std::string name, std::string schedulerType)
800  : TestCase("Test: " + name),
801  m_schedulerType(schedulerType)
802 {
803  m_dlBandwidth = 25;
804  m_ulBandwidth = 25;
805  m_usedWrongDlRbg = false;
806  m_usedWrongUlRbg = false;
807 }
808 
810 {
811 }
812 
813 void
815 {
816  // need time to report new UE measurements, and wait because of filtering
817  if ((Simulator::Now() - m_teleportTime) < MilliSeconds(400))
818  {
819  return;
820  }
821 
822  NS_LOG_DEBUG("DL DATA Power allocation :");
823  uint32_t i = 0;
824  for (auto it = spectrumValue->ConstValuesBegin(); it != spectrumValue->ConstValuesEnd(); it++)
825  {
826  double power = (*it) * (m_dlBandwidth * 180000);
827  NS_LOG_DEBUG("RB " << i << " POWER: "
828  << " " << power);
829  NS_LOG_DEBUG("RB " << i << " POWER: "
830  << " " << power << " Available: " << m_expectedDlRb[i]
831  << " Expected Power: " << m_expectedDlPower);
832 
833  if (!m_expectedDlRb[i] && power > 0)
834  {
835  m_usedWrongDlRbg = true;
836  }
837  else if (m_expectedDlRb[i] && power > 0)
838  {
841  0.1,
842  "Wrong Data Channel DL Power level");
843  }
844  i++;
845  }
846 }
847 
848 void
850 {
851  // need time to report new UE measurements, and wait because of filtering
852  if ((Simulator::Now() - m_teleportTime) < MilliSeconds(400))
853  {
854  return;
855  }
856 
857  NS_LOG_DEBUG("UL DATA Power allocation :");
858  uint32_t i = 0;
859  uint32_t numActiveRbs = 0;
860 
861  // At the moment I could not find a better way to find total number
862  // of active RBs. This method is independent of the bandwidth
863  // configuration done in a test scenario, thus, it requires
864  // minimum change to the script.
865  for (auto it = spectrumValue->ConstValuesBegin(); it != spectrumValue->ConstValuesEnd(); it++)
866  {
867  // Count the RB as active if it is part of
868  // the expected UL RBs and has Power Spectral Density (PSD) > 0
869  if (m_expectedUlRb[numActiveRbs] && (*it) > 0)
870  {
871  numActiveRbs++;
872  }
873  }
874  NS_LOG_DEBUG("Total number of active RBs = " << numActiveRbs);
875 
876  // The uplink power control and the uplink PSD
877  // calculation only consider active resource blocks.
878  for (auto it = spectrumValue->ConstValuesBegin(); it != spectrumValue->ConstValuesEnd(); it++)
879  {
880  double power = (*it) * (numActiveRbs * 180000);
881  NS_LOG_DEBUG("RB " << i << " POWER: " << power
882  << " expectedUlPower: " << m_expectedUlPower);
883  if (!m_expectedUlRb[i] && power > 0)
884  {
885  m_usedWrongUlRbg = true;
886  }
887  else if (m_expectedUlRb[i] && power > 0)
888  {
891  0.01,
892  "Wrong Data Channel UL Power level"
893  << Simulator::Now().As(Time::S));
894  }
895  i++;
896  }
897 }
898 
899 void
901 {
902  NS_LOG_FUNCTION(this);
903  NS_LOG_DEBUG("Teleport UE to : (" << x << ", " << y << ", 0)");
905  m_ueMobility->SetPosition(Vector(x, y, 0.0));
906 }
907 
908 void
910  uint32_t y,
911  double expectedPower,
912  std::vector<bool> expectedDlRb)
913 {
914  NS_LOG_FUNCTION(this);
915  NS_LOG_DEBUG("Teleport UE to : (" << x << ", " << y << ", 0)");
917  m_ueMobility->SetPosition(Vector(x, y, 0.0));
918  m_expectedDlPower = expectedPower;
919  m_expectedDlRb = expectedDlRb;
920 }
921 
922 void
924  uint32_t x,
925  uint32_t y,
926  double expectedPower,
927  std::vector<bool> expectedDlRb)
928 {
929  NS_LOG_FUNCTION(this);
930  NS_LOG_DEBUG("Teleport UE to : (" << x << ", " << y << ", 0)");
931 
932  Ptr<MobilityModel> ueMobility = ueNode->GetObject<MobilityModel>();
933  ueMobility->SetPosition(Vector(x, y, 0.0));
935  m_expectedDlPower = expectedPower;
936  m_expectedDlRb = expectedDlRb;
937 }
938 
939 void
940 LteFrAreaTestCase::SetDlExpectedValues(double expectedDlPower, std::vector<bool> expectedDlRb)
941 {
942  NS_LOG_FUNCTION(this);
943  m_expectedDlPower = expectedDlPower;
944  m_expectedDlRb = expectedDlRb;
945 }
946 
947 void
948 LteFrAreaTestCase::SetUlExpectedValues(double expectedUlPower, std::vector<bool> expectedUlRb)
949 {
950  NS_LOG_FUNCTION(this);
951  m_expectedUlPower = expectedUlPower;
952  m_expectedUlRb = expectedUlRb;
953 }
954 
955 void
957 {
958 }
959 
960 LteStrictFrAreaTestCase::LteStrictFrAreaTestCase(std::string name, std::string schedulerType)
961  : LteFrAreaTestCase(name, schedulerType)
962 {
963  NS_LOG_INFO("Creating LteFrTestCase");
964 }
965 
967 {
968 }
969 
970 void
972 {
973  NS_LOG_DEBUG("LteStrictFrAreaTestCase");
974 
975  Config::Reset();
976  Config::SetDefault("ns3::LteHelper::UseIdealRrc", BooleanValue(true));
977  Config::SetDefault("ns3::LteSpectrumPhy::CtrlErrorModelEnabled", BooleanValue(false));
978  Config::SetDefault("ns3::LteSpectrumPhy::DataErrorModelEnabled", BooleanValue(false));
979 
980  double eNbTxPower = 30;
981  Config::SetDefault("ns3::LteEnbPhy::TxPower", DoubleValue(eNbTxPower));
982  Config::SetDefault("ns3::LteUePhy::TxPower", DoubleValue(10.0));
983  Config::SetDefault("ns3::LteUePhy::EnableUplinkPowerControl", BooleanValue(true));
984 
985  Config::SetDefault("ns3::LteUePowerControl::ClosedLoop", BooleanValue(true));
986  Config::SetDefault("ns3::LteUePowerControl::AccumulationEnabled", BooleanValue(false));
987 
988  Ptr<LteHelper> lteHelper = CreateObject<LteHelper>();
989 
990  // Create Nodes: eNodeB and UE
991  NodeContainer enbNodes;
992  NodeContainer ueNodes1;
993  NodeContainer ueNodes2;
994  enbNodes.Create(2);
995  ueNodes1.Create(1);
996  ueNodes2.Create(1);
997  NodeContainer allNodes = NodeContainer(enbNodes, ueNodes1, ueNodes2);
998 
999  /*
1000  * The topology is the following:
1001  *
1002  * eNB1 UE1 eNB2
1003  * | | |
1004  * x ------------ x ------------------------ x ------------ x----UE2
1005  * 200 m 600 m 200 m 20 m
1006  *
1007  */
1008 
1009  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator>();
1010  positionAlloc->Add(Vector(0.0, 0.0, 0.0)); // eNB1
1011  positionAlloc->Add(Vector(1000, 0.0, 0.0)); // eNB2
1012  positionAlloc->Add(Vector(0.0, 0.0, 0.0)); // UE1
1013  positionAlloc->Add(Vector(1020, 0.0, 0.0)); // UE2
1015  mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
1016  mobility.SetPositionAllocator(positionAlloc);
1017  mobility.Install(allNodes);
1018  m_ueMobility = ueNodes1.Get(0)->GetObject<MobilityModel>();
1019 
1020  // Disable layer-3 filtering
1021  Config::SetDefault("ns3::LteEnbRrc::RsrpFilterCoefficient", UintegerValue(0));
1022  Config::SetDefault("ns3::LteEnbRrc::RsrqFilterCoefficient", UintegerValue(0));
1023 
1024  // Create Devices and install them in the Nodes (eNB and UE)
1025  NetDeviceContainer enbDevs;
1026  NetDeviceContainer ueDevs1;
1027  NetDeviceContainer ueDevs2;
1028  lteHelper->SetSchedulerType(m_schedulerType);
1029 
1030  lteHelper->SetFfrAlgorithmType("ns3::LteFrStrictAlgorithm");
1031  lteHelper->SetFfrAlgorithmAttribute("RsrqThreshold", UintegerValue(25));
1032  lteHelper->SetFfrAlgorithmAttribute("CenterPowerOffset",
1033  UintegerValue(LteRrcSap::PdschConfigDedicated::dB0));
1034  lteHelper->SetFfrAlgorithmAttribute("EdgePowerOffset",
1035  UintegerValue(LteRrcSap::PdschConfigDedicated::dB3));
1036 
1037  lteHelper->SetFfrAlgorithmAttribute("DlCommonSubBandwidth", UintegerValue(6));
1038  lteHelper->SetFfrAlgorithmAttribute("DlEdgeSubBandOffset", UintegerValue(6));
1039  lteHelper->SetFfrAlgorithmAttribute("DlEdgeSubBandwidth", UintegerValue(6));
1040 
1041  lteHelper->SetFfrAlgorithmAttribute("UlCommonSubBandwidth", UintegerValue(6));
1042  lteHelper->SetFfrAlgorithmAttribute("UlEdgeSubBandOffset", UintegerValue(6));
1043  lteHelper->SetFfrAlgorithmAttribute("UlEdgeSubBandwidth", UintegerValue(6));
1044  enbDevs.Add(lteHelper->InstallEnbDevice(enbNodes.Get(0)));
1045 
1046  lteHelper->SetFfrAlgorithmType("ns3::LteFrNoOpAlgorithm");
1047  enbDevs.Add(lteHelper->InstallEnbDevice(enbNodes.Get(1)));
1048 
1049  ueDevs1 = lteHelper->InstallUeDevice(ueNodes1);
1050  ueDevs2 = lteHelper->InstallUeDevice(ueNodes2);
1051 
1052  // Attach a UE to a eNB
1053  lteHelper->Attach(ueDevs1, enbDevs.Get(0));
1054  lteHelper->Attach(ueDevs2, enbDevs.Get(1));
1055 
1056  // Activate the default EPS bearer
1057  // Since this test includes the Token Bank Fair Queue Scheduler
1058  //(ns3::FdTbfqFfMacScheduler) we have to treat the default
1059  // bearer as the dedicated bearer with QoS.
1060  GbrQosInformation qos;
1061  qos.mbrUl = 1e6;
1062  qos.mbrDl = 1e6;
1063  qos.gbrUl = 1e4;
1064  qos.gbrDl = 1e4;
1065 
1066  EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE;
1067  EpsBearer bearer(q, qos);
1068 
1069  lteHelper->ActivateDataRadioBearer(ueDevs1, bearer);
1070  lteHelper->ActivateDataRadioBearer(ueDevs2, bearer);
1071 
1072  // Test SpectrumPhy to get signals form DL channel
1073  Ptr<LteSpectrumPhy> enbDlSpectrumPhy = enbDevs.Get(0)
1074  ->GetObject<LteEnbNetDevice>()
1075  ->GetPhy()
1076  ->GetDownlinkSpectrumPhy()
1078  Ptr<SpectrumChannel> dlChannel = enbDlSpectrumPhy->GetChannel();
1079 
1080  Ptr<LteSimpleSpectrumPhy> testDlSpectrumPhy = CreateObject<LteSimpleSpectrumPhy>();
1081  Ptr<LteEnbNetDevice> eNbDev = enbDevs.Get(0)->GetObject<LteEnbNetDevice>();
1082  testDlSpectrumPhy->SetRxSpectrumModel(
1083  LteSpectrumValueHelper::GetSpectrumModel(eNbDev->GetDlEarfcn(), m_dlBandwidth));
1084  dlChannel->AddRx(testDlSpectrumPhy);
1085 
1086  testDlSpectrumPhy->SetCellId(1);
1087 
1088  testDlSpectrumPhy->TraceConnectWithoutContext(
1089  "RxStart",
1091 
1092  // Test SpectrumPhy to get signals form UL channel
1093  Ptr<LteSpectrumPhy> ueUlSpectrumPhy = ueDevs1.Get(0)
1094  ->GetObject<LteUeNetDevice>()
1095  ->GetPhy()
1096  ->GetUplinkSpectrumPhy()
1098  Ptr<SpectrumChannel> ulChannel = ueUlSpectrumPhy->GetChannel();
1099 
1100  Ptr<LteSimpleSpectrumPhy> testUlSpectrumPhy = CreateObject<LteSimpleSpectrumPhy>();
1101  testUlSpectrumPhy->SetRxSpectrumModel(
1102  LteSpectrumValueHelper::GetSpectrumModel(eNbDev->GetUlEarfcn(), m_ulBandwidth));
1103  ulChannel->AddRx(testUlSpectrumPhy);
1104 
1105  testUlSpectrumPhy->SetCellId(1);
1106 
1107  testUlSpectrumPhy->TraceConnectWithoutContext(
1108  "RxStart",
1110 
1111  std::vector<bool> expectedDlRbCenterArea;
1112  expectedDlRbCenterArea.resize(m_dlBandwidth, false);
1113  std::vector<bool> expectedUlRbCenterArea;
1114  expectedUlRbCenterArea.resize(m_ulBandwidth, false);
1115  for (uint32_t i = 0; i < 6; i++)
1116  {
1117  expectedDlRbCenterArea[i] = true;
1118  expectedUlRbCenterArea[i] = true;
1119  }
1120 
1121  std::vector<bool> expectedDlRbEdgeArea;
1122  expectedDlRbEdgeArea.resize(m_dlBandwidth, false);
1123  std::vector<bool> expectedUlRbEdgeArea;
1124  expectedUlRbEdgeArea.resize(m_ulBandwidth, false);
1125  for (uint32_t i = 12; i < 18; i++)
1126  {
1127  expectedDlRbEdgeArea[i] = true;
1128  expectedUlRbEdgeArea[i] = true;
1129  }
1130 
1131  Simulator::Schedule(MilliSeconds(1),
1133  this,
1134  200,
1135  0,
1136  1,
1137  expectedDlRbCenterArea);
1138  Simulator::Schedule(MilliSeconds(1),
1140  this,
1141  0.0150543,
1142  expectedUlRbCenterArea);
1143 
1144  Simulator::Schedule(MilliSeconds(501),
1146  this,
1147  800,
1148  0,
1149  2,
1150  expectedDlRbEdgeArea);
1151  Simulator::Schedule(MilliSeconds(501),
1153  this,
1154  0.199526,
1155  expectedUlRbEdgeArea);
1156 
1157  Simulator::Schedule(MilliSeconds(1001),
1159  this,
1160  200,
1161  0,
1162  1,
1163  expectedDlRbCenterArea);
1164  Simulator::Schedule(MilliSeconds(1001),
1166  this,
1167  0.0150543,
1168  expectedUlRbCenterArea);
1169 
1170  Simulator::Stop(Seconds(1.500));
1171  Simulator::Run();
1172 
1173  NS_TEST_ASSERT_MSG_EQ(m_usedWrongDlRbg, false, "Scheduler used DL RB muted by FFR Algorithm");
1174  NS_TEST_ASSERT_MSG_EQ(m_usedWrongUlRbg, false, "Scheduler used UL RB muted by FFR Algorithm");
1175 
1176  Simulator::Destroy();
1177 }
1178 
1179 LteSoftFrAreaTestCase::LteSoftFrAreaTestCase(std::string name, std::string schedulerType)
1180  : LteFrAreaTestCase(name, schedulerType)
1181 {
1182  NS_LOG_INFO("Creating LteSoftFrAreaTestCase");
1183 }
1184 
1186 {
1187 }
1188 
1189 void
1191 {
1192  NS_LOG_DEBUG("LteSoftFrAreaTestCase");
1193 
1194  Config::Reset();
1195  Config::SetDefault("ns3::LteHelper::UseIdealRrc", BooleanValue(true));
1196  Config::SetDefault("ns3::LteSpectrumPhy::CtrlErrorModelEnabled", BooleanValue(false));
1197  Config::SetDefault("ns3::LteSpectrumPhy::DataErrorModelEnabled", BooleanValue(false));
1198 
1199  double eNbTxPower = 30;
1200  Config::SetDefault("ns3::LteEnbPhy::TxPower", DoubleValue(eNbTxPower));
1201  Config::SetDefault("ns3::LteUePhy::TxPower", DoubleValue(10.0));
1202  Config::SetDefault("ns3::LteUePhy::EnableUplinkPowerControl", BooleanValue(true));
1203 
1204  Config::SetDefault("ns3::LteUePowerControl::ClosedLoop", BooleanValue(true));
1205  Config::SetDefault("ns3::LteUePowerControl::AccumulationEnabled", BooleanValue(false));
1206 
1207  Ptr<LteHelper> lteHelper = CreateObject<LteHelper>();
1208 
1209  // Create Nodes: eNodeB and UE
1210  NodeContainer enbNodes;
1211  NodeContainer ueNodes1;
1212  NodeContainer ueNodes2;
1213  enbNodes.Create(2);
1214  ueNodes1.Create(1);
1215  ueNodes2.Create(1);
1216  NodeContainer allNodes = NodeContainer(enbNodes, ueNodes1, ueNodes2);
1217 
1218  /*
1219  * The topology is the following:
1220  *
1221  * eNB1 UE1 eNB2
1222  * | | |
1223  * x ------------ x ------------------------ x ------------ x----UE2
1224  * 200 m 600 m 200 m 20 m
1225  *
1226  */
1227 
1228  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator>();
1229  positionAlloc->Add(Vector(0.0, 0.0, 0.0)); // eNB1
1230  positionAlloc->Add(Vector(1000, 0.0, 0.0)); // eNB2
1231  positionAlloc->Add(Vector(0.0, 0.0, 0.0)); // UE1
1232  positionAlloc->Add(Vector(1020, 0.0, 0.0)); // UE2
1234  mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
1235  mobility.SetPositionAllocator(positionAlloc);
1236  mobility.Install(allNodes);
1237  m_ueMobility = ueNodes1.Get(0)->GetObject<MobilityModel>();
1238 
1239  // Disable layer-3 filtering
1240  Config::SetDefault("ns3::LteEnbRrc::RsrpFilterCoefficient", UintegerValue(0));
1241  Config::SetDefault("ns3::LteEnbRrc::RsrqFilterCoefficient", UintegerValue(0));
1242 
1243  // Create Devices and install them in the Nodes (eNB and UE)
1244  NetDeviceContainer enbDevs;
1245  NetDeviceContainer ueDevs1;
1246  NetDeviceContainer ueDevs2;
1247  lteHelper->SetSchedulerType(m_schedulerType);
1248 
1249  lteHelper->SetFfrAlgorithmType("ns3::LteFrSoftAlgorithm");
1250  lteHelper->SetFfrAlgorithmAttribute("AllowCenterUeUseEdgeSubBand", BooleanValue(false));
1251  lteHelper->SetFfrAlgorithmAttribute("RsrqThreshold", UintegerValue(25));
1252  lteHelper->SetFfrAlgorithmAttribute("CenterPowerOffset",
1253  UintegerValue(LteRrcSap::PdschConfigDedicated::dB0));
1254  lteHelper->SetFfrAlgorithmAttribute("EdgePowerOffset",
1255  UintegerValue(LteRrcSap::PdschConfigDedicated::dB3));
1256 
1257  lteHelper->SetFfrAlgorithmAttribute("DlEdgeSubBandOffset", UintegerValue(8));
1258  lteHelper->SetFfrAlgorithmAttribute("DlEdgeSubBandwidth", UintegerValue(8));
1259  lteHelper->SetFfrAlgorithmAttribute("UlEdgeSubBandOffset", UintegerValue(8));
1260  lteHelper->SetFfrAlgorithmAttribute("UlEdgeSubBandwidth", UintegerValue(8));
1261  enbDevs.Add(lteHelper->InstallEnbDevice(enbNodes.Get(0)));
1262 
1263  lteHelper->SetFfrAlgorithmType("ns3::LteFrNoOpAlgorithm");
1264  enbDevs.Add(lteHelper->InstallEnbDevice(enbNodes.Get(1)));
1265 
1266  ueDevs1 = lteHelper->InstallUeDevice(ueNodes1);
1267  ueDevs2 = lteHelper->InstallUeDevice(ueNodes2);
1268 
1269  // Attach a UE to a eNB
1270  lteHelper->Attach(ueDevs1, enbDevs.Get(0));
1271  lteHelper->Attach(ueDevs2, enbDevs.Get(1));
1272 
1273  // Activate the default EPS bearer
1274  // Since this test includes the Token Bank Fair Queue Scheduler
1275  //(ns3::FdTbfqFfMacScheduler) we have to treat the default
1276  // bearer as the dedicated bearer with QoS.
1277  GbrQosInformation qos;
1278  qos.mbrUl = 1e6;
1279  qos.mbrDl = 1e6;
1280  qos.gbrUl = 1e4;
1281  qos.gbrDl = 1e4;
1282 
1283  EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE;
1284  EpsBearer bearer(q, qos);
1285  lteHelper->ActivateDataRadioBearer(ueDevs1, bearer);
1286  lteHelper->ActivateDataRadioBearer(ueDevs2, bearer);
1287 
1288  // Test SpectrumPhy to get signals form DL channel
1289  Ptr<LteSpectrumPhy> enbDlSpectrumPhy = enbDevs.Get(0)
1290  ->GetObject<LteEnbNetDevice>()
1291  ->GetPhy()
1292  ->GetDownlinkSpectrumPhy()
1294  Ptr<SpectrumChannel> dlChannel = enbDlSpectrumPhy->GetChannel();
1295 
1296  Ptr<LteSimpleSpectrumPhy> testDlSpectrumPhy = CreateObject<LteSimpleSpectrumPhy>();
1297  Ptr<LteEnbNetDevice> eNbDev = enbDevs.Get(0)->GetObject<LteEnbNetDevice>();
1298  testDlSpectrumPhy->SetRxSpectrumModel(
1299  LteSpectrumValueHelper::GetSpectrumModel(eNbDev->GetDlEarfcn(), m_dlBandwidth));
1300  dlChannel->AddRx(testDlSpectrumPhy);
1301 
1302  testDlSpectrumPhy->SetCellId(1);
1303 
1304  testDlSpectrumPhy->TraceConnectWithoutContext(
1305  "RxStart",
1307 
1308  // Test SpectrumPhy to get signals form UL channel
1309  Ptr<LteSpectrumPhy> ueUlSpectrumPhy = ueDevs1.Get(0)
1310  ->GetObject<LteUeNetDevice>()
1311  ->GetPhy()
1312  ->GetUplinkSpectrumPhy()
1314  Ptr<SpectrumChannel> ulChannel = ueUlSpectrumPhy->GetChannel();
1315 
1316  Ptr<LteSimpleSpectrumPhy> testUlSpectrumPhy = CreateObject<LteSimpleSpectrumPhy>();
1317  testUlSpectrumPhy->SetRxSpectrumModel(
1318  LteSpectrumValueHelper::GetSpectrumModel(eNbDev->GetUlEarfcn(), m_ulBandwidth));
1319  ulChannel->AddRx(testUlSpectrumPhy);
1320 
1321  testUlSpectrumPhy->SetCellId(1);
1322 
1323  testUlSpectrumPhy->TraceConnectWithoutContext(
1324  "RxStart",
1326 
1327  std::vector<bool> expectedDlRbCenterArea;
1328  expectedDlRbCenterArea.resize(m_dlBandwidth, false);
1329  std::vector<bool> expectedUlRbCenterArea;
1330  expectedUlRbCenterArea.resize(m_ulBandwidth, false);
1331  for (uint32_t i = 0; i < 8; i++)
1332  {
1333  expectedDlRbCenterArea[i] = true;
1334  expectedUlRbCenterArea[i] = true;
1335  }
1336  for (uint32_t i = 16; i < 25; i++)
1337  {
1338  expectedDlRbCenterArea[i] = true;
1339  }
1340 
1341  std::vector<bool> expectedDlRbEdgeArea;
1342  expectedDlRbEdgeArea.resize(m_dlBandwidth, false);
1343  std::vector<bool> expectedUlRbEdgeArea;
1344  expectedUlRbEdgeArea.resize(m_ulBandwidth, false);
1345  for (uint32_t i = 8; i < 16; i++)
1346  {
1347  expectedDlRbEdgeArea[i] = true;
1348  expectedUlRbEdgeArea[i] = true;
1349  }
1350 
1351  Simulator::Schedule(MilliSeconds(1),
1353  this,
1354  200,
1355  0,
1356  1,
1357  expectedDlRbCenterArea);
1358  Simulator::Schedule(MilliSeconds(1),
1360  this,
1361  0.0150543,
1362  expectedUlRbCenterArea);
1363 
1364  Simulator::Schedule(MilliSeconds(501),
1366  this,
1367  800,
1368  0,
1369  2,
1370  expectedDlRbEdgeArea);
1371  Simulator::Schedule(MilliSeconds(501),
1373  this,
1374  0.199526,
1375  expectedUlRbEdgeArea);
1376 
1377  Simulator::Schedule(MilliSeconds(1001),
1379  this,
1380  200,
1381  0,
1382  1,
1383  expectedDlRbCenterArea);
1384  Simulator::Schedule(MilliSeconds(1001),
1386  this,
1387  0.0150543,
1388  expectedUlRbCenterArea);
1389 
1390  Simulator::Stop(Seconds(1.500));
1391  Simulator::Run();
1392 
1393 #if 0
1395  "Scheduler used DL RBG muted by FFR Algorithm");
1396 
1397 #endif
1398  NS_TEST_ASSERT_MSG_EQ(m_usedWrongUlRbg, false, "Scheduler used UL RB muted by FFR Algorithm");
1399 
1400  Simulator::Destroy();
1401 }
1402 
1403 LteSoftFfrAreaTestCase::LteSoftFfrAreaTestCase(std::string name, std::string schedulerType)
1404  : LteFrAreaTestCase(name, schedulerType)
1405 {
1406  NS_LOG_INFO("Creating LteSoftFfrAreaTestCase");
1407 }
1408 
1410 {
1411 }
1412 
1413 void
1415 {
1416  NS_LOG_DEBUG("LteSoftFfrAreaTestCase");
1417 
1418  Config::Reset();
1419  Config::SetDefault("ns3::LteHelper::UseIdealRrc", BooleanValue(true));
1420  Config::SetDefault("ns3::LteSpectrumPhy::CtrlErrorModelEnabled", BooleanValue(false));
1421  Config::SetDefault("ns3::LteSpectrumPhy::DataErrorModelEnabled", BooleanValue(false));
1422 
1423  double eNbTxPower = 30;
1424  Config::SetDefault("ns3::LteEnbPhy::TxPower", DoubleValue(eNbTxPower));
1425  Config::SetDefault("ns3::LteUePhy::TxPower", DoubleValue(10.0));
1426  Config::SetDefault("ns3::LteUePhy::EnableUplinkPowerControl", BooleanValue(true));
1427 
1428  Config::SetDefault("ns3::LteUePowerControl::ClosedLoop", BooleanValue(true));
1429  Config::SetDefault("ns3::LteUePowerControl::AccumulationEnabled", BooleanValue(false));
1430 
1431  Ptr<LteHelper> lteHelper = CreateObject<LteHelper>();
1432 
1433  // Create Nodes: eNodeB and UE
1434  NodeContainer enbNodes;
1435  NodeContainer ueNodes1;
1436  NodeContainer ueNodes2;
1437  enbNodes.Create(2);
1438  ueNodes1.Create(1);
1439  ueNodes2.Create(1);
1440  NodeContainer allNodes = NodeContainer(enbNodes, ueNodes1, ueNodes2);
1441 
1442  /*
1443  * The topology is the following:
1444  *
1445  * eNB1 UE1 eNB2
1446  * | | |
1447  * x ------------ x ------------------------ x ------------ x----UE2
1448  * 200 m 600 m 200 m 20 m
1449  *
1450  */
1451 
1452  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator>();
1453  positionAlloc->Add(Vector(0.0, 0.0, 0.0)); // eNB1
1454  positionAlloc->Add(Vector(1000, 0.0, 0.0)); // eNB2
1455  positionAlloc->Add(Vector(0.0, 0.0, 0.0)); // UE1
1456  positionAlloc->Add(Vector(1020, 0.0, 0.0)); // UE2
1458  mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
1459  mobility.SetPositionAllocator(positionAlloc);
1460  mobility.Install(allNodes);
1461  m_ueMobility = ueNodes1.Get(0)->GetObject<MobilityModel>();
1462 
1463  // Disable layer-3 filtering
1464  Config::SetDefault("ns3::LteEnbRrc::RsrpFilterCoefficient", UintegerValue(0));
1465  Config::SetDefault("ns3::LteEnbRrc::RsrqFilterCoefficient", UintegerValue(0));
1466 
1467  // Create Devices and install them in the Nodes (eNB and UE)
1468  NetDeviceContainer enbDevs;
1469  NetDeviceContainer ueDevs1;
1470  NetDeviceContainer ueDevs2;
1471  lteHelper->SetSchedulerType(m_schedulerType);
1472 
1473  lteHelper->SetFfrAlgorithmType("ns3::LteFfrSoftAlgorithm");
1474  lteHelper->SetFfrAlgorithmAttribute("CenterRsrqThreshold", UintegerValue(28));
1475  lteHelper->SetFfrAlgorithmAttribute("EdgeRsrqThreshold", UintegerValue(18));
1476  lteHelper->SetFfrAlgorithmAttribute("CenterAreaPowerOffset",
1477  UintegerValue(LteRrcSap::PdschConfigDedicated::dB_3));
1478  lteHelper->SetFfrAlgorithmAttribute("MediumAreaPowerOffset",
1479  UintegerValue(LteRrcSap::PdschConfigDedicated::dB0));
1480  lteHelper->SetFfrAlgorithmAttribute("EdgeAreaPowerOffset",
1481  UintegerValue(LteRrcSap::PdschConfigDedicated::dB3));
1482 
1483  lteHelper->SetFfrAlgorithmAttribute("UlCommonSubBandwidth", UintegerValue(6));
1484  lteHelper->SetFfrAlgorithmAttribute("DlCommonSubBandwidth", UintegerValue(6));
1485 
1486  lteHelper->SetFfrAlgorithmAttribute("DlEdgeSubBandOffset", UintegerValue(6));
1487  lteHelper->SetFfrAlgorithmAttribute("DlEdgeSubBandwidth", UintegerValue(6));
1488  lteHelper->SetFfrAlgorithmAttribute("UlEdgeSubBandOffset", UintegerValue(6));
1489  lteHelper->SetFfrAlgorithmAttribute("UlEdgeSubBandwidth", UintegerValue(6));
1490  enbDevs.Add(lteHelper->InstallEnbDevice(enbNodes.Get(0)));
1491 
1492  lteHelper->SetFfrAlgorithmType("ns3::LteFrNoOpAlgorithm");
1493  enbDevs.Add(lteHelper->InstallEnbDevice(enbNodes.Get(1)));
1494 
1495  ueDevs1 = lteHelper->InstallUeDevice(ueNodes1);
1496  ueDevs2 = lteHelper->InstallUeDevice(ueNodes2);
1497 
1498  // Attach a UE to a eNB
1499  lteHelper->Attach(ueDevs1, enbDevs.Get(0));
1500  lteHelper->Attach(ueDevs2, enbDevs.Get(1));
1501 
1502  // Activate the default EPS bearer
1503  // Since this test includes the Token Bank Fair Queue Scheduler
1504  //(ns3::FdTbfqFfMacScheduler) we have to treat the default
1505  // bearer as the dedicated bearer with QoS.
1506  GbrQosInformation qos;
1507  qos.mbrUl = 1e6;
1508  qos.mbrDl = 1e6;
1509  qos.gbrUl = 1e4;
1510  qos.gbrDl = 1e4;
1511 
1512  EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE;
1513  EpsBearer bearer(q, qos);
1514  lteHelper->ActivateDataRadioBearer(ueDevs1, bearer);
1515  lteHelper->ActivateDataRadioBearer(ueDevs2, bearer);
1516 
1517  // Test SpectrumPhy to get signals form DL channel
1518  Ptr<LteSpectrumPhy> enbDlSpectrumPhy = enbDevs.Get(0)
1519  ->GetObject<LteEnbNetDevice>()
1520  ->GetPhy()
1521  ->GetDownlinkSpectrumPhy()
1523  Ptr<SpectrumChannel> dlChannel = enbDlSpectrumPhy->GetChannel();
1524 
1525  Ptr<LteSimpleSpectrumPhy> testDlSpectrumPhy = CreateObject<LteSimpleSpectrumPhy>();
1526  Ptr<LteEnbNetDevice> eNbDev = enbDevs.Get(0)->GetObject<LteEnbNetDevice>();
1527  testDlSpectrumPhy->SetRxSpectrumModel(
1528  LteSpectrumValueHelper::GetSpectrumModel(eNbDev->GetDlEarfcn(), m_dlBandwidth));
1529  dlChannel->AddRx(testDlSpectrumPhy);
1530 
1531  testDlSpectrumPhy->SetCellId(1);
1532 
1533  testDlSpectrumPhy->TraceConnectWithoutContext(
1534  "RxStart",
1536 
1537  // Test SpectrumPhy to get signals form UL channel
1538  Ptr<LteSpectrumPhy> ueUlSpectrumPhy = ueDevs1.Get(0)
1539  ->GetObject<LteUeNetDevice>()
1540  ->GetPhy()
1541  ->GetUplinkSpectrumPhy()
1543  Ptr<SpectrumChannel> ulChannel = ueUlSpectrumPhy->GetChannel();
1544 
1545  Ptr<LteSimpleSpectrumPhy> testUlSpectrumPhy = CreateObject<LteSimpleSpectrumPhy>();
1546  testUlSpectrumPhy->SetRxSpectrumModel(
1547  LteSpectrumValueHelper::GetSpectrumModel(eNbDev->GetUlEarfcn(), m_ulBandwidth));
1548  ulChannel->AddRx(testUlSpectrumPhy);
1549 
1550  testUlSpectrumPhy->SetCellId(1);
1551 
1552  testUlSpectrumPhy->TraceConnectWithoutContext(
1553  "RxStart",
1555 
1556  double expectedDlPowerCenterArea = 0.5;
1557  std::vector<bool> expectedDlRbCenterArea;
1558  expectedDlRbCenterArea.resize(m_dlBandwidth, false);
1559  std::vector<bool> expectedUlRbCenterArea;
1560  expectedUlRbCenterArea.resize(m_ulBandwidth, false);
1561  for (uint32_t i = 6; i < 12; i++)
1562  {
1563  expectedDlRbCenterArea[i] = true;
1564  expectedUlRbCenterArea[i] = true;
1565  }
1566  for (uint32_t i = 18; i < 25; i++)
1567  {
1568  expectedDlRbCenterArea[i] = true;
1569  expectedUlRbCenterArea[i] = true;
1570  }
1571 
1572  double expectedDlPowerMiddleArea = 1.0;
1573  std::vector<bool> expectedDlRbMiddleArea;
1574  expectedDlRbMiddleArea.resize(m_dlBandwidth, false);
1575  std::vector<bool> expectedUlRbMiddleArea;
1576  expectedUlRbMiddleArea.resize(m_ulBandwidth, false);
1577  for (uint32_t i = 0; i < 6; i++)
1578  {
1579  expectedDlRbMiddleArea[i] = true;
1580  expectedUlRbMiddleArea[i] = true;
1581  }
1582 
1583  double expectedDlPowerEdgeArea = 2.0;
1584  std::vector<bool> expectedDlRbEdgeArea;
1585  expectedDlRbEdgeArea.resize(m_dlBandwidth, false);
1586  std::vector<bool> expectedUlRbEdgeArea;
1587  expectedUlRbEdgeArea.resize(m_ulBandwidth, false);
1588  for (uint32_t i = 12; i < 18; i++)
1589  {
1590  expectedDlRbEdgeArea[i] = true;
1591  expectedUlRbEdgeArea[i] = true;
1592  }
1593 
1594  Simulator::Schedule(MilliSeconds(1),
1596  this,
1597  200,
1598  0,
1599  expectedDlPowerCenterArea,
1600  expectedDlRbCenterArea);
1601  Simulator::Schedule(MilliSeconds(1),
1603  this,
1604  0.0150543,
1605  expectedUlRbCenterArea);
1606 
1607  Simulator::Schedule(MilliSeconds(501),
1609  this,
1610  600,
1611  0,
1612  expectedDlPowerMiddleArea,
1613  expectedDlRbMiddleArea);
1614  Simulator::Schedule(MilliSeconds(501),
1616  this,
1617  0.135489,
1618  expectedUlRbMiddleArea);
1619 
1620  Simulator::Schedule(MilliSeconds(1001),
1622  this,
1623  800,
1624  0,
1625  expectedDlPowerEdgeArea,
1626  expectedDlRbEdgeArea);
1627  Simulator::Schedule(MilliSeconds(1001),
1629  this,
1630  0.199526,
1631  expectedUlRbEdgeArea);
1632 
1633  Simulator::Schedule(MilliSeconds(1501),
1635  this,
1636  600,
1637  0,
1638  expectedDlPowerMiddleArea,
1639  expectedDlRbMiddleArea);
1640  Simulator::Schedule(MilliSeconds(1501),
1642  this,
1643  0.135489,
1644  expectedUlRbMiddleArea);
1645 
1646  Simulator::Schedule(MilliSeconds(2001),
1648  this,
1649  200,
1650  0,
1651  expectedDlPowerCenterArea,
1652  expectedDlRbCenterArea);
1653  Simulator::Schedule(MilliSeconds(2001),
1655  this,
1656  0.0150543,
1657  expectedUlRbCenterArea);
1658 
1659  Simulator::Stop(Seconds(2.500));
1660  Simulator::Run();
1661 
1662  NS_TEST_ASSERT_MSG_EQ(m_usedWrongDlRbg, false, "Scheduler used DL RBG muted by FFR Algorithm");
1663 
1664  NS_TEST_ASSERT_MSG_EQ(m_usedWrongUlRbg, false, "Scheduler used UL RB muted by FFR Algorithm");
1665 
1666  Simulator::Destroy();
1667 }
1668 
1669 LteEnhancedFfrAreaTestCase::LteEnhancedFfrAreaTestCase(std::string name, std::string schedulerType)
1670  : LteFrAreaTestCase(name, schedulerType)
1671 {
1672  NS_LOG_INFO("Creating LteEnhancedFfrAreaTestCase");
1673 }
1674 
1676 {
1677 }
1678 
1679 void
1681 {
1682  NS_LOG_DEBUG("LteEnhancedFfrAreaTestCase");
1683 
1684  Config::Reset();
1685  Config::SetDefault("ns3::LteHelper::UseIdealRrc", BooleanValue(true));
1686  Config::SetDefault("ns3::LteHelper::UsePdschForCqiGeneration", BooleanValue(true));
1687  Config::SetDefault("ns3::LteSpectrumPhy::CtrlErrorModelEnabled", BooleanValue(false));
1688  Config::SetDefault("ns3::LteSpectrumPhy::DataErrorModelEnabled", BooleanValue(false));
1689 
1690  double eNbTxPower = 30;
1691  Config::SetDefault("ns3::LteEnbPhy::TxPower", DoubleValue(eNbTxPower));
1692  Config::SetDefault("ns3::LteUePhy::TxPower", DoubleValue(10.0));
1693  Config::SetDefault("ns3::LteUePhy::EnableUplinkPowerControl", BooleanValue(true));
1694 
1695  Config::SetDefault("ns3::LteUePowerControl::ClosedLoop", BooleanValue(true));
1696  Config::SetDefault("ns3::LteUePowerControl::AccumulationEnabled", BooleanValue(false));
1697 
1698  Ptr<LteHelper> lteHelper = CreateObject<LteHelper>();
1699 
1700  // Create Nodes: eNodeB and UE
1701  NodeContainer enbNodes;
1702  NodeContainer ueNodes1;
1703  NodeContainer ueNodes2;
1704  enbNodes.Create(2);
1705  ueNodes1.Create(1);
1706  ueNodes2.Create(1);
1707  NodeContainer allNodes = NodeContainer(enbNodes, ueNodes1, ueNodes2);
1708 
1709  /*
1710  * The topology is the following:
1711  *
1712  * eNB1 UE1 eNB2
1713  * | | |
1714  * x ------------ x ------------------------ x ------------ x----UE2
1715  * 200 m 600 m 200 m 20 m
1716  *
1717  */
1718 
1719  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator>();
1720  positionAlloc->Add(Vector(0.0, 0.0, 0.0)); // eNB1
1721  positionAlloc->Add(Vector(1000, 0.0, 0.0)); // eNB2
1722  positionAlloc->Add(Vector(0.0, 0.0, 0.0)); // UE1
1723  positionAlloc->Add(Vector(1020, 0.0, 0.0)); // UE2
1725  mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
1726  mobility.SetPositionAllocator(positionAlloc);
1727  mobility.Install(allNodes);
1728  m_ueMobility = ueNodes1.Get(0)->GetObject<MobilityModel>();
1729 
1730  // Disable layer-3 filtering
1731  Config::SetDefault("ns3::LteEnbRrc::RsrpFilterCoefficient", UintegerValue(0));
1732  Config::SetDefault("ns3::LteEnbRrc::RsrqFilterCoefficient", UintegerValue(0));
1733 
1734  // Create Devices and install them in the Nodes (eNB and UE)
1735  NetDeviceContainer enbDevs;
1736  NetDeviceContainer ueDevs1;
1737  NetDeviceContainer ueDevs2;
1738  lteHelper->SetSchedulerType(m_schedulerType);
1739  lteHelper->SetSchedulerAttribute("HarqEnabled", BooleanValue(true));
1740 
1741  lteHelper->SetEnbDeviceAttribute("DlBandwidth", UintegerValue(m_dlBandwidth));
1742  lteHelper->SetEnbDeviceAttribute("UlBandwidth", UintegerValue(m_ulBandwidth));
1743 
1744  lteHelper->SetFfrAlgorithmType("ns3::LteFfrEnhancedAlgorithm");
1745  lteHelper->SetFfrAlgorithmAttribute("RsrqThreshold", UintegerValue(25));
1746  lteHelper->SetFfrAlgorithmAttribute("DlCqiThreshold", UintegerValue(10));
1747  lteHelper->SetFfrAlgorithmAttribute("UlCqiThreshold", UintegerValue(15));
1748  lteHelper->SetFfrAlgorithmAttribute("CenterAreaPowerOffset",
1749  UintegerValue(LteRrcSap::PdschConfigDedicated::dB_6));
1750  lteHelper->SetFfrAlgorithmAttribute("EdgeAreaPowerOffset",
1751  UintegerValue(LteRrcSap::PdschConfigDedicated::dB0));
1752 
1753  lteHelper->SetFfrAlgorithmAttribute("UlSubBandOffset", UintegerValue(0));
1754  lteHelper->SetFfrAlgorithmAttribute("UlReuse3SubBandwidth", UintegerValue(4));
1755  lteHelper->SetFfrAlgorithmAttribute("UlReuse1SubBandwidth", UintegerValue(4));
1756 
1757  lteHelper->SetFfrAlgorithmAttribute("DlSubBandOffset", UintegerValue(0));
1758  lteHelper->SetFfrAlgorithmAttribute("DlReuse3SubBandwidth", UintegerValue(4));
1759  lteHelper->SetFfrAlgorithmAttribute("DlReuse1SubBandwidth", UintegerValue(4));
1760 
1761  enbDevs.Add(lteHelper->InstallEnbDevice(enbNodes.Get(0)));
1762 
1763  lteHelper->SetFfrAlgorithmType("ns3::LteFrNoOpAlgorithm");
1764  enbDevs.Add(lteHelper->InstallEnbDevice(enbNodes.Get(1)));
1765 
1766  ueDevs1 = lteHelper->InstallUeDevice(ueNodes1);
1767  ueDevs2 = lteHelper->InstallUeDevice(ueNodes2);
1768 
1769  // Attach a UE to a eNB
1770  lteHelper->Attach(ueDevs1, enbDevs.Get(0));
1771  lteHelper->Attach(ueDevs2, enbDevs.Get(1));
1772 
1773  // Activate the default EPS bearer
1774  // Since this test includes the Token Bank Fair Queue Scheduler
1775  //(ns3::FdTbfqFfMacScheduler) we have to treat the default
1776  // bearer as the dedicated bearer with QoS.
1777  GbrQosInformation qos;
1778  qos.mbrUl = 1e6;
1779  qos.mbrDl = 1e6;
1780  qos.gbrUl = 1e4;
1781  qos.gbrDl = 1e4;
1782 
1783  EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE;
1784  EpsBearer bearer(q, qos);
1785  lteHelper->ActivateDataRadioBearer(ueDevs1, bearer);
1786  lteHelper->ActivateDataRadioBearer(ueDevs2, bearer);
1787 
1788  // Test SpectrumPhy to get signals form DL channel
1789  Ptr<LteSpectrumPhy> enbDlSpectrumPhy = enbDevs.Get(0)
1790  ->GetObject<LteEnbNetDevice>()
1791  ->GetPhy()
1792  ->GetDownlinkSpectrumPhy()
1794  Ptr<SpectrumChannel> dlChannel = enbDlSpectrumPhy->GetChannel();
1795 
1796  Ptr<LteSimpleSpectrumPhy> testDlSpectrumPhy = CreateObject<LteSimpleSpectrumPhy>();
1797  Ptr<LteEnbNetDevice> eNbDev = enbDevs.Get(0)->GetObject<LteEnbNetDevice>();
1798  testDlSpectrumPhy->SetRxSpectrumModel(
1799  LteSpectrumValueHelper::GetSpectrumModel(eNbDev->GetDlEarfcn(), m_dlBandwidth));
1800  dlChannel->AddRx(testDlSpectrumPhy);
1801 
1802  testDlSpectrumPhy->SetCellId(1);
1803 
1804  testDlSpectrumPhy->TraceConnectWithoutContext(
1805  "RxStart",
1807 
1808  // Test SpectrumPhy to get signals form UL channel
1809  Ptr<LteSpectrumPhy> ueUlSpectrumPhy = ueDevs1.Get(0)
1810  ->GetObject<LteUeNetDevice>()
1811  ->GetPhy()
1812  ->GetUplinkSpectrumPhy()
1814  Ptr<SpectrumChannel> ulChannel = ueUlSpectrumPhy->GetChannel();
1815 
1816  Ptr<LteSimpleSpectrumPhy> testUlSpectrumPhy = CreateObject<LteSimpleSpectrumPhy>();
1817  testUlSpectrumPhy->SetRxSpectrumModel(
1818  LteSpectrumValueHelper::GetSpectrumModel(eNbDev->GetUlEarfcn(), m_ulBandwidth));
1819  ulChannel->AddRx(testUlSpectrumPhy);
1820 
1821  testUlSpectrumPhy->SetCellId(1);
1822 
1823  testUlSpectrumPhy->TraceConnectWithoutContext(
1824  "RxStart",
1826 
1827  double expectedDlPowerCenterArea = 0.251189;
1828  std::vector<bool> expectedDlRbCenterArea;
1829  expectedDlRbCenterArea.resize(m_dlBandwidth, false);
1830  std::vector<bool> expectedUlRbCenterArea;
1831  expectedUlRbCenterArea.resize(m_ulBandwidth, false);
1832  for (uint32_t i = 0; i < 8; i++)
1833  {
1834  expectedDlRbCenterArea[i] = true;
1835  expectedUlRbCenterArea[i] = true;
1836  }
1837  for (uint32_t i = 12; i < 16; i++)
1838  {
1839  expectedDlRbCenterArea[i] = true;
1840  expectedUlRbCenterArea[i] = true;
1841  }
1842  for (uint32_t i = 20; i < 24; i++)
1843  {
1844  expectedDlRbCenterArea[i] = true;
1845  expectedUlRbCenterArea[i] = true;
1846  }
1847 
1848  double expectedDlPowerMiddleArea = 0.251189;
1849  std::vector<bool> expectedDlRbMiddleArea;
1850  expectedDlRbMiddleArea.resize(m_dlBandwidth, false);
1851  std::vector<bool> expectedUlRbMiddleArea;
1852  expectedUlRbMiddleArea.resize(m_ulBandwidth, false);
1853  for (uint32_t i = 4; i < 8; i++)
1854  {
1855  expectedDlRbMiddleArea[i] = true;
1856  expectedUlRbMiddleArea[i] = true;
1857  }
1858 
1859  double expectedDlPowerEdgeArea = 1.0;
1860  std::vector<bool> expectedDlRbEdgeArea;
1861  expectedDlRbEdgeArea.resize(m_dlBandwidth, false);
1862  std::vector<bool> expectedUlRbEdgeArea;
1863  expectedUlRbEdgeArea.resize(m_ulBandwidth, false);
1864  for (uint32_t i = 0; i < 4; i++)
1865  {
1866  expectedDlRbEdgeArea[i] = true;
1867  expectedUlRbEdgeArea[i] = true;
1868  }
1869 
1870  Simulator::Schedule(MilliSeconds(1),
1872  this,
1873  100,
1874  0,
1875  expectedDlPowerCenterArea,
1876  expectedDlRbCenterArea);
1877  Simulator::Schedule(MilliSeconds(1),
1879  this,
1880  0.00250905,
1881  expectedUlRbCenterArea);
1882 
1883  Simulator::Schedule(MilliSeconds(501),
1885  this,
1886  300,
1887  0,
1888  expectedDlPowerMiddleArea,
1889  expectedDlRbMiddleArea);
1890  Simulator::Schedule(MilliSeconds(501),
1892  this,
1893  0.0225815,
1894  expectedUlRbMiddleArea);
1895 
1896  Simulator::Schedule(MilliSeconds(1001),
1898  this,
1899  600,
1900  0,
1901  expectedDlPowerEdgeArea,
1902  expectedDlRbEdgeArea);
1903  Simulator::Schedule(MilliSeconds(1001),
1905  this,
1906  0.0903259,
1907  expectedUlRbEdgeArea);
1908 
1909  Simulator::Schedule(MilliSeconds(1501),
1911  this,
1912  100,
1913  0,
1914  expectedDlPowerCenterArea,
1915  expectedDlRbCenterArea);
1916  Simulator::Schedule(MilliSeconds(1501),
1918  this,
1919  0.00250905,
1920  expectedUlRbCenterArea);
1921 
1922  Simulator::Schedule(MilliSeconds(2001),
1924  this,
1925  300,
1926  0,
1927  expectedDlPowerMiddleArea,
1928  expectedDlRbMiddleArea);
1929  Simulator::Schedule(MilliSeconds(2001),
1931  this,
1932  0.0225815,
1933  expectedUlRbCenterArea);
1934 
1935  Simulator::Stop(Seconds(2.500));
1936  Simulator::Run();
1937 
1938  NS_TEST_ASSERT_MSG_EQ(m_usedWrongDlRbg, false, "Scheduler used DL RBG muted by FFR Algorithm");
1939 
1940  NS_TEST_ASSERT_MSG_EQ(m_usedWrongUlRbg, false, "Scheduler used UL RB muted by FFR Algorithm");
1941 
1942  Simulator::Destroy();
1943 }
1944 
1946  std::string schedulerType)
1947  : LteFrAreaTestCase(name, schedulerType)
1948 {
1949  NS_LOG_INFO("Creating LteDistributedFfrAreaTestCase");
1950 }
1951 
1953 {
1954 }
1955 
1956 void
1958 {
1959  NS_LOG_DEBUG("LteDistributedFfrAreaTestCase");
1960 
1961  Config::Reset();
1962  Config::SetDefault("ns3::LteHelper::UseIdealRrc", BooleanValue(true));
1963  Config::SetDefault("ns3::LteHelper::UsePdschForCqiGeneration", BooleanValue(true));
1964  Config::SetDefault("ns3::LteSpectrumPhy::CtrlErrorModelEnabled", BooleanValue(false));
1965  Config::SetDefault("ns3::LteSpectrumPhy::DataErrorModelEnabled", BooleanValue(false));
1966 
1967  double eNbTxPower = 30;
1968  Config::SetDefault("ns3::LteEnbPhy::TxPower", DoubleValue(eNbTxPower));
1969  Config::SetDefault("ns3::LteUePhy::TxPower", DoubleValue(10.0));
1970  Config::SetDefault("ns3::LteUePhy::EnableUplinkPowerControl", BooleanValue(true));
1971 
1972  Config::SetDefault("ns3::LteUePowerControl::ClosedLoop", BooleanValue(true));
1973  Config::SetDefault("ns3::LteUePowerControl::AccumulationEnabled", BooleanValue(false));
1974 
1975  // Disable layer-3 filtering
1976  Config::SetDefault("ns3::LteEnbRrc::RsrpFilterCoefficient", UintegerValue(0));
1977  Config::SetDefault("ns3::LteEnbRrc::RsrqFilterCoefficient", UintegerValue(0));
1978 
1979  uint16_t bandwidth = 25;
1980 
1981  Ptr<LteHelper> lteHelper = CreateObject<LteHelper>();
1982  Ptr<PointToPointEpcHelper> epcHelper = CreateObject<PointToPointEpcHelper>();
1983  lteHelper->SetEpcHelper(epcHelper);
1984  lteHelper->SetHandoverAlgorithmType("ns3::NoOpHandoverAlgorithm"); // disable automatic handover
1985 
1986  Ptr<Node> pgw = epcHelper->GetPgwNode();
1987 
1988  // Create a single RemoteHost
1989  NodeContainer remoteHostContainer;
1990  remoteHostContainer.Create(1);
1991  Ptr<Node> remoteHost = remoteHostContainer.Get(0);
1993  internet.Install(remoteHostContainer);
1994 
1995  // Create the Internet
1996  PointToPointHelper p2ph;
1997  p2ph.SetDeviceAttribute("DataRate", DataRateValue(DataRate("100Gb/s")));
1998  p2ph.SetDeviceAttribute("Mtu", UintegerValue(1500));
1999  p2ph.SetChannelAttribute("Delay", TimeValue(Seconds(0.010)));
2000  NetDeviceContainer internetDevices = p2ph.Install(pgw, remoteHost);
2001  Ipv4AddressHelper ipv4h;
2002  ipv4h.SetBase("1.0.0.0", "255.0.0.0");
2003  Ipv4InterfaceContainer internetIpIfaces = ipv4h.Assign(internetDevices);
2004  Ipv4Address remoteHostAddr = internetIpIfaces.GetAddress(1);
2005 
2006  // Routing of the Internet Host (towards the LTE network)
2007  Ipv4StaticRoutingHelper ipv4RoutingHelper;
2008  Ptr<Ipv4StaticRouting> remoteHostStaticRouting =
2009  ipv4RoutingHelper.GetStaticRouting(remoteHost->GetObject<Ipv4>());
2010  // interface 0 is localhost, 1 is the p2p device
2011  remoteHostStaticRouting->AddNetworkRouteTo(Ipv4Address("7.0.0.0"), Ipv4Mask("255.0.0.0"), 1);
2012 
2013  // Create Nodes: eNodeB and UE
2014  NodeContainer enbNodes;
2015  NodeContainer ueNodes1;
2016  NodeContainer ueNodes2;
2017  enbNodes.Create(2);
2018  ueNodes1.Create(2);
2019  ueNodes2.Create(1);
2020  NodeContainer ueNodes = NodeContainer(ueNodes1, ueNodes2);
2021  NodeContainer allNodes = NodeContainer(enbNodes, ueNodes1, ueNodes2);
2022 
2023  /*
2024  * The topology is the following:
2025  *
2026  * eNB1 UE1 UE2 eNB2
2027  * | | | |
2028  * x ------------ x ------------------------ x ------------ x
2029  * 200 m 600 m 200 m
2030  *
2031  */
2032 
2033  // Install Mobility Model
2034  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator>();
2035  positionAlloc->Add(Vector(0.0, 0.0, 0.0)); // eNB1
2036  positionAlloc->Add(Vector(1000, 0.0, 0.0)); // eNB2
2037 
2038  positionAlloc->Add(Vector(200, 0.0, 0.0)); // UE1
2039  positionAlloc->Add(Vector(200, 0.0, 0.0)); // UE1
2040  positionAlloc->Add(Vector(800, 0.0, 0.0)); // UE2
2041 
2043  mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
2044  mobility.SetPositionAllocator(positionAlloc);
2045  mobility.Install(allNodes);
2046  m_ueMobility = ueNodes2.Get(0)->GetObject<MobilityModel>();
2047 
2048  // Create Devices and install them in the Nodes (eNB and UE)
2049  NetDeviceContainer enbDevs;
2050  NetDeviceContainer ueDevs1;
2051  NetDeviceContainer ueDevs2;
2052  lteHelper->SetSchedulerType(m_schedulerType);
2053 
2054  lteHelper->SetEnbDeviceAttribute("DlBandwidth", UintegerValue(bandwidth));
2055  lteHelper->SetEnbDeviceAttribute("UlBandwidth", UintegerValue(bandwidth));
2056 
2057  lteHelper->SetFfrAlgorithmType("ns3::LteFfrDistributedAlgorithm");
2058  lteHelper->SetFfrAlgorithmAttribute("CalculationInterval", TimeValue(MilliSeconds(10)));
2059  lteHelper->SetFfrAlgorithmAttribute("RsrqThreshold", UintegerValue(25));
2060  lteHelper->SetFfrAlgorithmAttribute("RsrpDifferenceThreshold", UintegerValue(5));
2061  lteHelper->SetFfrAlgorithmAttribute("EdgeRbNum", UintegerValue(6));
2062  lteHelper->SetFfrAlgorithmAttribute("CenterPowerOffset",
2063  UintegerValue(LteRrcSap::PdschConfigDedicated::dB0));
2064  lteHelper->SetFfrAlgorithmAttribute("EdgePowerOffset",
2065  UintegerValue(LteRrcSap::PdschConfigDedicated::dB3));
2066 
2067  enbDevs = lteHelper->InstallEnbDevice(enbNodes);
2068  ueDevs1 = lteHelper->InstallUeDevice(ueNodes1);
2069  ueDevs2 = lteHelper->InstallUeDevice(ueNodes2);
2070 
2071  NetDeviceContainer ueLteDevs;
2072  ueLteDevs.Add(ueDevs1);
2073  ueLteDevs.Add(ueDevs2);
2074 
2075  // Add X2 interface
2076  lteHelper->AddX2Interface(enbNodes);
2077 
2078  // Install the IP stack on the UEs
2079  internet.Install(ueNodes);
2080  Ipv4InterfaceContainer ueIpIfaces;
2081  ueIpIfaces = epcHelper->AssignUeIpv4Address(NetDeviceContainer(ueLteDevs));
2082  // Assign IP address to UEs, and install applications
2083  for (uint32_t u = 0; u < ueNodes.GetN(); ++u)
2084  {
2085  Ptr<Node> ueNode = ueNodes.Get(u);
2086  // Set the default gateway for the UE
2087  Ptr<Ipv4StaticRouting> ueStaticRouting =
2088  ipv4RoutingHelper.GetStaticRouting(ueNode->GetObject<Ipv4>());
2089  ueStaticRouting->SetDefaultRoute(epcHelper->GetUeDefaultGatewayAddress(), 1);
2090  }
2091 
2092  // Attach a UE to a eNB
2093  lteHelper->Attach(ueDevs1, enbDevs.Get(0));
2094  lteHelper->Attach(ueDevs2, enbDevs.Get(1));
2095 
2096  // Install and start applications on UEs and remote host
2097  uint16_t dlPort = 10000;
2098  uint16_t ulPort = 20000;
2099 
2100  // randomize a bit start times to avoid simulation artifacts
2101  // (e.g., buffer overflows due to packet transmissions happening
2102  // exactly at the same time)
2103  Ptr<UniformRandomVariable> startTimeSeconds = CreateObject<UniformRandomVariable>();
2104  startTimeSeconds->SetAttribute("Min", DoubleValue(0));
2105  startTimeSeconds->SetAttribute("Max", DoubleValue(0.010));
2106 
2107  for (uint32_t u = 0; u < ueNodes.GetN(); ++u)
2108  {
2109  Ptr<Node> ue = ueNodes.Get(u);
2110  // Set the default gateway for the UE
2111  Ptr<Ipv4StaticRouting> ueStaticRouting =
2112  ipv4RoutingHelper.GetStaticRouting(ue->GetObject<Ipv4>());
2113  ueStaticRouting->SetDefaultRoute(epcHelper->GetUeDefaultGatewayAddress(), 1);
2114 
2115  for (uint32_t b = 0; b < 1; ++b)
2116  {
2117  ++dlPort;
2118  ++ulPort;
2119 
2122 
2123  NS_LOG_LOGIC("installing UDP DL app for UE " << u);
2124  UdpClientHelper dlClientHelper(ueIpIfaces.GetAddress(u), dlPort);
2125  dlClientHelper.SetAttribute("MaxPackets", UintegerValue(1000000));
2126  dlClientHelper.SetAttribute("Interval", TimeValue(MilliSeconds(1.0)));
2127  clientApps.Add(dlClientHelper.Install(remoteHost));
2128  PacketSinkHelper dlPacketSinkHelper("ns3::UdpSocketFactory",
2129  InetSocketAddress(Ipv4Address::GetAny(), dlPort));
2130  serverApps.Add(dlPacketSinkHelper.Install(ue));
2131 
2132  NS_LOG_LOGIC("installing UDP UL app for UE " << u);
2133  UdpClientHelper ulClientHelper(remoteHostAddr, ulPort);
2134  ulClientHelper.SetAttribute("MaxPackets", UintegerValue(1000000));
2135  ulClientHelper.SetAttribute("Interval", TimeValue(MilliSeconds(1.0)));
2136  clientApps.Add(ulClientHelper.Install(ue));
2137  PacketSinkHelper ulPacketSinkHelper("ns3::UdpSocketFactory",
2138  InetSocketAddress(Ipv4Address::GetAny(), ulPort));
2139  serverApps.Add(ulPacketSinkHelper.Install(remoteHost));
2140 
2141  Ptr<EpcTft> tft = Create<EpcTft>();
2142  EpcTft::PacketFilter dlpf;
2143  dlpf.localPortStart = dlPort;
2144  dlpf.localPortEnd = dlPort;
2145  tft->Add(dlpf);
2146  EpcTft::PacketFilter ulpf;
2147  ulpf.remotePortStart = ulPort;
2148  ulpf.remotePortEnd = ulPort;
2149  tft->Add(ulpf);
2150  // Since this test includes the Token Bank Fair Queue Scheduler
2151  //(ns3::FdTbfqFfMacScheduler) we have to use GBR bearer with
2152  // certain QoS.
2153  GbrQosInformation qos;
2154  qos.mbrUl = 1e6;
2155  qos.mbrDl = 1e6;
2156  qos.gbrUl = 1e4;
2157  qos.gbrDl = 1e4;
2158 
2159  EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE;
2160  EpsBearer bearer(q, qos);
2161  lteHelper->ActivateDedicatedEpsBearer(ueLteDevs.Get(u), bearer, tft);
2162 
2163  Time startTime = Seconds(startTimeSeconds->GetValue());
2164  serverApps.Start(startTime);
2165  clientApps.Start(startTime);
2166  }
2167  }
2168 
2169  // Test SpectrumPhy to get signals form DL channel
2170  Ptr<LteSpectrumPhy> enbDlSpectrumPhy = enbDevs.Get(0)
2171  ->GetObject<LteEnbNetDevice>()
2172  ->GetPhy()
2173  ->GetDownlinkSpectrumPhy()
2175  Ptr<SpectrumChannel> dlChannel = enbDlSpectrumPhy->GetChannel();
2176 
2177  Ptr<LteSimpleSpectrumPhy> testDlSpectrumPhy = CreateObject<LteSimpleSpectrumPhy>();
2178  Ptr<LteEnbNetDevice> eNbDev = enbDevs.Get(0)->GetObject<LteEnbNetDevice>();
2179  testDlSpectrumPhy->SetRxSpectrumModel(
2180  LteSpectrumValueHelper::GetSpectrumModel(eNbDev->GetDlEarfcn(), m_dlBandwidth));
2181  dlChannel->AddRx(testDlSpectrumPhy);
2182 
2183  testDlSpectrumPhy->SetCellId(2);
2184 
2185  testDlSpectrumPhy->TraceConnectWithoutContext(
2186  "RxStart",
2188 
2189  // Test SpectrumPhy to get signals form UL channel
2190  Ptr<LteSpectrumPhy> ueUlSpectrumPhy = ueDevs1.Get(0)
2191  ->GetObject<LteUeNetDevice>()
2192  ->GetPhy()
2193  ->GetUplinkSpectrumPhy()
2195  Ptr<SpectrumChannel> ulChannel = ueUlSpectrumPhy->GetChannel();
2196 
2197  Ptr<LteSimpleSpectrumPhy> testUlSpectrumPhy = CreateObject<LteSimpleSpectrumPhy>();
2198  testUlSpectrumPhy->SetRxSpectrumModel(
2199  LteSpectrumValueHelper::GetSpectrumModel(eNbDev->GetUlEarfcn(), m_ulBandwidth));
2200  ulChannel->AddRx(testUlSpectrumPhy);
2201 
2202  testUlSpectrumPhy->SetCellId(2);
2203 
2204  testUlSpectrumPhy->TraceConnectWithoutContext(
2205  "RxStart",
2207 
2208  double expectedDlPowerCenterArea = 1.0;
2209  std::vector<bool> expectedDlRbCenterArea;
2210  expectedDlRbCenterArea.resize(m_dlBandwidth, false);
2211  std::vector<bool> expectedUlRbCenterArea;
2212  expectedUlRbCenterArea.resize(m_ulBandwidth, false);
2213  for (uint32_t i = 0; i < m_dlBandwidth; i++)
2214  {
2215  expectedDlRbCenterArea[i] = true;
2216  expectedUlRbCenterArea[i] = true;
2217  }
2218 
2219  double expectedDlPowerEdgeArea = 2.0;
2220  std::vector<bool> expectedDlRbEdgeArea;
2221  expectedDlRbEdgeArea.resize(m_dlBandwidth, false);
2222  std::vector<bool> expectedUlRbEdgeArea;
2223  expectedUlRbEdgeArea.resize(m_ulBandwidth, false);
2224  for (uint32_t i = 0; i < 6; i++)
2225  {
2226  expectedDlRbEdgeArea[i] = true;
2227  expectedUlRbEdgeArea[i] = true;
2228  }
2229 
2230  std::vector<bool> expectedDlRbEdgeArea2;
2231  expectedDlRbEdgeArea2.resize(m_dlBandwidth, false);
2232  std::vector<bool> expectedUlRbEdgeArea2;
2233  expectedUlRbEdgeArea2.resize(m_dlBandwidth, false);
2234  for (uint32_t i = 6; i < 12; i++)
2235  {
2236  expectedDlRbEdgeArea2[i] = true;
2237  expectedUlRbEdgeArea2[i] = true;
2238  }
2239 
2240  Simulator::Schedule(MilliSeconds(1),
2242  this,
2243  800,
2244  0,
2245  expectedDlPowerCenterArea,
2246  expectedDlRbCenterArea);
2247  Simulator::Schedule(MilliSeconds(1),
2249  this,
2250  0.0225815,
2251  expectedUlRbCenterArea);
2252 
2253  Simulator::Schedule(MilliSeconds(501),
2255  this,
2256  400,
2257  0,
2258  expectedDlPowerEdgeArea,
2259  expectedDlRbEdgeArea);
2260  Simulator::Schedule(MilliSeconds(501),
2262  this,
2263  0.135489,
2264  expectedUlRbEdgeArea);
2265 
2266  Simulator::Schedule(MilliSeconds(1001),
2268  this,
2269  ueNodes1.Get(0),
2270  600,
2271  0,
2272  expectedDlPowerEdgeArea,
2273  expectedDlRbEdgeArea2);
2274  Simulator::Schedule(MilliSeconds(1001),
2276  this,
2277  0.135489,
2278  expectedUlRbEdgeArea2);
2279 
2280  Simulator::Schedule(MilliSeconds(1501),
2282  this,
2283  ueNodes1.Get(0),
2284  200,
2285  0,
2286  expectedDlPowerEdgeArea,
2287  expectedDlRbEdgeArea);
2288  Simulator::Schedule(MilliSeconds(1501),
2290  this,
2291  0.135489,
2292  expectedUlRbEdgeArea);
2293 
2294  Simulator::Schedule(MilliSeconds(2001),
2296  this,
2297  800,
2298  0,
2299  expectedDlPowerCenterArea,
2300  expectedDlRbCenterArea);
2301  Simulator::Schedule(MilliSeconds(2001),
2303  this,
2304  0.0225815,
2305  expectedUlRbCenterArea);
2306 
2307  Simulator::Stop(Seconds(2.500));
2308  Simulator::Run();
2309 
2310 #if 0
2312  "Scheduler used DL RBG muted by FFR Algorithm");
2313 #endif
2314 
2315  NS_TEST_ASSERT_MSG_EQ(m_usedWrongUlRbg, false, "Scheduler used UL RB muted by FFR Algorithm");
2316 
2317  Simulator::Destroy();
2318 }
Lte Distributed Ffr Area Test Case.
LteDistributedFfrAreaTestCase(std::string name, std::string schedulerType)
Constructor.
void DoRun() override
Implementation to actually run this TestCase.
Lte Enhanced Ffr Area Test Case.
void DoRun() override
Implementation to actually run this TestCase.
LteEnhancedFfrAreaTestCase(std::string name, std::string schedulerType)
Constructor.
Test frequency reuse algorithm by teleporting UEs to different parts of area and checking if the freq...
Time m_teleportTime
the teleport time
LteFrAreaTestCase(std::string name, std::string schedulerType)
Constructor.
bool m_usedWrongUlRbg
used wrong UL RBG?
std::vector< bool > m_expectedDlRb
the expected DL per RB
void SimpleTeleportUe(uint32_t x, uint32_t y)
Simple teleport UE function.
uint16_t m_ulBandwidth
the UL bandwidth
uint16_t m_dlBandwidth
the DL bandwidth
std::vector< bool > m_expectedUlRb
expected UL per RB
void UlDataRxStart(Ptr< const SpectrumValue > spectrumValue)
UL data receive start function.
void TeleportUe2(Ptr< Node > ueNode, uint32_t x, uint32_t y, double expectedPower, std::vector< bool > expectedDlRb)
Teleport UE 2 function.
void DlDataRxStart(Ptr< const SpectrumValue > spectrumValue)
DL data receive start function.
double m_expectedUlPower
expected UL power
std::string m_schedulerType
the scheduler type
void SetUlExpectedValues(double expectedPower, std::vector< bool > expectedDlRb)
Set UL expected values function.
double m_expectedDlPower
the expected DL power
void SetDlExpectedValues(double expectedPower, std::vector< bool > expectedDlRb)
Set DL expected values function.
bool m_usedWrongDlRbg
used wrong DL RBG?
void TeleportUe(uint32_t x, uint32_t y, double expectedPower, std::vector< bool > expectedDlRb)
Teleport UE function.
Ptr< MobilityModel > m_ueMobility
the UE mobility model
void DoRun() override
Implementation to actually run this TestCase.
Test frequency reuse algorithm.
void DlDataRxStart(Ptr< const SpectrumValue > spectrumValue)
DL data receive start function.
uint32_t m_userNum
the number of UE nodes
void UlDataRxStart(Ptr< const SpectrumValue > spectrumValue)
UL data receive start function.
void DoRun() override
Implementation to actually run this TestCase.
uint16_t m_dlBandwidth
the DL bandwidth
LteFrTestCase(std::string name, uint32_t userNum, uint16_t dlBandwidth, uint16_t ulBandwidth, std::vector< bool > availableDlRb, std::vector< bool > availableUlRb)
Constructor.
uint16_t m_ulBandwidth
the UL bandwidth
bool m_usedMutedDlRbg
used muted DL RBG?
std::vector< bool > m_availableDlRb
the available DL for each RB
std::vector< bool > m_availableUlRb
the available UL for each RB
bool m_usedMutedUlRbg
used muted UL RBG?
Test the fractional frequency reuse algorithms.
Test hard frequency reuse algorithm.
LteHardFrTestCase(std::string name, uint32_t userNum, std::string schedulerType, uint16_t dlBandwidth, uint16_t ulBandwidth, uint8_t dlSubBandOffset, uint16_t dlSubBandwidth, uint8_t ulSubBandOffset, uint16_t ulSubBandwidth, std::vector< bool > availableDlRb, std::vector< bool > availableUlRb)
Constructor.
uint8_t m_dlSubBandOffset
the DL subband offset
uint8_t m_ulSubBandwidth
UL subband offset.
uint8_t m_ulSubBandOffset
UL subband offset.
void DoRun() override
Implementation to actually run this TestCase.
uint8_t m_dlSubBandwidth
the DL subband width
std::string m_schedulerType
the scheduler type
Lte Soft Ffr Area Test Case.
void DoRun() override
Implementation to actually run this TestCase.
LteSoftFfrAreaTestCase(std::string name, std::string schedulerType)
Constructor.
Lte Soft Fr Area Test Case.
void DoRun() override
Implementation to actually run this TestCase.
LteSoftFrAreaTestCase(std::string name, std::string schedulerType)
Constructor.
void DoRun() override
Implementation to actually run this TestCase.
LteStrictFrAreaTestCase(std::string name, std::string schedulerType)
Constructor.
Test strict frequency reuse algorithm.
uint16_t m_ulCommonSubBandwidth
UL common subbandwidth.
void DoRun() override
Implementation to actually run this TestCase.
uint16_t m_dlCommonSubBandwidth
DL common subbandwidth.
uint8_t m_dlEdgeSubBandOffset
DL edge subband offset.
uint8_t m_ulEdgeSubBandOffset
UL edge subband offset.
std::string m_schedulerType
scheduler type
LteStrictFrTestCase(std::string name, uint32_t userNum, std::string schedulerType, uint16_t dlBandwidth, uint16_t ulBandwidth, uint16_t dlCommonSubBandwidth, uint8_t dlEdgeSubBandOffset, uint16_t dlEdgeSubBandwidth, uint16_t ulCommonSubBandwidth, uint8_t ulEdgeSubBandOffset, uint16_t ulEdgeSubBandwidth, std::vector< bool > availableDlRb, std::vector< bool > availableUlRb)
Constructor.
uint16_t m_dlEdgeSubBandwidth
DL edge subbandwidth.
uint16_t m_ulEdgeSubBandwidth
UL edge subbandwidth.
holds a vector of ns3::Application pointers.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition: double.h:42
This class contains the specification of EPS Bearers.
Definition: eps-bearer.h:91
Qci
QoS Class Indicator.
Definition: eps-bearer.h:106
an Inet address class
aggregate IP/TCP/UDP functionality to existing Nodes.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:42
Access to the IPv4 forwarding table, interfaces, and configuration.
Definition: ipv4.h:80
holds a vector of std::pair of Ptr<Ipv4> and interface index.
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
a class to represent an Ipv4 address mask
Definition: ipv4-address.h:257
Helper class that adds ns3::Ipv4StaticRouting objects.
Ptr< Ipv4StaticRouting > GetStaticRouting(Ptr< Ipv4 > ipv4) const
Try and find the static routing protocol as either the main routing protocol or in the list of routin...
The eNodeB device implementation.
uint32_t GetUlEarfcn() const
uint32_t GetDlEarfcn() const
void SetFfrAlgorithmType(std::string type)
Set the type of FFR algorithm to be used by eNodeB devices.
Definition: lte-helper.cc:319
void SetEpcHelper(Ptr< EpcHelper > h)
Set the EpcHelper to be used to setup the EPC network in conjunction with the setup of the LTE radio ...
Definition: lte-helper.cc:285
void SetSchedulerAttribute(std::string n, const AttributeValue &v)
Set an attribute for the scheduler to be created.
Definition: lte-helper.cc:306
NetDeviceContainer InstallEnbDevice(NodeContainer c)
Create a set of eNodeB devices.
Definition: lte-helper.cc:485
void SetHandoverAlgorithmType(std::string type)
Set the type of handover algorithm to be used by eNodeB devices.
Definition: lte-helper.cc:340
void SetFfrAlgorithmAttribute(std::string n, const AttributeValue &v)
Set an attribute for the FFR algorithm to be created.
Definition: lte-helper.cc:327
void SetSchedulerType(std::string type)
Set the type of scheduler to be used by eNodeB devices.
Definition: lte-helper.cc:292
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:1039
void SetEnbDeviceAttribute(std::string n, const AttributeValue &v)
Set an attribute for the eNodeB devices (LteEnbNetDevice) to be created.
Definition: lte-helper.cc:412
void ActivateDataRadioBearer(NetDeviceContainer ueDevices, EpsBearer bearer)
Activate a Data Radio Bearer on a given UE devices (for LTE-only simulation).
Definition: lte-helper.cc:1436
NetDeviceContainer InstallUeDevice(NodeContainer c)
Create a set of UE devices.
Definition: lte-helper.cc:500
void AddX2Interface(NodeContainer enbNodes)
Create an X2 interface between all the eNBs in a given set.
Definition: lte-helper.cc:1313
uint8_t ActivateDedicatedEpsBearer(NetDeviceContainer ueDevices, EpsBearer bearer, Ptr< EpcTft > tft)
Activate a dedicated EPS bearer on a given set of UE devices.
Definition: lte-helper.cc:1154
The LteSpectrumPhy models the physical layer of LTE.
The LteUeNetDevice class implements the UE net device.
Helper class used to assign positions and mobility models to nodes.
Keep track of the current position and velocity of an object.
void SetPosition(const Vector &position)
holds a vector of ns3::NetDevice pointers
void Add(NetDeviceContainer other)
Append the contents of another NetDeviceContainer to the end of this container.
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
Ptr< Node > GetPgwNode() const override
Get the PGW node.
Ipv4Address GetUeDefaultGatewayAddress() override
Ipv4InterfaceContainer AssignUeIpv4Address(NetDeviceContainer ueDevices) override
Assign IPv4 addresses to UE devices.
keep track of a set of node pointers.
uint32_t GetN() const
Get the number of Ptr<Node> stored in this container.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:204
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
Definition: object.h:471
A helper to make it easier to instantiate an ns3::PacketSinkApplication on a set of nodes.
ApplicationContainer Install(NodeContainer c) const
Install an ns3::PacketSinkApplication on each node of the input container configured with all the att...
Build a set of PointToPointNetDevice objects.
void SetDeviceAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each NetDevice created by the helper.
void SetChannelAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each Channel created by the helper.
NetDeviceContainer Install(NodeContainer c)
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
encapsulates test code
Definition: test.h:1060
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:301
A suite of tests to run.
Definition: test.h:1256
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
Create a client application which sends UDP packets carrying a 32bit sequence number and a 64 bit tim...
void SetAttribute(std::string name, const AttributeValue &value)
Record an attribute to be set in each Application after it is is created.
ApplicationContainer Install(NodeContainer c)
Hold an unsigned integer type.
Definition: uinteger.h:45
double GetValue(double min, double max)
Get the next random value drawn from the distribution.
void Reset()
Reset the initial value of every attribute as well as the value of every global to what they were bef...
Definition: config.cc:855
void SetDefault(std::string name, const AttributeValue &value)
Definition: config.cc:890
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:268
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:282
#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:275
static LteFrequencyReuseTestSuite lteFrequencyReuseTestSuite
Static variable for test initialization.
auto MakeBoundCallback(R(*fnPtr)(Args...), BArgs &&... bargs)
Make Callbacks with varying number of bound arguments.
Definition: callback.h:765
void(* DataRate)(DataRate oldValue, DataRate newValue)
TracedValue callback signature for DataRate.
Definition: data-rate.h:327
Time Now()
create an ns3::Time instance which contains the current simulation time.
Definition: simulator.cc:305
#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:144
#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:337
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1326
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1338
void UlDataRxStartNotificationArea(LteFrAreaTestCase *testcase, Ptr< const SpectrumValue > spectrumValue)
void UlDataRxStartNotification(LteFrTestCase *testcase, Ptr< const SpectrumValue > spectrumValue)
void DlDataRxStartNotification(LteFrTestCase *testcase, Ptr< const SpectrumValue > spectrumValue)
TestCase Data.
void DlDataRxStartNotificationArea(LteFrAreaTestCase *testcase, Ptr< const SpectrumValue > spectrumValue)
serverApps
Definition: first.py:54
clientApps
Definition: first.py:64
Every class exported by the ns3 library is enclosed in the ns3 namespace.
mobility
Definition: third.py:105
Implement the data structure representing a TrafficFlowTemplate Packet Filter.
Definition: epc-tft.h:71
uint16_t localPortEnd
end of the port number range of the UE
Definition: epc-tft.h:132
uint16_t remotePortEnd
end of the port number range of the remote host
Definition: epc-tft.h:130
uint16_t remotePortStart
start of the port number range of the remote host
Definition: epc-tft.h:129
uint16_t localPortStart
start of the port number range of the UE
Definition: epc-tft.h:131
3GPP TS 36.413 9.2.1.18 GBR QoS Information
Definition: eps-bearer.h:36
uint64_t gbrDl
Guaranteed Bit Rate (bit/s) in downlink.
Definition: eps-bearer.h:42
uint64_t gbrUl
Guaranteed Bit Rate (bit/s) in uplink.
Definition: eps-bearer.h:43
uint64_t mbrDl
Maximum Bit Rate (bit/s) in downlink.
Definition: eps-bearer.h:44
uint64_t mbrUl
Maximum Bit Rate (bit/s) in uplink.
Definition: eps-bearer.h:45