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