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  */
21 
22 
23 #include "lte-helper.h"
24 #include <ns3/string.h>
25 #include <ns3/log.h>
26 #include <ns3/abort.h>
27 #include <ns3/pointer.h>
28 #include <ns3/lte-enb-rrc.h>
29 #include <ns3/epc-ue-nas.h>
30 #include <ns3/epc-enb-application.h>
31 #include <ns3/lte-ue-rrc.h>
32 #include <ns3/lte-ue-mac.h>
33 #include <ns3/lte-enb-mac.h>
34 #include <ns3/lte-enb-net-device.h>
35 #include <ns3/lte-enb-phy.h>
36 #include <ns3/lte-ue-phy.h>
37 #include <ns3/lte-spectrum-phy.h>
38 #include <ns3/lte-chunk-processor.h>
39 #include <ns3/multi-model-spectrum-channel.h>
40 #include <ns3/friis-spectrum-propagation-loss.h>
41 #include <ns3/trace-fading-loss-model.h>
42 #include <ns3/isotropic-antenna-model.h>
43 #include <ns3/lte-enb-net-device.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-anr.h>
49 #include <ns3/lte-rlc.h>
50 #include <ns3/lte-rlc-um.h>
51 #include <ns3/lte-rlc-am.h>
52 #include <ns3/epc-enb-s1-sap.h>
53 #include <ns3/lte-rrc-protocol-ideal.h>
54 #include <ns3/lte-rrc-protocol-real.h>
55 #include <ns3/mac-stats-calculator.h>
56 #include <ns3/phy-stats-calculator.h>
57 #include <ns3/phy-tx-stats-calculator.h>
58 #include <ns3/phy-rx-stats-calculator.h>
59 #include <ns3/epc-helper.h>
60 #include <iostream>
61 #include <ns3/buildings-propagation-loss-model.h>
62 #include <ns3/lte-spectrum-value-helper.h>
63 #include <ns3/epc-x2.h>
64 
65 namespace ns3 {
66 
67 NS_LOG_COMPONENT_DEFINE ("LteHelper");
68 
69 NS_OBJECT_ENSURE_REGISTERED (LteHelper);
70 
72  : m_fadingStreamsAssigned (false),
73  m_imsiCounter (0),
74  m_cellIdCounter (0)
75 {
76  NS_LOG_FUNCTION (this);
82 }
83 
84 void
86 {
87  NS_LOG_FUNCTION (this);
90 
92  Ptr<SpectrumPropagationLossModel> dlSplm = m_downlinkPathlossModel->GetObject<SpectrumPropagationLossModel> ();
93  if (dlSplm != 0)
94  {
95  NS_LOG_LOGIC (this << " using a SpectrumPropagationLossModel in DL");
96  m_downlinkChannel->AddSpectrumPropagationLossModel (dlSplm);
97  }
98  else
99  {
100  NS_LOG_LOGIC (this << " using a PropagationLossModel in DL");
101  Ptr<PropagationLossModel> dlPlm = m_downlinkPathlossModel->GetObject<PropagationLossModel> ();
102  NS_ASSERT_MSG (dlPlm != 0, " " << m_downlinkPathlossModel << " is neither PropagationLossModel nor SpectrumPropagationLossModel");
103  m_downlinkChannel->AddPropagationLossModel (dlPlm);
104  }
105 
108  if (ulSplm != 0)
109  {
110  NS_LOG_LOGIC (this << " using a SpectrumPropagationLossModel in UL");
111  m_uplinkChannel->AddSpectrumPropagationLossModel (ulSplm);
112  }
113  else
114  {
115  NS_LOG_LOGIC (this << " using a PropagationLossModel in UL");
117  NS_ASSERT_MSG (ulPlm != 0, " " << m_uplinkPathlossModel << " is neither PropagationLossModel nor SpectrumPropagationLossModel");
118  m_uplinkChannel->AddPropagationLossModel (ulPlm);
119  }
120  if (!m_fadingModelType.empty ())
121  {
123  m_fadingModule->Initialize ();
124  m_downlinkChannel->AddSpectrumPropagationLossModel (m_fadingModule);
126  }
127  m_phyStats = CreateObject<PhyStatsCalculator> ();
128  m_phyTxStats = CreateObject<PhyTxStatsCalculator> ();
129  m_phyRxStats = CreateObject<PhyRxStatsCalculator> ();
130  m_macStats = CreateObject<MacStatsCalculator> ();
132 
133 }
134 
136 {
137  NS_LOG_FUNCTION (this);
138 }
139 
141 {
142  static TypeId
143  tid =
144  TypeId ("ns3::LteHelper")
145  .SetParent<Object> ()
146  .AddConstructor<LteHelper> ()
147  .AddAttribute ("Scheduler",
148  "The type of scheduler to be used for eNBs. "
149  "The allowed values for this attributes are the type names "
150  "of any class inheriting from ns3::FfMacScheduler.",
151  StringValue ("ns3::PfFfMacScheduler"),
155  .AddAttribute ("FfrAlgorithm",
156  "The type of FFR algorithm to be used for eNBs. "
157  "The allowed values for this attributes are the type names "
158  "of any class inheriting from ns3::LteFfrAlgorithm.",
159  StringValue ("ns3::LteFrNoOpAlgorithm"),
163  .AddAttribute ("HandoverAlgorithm",
164  "The type of handover algorithm to be used for eNBs. "
165  "The allowed values for this attributes are the type names "
166  "of any class inheriting from ns3::LteHandoverAlgorithm.",
167  StringValue ("ns3::NoOpHandoverAlgorithm"),
171  .AddAttribute ("PathlossModel",
172  "The type of pathloss model to be used. "
173  "The allowed values for this attributes are the type names "
174  "of any class inheriting from ns3::PropagationLossModel.",
175  StringValue ("ns3::FriisPropagationLossModel"),
178  .AddAttribute ("FadingModel",
179  "The type of fading model to be used."
180  "The allowed values for this attributes are the type names "
181  "of any class inheriting from ns3::SpectrumPropagationLossModel."
182  "If the type is set to an empty string, no fading model is used.",
183  StringValue (""),
186  .AddAttribute ("UseIdealRrc",
187  "If true, LteRrcProtocolIdeal will be used for RRC signaling. "
188  "If false, LteRrcProtocolReal will be used.",
189  BooleanValue (true),
192  .AddAttribute ("AnrEnabled",
193  "Activate or deactivate Automatic Neighbour Relation function",
194  BooleanValue (true),
197  .AddAttribute ("UsePdschForCqiGeneration",
198  "If true, DL-CQI will be calculated from PDCCH as signal and PDSCH as interference "
199  "If false, DL-CQI will be calculated from PDCCH as signal and PDCCH as interference ",
200  BooleanValue (true),
203  ;
204  return tid;
205 }
206 
207 void
209 {
210  NS_LOG_FUNCTION (this);
211  m_downlinkChannel = 0;
212  m_uplinkChannel = 0;
214 }
215 
216 
217 void
219 {
220  NS_LOG_FUNCTION (this << h);
221  m_epcHelper = h;
222 }
223 
224 void
225 LteHelper::SetSchedulerType (std::string type)
226 {
227  NS_LOG_FUNCTION (this << type);
230 }
231 
232 std::string
234 {
235  return m_schedulerFactory.GetTypeId ().GetName ();
236 }
237 
238 void
240 {
241  NS_LOG_FUNCTION (this << n);
242  m_schedulerFactory.Set (n, v);
243 }
244 
245 std::string
247 {
249 }
250 
251 void
253 {
254  NS_LOG_FUNCTION (this << type);
257 }
258 
259 void
261 {
262  NS_LOG_FUNCTION (this << n);
263  m_ffrAlgorithmFactory.Set (n, v);
264 }
265 
266 std::string
268 {
270 }
271 
272 void
274 {
275  NS_LOG_FUNCTION (this << type);
278 }
279 
280 void
282 {
283  NS_LOG_FUNCTION (this << n);
285 }
286 
287 
288 void
290 {
291  NS_LOG_FUNCTION (this << type);
296 }
297 
298 void
300 {
301  NS_LOG_FUNCTION (this << n);
304 }
305 
306 void
308 {
309  NS_LOG_FUNCTION (this);
310  m_enbNetDeviceFactory.Set (n, v);
311 }
312 
313 
314 void
316 {
317  NS_LOG_FUNCTION (this);
319 }
320 
321 void
323 {
324  NS_LOG_FUNCTION (this);
326 }
327 
328 void
330 {
331  NS_LOG_FUNCTION (this);
332  m_ueNetDeviceFactory.Set (n, v);
333 }
334 
335 void
337 {
338  NS_LOG_FUNCTION (this);
340 }
341 
342 void
344 {
345  NS_LOG_FUNCTION (this);
347 }
348 
349 void
350 LteHelper::SetFadingModel (std::string type)
351 {
352  NS_LOG_FUNCTION (this << type);
353  m_fadingModelType = type;
354  if (!type.empty ())
355  {
358  }
359 }
360 
361 void
363 {
364  m_fadingModelFactory.Set (n, v);
365 }
366 
367 void
369 {
370  NS_LOG_FUNCTION (this << type);
372 }
373 
374 void
376 {
377  m_channelFactory.Set (n, v);
378 }
379 
380 
383 {
384  NS_LOG_FUNCTION (this);
385  Initialize (); // will run DoInitialize () if necessary
387  for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
388  {
389  Ptr<Node> node = *i;
390  Ptr<NetDevice> device = InstallSingleEnbDevice (node);
391  devices.Add (device);
392  }
393  return devices;
394 }
395 
398 {
399  NS_LOG_FUNCTION (this);
401  for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
402  {
403  Ptr<Node> node = *i;
404  Ptr<NetDevice> device = InstallSingleUeDevice (node);
405  devices.Add (device);
406  }
407  return devices;
408 }
409 
410 
413 {
414 
415  NS_ABORT_MSG_IF (m_cellIdCounter == 65535, "max num eNBs exceeded");
416  uint16_t cellId = ++m_cellIdCounter;
417 
418  Ptr<LteSpectrumPhy> dlPhy = CreateObject<LteSpectrumPhy> ();
419  Ptr<LteSpectrumPhy> ulPhy = CreateObject<LteSpectrumPhy> ();
420 
421  Ptr<LteEnbPhy> phy = CreateObject<LteEnbPhy> (dlPhy, ulPhy);
422 
423  Ptr<LteHarqPhy> harq = Create<LteHarqPhy> ();
424  dlPhy->SetHarqPhyModule (harq);
425  ulPhy->SetHarqPhyModule (harq);
426  phy->SetHarqPhyModule (harq);
427 
428  Ptr<LteChunkProcessor> pCtrl = Create<LteChunkProcessor> ();
429  pCtrl->AddCallback (MakeCallback (&LteEnbPhy::GenerateCtrlCqiReport, phy));
430  ulPhy->AddCtrlSinrChunkProcessor (pCtrl); // for evaluating SRS UL-CQI
431 
432  Ptr<LteChunkProcessor> pData = Create<LteChunkProcessor> ();
433  pData->AddCallback (MakeCallback (&LteEnbPhy::GenerateDataCqiReport, phy));
434  pData->AddCallback (MakeCallback (&LteSpectrumPhy::UpdateSinrPerceived, ulPhy));
435  ulPhy->AddDataSinrChunkProcessor (pData); // for evaluating PUSCH UL-CQI
436 
437  Ptr<LteChunkProcessor> pInterf = Create<LteChunkProcessor> ();
438  pInterf->AddCallback (MakeCallback (&LteEnbPhy::ReportInterference, phy));
439  ulPhy->AddInterferenceDataChunkProcessor (pInterf); // for interference power tracing
440 
441  dlPhy->SetChannel (m_downlinkChannel);
442  ulPhy->SetChannel (m_uplinkChannel);
443 
445  NS_ASSERT_MSG (mm, "MobilityModel needs to be set on node before calling LteHelper::InstallUeDevice ()");
446  dlPhy->SetMobility (mm);
447  ulPhy->SetMobility (mm);
448 
449  Ptr<AntennaModel> antenna = (m_enbAntennaModelFactory.Create ())->GetObject<AntennaModel> ();
450  NS_ASSERT_MSG (antenna, "error in creating the AntennaModel object");
451  dlPhy->SetAntenna (antenna);
452  ulPhy->SetAntenna (antenna);
453 
454  Ptr<LteEnbMac> mac = CreateObject<LteEnbMac> ();
458  Ptr<LteEnbRrc> rrc = CreateObject<LteEnbRrc> ();
459 
460  if (m_useIdealRrc)
461  {
462  Ptr<LteEnbRrcProtocolIdeal> rrcProtocol = CreateObject<LteEnbRrcProtocolIdeal> ();
463  rrcProtocol->SetLteEnbRrcSapProvider (rrc->GetLteEnbRrcSapProvider ());
464  rrc->SetLteEnbRrcSapUser (rrcProtocol->GetLteEnbRrcSapUser ());
465  rrc->AggregateObject (rrcProtocol);
466  rrcProtocol->SetCellId (cellId);
467  }
468  else
469  {
470  Ptr<LteEnbRrcProtocolReal> rrcProtocol = CreateObject<LteEnbRrcProtocolReal> ();
471  rrcProtocol->SetLteEnbRrcSapProvider (rrc->GetLteEnbRrcSapProvider ());
472  rrc->SetLteEnbRrcSapUser (rrcProtocol->GetLteEnbRrcSapUser ());
473  rrc->AggregateObject (rrcProtocol);
474  rrcProtocol->SetCellId (cellId);
475  }
476 
477  if (m_epcHelper != 0)
478  {
479  EnumValue epsBearerToRlcMapping;
480  rrc->GetAttribute ("EpsBearerToRlcMapping", epsBearerToRlcMapping);
481  // it does not make sense to use RLC/SM when also using the EPC
482  if (epsBearerToRlcMapping.Get () == LteEnbRrc::RLC_SM_ALWAYS)
483  {
484  rrc->SetAttribute ("EpsBearerToRlcMapping", EnumValue (LteEnbRrc::RLC_UM_ALWAYS));
485  }
486  }
487 
488  rrc->SetLteEnbCmacSapProvider (mac->GetLteEnbCmacSapProvider ());
489  mac->SetLteEnbCmacSapUser (rrc->GetLteEnbCmacSapUser ());
490  rrc->SetLteMacSapProvider (mac->GetLteMacSapProvider ());
491 
492  rrc->SetLteHandoverManagementSapProvider (handoverAlgorithm->GetLteHandoverManagementSapProvider ());
493  handoverAlgorithm->SetLteHandoverManagementSapUser (rrc->GetLteHandoverManagementSapUser ());
494 
495  mac->SetFfMacSchedSapProvider (sched->GetFfMacSchedSapProvider ());
496  mac->SetFfMacCschedSapProvider (sched->GetFfMacCschedSapProvider ());
497 
498  sched->SetFfMacSchedSapUser (mac->GetFfMacSchedSapUser ());
499  sched->SetFfMacCschedSapUser (mac->GetFfMacCschedSapUser ());
500 
501  phy->SetLteEnbPhySapUser (mac->GetLteEnbPhySapUser ());
502  mac->SetLteEnbPhySapProvider (phy->GetLteEnbPhySapProvider ());
503 
504  phy->SetLteEnbCphySapUser (rrc->GetLteEnbCphySapUser ());
505  rrc->SetLteEnbCphySapProvider (phy->GetLteEnbCphySapProvider ());
506 
507  //FFR SAP
508  sched->SetLteFfrSapProvider (ffrAlgorithm->GetLteFfrSapProvider ());
509  ffrAlgorithm->SetLteFfrSapUser (sched->GetLteFfrSapUser ());
510 
511  rrc->SetLteFfrRrcSapProvider (ffrAlgorithm->GetLteFfrRrcSapProvider ());
512  ffrAlgorithm->SetLteFfrRrcSapUser (rrc->GetLteFfrRrcSapUser ());
513  //FFR SAP END
514 
516  dev->SetNode (n);
517  dev->SetAttribute ("CellId", UintegerValue (cellId));
518  dev->SetAttribute ("LteEnbPhy", PointerValue (phy));
519  dev->SetAttribute ("LteEnbMac", PointerValue (mac));
520  dev->SetAttribute ("FfMacScheduler", PointerValue (sched));
521  dev->SetAttribute ("LteEnbRrc", PointerValue (rrc));
522  dev->SetAttribute ("LteHandoverAlgorithm", PointerValue (handoverAlgorithm));
523  dev->SetAttribute ("LteFfrAlgorithm", PointerValue (ffrAlgorithm));
524 
525  if (m_isAnrEnabled)
526  {
527  Ptr<LteAnr> anr = CreateObject<LteAnr> (cellId);
528  rrc->SetLteAnrSapProvider (anr->GetLteAnrSapProvider ());
529  anr->SetLteAnrSapUser (rrc->GetLteAnrSapUser ());
530  dev->SetAttribute ("LteAnr", PointerValue (anr));
531  }
532 
533  phy->SetDevice (dev);
534  dlPhy->SetDevice (dev);
535  ulPhy->SetDevice (dev);
536 
537  n->AddDevice (dev);
538  ulPhy->SetLtePhyRxDataEndOkCallback (MakeCallback (&LteEnbPhy::PhyPduReceived, phy));
539  ulPhy->SetLtePhyRxCtrlEndOkCallback (MakeCallback (&LteEnbPhy::ReceiveLteControlMessageList, phy));
540  ulPhy->SetLtePhyUlHarqFeedbackCallback (MakeCallback (&LteEnbPhy::ReceiveLteUlHarqFeedback, phy));
541  rrc->SetForwardUpCallback (MakeCallback (&LteEnbNetDevice::Receive, dev));
542 
543  NS_LOG_LOGIC ("set the propagation model frequencies");
545  NS_LOG_LOGIC ("DL freq: " << dlFreq);
546  bool dlFreqOk = m_downlinkPathlossModel->SetAttributeFailSafe ("Frequency", DoubleValue (dlFreq));
547  if (!dlFreqOk)
548  {
549  NS_LOG_WARN ("DL propagation model does not have a Frequency attribute");
550  }
552  NS_LOG_LOGIC ("UL freq: " << ulFreq);
553  bool ulFreqOk = m_uplinkPathlossModel->SetAttributeFailSafe ("Frequency", DoubleValue (ulFreq));
554  if (!ulFreqOk)
555  {
556  NS_LOG_WARN ("UL propagation model does not have a Frequency attribute");
557  }
558 
559  dev->Initialize ();
560 
561  m_uplinkChannel->AddRx (ulPhy);
562 
563  if (m_epcHelper != 0)
564  {
565  NS_LOG_INFO ("adding this eNB to the EPC");
566  m_epcHelper->AddEnb (n, dev, dev->GetCellId ());
568  NS_ASSERT_MSG (enbApp != 0, "cannot retrieve EpcEnbApplication");
569 
570  // S1 SAPs
571  rrc->SetS1SapProvider (enbApp->GetS1SapProvider ());
572  enbApp->SetS1SapUser (rrc->GetS1SapUser ());
573 
574  // X2 SAPs
575  Ptr<EpcX2> x2 = n->GetObject<EpcX2> ();
576  x2->SetEpcX2SapUser (rrc->GetEpcX2SapUser ());
577  rrc->SetEpcX2SapProvider (x2->GetEpcX2SapProvider ());
578  }
579 
580  return dev;
581 }
582 
585 {
586  NS_LOG_FUNCTION (this);
587  Ptr<LteSpectrumPhy> dlPhy = CreateObject<LteSpectrumPhy> ();
588  Ptr<LteSpectrumPhy> ulPhy = CreateObject<LteSpectrumPhy> ();
589 
590  Ptr<LteUePhy> phy = CreateObject<LteUePhy> (dlPhy, ulPhy);
591 
592  Ptr<LteHarqPhy> harq = Create<LteHarqPhy> ();
593  dlPhy->SetHarqPhyModule (harq);
594  ulPhy->SetHarqPhyModule (harq);
595  phy->SetHarqPhyModule (harq);
596 
597  Ptr<LteChunkProcessor> pRs = Create<LteChunkProcessor> ();
598  pRs->AddCallback (MakeCallback (&LteUePhy::ReportRsReceivedPower, phy));
599  dlPhy->AddRsPowerChunkProcessor (pRs);
600 
601  Ptr<LteChunkProcessor> pInterf = Create<LteChunkProcessor> ();
602  pInterf->AddCallback (MakeCallback (&LteUePhy::ReportInterference, phy));
603  dlPhy->AddInterferenceCtrlChunkProcessor (pInterf); // for RSRQ evaluation of UE Measurements
604 
605  Ptr<LteChunkProcessor> pCtrl = Create<LteChunkProcessor> ();
606  pCtrl->AddCallback (MakeCallback (&LteSpectrumPhy::UpdateSinrPerceived, dlPhy));
607  dlPhy->AddCtrlSinrChunkProcessor (pCtrl);
608 
609  Ptr<LteChunkProcessor> pData = Create<LteChunkProcessor> ();
610  pData->AddCallback (MakeCallback (&LteSpectrumPhy::UpdateSinrPerceived, dlPhy));
611  dlPhy->AddDataSinrChunkProcessor (pData);
612 
614  {
615  // CQI calculation based on PDCCH for signal and PDSCH for interference
616  pCtrl->AddCallback (MakeCallback (&LteUePhy::GenerateMixedCqiReport, phy));
617  Ptr<LteChunkProcessor> pDataInterf = Create<LteChunkProcessor> ();
618  pDataInterf->AddCallback (MakeCallback (&LteUePhy::ReportDataInterference, phy));
619  dlPhy->AddInterferenceDataChunkProcessor (pDataInterf);
620  }
621  else
622  {
623  // CQI calculation based on PDCCH for both signal and interference
624  pCtrl->AddCallback (MakeCallback (&LteUePhy::GenerateCtrlCqiReport, phy));
625  }
626 
627 
628 
629  dlPhy->SetChannel (m_downlinkChannel);
630  ulPhy->SetChannel (m_uplinkChannel);
631 
633  NS_ASSERT_MSG (mm, "MobilityModel needs to be set on node before calling LteHelper::InstallUeDevice ()");
634  dlPhy->SetMobility (mm);
635  ulPhy->SetMobility (mm);
636 
637  Ptr<AntennaModel> antenna = (m_ueAntennaModelFactory.Create ())->GetObject<AntennaModel> ();
638  NS_ASSERT_MSG (antenna, "error in creating the AntennaModel object");
639  dlPhy->SetAntenna (antenna);
640  ulPhy->SetAntenna (antenna);
641 
642  Ptr<LteUeMac> mac = CreateObject<LteUeMac> ();
643  Ptr<LteUeRrc> rrc = CreateObject<LteUeRrc> ();
644 
645  if (m_useIdealRrc)
646  {
647  Ptr<LteUeRrcProtocolIdeal> rrcProtocol = CreateObject<LteUeRrcProtocolIdeal> ();
648  rrcProtocol->SetUeRrc (rrc);
649  rrc->AggregateObject (rrcProtocol);
650  rrcProtocol->SetLteUeRrcSapProvider (rrc->GetLteUeRrcSapProvider ());
651  rrc->SetLteUeRrcSapUser (rrcProtocol->GetLteUeRrcSapUser ());
652  }
653  else
654  {
655  Ptr<LteUeRrcProtocolReal> rrcProtocol = CreateObject<LteUeRrcProtocolReal> ();
656  rrcProtocol->SetUeRrc (rrc);
657  rrc->AggregateObject (rrcProtocol);
658  rrcProtocol->SetLteUeRrcSapProvider (rrc->GetLteUeRrcSapProvider ());
659  rrc->SetLteUeRrcSapUser (rrcProtocol->GetLteUeRrcSapUser ());
660  }
661 
662  if (m_epcHelper != 0)
663  {
664  rrc->SetUseRlcSm (false);
665  }
666  Ptr<EpcUeNas> nas = CreateObject<EpcUeNas> ();
667 
668  nas->SetAsSapProvider (rrc->GetAsSapProvider ());
669  rrc->SetAsSapUser (nas->GetAsSapUser ());
670 
671  rrc->SetLteUeCmacSapProvider (mac->GetLteUeCmacSapProvider ());
672  mac->SetLteUeCmacSapUser (rrc->GetLteUeCmacSapUser ());
673  rrc->SetLteMacSapProvider (mac->GetLteMacSapProvider ());
674 
675  phy->SetLteUePhySapUser (mac->GetLteUePhySapUser ());
676  mac->SetLteUePhySapProvider (phy->GetLteUePhySapProvider ());
677 
678  phy->SetLteUeCphySapUser (rrc->GetLteUeCphySapUser ());
679  rrc->SetLteUeCphySapProvider (phy->GetLteUeCphySapProvider ());
680 
681  NS_ABORT_MSG_IF (m_imsiCounter >= 0xFFFFFFFF, "max num UEs exceeded");
682  uint64_t imsi = ++m_imsiCounter;
683 
685  dev->SetNode (n);
686  dev->SetAttribute ("Imsi", UintegerValue (imsi));
687  dev->SetAttribute ("LteUePhy", PointerValue (phy));
688  dev->SetAttribute ("LteUeMac", PointerValue (mac));
689  dev->SetAttribute ("LteUeRrc", PointerValue (rrc));
690  dev->SetAttribute ("EpcUeNas", PointerValue (nas));
691 
692  phy->SetDevice (dev);
693  dlPhy->SetDevice (dev);
694  ulPhy->SetDevice (dev);
695  nas->SetDevice (dev);
696 
697  n->AddDevice (dev);
698  dlPhy->SetLtePhyRxDataEndOkCallback (MakeCallback (&LteUePhy::PhyPduReceived, phy));
699  dlPhy->SetLtePhyRxCtrlEndOkCallback (MakeCallback (&LteUePhy::ReceiveLteControlMessageList, phy));
700  dlPhy->SetLtePhyRxPssCallback (MakeCallback (&LteUePhy::ReceivePss, phy));
701  dlPhy->SetLtePhyDlHarqFeedbackCallback (MakeCallback (&LteUePhy::ReceiveLteDlHarqFeedback, phy));
702  nas->SetForwardUpCallback (MakeCallback (&LteUeNetDevice::Receive, dev));
703 
704  if (m_epcHelper != 0)
705  {
706  m_epcHelper->AddUe (dev, dev->GetImsi ());
707  }
708 
709  dev->Initialize ();
710 
711  return dev;
712 }
713 
714 
715 void
717 {
718  NS_LOG_FUNCTION (this);
719  for (NetDeviceContainer::Iterator i = ueDevices.Begin (); i != ueDevices.End (); ++i)
720  {
721  Attach (*i);
722  }
723 }
724 
725 void
727 {
728  NS_LOG_FUNCTION (this);
729 
730  if (m_epcHelper == 0)
731  {
732  NS_FATAL_ERROR ("This function is not valid without properly configured EPC");
733  }
734 
735  Ptr<LteUeNetDevice> ueLteDevice = ueDevice->GetObject<LteUeNetDevice> ();
736  if (ueLteDevice == 0)
737  {
738  NS_FATAL_ERROR ("The passed NetDevice must be an LteUeNetDevice");
739  }
740 
741  // initiate cell selection
742  Ptr<EpcUeNas> ueNas = ueLteDevice->GetNas ();
743  NS_ASSERT (ueNas != 0);
744  uint16_t dlEarfcn = ueLteDevice->GetDlEarfcn ();
745  ueNas->StartCellSelection (dlEarfcn);
746 
747  // instruct UE to immediately enter CONNECTED mode after camping
748  ueNas->Connect ();
749 
750  // activate default EPS bearer
751  m_epcHelper->ActivateEpsBearer (ueDevice, ueLteDevice->GetImsi (),
752  EpcTft::Default (),
754 }
755 
756 void
758 {
759  NS_LOG_FUNCTION (this);
760  for (NetDeviceContainer::Iterator i = ueDevices.Begin (); i != ueDevices.End (); ++i)
761  {
762  Attach (*i, enbDevice);
763  }
764 }
765 
766 void
768 {
769  NS_LOG_FUNCTION (this);
770  //enbRrc->SetCellId (enbDevice->GetObject<LteEnbNetDevice> ()->GetCellId ());
771 
772  Ptr<LteUeNetDevice> ueLteDevice = ueDevice->GetObject<LteUeNetDevice> ();
773  Ptr<LteEnbNetDevice> enbLteDevice = enbDevice->GetObject<LteEnbNetDevice> ();
774 
775  Ptr<EpcUeNas> ueNas = ueLteDevice->GetNas ();
776  ueNas->Connect (enbLteDevice->GetCellId (), enbLteDevice->GetDlEarfcn ());
777 
778  if (m_epcHelper != 0)
779  {
780  // activate default EPS bearer
781  m_epcHelper->ActivateEpsBearer (ueDevice, ueLteDevice->GetImsi (), EpcTft::Default (), EpsBearer (EpsBearer::NGBR_VIDEO_TCP_DEFAULT));
782  }
783 
784  // tricks needed for the simplified LTE-only simulations
785  if (m_epcHelper == 0)
786  {
787  ueDevice->GetObject<LteUeNetDevice> ()->SetTargetEnb (enbDevice->GetObject<LteEnbNetDevice> ());
788  }
789 }
790 
791 void
793 {
794  NS_LOG_FUNCTION (this);
795  for (NetDeviceContainer::Iterator i = ueDevices.Begin (); i != ueDevices.End (); ++i)
796  {
797  AttachToClosestEnb (*i, enbDevices);
798  }
799 }
800 
801 void
803 {
804  NS_LOG_FUNCTION (this);
805  NS_ASSERT_MSG (enbDevices.GetN () > 0, "empty enb device container");
806  Vector uepos = ueDevice->GetNode ()->GetObject<MobilityModel> ()->GetPosition ();
807  double minDistance = std::numeric_limits<double>::infinity ();
808  Ptr<NetDevice> closestEnbDevice;
809  for (NetDeviceContainer::Iterator i = enbDevices.Begin (); i != enbDevices.End (); ++i)
810  {
811  Vector enbpos = (*i)->GetNode ()->GetObject<MobilityModel> ()->GetPosition ();
812  double distance = CalculateDistance (uepos, enbpos);
813  if (distance < minDistance)
814  {
815  minDistance = distance;
816  closestEnbDevice = *i;
817  }
818  }
819  NS_ASSERT (closestEnbDevice != 0);
820  Attach (ueDevice, closestEnbDevice);
821 }
822 
823 uint8_t
825 {
826  NS_LOG_FUNCTION (this);
827  for (NetDeviceContainer::Iterator i = ueDevices.Begin (); i != ueDevices.End (); ++i)
828  {
829  uint8_t bearerId = ActivateDedicatedEpsBearer (*i, bearer, tft);
830  return bearerId;
831  }
832  return 0;
833 }
834 
835 
836 uint8_t
838 {
839  NS_LOG_FUNCTION (this);
840 
841  NS_ASSERT_MSG (m_epcHelper != 0, "dedicated EPS bearers cannot be set up when the EPC is not used");
842 
843  uint64_t imsi = ueDevice->GetObject<LteUeNetDevice> ()->GetImsi ();
844  uint8_t bearerId = m_epcHelper->ActivateEpsBearer (ueDevice, imsi, tft, bearer);
845  return bearerId;
846 }
847 
857 class DrbActivator : public SimpleRefCount<DrbActivator>
858 {
859 public:
866  DrbActivator (Ptr<NetDevice> ueDevice, EpsBearer bearer);
867 
878  static void ActivateCallback (Ptr<DrbActivator> a, std::string context, uint64_t imsi, uint16_t cellId, uint16_t rnti);
879 
890  void ActivateDrb (uint64_t imsi, uint16_t cellId, uint16_t rnti);
891 private:
897  bool m_active;
909  uint64_t m_imsi;
910 };
911 
913  : m_active (false),
914  m_ueDevice (ueDevice),
915  m_bearer (bearer),
916  m_imsi (m_ueDevice->GetObject<LteUeNetDevice> ()->GetImsi ())
917 {
918 }
919 
920 void
921 DrbActivator::ActivateCallback (Ptr<DrbActivator> a, std::string context, uint64_t imsi, uint16_t cellId, uint16_t rnti)
922 {
923  NS_LOG_FUNCTION (a << context << imsi << cellId << rnti);
924  a->ActivateDrb (imsi, cellId, rnti);
925 }
926 
927 void
928 DrbActivator::ActivateDrb (uint64_t imsi, uint16_t cellId, uint16_t rnti)
929 {
930  NS_LOG_FUNCTION (this << imsi << cellId << rnti << m_active);
931  if ((!m_active) && (imsi == m_imsi))
932  {
933  Ptr<LteUeRrc> ueRrc = m_ueDevice->GetObject<LteUeNetDevice> ()->GetRrc ();
934  NS_ASSERT (ueRrc->GetState () == LteUeRrc::CONNECTED_NORMALLY);
935  uint16_t rnti = ueRrc->GetRnti ();
936  Ptr<LteEnbNetDevice> enbLteDevice = m_ueDevice->GetObject<LteUeNetDevice> ()->GetTargetEnb ();
937  Ptr<LteEnbRrc> enbRrc = enbLteDevice->GetObject<LteEnbNetDevice> ()->GetRrc ();
938  NS_ASSERT (ueRrc->GetCellId () == enbLteDevice->GetCellId ());
939  Ptr<UeManager> ueManager = enbRrc->GetUeManager (rnti);
940  NS_ASSERT (ueManager->GetState () == UeManager::CONNECTED_NORMALLY
941  || ueManager->GetState () == UeManager::CONNECTION_RECONFIGURATION);
943  params.rnti = rnti;
944  params.bearer = m_bearer;
945  params.bearerId = 0;
946  params.gtpTeid = 0; // don't care
947  enbRrc->GetS1SapUser ()->DataRadioBearerSetupRequest (params);
948  m_active = true;
949  }
950 }
951 
952 
953 void
955 {
956  NS_LOG_FUNCTION (this << ueDevice);
957  NS_ASSERT_MSG (m_epcHelper == 0, "this method must not be used when the EPC is being used");
958 
959  // Normally it is the EPC that takes care of activating DRBs
960  // when the UE gets connected. When the EPC is not used, we achieve
961  // the same behavior by hooking a dedicated DRB activation function
962  // to the Enb RRC Connection Established trace source
963 
964 
965  Ptr<LteEnbNetDevice> enbLteDevice = ueDevice->GetObject<LteUeNetDevice> ()->GetTargetEnb ();
966 
967  std::ostringstream path;
968  path << "/NodeList/" << enbLteDevice->GetNode ()->GetId ()
969  << "/DeviceList/" << enbLteDevice->GetIfIndex ()
970  << "/LteEnbRrc/ConnectionEstablished";
971  Ptr<DrbActivator> arg = Create<DrbActivator> (ueDevice, bearer);
973 }
974 
975 void
977 {
978  NS_LOG_FUNCTION (this);
979 
980  NS_ASSERT_MSG (m_epcHelper != 0, "X2 interfaces cannot be set up when the EPC is not used");
981 
982  for (NodeContainer::Iterator i = enbNodes.Begin (); i != enbNodes.End (); ++i)
983  {
984  for (NodeContainer::Iterator j = i + 1; j != enbNodes.End (); ++j)
985  {
986  AddX2Interface (*i, *j);
987  }
988  }
989 }
990 
991 void
993 {
994  NS_LOG_FUNCTION (this);
995  NS_LOG_INFO ("setting up the X2 interface");
996 
997  m_epcHelper->AddX2Interface (enbNode1, enbNode2);
998 }
999 
1000 void
1002 {
1003  NS_LOG_FUNCTION (this << ueDev << sourceEnbDev << targetEnbDev);
1004  NS_ASSERT_MSG (m_epcHelper, "Handover requires the use of the EPC - did you forget to call LteHelper::SetEpcHelper () ?");
1005  Simulator::Schedule (hoTime, &LteHelper::DoHandoverRequest, this, ueDev, sourceEnbDev, targetEnbDev);
1006 }
1007 
1008 void
1010 {
1011  NS_LOG_FUNCTION (this << ueDev << sourceEnbDev << targetEnbDev);
1012 
1013  uint16_t targetCellId = targetEnbDev->GetObject<LteEnbNetDevice> ()->GetCellId ();
1014  Ptr<LteEnbRrc> sourceRrc = sourceEnbDev->GetObject<LteEnbNetDevice> ()->GetRrc ();
1015  uint16_t rnti = ueDev->GetObject<LteUeNetDevice> ()->GetRrc ()->GetRnti ();
1016  sourceRrc->SendHandoverRequest (rnti, targetCellId);
1017 }
1018 
1019 void
1021 {
1022  NS_LOG_FUNCTION (this << ueDevice << bearerId);
1023  NS_ASSERT_MSG (m_epcHelper != 0, "Dedicated EPS bearers cannot be de-activated when the EPC is not used");
1024  NS_ASSERT_MSG (bearerId != 1, "Default bearer cannot be de-activated until and unless and UE is released");
1025 
1026  DoDeActivateDedicatedEpsBearer (ueDevice, enbDevice, bearerId);
1027 }
1028 
1029 void
1031 {
1032  NS_LOG_FUNCTION (this << ueDevice << bearerId);
1033 
1034  //Extract IMSI and rnti
1035  uint64_t imsi = ueDevice->GetObject<LteUeNetDevice> ()->GetImsi ();
1036  uint16_t rnti = ueDevice->GetObject<LteUeNetDevice> ()->GetRrc ()->GetRnti ();
1037 
1038 
1039  Ptr<LteEnbRrc> enbRrc = enbDevice->GetObject<LteEnbNetDevice> ()->GetRrc ();
1040 
1041  enbRrc->DoSendReleaseDataRadioBearer (imsi,rnti,bearerId);
1042 }
1043 
1044 
1045 void
1047 {
1048  NS_LOG_FUNCTION (this);
1049  for (NetDeviceContainer::Iterator i = ueDevices.Begin (); i != ueDevices.End (); ++i)
1050  {
1051  ActivateDataRadioBearer (*i, bearer);
1052  }
1053 }
1054 
1055 void
1057 {
1058  LogComponentEnable ("LteHelper", LOG_LEVEL_ALL);
1059  LogComponentEnable ("LteEnbRrc", LOG_LEVEL_ALL);
1060  LogComponentEnable ("LteUeRrc", LOG_LEVEL_ALL);
1061  LogComponentEnable ("LteEnbMac", LOG_LEVEL_ALL);
1062  LogComponentEnable ("LteUeMac", LOG_LEVEL_ALL);
1063  LogComponentEnable ("LteRlc", LOG_LEVEL_ALL);
1064  LogComponentEnable ("LteRlcUm", LOG_LEVEL_ALL);
1065  LogComponentEnable ("LteRlcAm", LOG_LEVEL_ALL);
1066  LogComponentEnable ("RrFfMacScheduler", LOG_LEVEL_ALL);
1067  LogComponentEnable ("PfFfMacScheduler", LOG_LEVEL_ALL);
1068 
1069  LogComponentEnable ("LtePhy", LOG_LEVEL_ALL);
1070  LogComponentEnable ("LteEnbPhy", LOG_LEVEL_ALL);
1071  LogComponentEnable ("LteUePhy", LOG_LEVEL_ALL);
1072  LogComponentEnable ("LteSpectrumValueHelper", LOG_LEVEL_ALL);
1073  LogComponentEnable ("LteSpectrumPhy", LOG_LEVEL_ALL);
1074  LogComponentEnable ("LteInterference", LOG_LEVEL_ALL);
1075  LogComponentEnable ("LteChunkProcessor", LOG_LEVEL_ALL);
1076 
1077  std::string propModelStr = m_dlPathlossModelFactory.GetTypeId ().GetName ().erase (0,5).c_str ();
1078  LogComponentEnable ("LteNetDevice", LOG_LEVEL_ALL);
1079  LogComponentEnable ("LteUeNetDevice", LOG_LEVEL_ALL);
1080  LogComponentEnable ("LteEnbNetDevice", LOG_LEVEL_ALL);
1081 
1082  LogComponentEnable ("RadioBearerStatsCalculator", LOG_LEVEL_ALL);
1083  LogComponentEnable ("LteStatsCalculator", LOG_LEVEL_ALL);
1084  LogComponentEnable ("MacStatsCalculator", LOG_LEVEL_ALL);
1085  LogComponentEnable ("PhyTxStatsCalculator", LOG_LEVEL_ALL);
1086  LogComponentEnable ("PhyRxStatsCalculator", LOG_LEVEL_ALL);
1087  LogComponentEnable ("PhyStatsCalculator", LOG_LEVEL_ALL);
1088 
1089 
1090 }
1091 
1092 void
1094 {
1095  EnablePhyTraces ();
1096  EnableMacTraces ();
1097  EnableRlcTraces ();
1098  EnablePdcpTraces ();
1099 }
1100 
1101 void
1103 {
1104  NS_ASSERT_MSG (m_rlcStats == 0, "please make sure that LteHelper::EnableRlcTraces is called at most once");
1105  m_rlcStats = CreateObject<RadioBearerStatsCalculator> ("RLC");
1107 }
1108 
1109 int64_t
1111 {
1112  int64_t currentStream = stream;
1113  if ((m_fadingModule != 0) && (m_fadingStreamsAssigned == false))
1114  {
1116  if (tflm != 0)
1117  {
1118  currentStream += tflm->AssignStreams (currentStream);
1119  m_fadingStreamsAssigned = true;
1120  }
1121  }
1122  Ptr<NetDevice> netDevice;
1123  for (NetDeviceContainer::Iterator i = c.Begin (); i != c.End (); ++i)
1124  {
1125  netDevice = (*i);
1126  Ptr<LteEnbNetDevice> lteEnb = DynamicCast<LteEnbNetDevice> (netDevice);
1127  if (lteEnb)
1128  {
1129  Ptr<LteSpectrumPhy> dlPhy = lteEnb->GetPhy ()->GetDownlinkSpectrumPhy ();
1130  Ptr<LteSpectrumPhy> ulPhy = lteEnb->GetPhy ()->GetUplinkSpectrumPhy ();
1131  currentStream += dlPhy->AssignStreams (currentStream);
1132  currentStream += ulPhy->AssignStreams (currentStream);
1133  }
1134  Ptr<LteUeNetDevice> lteUe = DynamicCast<LteUeNetDevice> (netDevice);
1135  if (lteUe)
1136  {
1137  Ptr<LteSpectrumPhy> dlPhy = lteUe->GetPhy ()->GetDownlinkSpectrumPhy ();
1138  Ptr<LteSpectrumPhy> ulPhy = lteUe->GetPhy ()->GetUplinkSpectrumPhy ();
1139  Ptr<LteUeMac> ueMac = lteUe->GetMac ();
1140  currentStream += dlPhy->AssignStreams (currentStream);
1141  currentStream += ulPhy->AssignStreams (currentStream);
1142  currentStream += ueMac->AssignStreams (currentStream);
1143  }
1144  }
1145  return (currentStream - stream);
1146 }
1147 
1148 
1149 void
1151 {
1152  EnableDlPhyTraces ();
1153  EnableUlPhyTraces ();
1158 }
1159 
1160 void
1162 {
1163  Config::Connect ("/NodeList/*/DeviceList/*/LteEnbPhy/DlPhyTransmission",
1165 }
1166 
1167 void
1169 {
1170  Config::Connect ("/NodeList/*/DeviceList/*/LteUePhy/UlPhyTransmission",
1172 }
1173 
1174 void
1176 {
1177  Config::Connect ("/NodeList/*/DeviceList/*/LteUePhy/DlSpectrumPhy/DlPhyReception",
1179 }
1180 
1181 void
1183 {
1184  Config::Connect ("/NodeList/*/DeviceList/*/LteEnbPhy/UlSpectrumPhy/UlPhyReception",
1186 }
1187 
1188 
1189 void
1191 {
1192  EnableDlMacTraces ();
1193  EnableUlMacTraces ();
1194 }
1195 
1196 
1197 void
1199 {
1201  Config::Connect ("/NodeList/*/DeviceList/*/LteEnbMac/DlScheduling",
1203 }
1204 
1205 void
1207 {
1209  Config::Connect ("/NodeList/*/DeviceList/*/LteEnbMac/UlScheduling",
1211 }
1212 
1213 void
1215 {
1217  Config::Connect ("/NodeList/*/DeviceList/*/LteUePhy/ReportCurrentCellRsrpSinr",
1219 }
1220 
1221 void
1223 {
1225  Config::Connect ("/NodeList/*/DeviceList/*/LteEnbPhy/ReportUeSinr",
1227  Config::Connect ("/NodeList/*/DeviceList/*/LteEnbPhy/ReportInterference",
1229 
1230 }
1231 
1234 {
1235  return m_rlcStats;
1236 }
1237 
1238 void
1240 {
1241  NS_ASSERT_MSG (m_pdcpStats == 0, "please make sure that LteHelper::EnablePdcpTraces is called at most once");
1242  m_pdcpStats = CreateObject<RadioBearerStatsCalculator> ("PDCP");
1244 }
1245 
1248 {
1249  return m_pdcpStats;
1250 }
1251 
1252 } // 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:350
Ptr< const AttributeChecker > MakeStringChecker(void)
Definition: string.cc:30
Parameters passed to DataRadioBearerSetupRequest ()
uint16_t GetDlEarfcn() const
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:648
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:299
virtual void AddPropagationLossModel(Ptr< PropagationLossModel > loss)=0
Set the single-frequency propagation loss model to be used.
void EnableDlRxPhyTraces(void)
Enable trace sinks for DL reception PHY layer.
Definition: lte-helper.cc:1175
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
RadioBearerStatsConnector m_radioBearerStatsConnector
Connects RLC and PDCP statistics containers to appropriate trace sources.
Definition: lte-helper.h:696
#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:412
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:140
AttributeValue implementation for Boolean.
Definition: boolean.h:34
tuple devices
Definition: first.py:32
NetDeviceContainer InstallEnbDevice(NodeContainer c)
Create a set of eNodeB devices.
Definition: lte-helper.cc:382
virtual void GenerateMixedCqiReport(const SpectrumValue &sinr)
Definition: lte-ue-phy.cc:609
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:44
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:1056
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Definition: object.h:462
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:1001
static void DlSchedulingCallback(Ptr< MacStatsCalculator > macStats, std::string path, uint32_t frameNo, uint32_t subframeNo, uint16_t rnti, uint8_t mcsTb1, uint16_t sizeTb1, uint8_t mcsTb2, uint16_t sizeTb2)
Trace sink for the ns3::LteEnbMac::DlScheduling trace source.
bool m_fadingStreamsAssigned
True if a random variable stream number has been assigned for the fading model.
Definition: lte-helper.h:681
ObjectFactory m_fadingModelFactory
Factory of fading model object for both the downlink and uplink channels.
Definition: lte-helper.h:674
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:921
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:1214
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:472
virtual void ReceiveLteControlMessageList(std::list< Ptr< LteControlMessage > >)
PhySpectrum received a new list of LteControlMessage.
Definition: lte-enb-phy.cc:523
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:81
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:315
DrbActivator(Ptr< NetDevice > ueDevice, EpsBearer bearer)
DrbActivator Constructor.
Definition: lte-helper.cc:912
Ptr< LteEnbPhy > GetPhy(void) const
void SetUeAntennaModelAttribute(std::string n, const AttributeValue &v)
Set an attribute for the UE antenna model to be created.
Definition: lte-helper.cc:343
static Ptr< EpcTft > Default()
creates a TFT matching any traffic
Definition: epc-tft.cc:141
void ReportUeSinr(uint16_t cellId, uint64_t imsi, uint16_t rnti, double sinrLinear)
Notifies the stats calculator that an UE SINR report has occurred.
#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
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:716
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:201
void EnableRlcTraces(void)
Enable trace sinks for RLC layer.
Definition: lte-helper.cc:1102
bool m_usePdschForCqiGeneration
The UsePdschForCqiGeneration attribute.
Definition: lte-helper.h:733
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:684
void EnablePdcpStats(Ptr< RadioBearerStatsCalculator > pdcpStats)
Enables trace sinks for PDCP layer.
Ptr< PhyRxStatsCalculator > m_phyRxStats
Container of PHY layer statistics related to reception.
Definition: lte-helper.h:688
std::string m_fadingModelType
Name of fading model type, e.g., "ns3::TraceFadingLossModel".
Definition: lte-helper.h:672
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:211
void SetUeDeviceAttribute(std::string n, const AttributeValue &v)
Set an attribute for the UE devices (LteUeNetDevice) to be created.
Definition: lte-helper.cc:329
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:244
#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:336
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:690
int64_t AssignStreams(NetDeviceContainer c, int64_t stream)
Assign a fixed random variable stream number to the random variables used.
Definition: lte-helper.cc:1110
ObjectFactory m_ulPathlossModelFactory
Factory of path loss model object for the uplink channel.
Definition: lte-helper.h:667
void ActivateDataRadioBearer(NetDeviceContainer ueDevices, EpsBearer bearer)
Activate a Data Radio Bearer on a given UE devices (for LTE-only simulation).
Definition: lte-helper.cc:1046
ObjectFactory m_channelFactory
Factory of both the downlink and uplink LTE channels.
Definition: lte-helper.h:669
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:824
void SetHandoverAlgorithmType(std::string type)
Set the type of handover algorithm to be used by eNodeB devices.
Definition: lte-helper.cc:273
void EnableUlRxPhyTraces(void)
Enable trace sinks for UL reception PHY layer.
Definition: lte-helper.cc:1182
void SetFfrAlgorithmType(std::string type)
Set the type of FFR algorithm to be used by eNodeB devices.
Definition: lte-helper.cc:252
static TypeId GetTypeId(void)
void SetSchedulerType(std::string type)
Set the type of scheduler to be used by eNodeB devices.
Definition: lte-helper.cc:225
uint32_t GetN(void) const
Get the number of Ptr stored in this container.
Ptr< RadioBearerStatsCalculator > m_rlcStats
Container of RLC layer statistics.
Definition: lte-helper.h:692
std::string GetHandoverAlgorithmType() const
Definition: lte-helper.cc:267
void EnablePdcpTraces(void)
Enable trace sinks for PDCP layer.
Definition: lte-helper.cc:1239
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:792
static void ReportCurrentCellRsrpSinrCallback(Ptr< PhyStatsCalculator > phyStats, std::string path, uint16_t cellId, uint16_t rnti, double rsrp, double sinr)
trace sink
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:825
Ptr< Object > m_downlinkPathlossModel
The path loss model used in the downlink channel.
Definition: lte-helper.h:646
static double GetCarrierFrequency(uint16_t earfcn)
Calculates the carrier frequency from the E-UTRA Absolute Radio Frequency Channel Number (EARFCN) acc...
This class contains the specification of EPS Bearers.
Definition: eps-bearer.h:71
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:1020
Ptr< Application > GetApplication(uint32_t index) const
Retrieve the index-th Application associated to this node.
Definition: node.cc:168
void LogComponentEnable(char const *name, enum LogLevel level)
Enable the logging output associated with that log component.
Definition: log.cc:351
tuple phy
Definition: third.py:86
Ptr< NetDevice > m_ueDevice
UeNetDevice for which bearer will be activated.
Definition: lte-helper.cc:901
void SetHandoverAlgorithmAttribute(std::string n, const AttributeValue &v)
Set an attribute for the handover algorithm to be created.
Definition: lte-helper.cc:281
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:1238
virtual uint32_t GetIfIndex(void) const
void DoHandoverRequest(Ptr< NetDevice > ueDev, Ptr< NetDevice > sourceEnbDev, Ptr< NetDevice > targetEnbDev)
The actual function to trigger a manual handover.
Definition: lte-helper.cc:1009
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:837
double CalculateDistance(const Vector3D &a, const Vector3D &b)
Definition: vector.cc:78
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.
uint64_t m_imsi
imsi the unique UE identifier
Definition: lte-helper.cc:909
void EnableRlcStats(Ptr< RadioBearerStatsCalculator > rlcStats)
Enables trace sinks for RLC layer.
void EnableTraces(void)
Enables trace sinks for PHY, MAC, RLC and PDCP.
Definition: lte-helper.cc:1093
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:239
Ptr< NetDevice > InstallSingleUeDevice(Ptr< Node > n)
Create a UE device (LteUeNetDevice) on the given node.
Definition: lte-helper.cc:584
static TypeId GetTypeId(void)
Get the type ID.
uint64_t m_imsiCounter
Keep track of the number of IMSI allocated.
Definition: lte-helper.h:710
ObjectFactory m_enbAntennaModelFactory
Factory of antenna object for eNodeB.
Definition: lte-helper.h:659
holds a vector of ns3::NetDevice pointers
virtual void AddSpectrumPropagationLossModel(Ptr< SpectrumPropagationLossModel > loss)=0
Set the frequency-dependent propagation loss model to be used.
uint16_t m_cellIdCounter
Keep track of the number of cell ID allocated.
Definition: lte-helper.h:716
void EnablePhyTraces(void)
Enable trace sinks for PHY layer.
Definition: lte-helper.cc:1150
bool m_isAnrEnabled
The AnrEnabled attribute.
Definition: lte-helper.h:727
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
Definition: callback.h:1489
ObjectFactory m_handoverAlgorithmFactory
Factory of handover algorithm object.
Definition: lte-helper.h:655
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:857
tuple mac
Definition: third.py:92
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:252
void Connect(std::string path, const CallbackBase &cb)
Definition: config.cc:835
void SetEnbAntennaModelType(std::string type)
Set the type of antenna model to be used by eNodeB devices.
Definition: lte-helper.cc:315
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:845
ObjectFactory m_dlPathlossModelFactory
Factory of path loss model object for the downlink channel.
Definition: lte-helper.h:665
void SetSpectrumChannelType(std::string type)
Set the type of spectrum channel to be used in both DL and UL.
Definition: lte-helper.cc:368
static TypeId GetTypeId(void)
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:362
void EnableDlMacTraces(void)
Enable trace sinks for DL MAC layer.
Definition: lte-helper.cc:1198
virtual void ReportDataInterference(const SpectrumValue &interf)
Definition: lte-ue-phy.cc:665
virtual void ReceiveLteDlHarqFeedback(DlInfoListElement_s mes)
PhySpectrum generated a new DL HARQ feedback.
Definition: lte-ue-phy.cc:1423
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.
Hold objects of type Ptr.
Definition: pointer.h:36
This entity is installed inside an eNB and provides the functionality for the X2 interface.
Definition: epc-x2.h:70
void EnableUlTxPhyTraces(void)
Enable trace sinks for UL transmission PHY layer.
Definition: lte-helper.cc:1168
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:644
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:976
std::string GetName(void) const
Get the name.
Definition: type-id.cc:958
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:651
void EnableUlPhyTraces(void)
Enable trace sinks for UL PHY layer.
Definition: lte-helper.cc:1222
uint16_t GetUlEarfcn() const
void EnableDlTxPhyTraces(void)
Enable trace sinks for DL transmission PHY layer.
Definition: lte-helper.cc:1161
friend class ObjectFactory
Definition: object.h:322
Ptr< SpectrumPropagationLossModel > m_fadingModule
The fading model used in both the downlink and uplink channels.
Definition: lte-helper.h:676
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:1206
static void UlPhyReceptionCallback(Ptr< PhyRxStatsCalculator > phyRxStats, std::string path, PhyReceptionStatParameters params)
trace sink
static void UlSchedulingCallback(Ptr< MacStatsCalculator > macStats, std::string path, uint32_t frameNo, uint32_t subframeNo, uint16_t rnti, uint8_t mcs, uint16_t size)
Trace sink for the ns3::LteEnbMac::UlScheduling trace source.
This abstract base class identifies the interface by means of which the helper object can plug on the...
#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:90
Ptr< EpcHelper > m_epcHelper
Helper which provides implementation of core network.
Definition: lte-helper.h:703
Ptr< RadioBearerStatsCalculator > GetRlcStats(void)
Definition: lte-helper.cc:1233
virtual ~LteHelper(void)
Definition: lte-helper.cc:135
NetDeviceContainer InstallUeDevice(NodeContainer c)
Create a set of UE devices.
Definition: lte-helper.cc:397
Ptr< PhyTxStatsCalculator > m_phyTxStats
Container of PHY layer statistics related to transmission.
Definition: lte-helper.h:686
Ptr< RadioBearerStatsCalculator > GetPdcpStats(void)
Definition: lte-helper.cc:1247
static void UlPhyTransmissionCallback(Ptr< PhyTxStatsCalculator > phyTxStats, std::string path, PhyTransmissionStatParameters params)
trace sink
virtual void DoDispose(void)
Destructor implementation.
Definition: lte-helper.cc:208
ObjectFactory m_ffrAlgorithmFactory
Factory of FFR (frequency reuse) algorithm object.
Definition: lte-helper.h:653
This application is installed inside eNBs and provides the bridge functionality for user data plane p...
Models the propagation loss through a transmission medium.
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:218
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:905
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Definition: log.h:228
void SetPathlossModelType(std::string type)
Set the type of path loss model to be used for both DL and UL channels.
Definition: lte-helper.cc:289
std::vector< Ptr< NetDevice > >::const_iterator Iterator
NetDevice container iterator.
virtual void ReceiveLteControlMessageList(std::list< Ptr< LteControlMessage > >)
Definition: lte-ue-phy.cc:862
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:928
virtual void ReceivePss(uint16_t cellId, Ptr< SpectrumValue > p)
Definition: lte-ue-phy.cc:1014
void SetEnbAntennaModelAttribute(std::string n, const AttributeValue &v)
Set an attribute for the eNodeB antenna model to be created.
Definition: lte-helper.cc:322
ObjectFactory m_ueNetDeviceFactory
Factory for LteUeNetDevice objects.
Definition: lte-helper.h:661
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:375
Print everything.
Definition: log.h:112
Defines the interface for spectrum-aware channel implementations.
void PhyPduReceived(Ptr< Packet > p)
PhySpectrum received a new PHY-PDU.
Definition: lte-ue-phy.cc:420
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:85
spectrum-aware propagation loss model
void EnableMacTraces(void)
Enable trace sinks for MAC layer.
Definition: lte-helper.cc:1190
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:897
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
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:674
Iterator End(void) const
Get an iterator which indicates past-the-last NetDevice in the container.
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:1030
Ptr< RadioBearerStatsCalculator > m_pdcpStats
Container of PDCP layer statistics.
Definition: lte-helper.h:694
This class can be used to hold variables of floating point type such as 'double' or 'float'...
Definition: double.h:41
ObjectFactory m_ueAntennaModelFactory
Factory of antenna object for UE.
Definition: lte-helper.h:663
std::string GetFfrAlgorithmType() const
Definition: lte-helper.cc:246
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:191
The eNodeB device implementation.
A template-based reference counting class.
void PhyPduReceived(Ptr< Packet > p)
PhySpectrum received a new PHY-PDU.
Definition: lte-enb-phy.cc:430
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:260
ObjectFactory m_enbNetDeviceFactory
Factory of LteEnbNetDevice objects.
Definition: lte-helper.h:657
void UpdateSinrPerceived(const SpectrumValue &sinr)
Ptr< SpectrumChannel > m_downlinkChannel
The downlink LTE channel used in the simulation.
Definition: lte-helper.h:642
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:904
void Initialize(void)
Invoke DoInitialize on all Objects aggregated to this one.
Definition: object.cc:183
std::string GetSchedulerType() const
Definition: lte-helper.cc:233
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:657
void SetEnbDeviceAttribute(std::string n, const AttributeValue &v)
Set an attribute for the eNodeB devices (LteEnbNetDevice) to be created.
Definition: lte-helper.cc:307
bool m_useIdealRrc
The UseIdealRrc attribute.
Definition: lte-helper.h:722
The LteUeNetDevice class implements the UE net device.