A Discrete-Event Network Simulator
API
lte-helper.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
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: Nicola Baldo <nbaldo@cttc.es> (re-wrote from scratch this helper)
18  * Giuseppe Piro <g.piro@poliba.it> (parts of the PHY & channel creation & configuration
19  * copied from the GSoC 2011 code) Modified by: Danilo Abrignani <danilo.abrignani@unibo.it>
20  * (Carrier Aggregation - GSoC 2015) Biljana Bojovic <biljana.bojovic@cttc.es> (Carrier Aggregation)
21  */
22 
23 #include "lte-helper.h"
24 
25 #include <ns3/abort.h>
26 #include <ns3/buildings-propagation-loss-model.h>
27 #include <ns3/epc-enb-application.h>
28 #include <ns3/epc-enb-s1-sap.h>
29 #include <ns3/epc-helper.h>
30 #include <ns3/epc-ue-nas.h>
31 #include <ns3/epc-x2.h>
32 #include <ns3/ff-mac-scheduler.h>
33 #include <ns3/friis-spectrum-propagation-loss.h>
34 #include <ns3/isotropic-antenna-model.h>
35 #include <ns3/log.h>
36 #include <ns3/lte-anr.h>
37 #include <ns3/lte-chunk-processor.h>
38 #include <ns3/lte-enb-component-carrier-manager.h>
39 #include <ns3/lte-enb-mac.h>
40 #include <ns3/lte-enb-net-device.h>
41 #include <ns3/lte-enb-phy.h>
42 #include <ns3/lte-enb-rrc.h>
43 #include <ns3/lte-ffr-algorithm.h>
44 #include <ns3/lte-handover-algorithm.h>
45 #include <ns3/lte-rlc-am.h>
46 #include <ns3/lte-rlc-um.h>
47 #include <ns3/lte-rlc.h>
48 #include <ns3/lte-rrc-protocol-ideal.h>
49 #include <ns3/lte-rrc-protocol-real.h>
50 #include <ns3/lte-spectrum-phy.h>
51 #include <ns3/lte-spectrum-value-helper.h>
52 #include <ns3/lte-ue-component-carrier-manager.h>
53 #include <ns3/lte-ue-mac.h>
54 #include <ns3/lte-ue-net-device.h>
55 #include <ns3/lte-ue-phy.h>
56 #include <ns3/lte-ue-rrc.h>
57 #include <ns3/mac-stats-calculator.h>
58 #include <ns3/multi-model-spectrum-channel.h>
59 #include <ns3/object-factory.h>
60 #include <ns3/object-map.h>
61 #include <ns3/phy-rx-stats-calculator.h>
62 #include <ns3/phy-stats-calculator.h>
63 #include <ns3/phy-tx-stats-calculator.h>
64 #include <ns3/pointer.h>
65 #include <ns3/string.h>
66 #include <ns3/trace-fading-loss-model.h>
67 
68 #include <iostream>
69 
70 namespace ns3
71 {
72 
73 NS_LOG_COMPONENT_DEFINE("LteHelper");
74 
76 
78  : m_fadingStreamsAssigned(false),
79  m_imsiCounter(0),
80  m_cellIdCounter{1}
81 {
82  NS_LOG_FUNCTION(this);
88 }
89 
90 void
92 {
93  NS_LOG_FUNCTION(this);
95  m_phyStats = CreateObject<PhyStatsCalculator>();
96  m_phyTxStats = CreateObject<PhyTxStatsCalculator>();
97  m_phyRxStats = CreateObject<PhyRxStatsCalculator>();
98  m_macStats = CreateObject<MacStatsCalculator>();
100 }
101 
103 {
104  NS_LOG_FUNCTION(this);
105 }
106 
107 TypeId
109 {
110  static TypeId tid =
111  TypeId("ns3::LteHelper")
112  .SetParent<Object>()
113  .AddConstructor<LteHelper>()
114  .AddAttribute(
115  "Scheduler",
116  "The type of scheduler to be used for eNBs. "
117  "The allowed values for this attributes are the type names "
118  "of any class inheriting from ns3::FfMacScheduler.",
119  StringValue("ns3::PfFfMacScheduler"),
122  .AddAttribute("FfrAlgorithm",
123  "The type of FFR algorithm to be used for eNBs. "
124  "The allowed values for this attributes are the type names "
125  "of any class inheriting from ns3::LteFfrAlgorithm.",
126  StringValue("ns3::LteFrNoOpAlgorithm"),
130  .AddAttribute("HandoverAlgorithm",
131  "The type of handover algorithm to be used for eNBs. "
132  "The allowed values for this attributes are the type names "
133  "of any class inheriting from ns3::LteHandoverAlgorithm.",
134  StringValue("ns3::NoOpHandoverAlgorithm"),
138  .AddAttribute("PathlossModel",
139  "The type of pathloss model to be used. "
140  "The allowed values for this attributes are the type names "
141  "of any class inheriting from ns3::PropagationLossModel.",
145  .AddAttribute("FadingModel",
146  "The type of fading model to be used."
147  "The allowed values for this attributes are the type names "
148  "of any class inheriting from ns3::SpectrumPropagationLossModel."
149  "If the type is set to an empty string, no fading model is used.",
150  StringValue(""),
153  .AddAttribute("UseIdealRrc",
154  "If true, LteRrcProtocolIdeal will be used for RRC signaling. "
155  "If false, LteRrcProtocolReal will be used.",
156  BooleanValue(true),
159  .AddAttribute("AnrEnabled",
160  "Activate or deactivate Automatic Neighbour Relation function",
161  BooleanValue(true),
164  .AddAttribute("UsePdschForCqiGeneration",
165  "If true, DL-CQI will be calculated from PDCCH as signal and PDSCH as "
166  "interference. "
167  "If false, DL-CQI will be calculated from PDCCH as signal and PDCCH as "
168  "interference.",
169  BooleanValue(true),
172  .AddAttribute("EnbComponentCarrierManager",
173  "The type of Component Carrier Manager to be used for eNBs. "
174  "The allowed values for this attributes are the type names "
175  "of any class inheriting ns3::LteEnbComponentCarrierManager.",
176  StringValue("ns3::NoOpComponentCarrierManager"),
180  .AddAttribute("UeComponentCarrierManager",
181  "The type of Component Carrier Manager to be used for UEs. "
182  "The allowed values for this attributes are the type names "
183  "of any class inheriting ns3::LteUeComponentCarrierManager.",
184  StringValue("ns3::SimpleUeComponentCarrierManager"),
188  .AddAttribute("UseCa",
189  "If true, Carrier Aggregation feature is enabled and a valid Component "
190  "Carrier Map is expected. "
191  "If false, single carrier simulation.",
192  BooleanValue(false),
195  .AddAttribute("NumberOfComponentCarriers",
196  "Set the number of Component carrier to use. "
197  "If it is more than one and m_useCa is false, it will raise an error.",
198  UintegerValue(1),
200  MakeUintegerChecker<uint16_t>(MIN_NO_CC, MAX_NO_CC));
201  return tid;
202 }
203 
204 void
206 {
207  NS_LOG_FUNCTION(this);
208  m_downlinkChannel = nullptr;
209  m_uplinkChannel = nullptr;
212 }
213 
216 {
217  return m_uplinkChannel;
218 }
219 
222 {
223  return m_downlinkChannel;
224 }
225 
226 void
228 {
229  // Channel Object (i.e. Ptr<SpectrumChannel>) are within a vector
230  // PathLossModel Objects are vectors --> in InstallSingleEnb we will set the frequency
231  NS_LOG_FUNCTION(this << m_noOfCcs);
232 
235 
239  if (dlSplm)
240  {
241  NS_LOG_LOGIC(this << " using a SpectrumPropagationLossModel in DL");
242  m_downlinkChannel->AddSpectrumPropagationLossModel(dlSplm);
243  }
244  else
245  {
246  NS_LOG_LOGIC(this << " using a PropagationLossModel in DL");
249  NS_ASSERT_MSG(dlPlm,
251  << " is neither PropagationLossModel nor SpectrumPropagationLossModel");
252  m_downlinkChannel->AddPropagationLossModel(dlPlm);
253  }
254 
258  if (ulSplm)
259  {
260  NS_LOG_LOGIC(this << " using a SpectrumPropagationLossModel in UL");
261  m_uplinkChannel->AddSpectrumPropagationLossModel(ulSplm);
262  }
263  else
264  {
265  NS_LOG_LOGIC(this << " using a PropagationLossModel in UL");
267  NS_ASSERT_MSG(ulPlm,
268  " " << m_uplinkPathlossModel
269  << " is neither PropagationLossModel nor SpectrumPropagationLossModel");
270  m_uplinkChannel->AddPropagationLossModel(ulPlm);
271  }
272  if (!m_fadingModelType.empty())
273  {
275  m_fadingModel->Initialize();
276  m_downlinkChannel->AddSpectrumPropagationLossModel(m_fadingModel);
277  m_uplinkChannel->AddSpectrumPropagationLossModel(m_fadingModel);
278  }
279 }
280 
281 void
283 {
284  NS_LOG_FUNCTION(this << h);
285  m_epcHelper = h;
286 }
287 
288 void
290 {
291  NS_LOG_FUNCTION(this << type);
294 }
295 
296 std::string
298 {
300 }
301 
302 void
304 {
305  NS_LOG_FUNCTION(this << n);
306  m_schedulerFactory.Set(n, v);
307 }
308 
309 std::string
311 {
313 }
314 
315 void
317 {
318  NS_LOG_FUNCTION(this << type);
321 }
322 
323 void
325 {
326  NS_LOG_FUNCTION(this << n);
328 }
329 
330 std::string
332 {
334 }
335 
336 void
338 {
339  NS_LOG_FUNCTION(this << type);
342 }
343 
344 void
346 {
347  NS_LOG_FUNCTION(this << n);
349 }
350 
351 std::string
353 {
355 }
356 
357 void
359 {
360  NS_LOG_FUNCTION(this << type);
363 }
364 
365 void
367 {
368  NS_LOG_FUNCTION(this << n);
370 }
371 
372 std::string
374 {
376 }
377 
378 void
380 {
381  NS_LOG_FUNCTION(this << type);
384 }
385 
386 void
388 {
389  NS_LOG_FUNCTION(this << n);
391 }
392 
393 void
395 {
396  NS_LOG_FUNCTION(this << type);
399 }
400 
401 void
403 {
404  NS_LOG_FUNCTION(this << n);
406 }
407 
408 void
410 {
411  NS_LOG_FUNCTION(this);
413 }
414 
415 void
417 {
418  NS_LOG_FUNCTION(this);
420 }
421 
422 void
424 {
425  NS_LOG_FUNCTION(this);
427 }
428 
429 void
431 {
432  NS_LOG_FUNCTION(this);
434 }
435 
436 void
438 {
439  NS_LOG_FUNCTION(this);
441 }
442 
443 void
445 {
446  NS_LOG_FUNCTION(this);
448 }
449 
450 void
452 {
453  NS_LOG_FUNCTION(this << type);
455  if (!type.empty())
456  {
459  }
460 }
461 
462 void
464 {
466 }
467 
468 void
470 {
471  NS_LOG_FUNCTION(this << type);
473 }
474 
475 void
477 {
478  m_channelFactory.Set(n, v);
479 }
480 
483 {
484  NS_LOG_FUNCTION(this);
485  Initialize(); // will run DoInitialize () if necessary
487  for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i)
488  {
489  Ptr<Node> node = *i;
490  Ptr<NetDevice> device = InstallSingleEnbDevice(node);
491  devices.Add(device);
492  }
493  return devices;
494 }
495 
498 {
499  NS_LOG_FUNCTION(this);
501  for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i)
502  {
503  Ptr<Node> node = *i;
504  Ptr<NetDevice> device = InstallSingleUeDevice(node);
505  devices.Add(device);
506  }
507  return devices;
508 }
509 
512 {
513  NS_LOG_FUNCTION(this << n);
514  uint16_t cellId = m_cellIdCounter; // \todo Remove, eNB has no cell ID
515 
517  Ptr<LteHandoverAlgorithm> handoverAlgorithm =
519 
520  NS_ABORT_MSG_IF(!m_componentCarrierPhyParams.empty(), "CC map is not clean");
522  dev->GetDlEarfcn(),
523  dev->GetUlBandwidth(),
524  dev->GetDlBandwidth());
526  "CC map size (" << m_componentCarrierPhyParams.size()
527  << ") must be equal to number of carriers (" << m_noOfCcs
528  << ")");
529  // create component carrier map for this eNb device
530  std::map<uint8_t, Ptr<ComponentCarrierBaseStation>> ccMap;
531  for (std::map<uint8_t, ComponentCarrier>::iterator it = m_componentCarrierPhyParams.begin();
532  it != m_componentCarrierPhyParams.end();
533  ++it)
534  {
535  Ptr<ComponentCarrierEnb> cc = CreateObject<ComponentCarrierEnb>();
536  cc->SetUlBandwidth(it->second.GetUlBandwidth());
537  cc->SetDlBandwidth(it->second.GetDlBandwidth());
538  cc->SetDlEarfcn(it->second.GetDlEarfcn());
539  cc->SetUlEarfcn(it->second.GetUlEarfcn());
540  cc->SetAsPrimary(it->second.IsPrimary());
541  NS_ABORT_MSG_IF(m_cellIdCounter == 65535, "max num cells exceeded");
542  cc->SetCellId(m_cellIdCounter++);
543  ccMap[it->first] = cc;
544  }
545  // CC map is not needed anymore
547 
548  NS_ABORT_MSG_IF(m_useCa && ccMap.size() < 2,
549  "You have to either specify carriers or disable carrier aggregation");
550  NS_ASSERT(ccMap.size() == m_noOfCcs);
551 
552  for (auto it = ccMap.begin(); it != ccMap.end(); ++it)
553  {
554  NS_LOG_DEBUG(this << "component carrier map size " << (uint16_t)ccMap.size());
555  Ptr<LteSpectrumPhy> dlPhy = CreateObject<LteSpectrumPhy>();
556  Ptr<LteSpectrumPhy> ulPhy = CreateObject<LteSpectrumPhy>();
557  Ptr<LteEnbPhy> phy = CreateObject<LteEnbPhy>(dlPhy, ulPhy);
558 
559  Ptr<LteHarqPhy> harq = Create<LteHarqPhy>();
560  dlPhy->SetHarqPhyModule(harq);
561  ulPhy->SetHarqPhyModule(harq);
562  phy->SetHarqPhyModule(harq);
563 
564  Ptr<LteChunkProcessor> pCtrl = Create<LteChunkProcessor>();
565  pCtrl->AddCallback(MakeCallback(&LteEnbPhy::GenerateCtrlCqiReport, phy));
566  ulPhy->AddCtrlSinrChunkProcessor(pCtrl); // for evaluating SRS UL-CQI
567 
568  Ptr<LteChunkProcessor> pData = Create<LteChunkProcessor>();
569  pData->AddCallback(MakeCallback(&LteEnbPhy::GenerateDataCqiReport, phy));
570  pData->AddCallback(MakeCallback(&LteSpectrumPhy::UpdateSinrPerceived, ulPhy));
571  ulPhy->AddDataSinrChunkProcessor(pData); // for evaluating PUSCH UL-CQI
572 
573  Ptr<LteChunkProcessor> pInterf = Create<LteChunkProcessor>();
574  pInterf->AddCallback(MakeCallback(&LteEnbPhy::ReportInterference, phy));
575  ulPhy->AddInterferenceDataChunkProcessor(pInterf); // for interference power tracing
576 
577  dlPhy->SetChannel(m_downlinkChannel);
578  ulPhy->SetChannel(m_uplinkChannel);
579 
582  mm,
583  "MobilityModel needs to be set on node before calling LteHelper::InstallEnbDevice ()");
584  dlPhy->SetMobility(mm);
585  ulPhy->SetMobility(mm);
586 
587  Ptr<AntennaModel> antenna = (m_enbAntennaModelFactory.Create())->GetObject<AntennaModel>();
588  NS_ASSERT_MSG(antenna, "error in creating the AntennaModel object");
589  dlPhy->SetAntenna(antenna);
590  ulPhy->SetAntenna(antenna);
591 
592  Ptr<LteEnbMac> mac = CreateObject<LteEnbMac>();
595  DynamicCast<ComponentCarrierEnb>(it->second)->SetMac(mac);
596  DynamicCast<ComponentCarrierEnb>(it->second)->SetFfMacScheduler(sched);
597  DynamicCast<ComponentCarrierEnb>(it->second)->SetFfrAlgorithm(ffrAlgorithm);
598  DynamicCast<ComponentCarrierEnb>(it->second)->SetPhy(phy);
599  }
600 
601  Ptr<LteEnbRrc> rrc = CreateObject<LteEnbRrc>();
602  Ptr<LteEnbComponentCarrierManager> ccmEnbManager =
604 
605  // ComponentCarrierManager SAP
606  rrc->SetLteCcmRrcSapProvider(ccmEnbManager->GetLteCcmRrcSapProvider());
607  ccmEnbManager->SetLteCcmRrcSapUser(rrc->GetLteCcmRrcSapUser());
608  // Set number of component carriers. Note: eNB CCM would also set the
609  // number of component carriers in eNB RRC
610  ccmEnbManager->SetNumberOfComponentCarriers(m_noOfCcs);
611 
612  rrc->ConfigureCarriers(ccMap);
613 
614  if (m_useIdealRrc)
615  {
616  Ptr<LteEnbRrcProtocolIdeal> rrcProtocol = CreateObject<LteEnbRrcProtocolIdeal>();
617  rrcProtocol->SetLteEnbRrcSapProvider(rrc->GetLteEnbRrcSapProvider());
618  rrc->SetLteEnbRrcSapUser(rrcProtocol->GetLteEnbRrcSapUser());
619  rrc->AggregateObject(rrcProtocol);
620  rrcProtocol->SetCellId(cellId);
621  }
622  else
623  {
624  Ptr<LteEnbRrcProtocolReal> rrcProtocol = CreateObject<LteEnbRrcProtocolReal>();
625  rrcProtocol->SetLteEnbRrcSapProvider(rrc->GetLteEnbRrcSapProvider());
626  rrc->SetLteEnbRrcSapUser(rrcProtocol->GetLteEnbRrcSapUser());
627  rrc->AggregateObject(rrcProtocol);
628  rrcProtocol->SetCellId(cellId);
629  }
630 
631  if (m_epcHelper)
632  {
633  EnumValue epsBearerToRlcMapping;
634  rrc->GetAttribute("EpsBearerToRlcMapping", epsBearerToRlcMapping);
635  // it does not make sense to use RLC/SM when also using the EPC
636  if (epsBearerToRlcMapping.Get() == LteEnbRrc::RLC_SM_ALWAYS)
637  {
638  rrc->SetAttribute("EpsBearerToRlcMapping", EnumValue(LteEnbRrc::RLC_UM_ALWAYS));
639  }
640  }
641 
642  rrc->SetLteHandoverManagementSapProvider(
643  handoverAlgorithm->GetLteHandoverManagementSapProvider());
644  handoverAlgorithm->SetLteHandoverManagementSapUser(rrc->GetLteHandoverManagementSapUser());
645 
646  // This RRC attribute is used to connect each new RLC instance with the MAC layer
647  // (for function such as TransmitPdu, ReportBufferStatusReport).
648  // Since in this new architecture, the component carrier manager acts a proxy, it
649  // will have its own LteMacSapProvider interface, RLC will see it as through original MAC
650  // interface LteMacSapProvider, but the function call will go now through
651  // LteEnbComponentCarrierManager instance that needs to implement functions of this interface,
652  // and its task will be to forward these calls to the specific MAC of some of the instances of
653  // component carriers. This decision will depend on the specific implementation of the component
654  // carrier manager.
655  rrc->SetLteMacSapProvider(ccmEnbManager->GetLteMacSapProvider());
656 
657  bool ccmTest;
658  for (auto it = ccMap.begin(); it != ccMap.end(); ++it)
659  {
660  DynamicCast<ComponentCarrierEnb>(it->second)
661  ->GetPhy()
662  ->SetLteEnbCphySapUser(rrc->GetLteEnbCphySapUser(it->first));
663  rrc->SetLteEnbCphySapProvider(
664  DynamicCast<ComponentCarrierEnb>(it->second)->GetPhy()->GetLteEnbCphySapProvider(),
665  it->first);
666 
667  rrc->SetLteEnbCmacSapProvider(
668  DynamicCast<ComponentCarrierEnb>(it->second)->GetMac()->GetLteEnbCmacSapProvider(),
669  it->first);
670  DynamicCast<ComponentCarrierEnb>(it->second)
671  ->GetMac()
672  ->SetLteEnbCmacSapUser(rrc->GetLteEnbCmacSapUser(it->first));
673 
674  DynamicCast<ComponentCarrierEnb>(it->second)->GetPhy()->SetComponentCarrierId(it->first);
675  DynamicCast<ComponentCarrierEnb>(it->second)->GetMac()->SetComponentCarrierId(it->first);
676  // FFR SAP
677  DynamicCast<ComponentCarrierEnb>(it->second)
678  ->GetFfMacScheduler()
679  ->SetLteFfrSapProvider(DynamicCast<ComponentCarrierEnb>(it->second)
680  ->GetFfrAlgorithm()
681  ->GetLteFfrSapProvider());
682  DynamicCast<ComponentCarrierEnb>(it->second)
683  ->GetFfrAlgorithm()
684  ->SetLteFfrSapUser(DynamicCast<ComponentCarrierEnb>(it->second)
685  ->GetFfMacScheduler()
686  ->GetLteFfrSapUser());
687  rrc->SetLteFfrRrcSapProvider(DynamicCast<ComponentCarrierEnb>(it->second)
688  ->GetFfrAlgorithm()
689  ->GetLteFfrRrcSapProvider(),
690  it->first);
691  DynamicCast<ComponentCarrierEnb>(it->second)
692  ->GetFfrAlgorithm()
693  ->SetLteFfrRrcSapUser(rrc->GetLteFfrRrcSapUser(it->first));
694  // FFR SAP END
695 
696  // PHY <--> MAC SAP
697  DynamicCast<ComponentCarrierEnb>(it->second)
698  ->GetPhy()
699  ->SetLteEnbPhySapUser(
700  DynamicCast<ComponentCarrierEnb>(it->second)->GetMac()->GetLteEnbPhySapUser());
701  DynamicCast<ComponentCarrierEnb>(it->second)
702  ->GetMac()
703  ->SetLteEnbPhySapProvider(
704  DynamicCast<ComponentCarrierEnb>(it->second)->GetPhy()->GetLteEnbPhySapProvider());
705  // PHY <--> MAC SAP END
706 
707  // Scheduler SAP
708  DynamicCast<ComponentCarrierEnb>(it->second)
709  ->GetMac()
710  ->SetFfMacSchedSapProvider(DynamicCast<ComponentCarrierEnb>(it->second)
711  ->GetFfMacScheduler()
712  ->GetFfMacSchedSapProvider());
713  DynamicCast<ComponentCarrierEnb>(it->second)
714  ->GetMac()
715  ->SetFfMacCschedSapProvider(DynamicCast<ComponentCarrierEnb>(it->second)
716  ->GetFfMacScheduler()
717  ->GetFfMacCschedSapProvider());
718 
719  DynamicCast<ComponentCarrierEnb>(it->second)
720  ->GetFfMacScheduler()
721  ->SetFfMacSchedSapUser(
722  DynamicCast<ComponentCarrierEnb>(it->second)->GetMac()->GetFfMacSchedSapUser());
723  DynamicCast<ComponentCarrierEnb>(it->second)
724  ->GetFfMacScheduler()
725  ->SetFfMacCschedSapUser(
726  DynamicCast<ComponentCarrierEnb>(it->second)->GetMac()->GetFfMacCschedSapUser());
727  // Scheduler SAP END
728 
729  DynamicCast<ComponentCarrierEnb>(it->second)
730  ->GetMac()
731  ->SetLteCcmMacSapUser(ccmEnbManager->GetLteCcmMacSapUser());
732  ccmEnbManager->SetCcmMacSapProviders(
733  it->first,
734  DynamicCast<ComponentCarrierEnb>(it->second)->GetMac()->GetLteCcmMacSapProvider());
735 
736  // insert the pointer to the LteMacSapProvider interface of the MAC layer of the specific
737  // component carrier
738  ccmTest = ccmEnbManager->SetMacSapProvider(
739  it->first,
740  DynamicCast<ComponentCarrierEnb>(it->second)->GetMac()->GetLteMacSapProvider());
741 
742  if (ccmTest == false)
743  {
744  NS_FATAL_ERROR("Error in SetComponentCarrierMacSapProviders");
745  }
746  }
747 
748  dev->SetNode(n);
749  dev->SetAttribute("CellId", UintegerValue(cellId));
750  dev->SetAttribute("LteEnbComponentCarrierManager", PointerValue(ccmEnbManager));
751  dev->SetCcMap(ccMap);
752  std::map<uint8_t, Ptr<ComponentCarrierBaseStation>>::iterator it = ccMap.begin();
753  dev->SetAttribute("LteEnbRrc", PointerValue(rrc));
754  dev->SetAttribute("LteHandoverAlgorithm", PointerValue(handoverAlgorithm));
755  dev->SetAttribute(
756  "LteFfrAlgorithm",
757  PointerValue(DynamicCast<ComponentCarrierEnb>(it->second)->GetFfrAlgorithm()));
758 
759  if (m_isAnrEnabled)
760  {
761  Ptr<LteAnr> anr = CreateObject<LteAnr>(cellId);
762  rrc->SetLteAnrSapProvider(anr->GetLteAnrSapProvider());
763  anr->SetLteAnrSapUser(rrc->GetLteAnrSapUser());
764  dev->SetAttribute("LteAnr", PointerValue(anr));
765  }
766 
767  for (it = ccMap.begin(); it != ccMap.end(); ++it)
768  {
769  Ptr<LteEnbPhy> ccPhy = DynamicCast<ComponentCarrierEnb>(it->second)->GetPhy();
770  ccPhy->SetDevice(dev);
771  ccPhy->GetUlSpectrumPhy()->SetDevice(dev);
772  ccPhy->GetDlSpectrumPhy()->SetDevice(dev);
773  ccPhy->GetUlSpectrumPhy()->SetLtePhyRxDataEndOkCallback(
775  ccPhy->GetUlSpectrumPhy()->SetLtePhyRxCtrlEndOkCallback(
777  ccPhy->GetUlSpectrumPhy()->SetLtePhyUlHarqFeedbackCallback(
779  NS_LOG_LOGIC("set the propagation model frequencies");
780  double dlFreq = LteSpectrumValueHelper::GetCarrierFrequency(it->second->GetDlEarfcn());
781  NS_LOG_LOGIC("DL freq: " << dlFreq);
782  bool dlFreqOk =
784  if (!dlFreqOk)
785  {
786  NS_LOG_WARN("DL propagation model does not have a Frequency attribute");
787  }
788 
789  double ulFreq = LteSpectrumValueHelper::GetCarrierFrequency(it->second->GetUlEarfcn());
790 
791  NS_LOG_LOGIC("UL freq: " << ulFreq);
792  bool ulFreqOk =
794  if (!ulFreqOk)
795  {
796  NS_LOG_WARN("UL propagation model does not have a Frequency attribute");
797  }
798  } // end for
799  rrc->SetForwardUpCallback(MakeCallback(&LteEnbNetDevice::Receive, dev));
800  dev->Initialize();
801  n->AddDevice(dev);
802 
803  for (it = ccMap.begin(); it != ccMap.end(); ++it)
804  {
805  m_uplinkChannel->AddRx(
806  DynamicCast<ComponentCarrierEnb>(it->second)->GetPhy()->GetUlSpectrumPhy());
807  }
808 
809  if (m_epcHelper)
810  {
811  NS_LOG_INFO("adding this eNB to the EPC");
812  m_epcHelper->AddEnb(n, dev, dev->GetCellIds());
814  NS_ASSERT_MSG(enbApp, "cannot retrieve EpcEnbApplication");
815 
816  // S1 SAPs
817  rrc->SetS1SapProvider(enbApp->GetS1SapProvider());
818  enbApp->SetS1SapUser(rrc->GetS1SapUser());
819 
820  // X2 SAPs
821  Ptr<EpcX2> x2 = n->GetObject<EpcX2>();
822  x2->SetEpcX2SapUser(rrc->GetEpcX2SapUser());
823  rrc->SetEpcX2SapProvider(x2->GetEpcX2SapProvider());
824  }
825 
826  return dev;
827 }
828 
831 {
832  NS_LOG_FUNCTION(this);
833 
835 
836  // Initialize the component carriers with default values in order to initialize MACs and PHYs
837  // of each component carrier. These values must be updated once the UE is attached to the
838  // eNB and receives RRC Connection Reconfiguration message. In case of primary carrier or
839  // a single carrier, these values will be updated once the UE will receive SIB2 and MIB.
840  NS_ABORT_MSG_IF(!m_componentCarrierPhyParams.empty(), "CC map is not clean");
841  DoComponentCarrierConfigure(dev->GetDlEarfcn() + 18000, dev->GetDlEarfcn(), 25, 25);
843  "CC map size (" << m_componentCarrierPhyParams.size()
844  << ") must be equal to number of carriers (" << m_noOfCcs
845  << ")");
846  std::map<uint8_t, Ptr<ComponentCarrierUe>> ueCcMap;
847 
848  for (std::map<uint8_t, ComponentCarrier>::iterator it = m_componentCarrierPhyParams.begin();
849  it != m_componentCarrierPhyParams.end();
850  ++it)
851  {
852  Ptr<ComponentCarrierUe> cc = CreateObject<ComponentCarrierUe>();
853  cc->SetUlBandwidth(it->second.GetUlBandwidth());
854  cc->SetDlBandwidth(it->second.GetDlBandwidth());
855  cc->SetDlEarfcn(it->second.GetDlEarfcn());
856  cc->SetUlEarfcn(it->second.GetUlEarfcn());
857  cc->SetAsPrimary(it->second.IsPrimary());
858  Ptr<LteUeMac> mac = CreateObject<LteUeMac>();
859  cc->SetMac(mac);
860  // cc->GetPhy ()->Initialize (); // it is initialized within the
861  // LteUeNetDevice::DoInitialize ()
862  ueCcMap.insert(std::pair<uint8_t, Ptr<ComponentCarrierUe>>(it->first, cc));
863  }
864  // CC map is not needed anymore
866 
867  for (std::map<uint8_t, Ptr<ComponentCarrierUe>>::iterator it = ueCcMap.begin();
868  it != ueCcMap.end();
869  ++it)
870  {
871  Ptr<LteSpectrumPhy> dlPhy = CreateObject<LteSpectrumPhy>();
872  Ptr<LteSpectrumPhy> ulPhy = CreateObject<LteSpectrumPhy>();
873 
874  Ptr<LteUePhy> phy = CreateObject<LteUePhy>(dlPhy, ulPhy);
875 
876  Ptr<LteHarqPhy> harq = Create<LteHarqPhy>();
877  dlPhy->SetHarqPhyModule(harq);
878  ulPhy->SetHarqPhyModule(harq);
879  phy->SetHarqPhyModule(harq);
880 
881  Ptr<LteChunkProcessor> pRs = Create<LteChunkProcessor>();
882  pRs->AddCallback(MakeCallback(&LteUePhy::ReportRsReceivedPower, phy));
883  dlPhy->AddRsPowerChunkProcessor(pRs);
884 
885  Ptr<LteChunkProcessor> pInterf = Create<LteChunkProcessor>();
886  pInterf->AddCallback(MakeCallback(&LteUePhy::ReportInterference, phy));
887  dlPhy->AddInterferenceCtrlChunkProcessor(pInterf); // for RSRQ evaluation of UE Measurements
888 
889  Ptr<LteChunkProcessor> pCtrl = Create<LteChunkProcessor>();
890  pCtrl->AddCallback(MakeCallback(&LteSpectrumPhy::UpdateSinrPerceived, dlPhy));
891  dlPhy->AddCtrlSinrChunkProcessor(pCtrl);
892 
893  Ptr<LteChunkProcessor> pData = Create<LteChunkProcessor>();
894  pData->AddCallback(MakeCallback(&LteSpectrumPhy::UpdateSinrPerceived, dlPhy));
895  dlPhy->AddDataSinrChunkProcessor(pData);
896 
898  {
899  // CQI calculation based on PDCCH for signal and PDSCH for interference
900  // NOTE: Change in pCtrl chunk processor could impact the RLF detection
901  // since it is based on CTRL SINR.
902  pCtrl->AddCallback(MakeCallback(&LteUePhy::GenerateMixedCqiReport, phy));
903  Ptr<LteChunkProcessor> pDataInterf = Create<LteChunkProcessor>();
904  pDataInterf->AddCallback(MakeCallback(&LteUePhy::ReportDataInterference, phy));
905  dlPhy->AddInterferenceDataChunkProcessor(pDataInterf);
906  }
907  else
908  {
909  // CQI calculation based on PDCCH for both signal and interference
910  pCtrl->AddCallback(MakeCallback(&LteUePhy::GenerateCtrlCqiReport, phy));
911  }
912 
913  dlPhy->SetChannel(m_downlinkChannel);
914  ulPhy->SetChannel(m_uplinkChannel);
915 
918  mm,
919  "MobilityModel needs to be set on node before calling LteHelper::InstallUeDevice ()");
920  dlPhy->SetMobility(mm);
921  ulPhy->SetMobility(mm);
922 
923  Ptr<AntennaModel> antenna = (m_ueAntennaModelFactory.Create())->GetObject<AntennaModel>();
924  NS_ASSERT_MSG(antenna, "error in creating the AntennaModel object");
925  dlPhy->SetAntenna(antenna);
926  ulPhy->SetAntenna(antenna);
927 
928  it->second->SetPhy(phy);
929  }
932 
933  Ptr<LteUeRrc> rrc = CreateObject<LteUeRrc>();
934  rrc->SetLteMacSapProvider(ccmUe->GetLteMacSapProvider());
935  // setting ComponentCarrierManager SAP
936  rrc->SetLteCcmRrcSapProvider(ccmUe->GetLteCcmRrcSapProvider());
937  ccmUe->SetLteCcmRrcSapUser(rrc->GetLteCcmRrcSapUser());
938  // Set number of component carriers. Note: UE CCM would also set the
939  // number of component carriers in UE RRC
940  ccmUe->SetNumberOfComponentCarriers(m_noOfCcs);
941 
942  // run intializeSap to create the proper number of MAC and PHY control sap provider/users
943  rrc->InitializeSap();
944 
945  if (m_useIdealRrc)
946  {
947  Ptr<LteUeRrcProtocolIdeal> rrcProtocol = CreateObject<LteUeRrcProtocolIdeal>();
948  rrcProtocol->SetUeRrc(rrc);
949  rrc->AggregateObject(rrcProtocol);
950  rrcProtocol->SetLteUeRrcSapProvider(rrc->GetLteUeRrcSapProvider());
951  rrc->SetLteUeRrcSapUser(rrcProtocol->GetLteUeRrcSapUser());
952  }
953  else
954  {
955  Ptr<LteUeRrcProtocolReal> rrcProtocol = CreateObject<LteUeRrcProtocolReal>();
956  rrcProtocol->SetUeRrc(rrc);
957  rrc->AggregateObject(rrcProtocol);
958  rrcProtocol->SetLteUeRrcSapProvider(rrc->GetLteUeRrcSapProvider());
959  rrc->SetLteUeRrcSapUser(rrcProtocol->GetLteUeRrcSapUser());
960  }
961 
962  if (m_epcHelper)
963  {
964  rrc->SetUseRlcSm(false);
965  }
966  Ptr<EpcUeNas> nas = CreateObject<EpcUeNas>();
967 
968  nas->SetAsSapProvider(rrc->GetAsSapProvider());
969  rrc->SetAsSapUser(nas->GetAsSapUser());
970 
971  for (std::map<uint8_t, Ptr<ComponentCarrierUe>>::iterator it = ueCcMap.begin();
972  it != ueCcMap.end();
973  ++it)
974  {
975  rrc->SetLteUeCmacSapProvider(it->second->GetMac()->GetLteUeCmacSapProvider(), it->first);
976  it->second->GetMac()->SetLteUeCmacSapUser(rrc->GetLteUeCmacSapUser(it->first));
977  it->second->GetMac()->SetComponentCarrierId(it->first);
978 
979  it->second->GetPhy()->SetLteUeCphySapUser(rrc->GetLteUeCphySapUser(it->first));
980  rrc->SetLteUeCphySapProvider(it->second->GetPhy()->GetLteUeCphySapProvider(), it->first);
981  it->second->GetPhy()->SetComponentCarrierId(it->first);
982  it->second->GetPhy()->SetLteUePhySapUser(it->second->GetMac()->GetLteUePhySapUser());
983  it->second->GetMac()->SetLteUePhySapProvider(
984  it->second->GetPhy()->GetLteUePhySapProvider());
985 
986  bool ccmTest =
987  ccmUe->SetComponentCarrierMacSapProviders(it->first,
988  it->second->GetMac()->GetLteMacSapProvider());
989 
990  if (ccmTest == false)
991  {
992  NS_FATAL_ERROR("Error in SetComponentCarrierMacSapProviders");
993  }
994  }
995 
996  NS_ABORT_MSG_IF(m_imsiCounter >= 0xFFFFFFFF, "max num UEs exceeded");
997  uint64_t imsi = ++m_imsiCounter;
998 
999  dev->SetNode(n);
1000  dev->SetAttribute("Imsi", UintegerValue(imsi));
1001  dev->SetCcMap(ueCcMap);
1002  dev->SetAttribute("LteUeRrc", PointerValue(rrc));
1003  dev->SetAttribute("EpcUeNas", PointerValue(nas));
1004  dev->SetAttribute("LteUeComponentCarrierManager", PointerValue(ccmUe));
1005  // \todo The UE identifier should be dynamically set by the EPC
1006  // when the default PDP context is created. This is a simplification.
1007  dev->SetAddress(Mac64Address::Allocate());
1008 
1009  for (std::map<uint8_t, Ptr<ComponentCarrierUe>>::iterator it = ueCcMap.begin();
1010  it != ueCcMap.end();
1011  ++it)
1012  {
1013  Ptr<LteUePhy> ccPhy = it->second->GetPhy();
1014  ccPhy->SetDevice(dev);
1015  ccPhy->GetUlSpectrumPhy()->SetDevice(dev);
1016  ccPhy->GetDlSpectrumPhy()->SetDevice(dev);
1017  ccPhy->GetDlSpectrumPhy()->SetLtePhyRxDataEndOkCallback(
1019  ccPhy->GetDlSpectrumPhy()->SetLtePhyRxCtrlEndOkCallback(
1021  ccPhy->GetDlSpectrumPhy()->SetLtePhyRxPssCallback(
1023  ccPhy->GetDlSpectrumPhy()->SetLtePhyDlHarqFeedbackCallback(
1025  }
1026 
1027  nas->SetDevice(dev);
1028 
1029  n->AddDevice(dev);
1030 
1031  nas->SetForwardUpCallback(MakeCallback(&LteUeNetDevice::Receive, dev));
1032 
1033  if (m_epcHelper)
1034  {
1035  m_epcHelper->AddUe(dev, dev->GetImsi());
1036  }
1037 
1038  dev->Initialize();
1039 
1040  return dev;
1041 }
1042 
1043 void
1045 {
1046  NS_LOG_FUNCTION(this);
1047  for (NetDeviceContainer::Iterator i = ueDevices.Begin(); i != ueDevices.End(); ++i)
1048  {
1049  Attach(*i);
1050  }
1051 }
1052 
1053 void
1055 {
1056  NS_LOG_FUNCTION(this);
1057 
1058  if (!m_epcHelper)
1059  {
1060  NS_FATAL_ERROR("This function is not valid without properly configured EPC");
1061  }
1062 
1063  Ptr<LteUeNetDevice> ueLteDevice = ueDevice->GetObject<LteUeNetDevice>();
1064  if (!ueLteDevice)
1065  {
1066  NS_FATAL_ERROR("The passed NetDevice must be an LteUeNetDevice");
1067  }
1068 
1069  // initiate cell selection
1070  Ptr<EpcUeNas> ueNas = ueLteDevice->GetNas();
1071  NS_ASSERT(ueNas);
1072  uint32_t dlEarfcn = ueLteDevice->GetDlEarfcn();
1073  ueNas->StartCellSelection(dlEarfcn);
1074 
1075  // instruct UE to immediately enter CONNECTED mode after camping
1076  ueNas->Connect();
1077 
1078  // activate default EPS bearer
1079  m_epcHelper->ActivateEpsBearer(ueDevice,
1080  ueLteDevice->GetImsi(),
1081  EpcTft::Default(),
1083 }
1084 
1085 void
1087 {
1088  NS_LOG_FUNCTION(this);
1089  for (NetDeviceContainer::Iterator i = ueDevices.Begin(); i != ueDevices.End(); ++i)
1090  {
1091  Attach(*i, enbDevice);
1092  }
1093 }
1094 
1095 void
1096 LteHelper::Attach(Ptr<NetDevice> ueDevice, Ptr<NetDevice> enbDevice, uint8_t componentCarrierId)
1097 {
1098  NS_LOG_FUNCTION(this);
1099  // enbRrc->SetCellId (enbDevice->GetObject<LteEnbNetDevice> ()->GetCellId ());
1100 
1101  Ptr<LteUeNetDevice> ueLteDevice = ueDevice->GetObject<LteUeNetDevice>();
1102  Ptr<LteEnbNetDevice> enbLteDevice = enbDevice->GetObject<LteEnbNetDevice>();
1103 
1104  Ptr<EpcUeNas> ueNas = ueLteDevice->GetNas();
1105  Ptr<ComponentCarrierEnb> componentCarrier =
1106  DynamicCast<ComponentCarrierEnb>(enbLteDevice->GetCcMap().at(componentCarrierId));
1107  ueNas->Connect(componentCarrier->GetCellId(), componentCarrier->GetDlEarfcn());
1108 
1109  if (m_epcHelper)
1110  {
1111  // activate default EPS bearer
1112  m_epcHelper->ActivateEpsBearer(ueDevice,
1113  ueLteDevice->GetImsi(),
1114  EpcTft::Default(),
1116  }
1117 
1118  // tricks needed for the simplified LTE-only simulations
1119  if (!m_epcHelper)
1120  {
1121  ueDevice->GetObject<LteUeNetDevice>()->SetTargetEnb(
1122  enbDevice->GetObject<LteEnbNetDevice>());
1123  }
1124 }
1125 
1126 void
1128 {
1129  NS_LOG_FUNCTION(this);
1130  for (NetDeviceContainer::Iterator i = ueDevices.Begin(); i != ueDevices.End(); ++i)
1131  {
1132  AttachToClosestEnb(*i, enbDevices);
1133  }
1134 }
1135 
1136 void
1138 {
1139  NS_LOG_FUNCTION(this);
1140  NS_ASSERT_MSG(enbDevices.GetN() > 0, "empty enb device container");
1141  Vector uepos = ueDevice->GetNode()->GetObject<MobilityModel>()->GetPosition();
1142  double minDistance = std::numeric_limits<double>::infinity();
1143  Ptr<NetDevice> closestEnbDevice;
1144  for (NetDeviceContainer::Iterator i = enbDevices.Begin(); i != enbDevices.End(); ++i)
1145  {
1146  Vector enbpos = (*i)->GetNode()->GetObject<MobilityModel>()->GetPosition();
1147  double distance = CalculateDistance(uepos, enbpos);
1148  if (distance < minDistance)
1149  {
1150  minDistance = distance;
1151  closestEnbDevice = *i;
1152  }
1153  }
1154  NS_ASSERT(closestEnbDevice);
1155  Attach(ueDevice, closestEnbDevice);
1156 }
1157 
1158 uint8_t
1160  EpsBearer bearer,
1161  Ptr<EpcTft> tft)
1162 {
1163  NS_LOG_FUNCTION(this);
1164  for (NetDeviceContainer::Iterator i = ueDevices.Begin(); i != ueDevices.End(); ++i)
1165  {
1166  uint8_t bearerId = ActivateDedicatedEpsBearer(*i, bearer, tft);
1167  return bearerId;
1168  }
1169  return 0;
1170 }
1171 
1172 uint8_t
1174 {
1175  NS_LOG_FUNCTION(this);
1176 
1177  NS_ASSERT_MSG(m_epcHelper, "dedicated EPS bearers cannot be set up when the EPC is not used");
1178 
1179  uint64_t imsi = ueDevice->GetObject<LteUeNetDevice>()->GetImsi();
1180  uint8_t bearerId = m_epcHelper->ActivateEpsBearer(ueDevice, imsi, tft, bearer);
1181  return bearerId;
1182 }
1183 
1193 class DrbActivator : public SimpleRefCount<DrbActivator>
1194 {
1195  public:
1202  DrbActivator(Ptr<NetDevice> ueDevice, EpsBearer bearer);
1203 
1214  static void ActivateCallback(Ptr<DrbActivator> a,
1215  std::string context,
1216  uint64_t imsi,
1217  uint16_t cellId,
1218  uint16_t rnti);
1219 
1230  void ActivateDrb(uint64_t imsi, uint16_t cellId, uint16_t rnti);
1231 
1232  private:
1238  bool m_active;
1250  uint64_t m_imsi;
1251 };
1252 
1254  : m_active(false),
1255  m_ueDevice(ueDevice),
1256  m_bearer(bearer),
1257  m_imsi(m_ueDevice->GetObject<LteUeNetDevice>()->GetImsi())
1258 {
1259 }
1260 
1261 void
1263  std::string context,
1264  uint64_t imsi,
1265  uint16_t cellId,
1266  uint16_t rnti)
1267 {
1268  NS_LOG_FUNCTION(a << context << imsi << cellId << rnti);
1269  a->ActivateDrb(imsi, cellId, rnti);
1270 }
1271 
1272 void
1273 DrbActivator::ActivateDrb(uint64_t imsi, uint16_t cellId, uint16_t rnti)
1274 {
1275  NS_LOG_FUNCTION(this << imsi << cellId << rnti << m_active);
1276  if ((!m_active) && (imsi == m_imsi))
1277  {
1278  Ptr<LteUeRrc> ueRrc = m_ueDevice->GetObject<LteUeNetDevice>()->GetRrc();
1279  NS_ASSERT(ueRrc->GetState() == LteUeRrc::CONNECTED_NORMALLY);
1280  uint16_t rnti = ueRrc->GetRnti();
1281  Ptr<LteEnbNetDevice> enbLteDevice = m_ueDevice->GetObject<LteUeNetDevice>()->GetTargetEnb();
1282  Ptr<LteEnbRrc> enbRrc = enbLteDevice->GetObject<LteEnbNetDevice>()->GetRrc();
1283  NS_ASSERT(ueRrc->GetCellId() == enbLteDevice->GetCellId());
1284  Ptr<UeManager> ueManager = enbRrc->GetUeManager(rnti);
1285  NS_ASSERT(ueManager->GetState() == UeManager::CONNECTED_NORMALLY ||
1286  ueManager->GetState() == UeManager::CONNECTION_RECONFIGURATION);
1288  params.rnti = rnti;
1289  params.bearer = m_bearer;
1290  params.bearerId = 0;
1291  params.gtpTeid = 0; // don't care
1292  enbRrc->GetS1SapUser()->DataRadioBearerSetupRequest(params);
1293  m_active = true;
1294  }
1295 }
1296 
1297 void
1299 {
1300  NS_LOG_FUNCTION(this << ueDevice);
1301  NS_ASSERT_MSG(!m_epcHelper, "this method must not be used when the EPC is being used");
1302 
1303  // Normally it is the EPC that takes care of activating DRBs
1304  // when the UE gets connected. When the EPC is not used, we achieve
1305  // the same behavior by hooking a dedicated DRB activation function
1306  // to the Enb RRC Connection Established trace source
1307 
1308  Ptr<LteEnbNetDevice> enbLteDevice = ueDevice->GetObject<LteUeNetDevice>()->GetTargetEnb();
1309 
1310  std::ostringstream path;
1311  path << "/NodeList/" << enbLteDevice->GetNode()->GetId() << "/DeviceList/"
1312  << enbLteDevice->GetIfIndex() << "/LteEnbRrc/ConnectionEstablished";
1313  Ptr<DrbActivator> arg = Create<DrbActivator>(ueDevice, bearer);
1315 }
1316 
1317 void
1319 {
1320  NS_LOG_FUNCTION(this);
1321 
1322  NS_ASSERT_MSG(m_epcHelper, "X2 interfaces cannot be set up when the EPC is not used");
1323 
1324  for (NodeContainer::Iterator i = enbNodes.Begin(); i != enbNodes.End(); ++i)
1325  {
1326  for (NodeContainer::Iterator j = i + 1; j != enbNodes.End(); ++j)
1327  {
1328  AddX2Interface(*i, *j);
1329  }
1330  }
1331 }
1332 
1333 void
1335 {
1336  NS_LOG_FUNCTION(this);
1337  NS_LOG_INFO("setting up the X2 interface");
1338 
1339  m_epcHelper->AddX2Interface(enbNode1, enbNode2);
1340 }
1341 
1342 void
1344  Ptr<NetDevice> ueDev,
1345  Ptr<NetDevice> sourceEnbDev,
1346  Ptr<NetDevice> targetEnbDev)
1347 {
1348  NS_LOG_FUNCTION(this << ueDev << sourceEnbDev << targetEnbDev);
1350  "Handover requires the use of the EPC - did you forget to call "
1351  "LteHelper::SetEpcHelper () ?");
1352  uint16_t targetCellId = targetEnbDev->GetObject<LteEnbNetDevice>()->GetCellId();
1353  Simulator::Schedule(hoTime,
1355  this,
1356  ueDev,
1357  sourceEnbDev,
1358  targetCellId);
1359 }
1360 
1361 void
1363  Ptr<NetDevice> ueDev,
1364  Ptr<NetDevice> sourceEnbDev,
1365  uint16_t targetCellId)
1366 {
1367  NS_LOG_FUNCTION(this << ueDev << sourceEnbDev << targetCellId);
1369  "Handover requires the use of the EPC - did you forget to call "
1370  "LteHelper::SetEpcHelper () ?");
1371  Simulator::Schedule(hoTime,
1373  this,
1374  ueDev,
1375  sourceEnbDev,
1376  targetCellId);
1377 }
1378 
1379 void
1381  Ptr<NetDevice> sourceEnbDev,
1382  uint16_t targetCellId)
1383 {
1384  NS_LOG_FUNCTION(this << ueDev << sourceEnbDev << targetCellId);
1385 
1386  Ptr<LteEnbRrc> sourceRrc = sourceEnbDev->GetObject<LteEnbNetDevice>()->GetRrc();
1387  uint16_t rnti = ueDev->GetObject<LteUeNetDevice>()->GetRrc()->GetRnti();
1388  sourceRrc->SendHandoverRequest(rnti, targetCellId);
1389 }
1390 
1391 void
1393  Ptr<NetDevice> enbDevice,
1394  uint8_t bearerId)
1395 {
1396  NS_LOG_FUNCTION(this << ueDevice << bearerId);
1398  "Dedicated EPS bearers cannot be de-activated when the EPC is not used");
1399  NS_ASSERT_MSG(bearerId != 1,
1400  "Default bearer cannot be de-activated until and unless and UE is released");
1401 
1402  DoDeActivateDedicatedEpsBearer(ueDevice, enbDevice, bearerId);
1403 }
1404 
1405 void
1407  Ptr<NetDevice> enbDevice,
1408  uint8_t bearerId)
1409 {
1410  NS_LOG_FUNCTION(this << ueDevice << bearerId);
1411 
1412  // Extract IMSI and rnti
1413  uint64_t imsi = ueDevice->GetObject<LteUeNetDevice>()->GetImsi();
1414  uint16_t rnti = ueDevice->GetObject<LteUeNetDevice>()->GetRrc()->GetRnti();
1415 
1416  Ptr<LteEnbRrc> enbRrc = enbDevice->GetObject<LteEnbNetDevice>()->GetRrc();
1417 
1418  enbRrc->DoSendReleaseDataRadioBearer(imsi, rnti, bearerId);
1419 }
1420 
1421 void
1423  uint32_t dlEarfcn,
1424  uint16_t ulbw,
1425  uint16_t dlbw)
1426 {
1427  NS_LOG_FUNCTION(this << ulEarfcn << dlEarfcn << ulbw << dlbw);
1428 
1429  NS_ABORT_MSG_IF(!m_componentCarrierPhyParams.empty(), "CC map is not clean");
1430  Ptr<CcHelper> ccHelper = CreateObject<CcHelper>();
1431  ccHelper->SetNumberOfComponentCarriers(m_noOfCcs);
1432  ccHelper->SetUlEarfcn(ulEarfcn);
1433  ccHelper->SetDlEarfcn(dlEarfcn);
1434  ccHelper->SetDlBandwidth(dlbw);
1435  ccHelper->SetUlBandwidth(ulbw);
1436  m_componentCarrierPhyParams = ccHelper->EquallySpacedCcs();
1437  m_componentCarrierPhyParams.at(0).SetAsPrimary(true);
1438 }
1439 
1440 void
1442 {
1443  NS_LOG_FUNCTION(this);
1444  for (NetDeviceContainer::Iterator i = ueDevices.Begin(); i != ueDevices.End(); ++i)
1445  {
1446  ActivateDataRadioBearer(*i, bearer);
1447  }
1448 }
1449 
1450 void
1452 {
1456  // Model directory
1457  LogComponentEnable("A2A4RsrqHandoverAlgorithm", LOG_LEVEL_ALL);
1458  LogComponentEnable("A3RsrpHandoverAlgorithm", LOG_LEVEL_ALL);
1459  LogComponentEnable("Asn1Header", LOG_LEVEL_ALL);
1460  LogComponentEnable("ComponentCarrier", LOG_LEVEL_ALL);
1461  LogComponentEnable("ComponentCarrierEnb", LOG_LEVEL_ALL);
1462  LogComponentEnable("ComponentCarrierUe", LOG_LEVEL_ALL);
1463  LogComponentEnable("CqaFfMacScheduler", LOG_LEVEL_ALL);
1464  LogComponentEnable("EpcEnbApplication", LOG_LEVEL_ALL);
1465  LogComponentEnable("EpcMmeApplication", LOG_LEVEL_ALL);
1466  LogComponentEnable("EpcPgwApplication", LOG_LEVEL_ALL);
1467  LogComponentEnable("EpcSgwApplication", LOG_LEVEL_ALL);
1468  LogComponentEnable("EpcTft", LOG_LEVEL_ALL);
1469  LogComponentEnable("EpcTftClassifier", LOG_LEVEL_ALL);
1470  LogComponentEnable("EpcUeNas", LOG_LEVEL_ALL);
1472  LogComponentEnable("EpcX2Header", LOG_LEVEL_ALL);
1473  LogComponentEnable("FdBetFfMacScheduler", LOG_LEVEL_ALL);
1474  LogComponentEnable("FdMtFfMacScheduler", LOG_LEVEL_ALL);
1475  LogComponentEnable("FdTbfqFfMacScheduler", LOG_LEVEL_ALL);
1476  LogComponentEnable("FfMacScheduler", LOG_LEVEL_ALL);
1477  LogComponentEnable("GtpuHeader", LOG_LEVEL_ALL);
1478  LogComponentEnable("LteAmc", LOG_LEVEL_ALL);
1479  LogComponentEnable("LteAnr", LOG_LEVEL_ALL);
1480  LogComponentEnable("LteChunkProcessor", LOG_LEVEL_ALL);
1481  LogComponentEnable("LteCommon", LOG_LEVEL_ALL);
1482  LogComponentEnable("LteControlMessage", LOG_LEVEL_ALL);
1483  LogComponentEnable("LteEnbComponentCarrierManager", LOG_LEVEL_ALL);
1484  LogComponentEnable("LteEnbMac", LOG_LEVEL_ALL);
1485  LogComponentEnable("LteEnbNetDevice", LOG_LEVEL_ALL);
1486  LogComponentEnable("LteEnbPhy", LOG_LEVEL_ALL);
1487  LogComponentEnable("LteEnbRrc", LOG_LEVEL_ALL);
1488  LogComponentEnable("LteFfrAlgorithm", LOG_LEVEL_ALL);
1489  LogComponentEnable("LteFfrDistributedAlgorithm", LOG_LEVEL_ALL);
1490  LogComponentEnable("LteFfrEnhancedAlgorithm", LOG_LEVEL_ALL);
1491  LogComponentEnable("LteFfrSoftAlgorithm", LOG_LEVEL_ALL);
1492  LogComponentEnable("LteFrHardAlgorithm", LOG_LEVEL_ALL);
1493  LogComponentEnable("LteFrNoOpAlgorithm", LOG_LEVEL_ALL);
1494  LogComponentEnable("LteFrSoftAlgorithm", LOG_LEVEL_ALL);
1495  LogComponentEnable("LteFrStrictAlgorithm", LOG_LEVEL_ALL);
1496  LogComponentEnable("LteHandoverAlgorithm", LOG_LEVEL_ALL);
1497  LogComponentEnable("LteHarqPhy", LOG_LEVEL_ALL);
1498  LogComponentEnable("LteInterference", LOG_LEVEL_ALL);
1499  LogComponentEnable("LteMiErrorModel", LOG_LEVEL_ALL);
1500  LogComponentEnable("LteNetDevice", LOG_LEVEL_ALL);
1501  LogComponentEnable("LtePdcp", LOG_LEVEL_ALL);
1502  LogComponentEnable("LtePdcpHeader", LOG_LEVEL_ALL);
1503  LogComponentEnable("LtePhy", LOG_LEVEL_ALL);
1504  LogComponentEnable("LteRlc", LOG_LEVEL_ALL);
1505  LogComponentEnable("LteRlcAm", LOG_LEVEL_ALL);
1506  LogComponentEnable("LteRlcAmHeader", LOG_LEVEL_ALL);
1507  LogComponentEnable("LteRlcHeader", LOG_LEVEL_ALL);
1508  LogComponentEnable("LteRlcTm", LOG_LEVEL_ALL);
1509  LogComponentEnable("LteRlcUm", LOG_LEVEL_ALL);
1510  LogComponentEnable("LteRrcProtocolIdeal", LOG_LEVEL_ALL);
1511  LogComponentEnable("LteRrcProtocolReal", LOG_LEVEL_ALL);
1512  LogComponentEnable("LteSpectrumPhy", LOG_LEVEL_ALL);
1513  LogComponentEnable("LteSpectrumSignalParameters", LOG_LEVEL_ALL);
1514  LogComponentEnable("LteSpectrumValueHelper", LOG_LEVEL_ALL);
1515  LogComponentEnable("LteUeComponentCarrierManager", LOG_LEVEL_ALL);
1516  LogComponentEnable("LteUeMac", LOG_LEVEL_ALL);
1517  LogComponentEnable("LteUeNetDevice", LOG_LEVEL_ALL);
1518  LogComponentEnable("LteUePhy", LOG_LEVEL_ALL);
1519  LogComponentEnable("LteUePowerControl", LOG_LEVEL_ALL);
1520  LogComponentEnable("LteUeRrc", LOG_LEVEL_ALL);
1521  LogComponentEnable("LteVendorSpecificParameters", LOG_LEVEL_ALL);
1522  LogComponentEnable("NoOpComponentCarrierManager", LOG_LEVEL_ALL);
1523  LogComponentEnable("NoOpHandoverAlgorithm", LOG_LEVEL_ALL);
1524  LogComponentEnable("PfFfMacScheduler", LOG_LEVEL_ALL);
1525  LogComponentEnable("PssFfMacScheduler", LOG_LEVEL_ALL);
1526  LogComponentEnable("RemSpectrumPhy", LOG_LEVEL_ALL);
1527  LogComponentEnable("RrcHeader", LOG_LEVEL_ALL);
1528  LogComponentEnable("RrFfMacScheduler", LOG_LEVEL_ALL);
1529  LogComponentEnable("SimpleUeComponentCarrierManager", LOG_LEVEL_ALL);
1530  LogComponentEnable("TdBetFfMacScheduler", LOG_LEVEL_ALL);
1531  LogComponentEnable("TdMtFfMacScheduler", LOG_LEVEL_ALL);
1532  LogComponentEnable("TdTbfqFfMacScheduler", LOG_LEVEL_ALL);
1533  LogComponentEnable("TraceFadingLossModel", LOG_LEVEL_ALL);
1534  LogComponentEnable("TtaFfMacScheduler", LOG_LEVEL_ALL);
1535  // Helper directory
1536  LogComponentEnable("CcHelper", LOG_LEVEL_ALL);
1537  LogComponentEnable("EmuEpcHelper", LOG_LEVEL_ALL);
1538  LogComponentEnable("EpcHelper", LOG_LEVEL_ALL);
1539  LogComponentEnable("LteGlobalPathlossDatabase", LOG_LEVEL_ALL);
1540  LogComponentEnable("LteHelper", LOG_LEVEL_ALL);
1541  LogComponentEnable("LteHexGridEnbTopologyHelper", LOG_LEVEL_ALL);
1542  LogComponentEnable("LteStatsCalculator", LOG_LEVEL_ALL);
1543  LogComponentEnable("MacStatsCalculator", LOG_LEVEL_ALL);
1544  LogComponentEnable("PhyRxStatsCalculator", LOG_LEVEL_ALL);
1545  LogComponentEnable("PhyStatsCalculator", LOG_LEVEL_ALL);
1546  LogComponentEnable("PhyTxStatsCalculator", LOG_LEVEL_ALL);
1547  LogComponentEnable("PointToPointEpcHelper", LOG_LEVEL_ALL);
1548  LogComponentEnable("RadioBearerStatsCalculator", LOG_LEVEL_ALL);
1549  LogComponentEnable("RadioBearerStatsConnector", LOG_LEVEL_ALL);
1550  LogComponentEnable("RadioEnvironmentMapHelper", LOG_LEVEL_ALL);
1551 }
1552 
1553 void
1555 {
1556  EnablePhyTraces();
1557  EnableMacTraces();
1558  EnableRlcTraces();
1559  EnablePdcpTraces();
1560 }
1561 
1562 void
1564 {
1566  "please make sure that LteHelper::EnableRlcTraces is called at most once");
1567  m_rlcStats = CreateObject<RadioBearerStatsCalculator>("RLC");
1569 }
1570 
1571 int64_t
1573 {
1574  int64_t currentStream = stream;
1575  if (m_fadingModel && (m_fadingStreamsAssigned == false))
1576  {
1578  if (tflm)
1579  {
1580  currentStream += tflm->AssignStreams(currentStream);
1581  m_fadingStreamsAssigned = true;
1582  }
1583  }
1584  Ptr<NetDevice> netDevice;
1585  for (NetDeviceContainer::Iterator i = c.Begin(); i != c.End(); ++i)
1586  {
1587  netDevice = (*i);
1588  Ptr<LteEnbNetDevice> lteEnb = DynamicCast<LteEnbNetDevice>(netDevice);
1589  if (lteEnb)
1590  {
1591  std::map<uint8_t, Ptr<ComponentCarrierBaseStation>> tmpMap = lteEnb->GetCcMap();
1592  std::map<uint8_t, Ptr<ComponentCarrierBaseStation>>::iterator it;
1593  it = tmpMap.begin();
1594  Ptr<LteSpectrumPhy> dlPhy =
1595  DynamicCast<ComponentCarrierEnb>(it->second)->GetPhy()->GetDownlinkSpectrumPhy();
1596  Ptr<LteSpectrumPhy> ulPhy =
1597  DynamicCast<ComponentCarrierEnb>(it->second)->GetPhy()->GetUplinkSpectrumPhy();
1598  currentStream += dlPhy->AssignStreams(currentStream);
1599  currentStream += ulPhy->AssignStreams(currentStream);
1600  }
1601  Ptr<LteUeNetDevice> lteUe = DynamicCast<LteUeNetDevice>(netDevice);
1602  if (lteUe)
1603  {
1604  std::map<uint8_t, Ptr<ComponentCarrierUe>> tmpMap = lteUe->GetCcMap();
1605  std::map<uint8_t, Ptr<ComponentCarrierUe>>::iterator it;
1606  it = tmpMap.begin();
1607  Ptr<LteSpectrumPhy> dlPhy = it->second->GetPhy()->GetDownlinkSpectrumPhy();
1608  Ptr<LteSpectrumPhy> ulPhy = it->second->GetPhy()->GetUplinkSpectrumPhy();
1609  Ptr<LteUeMac> ueMac = lteUe->GetMac();
1610  currentStream += dlPhy->AssignStreams(currentStream);
1611  currentStream += ulPhy->AssignStreams(currentStream);
1612  currentStream += ueMac->AssignStreams(currentStream);
1613  }
1614  }
1615  if (m_epcHelper)
1616  {
1617  currentStream += m_epcHelper->AssignStreams(currentStream);
1618  }
1619  return (currentStream - stream);
1620 }
1621 
1622 void
1624 {
1631 }
1632 
1633 void
1635 {
1637  "/NodeList/*/DeviceList/*/ComponentCarrierMap/*/LteEnbPhy/DlPhyTransmission",
1639 }
1640 
1641 void
1643 {
1645  "/NodeList/*/DeviceList/*/ComponentCarrierMapUe/*/LteUePhy/UlPhyTransmission",
1647 }
1648 
1649 void
1651 {
1653  "/NodeList/*/DeviceList/*/ComponentCarrierMapUe/*/LteUePhy/DlSpectrumPhy/DlPhyReception",
1655 }
1656 
1657 void
1659 {
1661  "/NodeList/*/DeviceList/*/ComponentCarrierMap/*/LteEnbPhy/UlSpectrumPhy/UlPhyReception",
1663 }
1664 
1665 void
1667 {
1670 }
1671 
1672 void
1674 {
1676  Config::Connect("/NodeList/*/DeviceList/*/ComponentCarrierMap/*/LteEnbMac/DlScheduling",
1678 }
1679 
1680 void
1682 {
1684  Config::Connect("/NodeList/*/DeviceList/*/ComponentCarrierMap/*/LteEnbMac/UlScheduling",
1686 }
1687 
1688 void
1690 {
1693  "/NodeList/*/DeviceList/*/ComponentCarrierMapUe/*/LteUePhy/ReportCurrentCellRsrpSinr",
1695 }
1696 
1697 void
1699 {
1701  Config::Connect("/NodeList/*/DeviceList/*/ComponentCarrierMap/*/LteEnbPhy/ReportUeSinr",
1703  Config::Connect("/NodeList/*/DeviceList/*/ComponentCarrierMap/*/LteEnbPhy/ReportInterference",
1705 }
1706 
1709 {
1710  return m_rlcStats;
1711 }
1712 
1713 void
1715 {
1717  "please make sure that LteHelper::EnablePdcpTraces is called at most once");
1718  m_pdcpStats = CreateObject<RadioBearerStatsCalculator>("PDCP");
1720 }
1721 
1724 {
1725  return m_pdcpStats;
1726 }
1727 
1728 } // namespace ns3
Hold a value for an Attribute.
Definition: attribute.h:70
AttributeValue implementation for Boolean.
Definition: boolean.h:37
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition: double.h:42
DrbActivatior allows user to activate bearers for UEs when EPC is not used.
Definition: lte-helper.cc:1194
EpsBearer m_bearer
Configuration of bearer which will be activated.
Definition: lte-helper.cc:1246
uint64_t m_imsi
imsi the unique UE identifier
Definition: lte-helper.cc:1250
DrbActivator(Ptr< NetDevice > ueDevice, EpsBearer bearer)
DrbActivator Constructor.
Definition: lte-helper.cc:1253
static void ActivateCallback(Ptr< DrbActivator > a, std::string context, uint64_t imsi, uint16_t cellId, uint16_t rnti)
Function hooked to the Enb RRC Connection Established trace source Fired upon successful RRC connecti...
Definition: lte-helper.cc:1262
Ptr< NetDevice > m_ueDevice
UeNetDevice for which bearer will be activated.
Definition: lte-helper.cc:1242
void ActivateDrb(uint64_t imsi, uint16_t cellId, uint16_t rnti)
Procedure firstly checks if bearer was not activated, if IMSI from trace source equals configured one...
Definition: lte-helper.cc:1273
bool m_active
Bearer can be activated only once.
Definition: lte-helper.cc:1238
Hold variables of type enum.
Definition: enum.h:56
int Get() const
Definition: enum.cc:59
This application is installed inside eNBs and provides the bridge functionality for user data plane p...
static Ptr< EpcTft > Default()
creates a TFT matching any traffic
Definition: epc-tft.cc:229
This entity is installed inside an eNB and provides the functionality for the X2 interface.
Definition: epc-x2.h:98
This class contains the specification of EPS Bearers.
Definition: eps-bearer.h:91
@ NGBR_VIDEO_TCP_DEFAULT
Non-GBR TCP-based Video (Buffered Streaming, e.g., www, e-mail...)
Definition: eps-bearer.h:121
This abstract base class identifies the interface by means of which the helper object can plug on the...
static TypeId GetTypeId()
Get the type ID.
static TypeId GetTypeId()
Get the type ID.
The class implements Component Carrier Manager (CCM) that operates using the Component Carrier Manage...
The eNodeB device implementation.
std::map< uint8_t, Ptr< ComponentCarrierBaseStation > > GetCcMap() const
uint16_t GetDlBandwidth() const
uint32_t GetUlEarfcn() const
uint32_t GetDlEarfcn() const
void SetCcMap(std::map< uint8_t, Ptr< ComponentCarrierBaseStation >> ccm)
Set the ComponentCarrier Map of the Enb.
uint16_t GetUlBandwidth() const
std::vector< uint16_t > GetCellIds() const
static TypeId GetTypeId()
Get the type ID.
uint16_t GetCellId() const
virtual void ReportUlHarqFeedback(UlInfoListElement_s mes)
Report the uplink HARQ feedback generated by LteSpectrumPhy to MAC.
virtual void ReceiveLteControlMessageList(std::list< Ptr< LteControlMessage >> msgList)
PhySpectrum received a new list of LteControlMessage.
Definition: lte-enb-phy.cc:530
void GenerateCtrlCqiReport(const SpectrumValue &sinr) override
generate a CQI report based on the given SINR of Ctrl frame
Definition: lte-enb-phy.cc:836
void GenerateDataCqiReport(const SpectrumValue &sinr) override
generate a CQI report based on the given SINR of Data frame (used for PUSCH CQIs)
Definition: lte-enb-phy.cc:848
void PhyPduReceived(Ptr< Packet > p)
PhySpectrum received a new PHY-PDU.
Definition: lte-enb-phy.cc:432
void ReportInterference(const SpectrumValue &interf) override
generate a report based on the linear interference and noise power perceived during DATA frame NOTE: ...
Definition: lte-enb-phy.cc:856
The abstract base class of a Frequency Reuse algorithm.
The abstract base class of a handover algorithm that operates using the Handover Management SAP inter...
void SetFfrAlgorithmType(std::string type)
Set the type of FFR algorithm to be used by eNodeB devices.
Definition: lte-helper.cc:316
Ptr< SpectrumPropagationLossModel > m_fadingModel
The fading model used in both the downlink and uplink channels.
Definition: lte-helper.h:785
Ptr< Object > m_uplinkPathlossModel
The path loss model used in the uplink channel.
Definition: lte-helper.h:755
void EnableLogComponents()
Enables full-blown logging for major components of the LENA architecture.
Definition: lte-helper.cc:1451
Ptr< SpectrumChannel > GetUplinkSpectrumChannel() const
Definition: lte-helper.cc:215
void SetEnbComponentCarrierManagerType(std::string type)
Set the type of carrier component algorithm to be used by eNodeB devices.
Definition: lte-helper.cc:358
void EnableUlRxPhyTraces()
Enable trace sinks for UL reception PHY layer.
Definition: lte-helper.cc:1658
ObjectFactory m_schedulerFactory
Factory of MAC scheduler object.
Definition: lte-helper.h:758
void SetUeAntennaModelType(std::string type)
Set the type of antenna model to be used by UE devices.
Definition: lte-helper.cc:437
ObjectFactory m_ffrAlgorithmFactory
Factory of FFR (frequency reuse) algorithm object.
Definition: lte-helper.h:760
ObjectFactory m_channelFactory
Factory of both the downlink and uplink LTE channels.
Definition: lte-helper.h:778
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:282
Ptr< RadioBearerStatsCalculator > GetRlcStats()
Definition: lte-helper.cc:1708
ObjectFactory m_handoverAlgorithmFactory
Factory of handover algorithm object.
Definition: lte-helper.h:762
std::string m_fadingModelType
Name of fading model type, e.g., "ns3::TraceFadingLossModel".
Definition: lte-helper.h:781
Ptr< RadioBearerStatsCalculator > GetPdcpStats()
Definition: lte-helper.cc:1723
void EnableDlMacTraces()
Enable trace sinks for DL MAC layer.
Definition: lte-helper.cc:1673
ObjectFactory m_enbComponentCarrierManagerFactory
Factory of enb component carrier manager object.
Definition: lte-helper.h:764
void SetFadingModel(std::string type)
Set the type of fading model to be used in both DL and UL.
Definition: lte-helper.cc:451
void DoDeActivateDedicatedEpsBearer(Ptr< NetDevice > ueDevice, Ptr< NetDevice > enbDevice, uint8_t bearerId)
The actual function to trigger a manual bearer de-activation.
Definition: lte-helper.cc:1406
std::string GetEnbComponentCarrierManagerType() const
Definition: lte-helper.cc:352
void SetSchedulerAttribute(std::string n, const AttributeValue &v)
Set an attribute for the scheduler to be created.
Definition: lte-helper.cc:303
Ptr< SpectrumChannel > GetDownlinkSpectrumChannel() const
Definition: lte-helper.cc:221
~LteHelper() override
Definition: lte-helper.cc:102
std::map< uint8_t, ComponentCarrier > m_componentCarrierPhyParams
This contains all the information about each component carrier.
Definition: lte-helper.h:855
Ptr< MacStatsCalculator > m_macStats
Container of MAC layer statistics.
Definition: lte-helper.h:799
void SetHandoverAlgorithmAttribute(std::string n, const AttributeValue &v)
Set an attribute for the handover algorithm to be created.
Definition: lte-helper.cc:345
void EnablePhyTraces()
Enable trace sinks for PHY layer.
Definition: lte-helper.cc:1623
void DeActivateDedicatedEpsBearer(Ptr< NetDevice > ueDevice, Ptr< NetDevice > enbDevice, uint8_t bearerId)
Manually trigger dedicated bearer de-activation at specific simulation time.
Definition: lte-helper.cc:1392
void HandoverRequest(Time hoTime, Ptr< NetDevice > ueDev, Ptr< NetDevice > sourceEnbDev, Ptr< NetDevice > targetEnbDev)
Manually trigger an X2-based handover.
Definition: lte-helper.cc:1343
Ptr< SpectrumChannel > m_downlinkChannel
This function create the component carrier based on provided configuration parameters.
Definition: lte-helper.h:749
NetDeviceContainer InstallEnbDevice(NodeContainer c)
Create a set of eNodeB devices.
Definition: lte-helper.cc:482
void SetUeComponentCarrierManagerAttribute(std::string n, const AttributeValue &v)
Set an attribute for the ue component carrier manager to be created.
Definition: lte-helper.cc:387
uint16_t m_cellIdCounter
Keep track of the number of cell ID allocated.
Definition: lte-helper.h:825
std::string GetFfrAlgorithmType() const
Definition: lte-helper.cc:310
void SetHandoverAlgorithmType(std::string type)
Set the type of handover algorithm to be used by eNodeB devices.
Definition: lte-helper.cc:337
void SetPathlossModelType(TypeId type)
Set the type of path loss model to be used for both DL and UL channels.
Definition: lte-helper.cc:394
void EnablePdcpTraces()
Enable trace sinks for PDCP layer.
Definition: lte-helper.cc:1714
Ptr< PhyTxStatsCalculator > m_phyTxStats
Container of PHY layer statistics related to transmission.
Definition: lte-helper.h:795
void SetEnbAntennaModelType(std::string type)
Set the type of antenna model to be used by eNodeB devices.
Definition: lte-helper.cc:416
void EnableTraces()
Enables trace sinks for PHY, MAC, RLC and PDCP.
Definition: lte-helper.cc:1554
void SetFfrAlgorithmAttribute(std::string n, const AttributeValue &v)
Set an attribute for the FFR algorithm to be created.
Definition: lte-helper.cc:324
void DoHandoverRequest(Ptr< NetDevice > ueDev, Ptr< NetDevice > sourceEnbDev, uint16_t targetCellId)
The actual function to trigger a manual handover.
Definition: lte-helper.cc:1380
bool m_isAnrEnabled
The AnrEnabled attribute.
Definition: lte-helper.h:836
void SetEnbComponentCarrierManagerAttribute(std::string n, const AttributeValue &v)
Set an attribute for the enb component carrier manager to be created.
Definition: lte-helper.cc:366
void DoInitialize() override
Initialize() implementation.
Definition: lte-helper.cc:91
Ptr< PhyRxStatsCalculator > m_phyRxStats
Container of PHY layer statistics related to reception.
Definition: lte-helper.h:797
void SetSpectrumChannelType(std::string type)
Set the type of spectrum channel to be used in both DL and UL.
Definition: lte-helper.cc:469
void EnableDlRxPhyTraces()
Enable trace sinks for DL reception PHY layer.
Definition: lte-helper.cc:1650
ObjectFactory m_pathlossModelFactory
Factory of path loss model object.
Definition: lte-helper.h:776
bool m_fadingStreamsAssigned
True if a random variable stream number has been assigned for the fading model.
Definition: lte-helper.h:790
std::string GetUeComponentCarrierManagerType() const
Definition: lte-helper.cc:373
void SetSchedulerType(std::string type)
Set the type of scheduler to be used by eNodeB devices.
Definition: lte-helper.cc:289
RadioBearerStatsConnector m_radioBearerStatsConnector
Connects RLC and PDCP statistics containers to appropriate trace sources.
Definition: lte-helper.h:805
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:1044
void DoDispose() override
Destructor implementation.
Definition: lte-helper.cc:205
ObjectFactory m_enbNetDeviceFactory
Factory of LteEnbNetDevice objects.
Definition: lte-helper.h:768
void EnableUlMacTraces()
Enable trace sinks for UL MAC layer.
Definition: lte-helper.cc:1681
std::string GetHandoverAlgorithmType() const
Definition: lte-helper.cc:331
Ptr< PhyStatsCalculator > m_phyStats
Container of PHY layer statistics.
Definition: lte-helper.h:793
void EnableUlPhyTraces()
Enable trace sinks for UL PHY layer.
Definition: lte-helper.cc:1698
void EnableDlTxPhyTraces()
Enable trace sinks for DL transmission PHY layer.
Definition: lte-helper.cc:1634
void SetPathlossModelAttribute(std::string n, const AttributeValue &v)
Set an attribute for the path loss models to be created.
Definition: lte-helper.cc:402
void EnableRlcTraces()
Enable trace sinks for RLC layer.
Definition: lte-helper.cc:1563
bool m_useIdealRrc
The UseIdealRrc attribute.
Definition: lte-helper.h:831
ObjectFactory m_ueComponentCarrierManagerFactory
Factory of ue component carrier manager object.
Definition: lte-helper.h:766
void DoComponentCarrierConfigure(uint32_t ulEarfcn, uint32_t dlEarfcn, uint16_t ulbw, uint16_t dlbw)
Configure the component carriers.
Definition: lte-helper.cc:1422
Ptr< Object > m_downlinkPathlossModel
The path loss model used in the downlink channel.
Definition: lte-helper.h:753
Ptr< RadioBearerStatsCalculator > m_pdcpStats
Container of PDCP layer statistics.
Definition: lte-helper.h:803
void ChannelModelInitialization()
Function that performs a channel model initialization of all component carriers.
Definition: lte-helper.cc:227
void EnableUlTxPhyTraces()
Enable trace sinks for UL transmission PHY layer.
Definition: lte-helper.cc:1642
bool m_usePdschForCqiGeneration
The UsePdschForCqiGeneration attribute.
Definition: lte-helper.h:842
void SetUeAntennaModelAttribute(std::string n, const AttributeValue &v)
Set an attribute for the UE antenna model to be created.
Definition: lte-helper.cc:444
void SetEnbAntennaModelAttribute(std::string n, const AttributeValue &v)
Set an attribute for the eNodeB antenna model to be created.
Definition: lte-helper.cc:423
static TypeId GetTypeId()
Register this type.
Definition: lte-helper.cc:108
void SetEnbDeviceAttribute(std::string n, const AttributeValue &v)
Set an attribute for the eNodeB devices (LteEnbNetDevice) to be created.
Definition: lte-helper.cc:409
bool m_useCa
The UseCa attribute.
Definition: lte-helper.h:850
void ActivateDataRadioBearer(NetDeviceContainer ueDevices, EpsBearer bearer)
Activate a Data Radio Bearer on a given UE devices (for LTE-only simulation).
Definition: lte-helper.cc:1441
NetDeviceContainer InstallUeDevice(NodeContainer c)
Create a set of UE devices.
Definition: lte-helper.cc:497
uint64_t m_imsiCounter
Keep track of the number of IMSI allocated.
Definition: lte-helper.h:819
ObjectFactory m_ueNetDeviceFactory
Factory for LteUeNetDevice objects.
Definition: lte-helper.h:772
ObjectFactory m_ueAntennaModelFactory
Factory of antenna object for UE.
Definition: lte-helper.h:774
Ptr< SpectrumChannel > m_uplinkChannel
The uplink LTE channel used in the simulation.
Definition: lte-helper.h:751
void EnableMacTraces()
Enable trace sinks for MAC layer.
Definition: lte-helper.cc:1666
void SetSpectrumChannelAttribute(std::string n, const AttributeValue &v)
Set an attribute for the spectrum channel to be created (both DL and UL).
Definition: lte-helper.cc:476
void EnableDlPhyTraces()
Enable trace sinks for DL PHY layer.
Definition: lte-helper.cc:1689
void AddX2Interface(NodeContainer enbNodes)
Create an X2 interface between all the eNBs in a given set.
Definition: lte-helper.cc:1318
void SetUeDeviceAttribute(std::string n, const AttributeValue &v)
Set an attribute for the UE devices (LteUeNetDevice) to be created.
Definition: lte-helper.cc:430
uint16_t m_noOfCcs
Number of component carriers that will be installed by default at eNodeB and UE devices.
Definition: lte-helper.h:860
int64_t AssignStreams(NetDeviceContainer c, int64_t stream)
Assign a fixed random variable stream number to the random variables used.
Definition: lte-helper.cc:1572
void SetFadingModelAttribute(std::string n, const AttributeValue &v)
Set an attribute for the fading model to be created (both DL and UL).
Definition: lte-helper.cc:463
Ptr< EpcHelper > m_epcHelper
Helper which provides implementation of core network.
Definition: lte-helper.h:812
void AttachToClosestEnb(NetDeviceContainer ueDevices, NetDeviceContainer enbDevices)
Manual attachment of a set of UE devices to the network via the closest eNodeB (with respect to dista...
Definition: lte-helper.cc:1127
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:1159
ObjectFactory m_enbAntennaModelFactory
Factory of antenna object for eNodeB.
Definition: lte-helper.h:770
Ptr< RadioBearerStatsCalculator > m_rlcStats
Container of RLC layer statistics.
Definition: lte-helper.h:801
std::string GetSchedulerType() const
Definition: lte-helper.cc:297
Ptr< NetDevice > InstallSingleUeDevice(Ptr< Node > n)
Create a UE device (LteUeNetDevice) on the given node.
Definition: lte-helper.cc:830
Ptr< NetDevice > InstallSingleEnbDevice(Ptr< Node > n)
Create an eNodeB device (LteEnbNetDevice) on the given node.
Definition: lte-helper.cc:511
void SetUeComponentCarrierManagerType(std::string type)
Set the type of Component Carrier Manager to be used by Ue devices.
Definition: lte-helper.cc:379
ObjectFactory m_fadingModelFactory
Factory of fading model object for both the downlink and uplink channels.
Definition: lte-helper.h:783
void Receive(Ptr< Packet > p)
receive a packet from the lower layers in order to forward it to the upper layers
void SetNode(Ptr< Node > node) override
Ptr< Node > GetNode() const override
uint32_t GetIfIndex() const override
void UpdateSinrPerceived(const SpectrumValue &sinr)
static double GetCarrierFrequency(uint32_t earfcn)
Calculates the carrier frequency from the E-UTRA Absolute Radio Frequency Channel Number (EARFCN) acc...
The abstract base class of a Component Carrier Manager* for UE that operates using the component carr...
The LteUeNetDevice class implements the UE net device.
static TypeId GetTypeId()
Get the type ID.
virtual void ReportDataInterference(const SpectrumValue &interf)
Create the mixed CQI report.
Definition: lte-ue-phy.cc:807
virtual void ReceivePss(uint16_t cellId, Ptr< SpectrumValue > p)
Receive PSS function.
Definition: lte-ue-phy.cc:1196
void ReportRsReceivedPower(const SpectrumValue &power) override
generate a report based on the linear RS power perceived during CTRL frame NOTE: used only by UE for ...
Definition: lte-ue-phy.cc:816
void GenerateCtrlCqiReport(const SpectrumValue &sinr) override
generate a CQI report based on the given SINR of Ctrl frame
Definition: lte-ue-phy.cc:548
virtual void ReceiveLteControlMessageList(std::list< Ptr< LteControlMessage >> msgList)
Receive LTE control message list function.
Definition: lte-ue-phy.cc:1032
void PhyPduReceived(Ptr< Packet > p)
PhySpectrum received a new PHY-PDU.
Definition: lte-ue-phy.cc:496
virtual void EnqueueDlHarqFeedback(DlInfoListElement_s mes)
Enqueue the downlink HARQ feedback generated by LteSpectrumPhy.
Definition: lte-ue-phy.cc:1762
void ReportInterference(const SpectrumValue &interf) override
generate a report based on the linear interference and noise power perceived during DATA frame NOTE: ...
Definition: lte-ue-phy.cc:799
virtual void GenerateMixedCqiReport(const SpectrumValue &sinr)
Create the mixed CQI report.
Definition: lte-ue-phy.cc:733
static Mac64Address Allocate()
Allocate a new Mac64Address.
static void DlSchedulingCallback(Ptr< MacStatsCalculator > macStats, std::string path, DlSchedulingCallbackInfo dlSchedulingCallbackInfo)
Trace sink for the ns3::LteEnbMac::DlScheduling trace source.
static void UlSchedulingCallback(Ptr< MacStatsCalculator > macStats, std::string path, uint32_t frameNo, uint32_t subframeNo, uint16_t rnti, uint8_t mcs, uint16_t size, uint8_t componentCarrierId)
Trace sink for the ns3::LteEnbMac::UlScheduling trace source.
Keep track of the current position and velocity of an object.
static TypeId GetTypeId()
Get the type ID.
holds a vector of ns3::NetDevice pointers
uint32_t GetN() const
Get the number of Ptr<NetDevice> stored in this container.
std::vector< Ptr< NetDevice > >::const_iterator Iterator
NetDevice container iterator.
Iterator Begin() const
Get an iterator which refers to the first NetDevice in the container.
Iterator End() const
Get an iterator which indicates past-the-last NetDevice in the container.
keep track of a set of node pointers.
Iterator End() const
Get an iterator which indicates past-the-last Node in the container.
std::vector< Ptr< Node > >::const_iterator Iterator
Node container iterator.
Iterator Begin() const
Get an iterator which refers to the first Node in the container.
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
Definition: node.cc:138
Ptr< Application > GetApplication(uint32_t index) const
Retrieve the index-th Application associated to this node.
Definition: node.cc:180
uint32_t GetId() const
Definition: node.cc:117
bool SetAttributeFailSafe(std::string name, const AttributeValue &value)
Set a single attribute without raising errors.
Definition: object-base.cc:223
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:200
Ptr< Object > Create() const
Create an Object instance of the configured TypeId.
void Set(const std::string &name, const AttributeValue &value, Args &&... args)
Set an attribute to be set during construction.
TypeId GetTypeId() const
Get the TypeId which will be created by this ObjectFactory.
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
A base class which provides memory management and object aggregation.
Definition: object.h:89
void Initialize()
Invoke DoInitialize on all Objects aggregated to this one.
Definition: object.cc:186
friend class ObjectFactory
Friends.
Definition: object.h:328
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
Definition: object.h:471
virtual void DoInitialize()
Initialize() implementation.
Definition: object.cc:360
virtual void DoDispose()
Destructor implementation.
Definition: object.cc:353
static void UlPhyReceptionCallback(Ptr< PhyRxStatsCalculator > phyRxStats, std::string path, PhyReceptionStatParameters params)
trace sink
static void DlPhyReceptionCallback(Ptr< PhyRxStatsCalculator > phyRxStats, std::string path, PhyReceptionStatParameters params)
trace sink
void ReportUeSinr(uint16_t cellId, uint64_t imsi, uint16_t rnti, double sinrLinear, uint8_t componentCarrierId)
Notifies the stats calculator that an UE SINR report has occurred.
void ReportInterference(uint16_t cellId, Ptr< SpectrumValue > interference)
Notifies the stats calculator that an interference report has occurred.
static void ReportCurrentCellRsrpSinrCallback(Ptr< PhyStatsCalculator > phyStats, std::string path, uint16_t cellId, uint16_t rnti, double rsrp, double sinr, uint8_t componentCarrierId)
trace sink
static void DlPhyTransmissionCallback(Ptr< PhyTxStatsCalculator > phyTxStats, std::string path, PhyTransmissionStatParameters params)
trace sink
static void UlPhyTransmissionCallback(Ptr< PhyTxStatsCalculator > phyTxStats, std::string path, PhyTransmissionStatParameters params)
trace sink
Hold objects of type Ptr<T>.
Definition: pointer.h:37
Models the propagation loss through a transmission medium.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:78
void EnablePdcpStats(Ptr< RadioBearerStatsCalculator > pdcpStats)
Enables trace sinks for PDCP layer.
void EnableRlcStats(Ptr< RadioBearerStatsCalculator > rlcStats)
Enables trace sinks for RLC layer.
A template-based reference counting class.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition: simulator.h:568
Defines the interface for spectrum-aware channel implementations.
spectrum-aware propagation loss model
Hold variables of type string.
Definition: string.h:56
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
fading loss model based on precalculated fading traces
a unique identifier for an interface.
Definition: type-id.h:60
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:935
std::string GetName() const
Get the name.
Definition: type-id.cc:995
AttributeValue implementation for TypeId.
Definition: type-id.h:600
@ CONNECTION_RECONFIGURATION
Definition: lte-enb-rrc.h:88
Hold an unsigned integer type.
Definition: uinteger.h:45
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition: assert.h:66
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition: assert.h:86
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Definition: boolean.h:86
Ptr< const AttributeChecker > MakeBooleanChecker()
Definition: boolean.cc:124
Ptr< const AttributeChecker > MakeStringChecker()
Definition: string.cc:30
Ptr< const AttributeAccessor > MakeStringAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Definition: string.h:57
Ptr< const AttributeChecker > MakeTypeIdChecker()
Definition: type-id.cc:1254
Ptr< const AttributeAccessor > MakeTypeIdAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Definition: type-id.h:600
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Definition: uinteger.h:46
void Connect(std::string path, const CallbackBase &cb)
Definition: config.cc:975
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:179
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
Definition: abort.h:108
#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_NOARGS()
Output the name of the function.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Definition: log.h:261
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:275
auto MakeBoundCallback(R(*fnPtr)(Args...), BArgs &&... bargs)
Make Callbacks with varying number of bound arguments.
Definition: callback.h:768
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:46
#define MIN_NO_CC
Definition: lte-enb-rrc.h:54
#define MAX_NO_CC
Definition: lte-enb-rrc.h:55
devices
Definition: first.py:35
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void LogComponentEnable(const std::string &name, LogLevel level)
Enable the logging output associated with that log component.
Definition: log.cc:305
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Definition: callback.h:707
@ LOG_LEVEL_ALL
Print everything.
Definition: log.h:116
@ LOG_PREFIX_FUNC
Prefix all trace prints with function.
Definition: log.h:118
@ LOG_PREFIX_TIME
Prefix all trace prints with simulation time.
Definition: log.h:119
@ LOG_PREFIX_NODE
Prefix all trace prints with simulation node.
Definition: log.h:120
double CalculateDistance(const Vector3D &a, const Vector3D &b)
Definition: vector.cc:109
void LogComponentEnableAll(LogLevel level)
Enable the logging output for all registered log components.
Definition: log.cc:329
mac
Definition: third.py:85
phy
Definition: third.py:82
params
Fit Fluctuating Two Ray model to the 3GPP TR 38.901 using the Anderson-Darling goodness-of-fit ##.
Parameters passed to DataRadioBearerSetupRequest ()