A Discrete-Event Network Simulator
API
lte-ue-phy.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
4  * Copyright (c) 2018 Fraunhofer ESK : RLF extensions
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation;
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Author: Giuseppe Piro <g.piro@poliba.it>
20  * Marco Miozzo <marco.miozzo@cttc.es>
21  * Nicola Baldo <nbaldo@cttc.es>
22  * Modified by:
23  * Vignesh Babu <ns3-dev@esk.fraunhofer.de> (RLF extensions)
24  */
25 
26 #include <ns3/object-factory.h>
27 #include <ns3/log.h>
28 #include <ns3/node.h>
29 #include <cfloat>
30 #include <cmath>
31 #include <ns3/simulator.h>
32 #include <ns3/double.h>
33 #include "lte-ue-phy.h"
34 #include "lte-enb-phy.h"
35 #include "lte-net-device.h"
36 #include "lte-ue-net-device.h"
37 #include "lte-enb-net-device.h"
39 #include "lte-amc.h"
40 #include "lte-ue-mac.h"
41 #include "ff-mac-common.h"
42 #include "lte-chunk-processor.h"
43 #include <ns3/lte-common.h>
44 #include <ns3/pointer.h>
45 #include <ns3/boolean.h>
46 #include <ns3/lte-ue-power-control.h>
47 
48 namespace ns3 {
49 
50 NS_LOG_COMPONENT_DEFINE ("LteUePhy");
51 
52 
53 
61 static const Time UL_DATA_DURATION = NanoSeconds (1e6 - 71429 - 1);
62 
67 static const Time UL_SRS_DELAY_FROM_SUBFRAME_START = NanoSeconds (1e6 - 71429);
68 
69 
70 
71 
73 // member SAP forwarders
75 
78 {
79 public:
86 
87  // inherited from LtePhySapProvider
88  virtual void SendMacPdu (Ptr<Packet> p);
90  virtual void SendRachPreamble (uint32_t prachId, uint32_t raRnti);
91  virtual void NotifyConnectionSuccessful ();
92 
93 private:
95 };
96 
98 {
99 
100 }
101 
102 void
104 {
105  m_phy->DoSendMacPdu (p);
106 }
107 
108 void
110 {
112 }
113 
114 void
115 UeMemberLteUePhySapProvider::SendRachPreamble (uint32_t prachId, uint32_t raRnti)
116 {
117  m_phy->DoSendRachPreamble (prachId, raRnti);
118 }
119 
120 void
122 {
124 }
125 
126 
128 // LteUePhy methods
130 
132 static const std::string g_uePhyStateName[LteUePhy::NUM_STATES] =
133 {
134  "CELL_SEARCH",
135  "SYNCHRONIZED"
136 };
137 
142 static inline const std::string & ToString (LteUePhy::State s)
143 {
144  return g_uePhyStateName[s];
145 }
146 
147 
148 NS_OBJECT_ENSURE_REGISTERED (LteUePhy);
149 
150 
152 {
153  NS_LOG_FUNCTION (this);
154  NS_FATAL_ERROR ("This constructor should not be called");
155 }
156 
158  : LtePhy (dlPhy, ulPhy),
159  m_uePhySapUser (0),
160  m_ueCphySapUser (0),
161  m_state (CELL_SEARCH),
162  m_subframeNo (0),
163  m_rsReceivedPowerUpdated (false),
164  m_rsInterferencePowerUpdated (false),
165  m_dataInterferencePowerUpdated (false),
166  m_pssReceived (false),
167  m_ueMeasurementsFilterPeriod (MilliSeconds (200)),
168  m_ueMeasurementsFilterLast (MilliSeconds (0)),
169  m_rsrpSinrSampleCounter (0),
170  m_imsi (0)
171 {
172  m_amc = CreateObject <LteAmc> ();
173  m_powerControl = CreateObject <LteUePowerControl> ();
177 
178  NS_ASSERT_MSG (Simulator::Now ().GetNanoSeconds () == 0,
179  "Cannot create UE devices after simulation started");
181 
182  DoReset ();
183 }
184 
185 
187 {
188  m_txModeGain.clear ();
189 }
190 
191 void
193 {
194  NS_LOG_FUNCTION (this);
195  delete m_uePhySapProvider;
196  delete m_ueCphySapProvider;
198 }
199 
200 
201 
202 TypeId
204 {
205  static TypeId tid = TypeId ("ns3::LteUePhy")
206  .SetParent<LtePhy> ()
207  .SetGroupName("Lte")
208  .AddConstructor<LteUePhy> ()
209  .AddAttribute ("TxPower",
210  "Transmission power in dBm",
211  DoubleValue (10.0),
214  MakeDoubleChecker<double> ())
215  .AddAttribute ("NoiseFigure",
216  "Loss (dB) in the Signal-to-Noise-Ratio due to non-idealities in the receiver."
217  " According to Wikipedia (http://en.wikipedia.org/wiki/Noise_figure), this is "
218  "\"the difference in decibels (dB) between"
219  " the noise output of the actual receiver to the noise output of an "
220  " ideal receiver with the same overall gain and bandwidth when the receivers "
221  " are connected to sources at the standard noise temperature T0.\" "
222  "In this model, we consider T0 = 290K.",
223  DoubleValue (9.0),
226  MakeDoubleChecker<double> ())
227  .AddAttribute ("TxMode1Gain",
228  "Transmission mode 1 gain in dB",
229  DoubleValue (0.0),
231  MakeDoubleChecker<double> ())
232  .AddAttribute ("TxMode2Gain",
233  "Transmission mode 2 gain in dB",
234  DoubleValue (4.2),
236  MakeDoubleChecker<double> ())
237  .AddAttribute ("TxMode3Gain",
238  "Transmission mode 3 gain in dB",
239  DoubleValue (-2.8),
241  MakeDoubleChecker<double> ())
242  .AddAttribute ("TxMode4Gain",
243  "Transmission mode 4 gain in dB",
244  DoubleValue (0.0),
246  MakeDoubleChecker<double> ())
247  .AddAttribute ("TxMode5Gain",
248  "Transmission mode 5 gain in dB",
249  DoubleValue (0.0),
251  MakeDoubleChecker<double> ())
252  .AddAttribute ("TxMode6Gain",
253  "Transmission mode 6 gain in dB",
254  DoubleValue (0.0),
256  MakeDoubleChecker<double> ())
257  .AddAttribute ("TxMode7Gain",
258  "Transmission mode 7 gain in dB",
259  DoubleValue (0.0),
261  MakeDoubleChecker<double> ())
262  .AddTraceSource ("ReportCurrentCellRsrpSinr",
263  "RSRP and SINR statistics.",
265  "ns3::LteUePhy::RsrpSinrTracedCallback")
266  .AddAttribute ("RsrpSinrSamplePeriod",
267  "The sampling period for reporting RSRP-SINR stats (default value 1)",
268  UintegerValue (1),
270  MakeUintegerChecker<uint16_t> ())
271  .AddTraceSource ("ReportUlPhyResourceBlocks",
272  "UL transmission PHY layer resource blocks.",
274  "ns3::LteUePhy::UlPhyResourceBlocksTracedCallback")
275  .AddTraceSource ("ReportPowerSpectralDensity",
276  "Power Spectral Density data.",
278  "ns3::LteUePhy::PowerSpectralDensityTracedCallback")
279  .AddTraceSource ("UlPhyTransmission",
280  "DL transmission PHY layer statistics.",
282  "ns3::PhyTransmissionStatParameters::TracedCallback")
283  .AddAttribute ("DlSpectrumPhy",
284  "The downlink LteSpectrumPhy associated to this LtePhy",
286  PointerValue (),
288  MakePointerChecker <LteSpectrumPhy> ())
289  .AddAttribute ("UlSpectrumPhy",
290  "The uplink LteSpectrumPhy associated to this LtePhy",
292  PointerValue (),
294  MakePointerChecker <LteSpectrumPhy> ())
295  .AddAttribute ("RsrqUeMeasThreshold",
296  "Receive threshold for PSS on RSRQ [dB]",
297  DoubleValue (-1000.0),
299  MakeDoubleChecker<double> ())
300  .AddAttribute ("UeMeasurementsFilterPeriod",
301  "Time period for reporting UE measurements, i.e., the"
302  "length of layer-1 filtering.",
303  TimeValue (MilliSeconds (200)),
305  MakeTimeChecker ())
306  .AddAttribute ("DownlinkCqiPeriodicity",
307  "Periodicity in milliseconds for reporting the"
308  "wideband and subband downlink CQIs to the eNB",
309  TimeValue (MilliSeconds (1)),
311  MakeTimeChecker ())
312  .AddTraceSource ("ReportUeMeasurements",
313  "Report UE measurements RSRP (dBm) and RSRQ (dB).",
315  "ns3::LteUePhy::RsrpRsrqTracedCallback")
316  .AddTraceSource ("StateTransition",
317  "Trace fired upon every UE PHY state transition",
319  "ns3::LteUePhy::StateTracedCallback")
320  .AddAttribute ("EnableUplinkPowerControl",
321  "If true, Uplink Power Control will be enabled.",
322  BooleanValue (true),
325  .AddAttribute ("Qout",
326  "corresponds to 10% block error rate of a hypothetical PDCCH transmission"
327  "taking into account the PCFICH errors with transmission parameters."
328  "see 3GPP TS 36.213 4.2.1 and TS 36.133 7.6",
329  DoubleValue (-5),
331  MakeDoubleChecker<double> ())
332  .AddAttribute ("Qin",
333  "corresponds to 2% block error rate of a hypothetical PDCCH transmission"
334  "taking into account the PCFICH errors with transmission parameters."
335  "see 3GPP TS 36.213 4.2.1 and TS 36.133 7.6",
336  DoubleValue (-3.9),
338  MakeDoubleChecker<double> ())
339  .AddAttribute ("NumQoutEvalSf",
340  "This specifies the total number of consecutive subframes"
341  "which corresponds to the Qout evaluation period",
342  UintegerValue (200), //see 3GPP 3GPP TS 36.133 7.6.2.1
345  MakeUintegerChecker<uint16_t> ())
346  .AddAttribute ("NumQinEvalSf",
347  "This specifies the total number of consecutive subframes"
348  "which corresponds to the Qin evaluation period",
349  UintegerValue (100), //see 3GPP 3GPP TS 36.133 7.6.2.1
352  MakeUintegerChecker<uint16_t> ())
353  .AddAttribute ("EnableRlfDetection",
354  "If true, RLF detection will be enabled.",
355  BooleanValue (true),
358  ;
359  return tid;
360 }
361 
362 void
364 {
365  NS_LOG_FUNCTION (this);
366 
367  NS_ABORT_MSG_IF (m_netDevice == nullptr, "LteNetDevice is not available in LteUePhy");
368  Ptr<Node> node = m_netDevice->GetNode ();
369  NS_ABORT_MSG_IF (node == nullptr, "Node is not available in the LteNetDevice of LteUePhy");
370  uint32_t nodeId = node->GetId ();
371 
372  //ScheduleWithContext() is needed here to set context for logs,
373  //because Initialize() is called outside of Node::AddDevice().
374 
376 
378 }
379 
380 void
382 {
383  NS_LOG_FUNCTION (this);
384  m_uePhySapUser = s;
385 }
386 
389 {
390  NS_LOG_FUNCTION (this);
391  return (m_uePhySapProvider);
392 }
393 
394 
395 void
397 {
398  NS_LOG_FUNCTION (this);
399  m_ueCphySapUser = s;
400 }
401 
404 {
405  NS_LOG_FUNCTION (this);
406  return (m_ueCphySapProvider);
407 }
408 
409 void
411 {
412  NS_LOG_FUNCTION (this << nf);
413  m_noiseFigure = nf;
414 }
415 
416 double
418 {
419  NS_LOG_FUNCTION (this);
420  return m_noiseFigure;
421 }
422 
423 void
425 {
426  NS_LOG_FUNCTION (this << pow);
427  m_txPower = pow;
428  m_powerControl->SetTxPower (pow);
429 }
430 
431 double
433 {
434  NS_LOG_FUNCTION (this);
435  return m_txPower;
436 }
437 
440 {
441  NS_LOG_FUNCTION (this);
442  return m_powerControl;
443 }
444 
445 uint8_t
447 {
448  return (m_macChTtiDelay);
449 }
450 
453 {
454  return m_downlinkSpectrumPhy;
455 }
456 
459 {
460  return m_uplinkSpectrumPhy;
461 }
462 
463 void
464 LteUePhy::SetNumQoutEvalSf (uint16_t numSubframes)
465 {
466  NS_LOG_FUNCTION (this << numSubframes);
467  NS_ABORT_MSG_IF (numSubframes % 10 != 0, "Number of subframes used for Qout "
468  "evaluation must be multiple of 10");
469  m_numOfQoutEvalSf = numSubframes;
470 }
471 
472 void
473 LteUePhy::SetNumQinEvalSf (uint16_t numSubframes)
474 {
475  NS_LOG_FUNCTION (this << numSubframes);
476  NS_ABORT_MSG_IF (numSubframes % 10 != 0, "Number of subframes used for Qin "
477  "evaluation must be multiple of 10");
478  m_numOfQinEvalSf = numSubframes;
479 }
480 
481 uint16_t
483 {
484  NS_LOG_FUNCTION (this);
485  return m_numOfQoutEvalSf;
486 }
487 
488 uint16_t
490 {
491  NS_LOG_FUNCTION (this);
492  return m_numOfQinEvalSf;
493 }
494 
495 void
497 {
498  NS_LOG_FUNCTION (this);
499 
500  SetMacPdu (p);
501 }
502 
503 
504 void
506 {
508 }
509 
510 void
512 {
513  NS_LOG_FUNCTION (this);
514 
516 
518  m_uplinkSpectrumPhy->SetTxPowerSpectralDensity (txPsd);
519 }
520 
521 
522 void
523 LteUePhy::SetSubChannelsForReception (std::vector <int> mask)
524 {
525  NS_LOG_FUNCTION (this);
527 }
528 
529 
530 std::vector <int>
532 {
533  NS_LOG_FUNCTION (this);
535 }
536 
537 
538 std::vector <int>
540 {
541  NS_LOG_FUNCTION (this);
543 }
544 
545 
548 {
549  NS_LOG_FUNCTION (this);
550  LteSpectrumValueHelper psdHelper;
553 
554  return psd;
555 }
556 
557 void
559 {
560  NS_LOG_FUNCTION (this);
570  if (m_cellId == 0)
571  {
572  return;
573  }
574  m_ctrlSinrForRlf = sinr;
575  GenerateCqiRsrpRsrq (sinr);
576 }
577 
578 void
580 {
581  NS_LOG_FUNCTION (this << sinr);
582 
584  NS_ASSERT (m_cellId > 0);
585 
586  if (m_dlConfigured && m_ulConfigured && (m_rnti > 0))
587  {
588  // check periodic wideband CQI
590  {
591  NS_LOG_DEBUG("Reporting P10 CQI at : " << Simulator::Now().GetMilliSeconds()
592  << " ms. Last reported at : " << m_p10CqiLast.GetMilliSeconds() << " ms");
593  Ptr<LteUeNetDevice> thisDevice = GetDevice ()->GetObject<LteUeNetDevice> ();
595  if (msg)
596  {
598  }
600  }
601  // check aperiodic high-layer configured subband CQI
603  {
604  NS_LOG_DEBUG("Reporting A30 CQI at : " << Simulator::Now().GetMilliSeconds()
605  << " ms. Last reported at : " << m_a30CqiLast.GetMilliSeconds() << " ms");
606  Ptr<LteUeNetDevice> thisDevice = GetDevice ()->GetObject<LteUeNetDevice> ();
608  if (msg)
609  {
611  }
613  }
614  }
615 
616  // Generate PHY trace
619  {
620  NS_ASSERT_MSG (m_rsReceivedPowerUpdated, " RS received power info obsolete");
621  // RSRP evaluated as averaged received power among RBs
622  double sum = 0.0;
623  uint8_t rbNum = 0;
624  Values::const_iterator it;
626  {
627  // convert PSD [W/Hz] to linear power [W] for the single RE
628  // we consider only one RE for the RS since the channel is
629  // flat within the same RB
630  double powerTxW = ((*it) * 180000.0) / 12.0;
631  sum += powerTxW;
632  rbNum++;
633  }
634  double rsrp = (rbNum > 0) ? (sum / rbNum) : DBL_MAX;
635  // averaged SINR among RBs
636  double avSinr = ComputeAvgSinr (sinr);
637 
638  NS_LOG_INFO (this << " cellId " << m_cellId << " rnti " << m_rnti << " RSRP " << rsrp << " SINR " << avSinr << " ComponentCarrierId " << (uint16_t) m_componentCarrierId);
639  //trigger RLF detection only when UE has an active RRC connection
640  //and RLF detection attribute is set to true
642  {
643  double avrgSinrForRlf = ComputeAvgSinr (m_ctrlSinrForRlf);
644  RlfDetection (10 * log10 (avrgSinrForRlf));
645  }
646 
649  }
650 
651  if (m_pssReceived)
652  {
653  // measure instantaneous RSRQ now
654  NS_ASSERT_MSG (m_rsInterferencePowerUpdated, " RS interference power info obsolete");
655 
656  std::list <PssElement>::iterator itPss = m_pssList.begin ();
657  while (itPss != m_pssList.end ())
658  {
659  uint16_t rbNum = 0;
660  double rssiSum = 0.0;
661 
662  Values::const_iterator itIntN = m_rsInterferencePower.ConstValuesBegin ();
663  Values::const_iterator itPj = m_rsReceivedPower.ConstValuesBegin ();
664  for (itPj = m_rsReceivedPower.ConstValuesBegin ();
666  itIntN++, itPj++)
667  {
668  rbNum++;
669  // convert PSD [W/Hz] to linear power [W] for the single RE
670  double interfPlusNoisePowerTxW = ((*itIntN) * 180000.0) / 12.0;
671  double signalPowerTxW = ((*itPj) * 180000.0) / 12.0;
672  rssiSum += (2 * (interfPlusNoisePowerTxW + signalPowerTxW));
673  }
674 
675  NS_ASSERT (rbNum == (*itPss).nRB);
676  double rsrq_dB = 10 * log10 ((*itPss).pssPsdSum / rssiSum);
677 
678  if (rsrq_dB > m_pssReceptionThreshold)
679  {
680  NS_LOG_INFO (this << " PSS RNTI " << m_rnti << " cellId " << m_cellId
681  << " has RSRQ " << rsrq_dB << " and RBnum " << rbNum);
682  // store measurements
683  std::map <uint16_t, UeMeasurementsElement>::iterator itMeasMap;
684  itMeasMap = m_ueMeasurementsMap.find ((*itPss).cellId);
685  if (itMeasMap != m_ueMeasurementsMap.end ())
686  {
687  (*itMeasMap).second.rsrqSum += rsrq_dB;
688  (*itMeasMap).second.rsrqNum++;
689  }
690  else
691  {
692  NS_LOG_WARN ("race condition of bug 2091 occurred");
693  }
694  }
695 
696  itPss++;
697 
698  } // end of while (itPss != m_pssList.end ())
699 
700  m_pssList.clear ();
701 
702  } // end of if (m_pssReceived)
703 
704 } // end of void LteUePhy::GenerateCtrlCqiReport (const SpectrumValue& sinr)
705 
706 double
708 {
709  NS_LOG_FUNCTION (this);
710 
711  // averaged SINR among RBs
712  double sum = 0.0;
713  uint8_t rbNum = 0;
714  Values::const_iterator it;
715 
716  for (it = sinr.ConstValuesBegin (); it != sinr.ConstValuesEnd (); it++)
717  {
718  sum += (*it);
719  rbNum++;
720  }
721 
722  double avrgSinr = (rbNum > 0) ? (sum / rbNum) : DBL_MAX;
723 
724  return avrgSinr;
725 }
726 
727 void
729 {
730  // Not used by UE, CQI are based only on RS
731 }
732 
733 void
735 {
736  NS_LOG_FUNCTION (this);
737 
747  if (m_cellId == 0)
748  {
749  return;
750  }
751 
753  //NOTE: The SINR received by this method is
754  //based on CTRL, which is not used to compute
755  //PDSCH (i.e., data) based SINR. It is used
756  //for RLF detection.
757  m_ctrlSinrForRlf = sinr;
758 
761  {
762  // we have a measurement of interf + noise for the denominator
763  // of SINR = S/(I+N)
764  mixedSinr /= m_dataInterferencePower;
766  NS_LOG_LOGIC ("data interf measurement available, SINR = " << mixedSinr);
767  }
768  else
769  {
770  // we did not see any interference on data, so interference is
771  // there and we have only noise at the denominator of SINR
772  mixedSinr /= (*m_noisePsd);
773  NS_LOG_LOGIC ("no data interf measurement available, SINR = " << mixedSinr);
774  }
775 
776  /*
777  * some RBs are not used in PDSCH and their SINR is very high
778  * for example with bandwidth 25, last RB is not used
779  * it can make avgSinr value very high, what is incorrect
780  */
781  uint32_t rbgSize = GetRbgSize ();
782  uint32_t modulo = m_dlBandwidth % rbgSize;
783  double avgMixedSinr = 0;
784  uint32_t usedRbgNum = 0;
785  for(uint32_t i = 0; i < (m_dlBandwidth-1-modulo); i++)
786  {
787  usedRbgNum++;
788  avgMixedSinr+=mixedSinr[i];
789  }
790  avgMixedSinr = avgMixedSinr/usedRbgNum;
791  for(uint32_t i = 0; i < modulo; i++)
792  {
793  mixedSinr[m_dlBandwidth-1-i] = avgMixedSinr;
794  }
795 
796  GenerateCqiRsrpRsrq (mixedSinr);
797 }
798 
799 void
801 {
802  NS_LOG_FUNCTION (this << interf);
804  m_rsInterferencePower = interf;
805 }
806 
807 void
809 {
810  NS_LOG_FUNCTION (this << interf);
811 
813  m_dataInterferencePower = interf;
814 }
815 
816 void
818 {
819  NS_LOG_FUNCTION (this << power);
821  m_rsReceivedPower = power;
822 
824  {
825  double sum = 0;
826  uint32_t rbNum = 0;
827  Values::const_iterator it;
829  {
830  double powerTxW = ((*it) * 180000);
831  sum += powerTxW;
832  rbNum++;
833  }
834  double rsrp = 10 * log10 (sum) + 30;
835 
836  NS_LOG_INFO ("RSRP: " << rsrp);
837  m_powerControl->SetRsrp (rsrp);
838  }
839 }
840 
843 {
844  NS_LOG_FUNCTION (this);
845 
846 
847  // apply transmission mode gain
849  SpectrumValue newSinr = sinr;
850  newSinr *= m_txModeGain.at (m_transmissionMode);
851 
852  // CREATE DlCqiLteControlMessage
853  Ptr<DlCqiLteControlMessage> msg = Create<DlCqiLteControlMessage> ();
854  CqiListElement_s dlcqi;
855  std::vector<int> cqi;
857  {
858  cqi = m_amc->CreateCqiFeedbacks (newSinr, m_dlBandwidth);
859 
861  int nbSubChannels = cqi.size ();
862  double cqiSum = 0.0;
863  int activeSubChannels = 0;
864  // average the CQIs of the different RBs
865  for (int i = 0; i < nbSubChannels; i++)
866  {
867  if (cqi.at (i) != -1)
868  {
869  cqiSum += cqi.at (i);
870  activeSubChannels++;
871  }
872  NS_LOG_DEBUG (this << " subch " << i << " cqi " << cqi.at (i));
873  }
874  dlcqi.m_rnti = m_rnti;
875  dlcqi.m_ri = 1; // not yet used
876  dlcqi.m_cqiType = CqiListElement_s::P10; // Peridic CQI using PUCCH wideband
877  NS_ASSERT_MSG (nLayer > 0, " nLayer negative");
878  NS_ASSERT_MSG (nLayer < 3, " nLayer limit is 2s");
879  for (int i = 0; i < nLayer; i++)
880  {
881  if (activeSubChannels > 0)
882  {
883  dlcqi.m_wbCqi.push_back ((uint16_t) cqiSum / activeSubChannels);
884  }
885  else
886  {
887  // approximate with the worst case -> CQI = 1
888  dlcqi.m_wbCqi.push_back (1);
889  }
890  }
891  //NS_LOG_DEBUG (this << " Generate P10 CQI feedback " << (uint16_t) cqiSum / activeSubChannels);
892  dlcqi.m_wbPmi = 0; // not yet used
893  // dl.cqi.m_sbMeasResult others CQI report modes: not yet implemented
894  }
896  {
897  cqi = m_amc->CreateCqiFeedbacks (newSinr, GetRbgSize ());
899  int nbSubChannels = cqi.size ();
900  int rbgSize = GetRbgSize ();
901  double cqiSum = 0.0;
902  int cqiNum = 0;
903  SbMeasResult_s rbgMeas;
904  //NS_LOG_DEBUG (this << " Create A30 CQI feedback, RBG " << rbgSize << " cqiNum " << nbSubChannels << " band " << (uint16_t)m_dlBandwidth);
905  for (int i = 0; i < nbSubChannels; i++)
906  {
907  if (cqi.at (i) != -1)
908  {
909  cqiSum += cqi.at (i);
910  }
911  // else "nothing" no CQI is treated as CQI = 0 (worst case scenario)
912  cqiNum++;
913  if (cqiNum == rbgSize)
914  {
915  // average the CQIs of the different RBGs
916  //NS_LOG_DEBUG (this << " RBG CQI " << (uint16_t) cqiSum / rbgSize);
917  HigherLayerSelected_s hlCqi;
918  hlCqi.m_sbPmi = 0; // not yet used
919  for (int i = 0; i < nLayer; i++)
920  {
921  hlCqi.m_sbCqi.push_back ((uint16_t) cqiSum / rbgSize);
922  }
923  rbgMeas.m_higherLayerSelected.push_back (hlCqi);
924  cqiSum = 0.0;
925  cqiNum = 0;
926  }
927  }
928  dlcqi.m_rnti = m_rnti;
929  dlcqi.m_ri = 1; // not yet used
930  dlcqi.m_cqiType = CqiListElement_s::A30; // Aperidic CQI using PUSCH
931  //dlcqi.m_wbCqi.push_back ((uint16_t) cqiSum / nbSubChannels);
932  dlcqi.m_wbPmi = 0; // not yet used
933  dlcqi.m_sbMeasResult = rbgMeas;
934  }
935 
936  msg->SetDlCqi (dlcqi);
937  return msg;
938 }
939 
940 
941 void
943 {
944  NS_LOG_FUNCTION (this << Simulator::Now ());
945  NS_LOG_DEBUG (this << " Report UE Measurements ");
946 
948 
949  std::map <uint16_t, UeMeasurementsElement>::iterator it;
950  for (it = m_ueMeasurementsMap.begin (); it != m_ueMeasurementsMap.end (); it++)
951  {
952  double avg_rsrp = (*it).second.rsrpSum / (double)(*it).second.rsrpNum;
953  double avg_rsrq = (*it).second.rsrqSum / (double)(*it).second.rsrqNum;
954  /*
955  * In CELL_SEARCH state, this may result in avg_rsrq = 0/0 = -nan.
956  * UE RRC must take this into account when receiving measurement reports.
957  * TODO remove this shortcoming by calculating RSRQ during CELL_SEARCH
958  */
959  NS_LOG_DEBUG (this << " CellId " << (*it).first
960  << " RSRP " << avg_rsrp
961  << " (nSamples " << (uint16_t)(*it).second.rsrpNum << ")"
962  << " RSRQ " << avg_rsrq
963  << " (nSamples " << (uint16_t)(*it).second.rsrqNum << ")"
964  << " ComponentCarrierID " << (uint16_t)m_componentCarrierId);
965 
967  newEl.m_cellId = (*it).first;
968  newEl.m_rsrp = avg_rsrp;
969  newEl.m_rsrq = avg_rsrq;
970  ret.m_ueMeasurementsList.push_back (newEl);
972 
973  // report to UE measurements trace
974  m_reportUeMeasurements (m_rnti, (*it).first, avg_rsrp, avg_rsrq, ((*it).first == m_cellId ? 1 : 0), m_componentCarrierId);
975  }
976 
977  // report to RRC
979 
980  m_ueMeasurementsMap.clear ();
982 }
983 
984 void
986 {
987  NS_LOG_FUNCTION (this << cqiPeriodicity);
988  m_a30CqiPeriodicity = cqiPeriodicity;
989  m_p10CqiPeriodicity = cqiPeriodicity;
990 }
991 
992 void
994 {
995  NS_LOG_FUNCTION (this << msg);
996 
997  SetControlMessages (msg);
998 }
999 
1000 void
1001 LteUePhy::DoSendRachPreamble (uint32_t raPreambleId, uint32_t raRnti)
1002 {
1003  NS_LOG_FUNCTION (this << raPreambleId);
1004 
1005  // unlike other control messages, RACH preamble is sent ASAP
1006  Ptr<RachPreambleLteControlMessage> msg = Create<RachPreambleLteControlMessage> ();
1007  msg->SetRapId (raPreambleId);
1008  m_raPreambleId = raPreambleId;
1009  m_raRnti = raRnti;
1010  m_controlMessagesQueue.at (0).push_back (msg);
1011 }
1012 
1013 void
1015 {
1021  if (m_componentCarrierId == 0)
1022  {
1023  m_isConnected = true;
1024  // Initialize the parameters for radio link failure detection
1026  }
1027 }
1028 
1029 
1030 
1031 void
1033 {
1034  NS_LOG_FUNCTION (this);
1035 
1036  std::list<Ptr<LteControlMessage> >::iterator it;
1037  NS_LOG_DEBUG (this << " I am rnti = " << m_rnti << " and I received msgs " << (uint16_t) msgList.size ());
1038  for (it = msgList.begin (); it != msgList.end (); it++)
1039  {
1040  Ptr<LteControlMessage> msg = (*it);
1041 
1042  if (msg->GetMessageType () == LteControlMessage::DL_DCI)
1043  {
1044  Ptr<DlDciLteControlMessage> msg2 = DynamicCast<DlDciLteControlMessage> (msg);
1045 
1046  DlDciListElement_s dci = msg2->GetDci ();
1047  if (dci.m_rnti != m_rnti)
1048  {
1049  // DCI not for me
1050  continue;
1051  }
1052 
1053  if (dci.m_resAlloc != 0)
1054  {
1055  NS_FATAL_ERROR ("Resource Allocation type not implemented");
1056  }
1057 
1058  std::vector <int> dlRb;
1059 
1060  // translate the DCI to Spectrum framework
1061  uint32_t mask = 0x1;
1062  for (int i = 0; i < 32; i++)
1063  {
1064  if (((dci.m_rbBitmap & mask) >> i) == 1)
1065  {
1066  for (int k = 0; k < GetRbgSize (); k++)
1067  {
1068  dlRb.push_back ((i * GetRbgSize ()) + k);
1069 // NS_LOG_DEBUG(this << " RNTI " << m_rnti << " RBG " << i << " DL-DCI allocated PRB " << (i*GetRbgSize()) + k);
1070  }
1071  }
1072  mask = (mask << 1);
1073  }
1075  {
1076  m_powerControl->ReportTpc (dci.m_tpc);
1077  }
1078 
1079 
1080  // send TB info to LteSpectrumPhy
1081  NS_LOG_DEBUG (this << " UE " << m_rnti << " DL-DCI " << dci.m_rnti << " bitmap " << dci.m_rbBitmap);
1082  for (uint8_t i = 0; i < dci.m_tbsSize.size (); i++)
1083  {
1084  m_downlinkSpectrumPhy->AddExpectedTb (dci.m_rnti, dci.m_ndi.at (i), dci.m_tbsSize.at (i), dci.m_mcs.at (i), dlRb, i, dci.m_harqProcess, dci.m_rv.at (i), true /* DL */);
1085  }
1086 
1088 
1089 
1090  }
1091  else if (msg->GetMessageType () == LteControlMessage::UL_DCI)
1092  {
1093  // set the uplink bandwidth according to the UL-CQI
1094  Ptr<UlDciLteControlMessage> msg2 = DynamicCast<UlDciLteControlMessage> (msg);
1095  UlDciListElement_s dci = msg2->GetDci ();
1096  if (dci.m_rnti != m_rnti)
1097  {
1098  // DCI not for me
1099  continue;
1100  }
1101  NS_LOG_INFO (this << " UL DCI");
1102  std::vector <int> ulRb;
1103  for (int i = 0; i < dci.m_rbLen; i++)
1104  {
1105  ulRb.push_back (i + dci.m_rbStart);
1106  //NS_LOG_DEBUG (this << " UE RB " << i + dci.m_rbStart);
1107  }
1110  // fire trace of UL Tx PHY stats
1111  HarqProcessInfoList_t harqInfoList = m_harqPhyModule->GetHarqProcessInfoUl (m_rnti, 0);
1113  params.m_cellId = m_cellId;
1114  params.m_imsi = 0; // it will be set by DlPhyTransmissionCallback in LteHelper
1116  params.m_rnti = m_rnti;
1117  params.m_txMode = 0; // always SISO for UE
1118  params.m_layer = 0;
1119  params.m_mcs = dci.m_mcs;
1120  params.m_size = dci.m_tbSize;
1121  params.m_rv = harqInfoList.size ();
1122  params.m_ndi = dci.m_ndi;
1123  params.m_ccId = m_componentCarrierId;
1124  m_ulPhyTransmission (params);
1125  // pass the info to the MAC
1127  }
1128  else if (msg->GetMessageType () == LteControlMessage::RAR)
1129  {
1130  Ptr<RarLteControlMessage> rarMsg = DynamicCast<RarLteControlMessage> (msg);
1131  if (rarMsg->GetRaRnti () == m_raRnti)
1132  {
1133  for (std::list<RarLteControlMessage::Rar>::const_iterator it = rarMsg->RarListBegin (); it != rarMsg->RarListEnd (); ++it)
1134  {
1135  if (it->rapId != m_raPreambleId)
1136  {
1137  // UL grant not for me
1138  continue;
1139  }
1140  else
1141  {
1142  NS_LOG_INFO ("received RAR RNTI " << m_raRnti);
1143  // set the uplink bandwidth according to the UL grant
1144  std::vector <int> ulRb;
1145  for (int i = 0; i < it->rarPayload.m_grant.m_rbLen; i++)
1146  {
1147  ulRb.push_back (i + it->rarPayload.m_grant.m_rbStart);
1148  }
1149 
1151  // pass the info to the MAC
1153  // reset RACH variables with out of range values
1154  m_raPreambleId = 255;
1155  m_raRnti = 11;
1156  }
1157  }
1158  }
1159  }
1160  else if (msg->GetMessageType () == LteControlMessage::MIB)
1161  {
1162  NS_LOG_INFO ("received MIB");
1163  NS_ASSERT (m_cellId > 0);
1164  Ptr<MibLteControlMessage> msg2 = DynamicCast<MibLteControlMessage> (msg);
1166  }
1167  else if (msg->GetMessageType () == LteControlMessage::SIB1)
1168  {
1169  NS_LOG_INFO ("received SIB1");
1170  NS_ASSERT (m_cellId > 0);
1171  Ptr<Sib1LteControlMessage> msg2 = DynamicCast<Sib1LteControlMessage> (msg);
1173  }
1174  else
1175  {
1176  // pass the message to UE-MAC
1178  }
1179 
1180  }
1181 
1182 
1183 }
1184 
1185 
1186 void
1188 {
1189  NS_LOG_FUNCTION (this << cellId << (*p));
1190 
1191  double sum = 0.0;
1192  uint16_t nRB = 0;
1193  Values::const_iterator itPi;
1194  for (itPi = p->ConstValuesBegin (); itPi != p->ConstValuesEnd (); itPi++)
1195  {
1196  // convert PSD [W/Hz] to linear power [W] for the single RE
1197  double powerTxW = ((*itPi) * 180000.0) / 12.0;
1198  sum += powerTxW;
1199  nRB++;
1200  }
1201 
1202  // measure instantaneous RSRP now
1203  double rsrp_dBm = 10 * log10 (1000 * (sum / (double)nRB));
1204  NS_LOG_INFO (this << " PSS RNTI " << m_rnti << " cellId " << m_cellId
1205  << " has RSRP " << rsrp_dBm << " and RBnum " << nRB);
1206  // note that m_pssReceptionThreshold does not apply here
1207 
1208  // store measurements
1209  std::map <uint16_t, UeMeasurementsElement>::iterator itMeasMap = m_ueMeasurementsMap.find (cellId);
1210  if (itMeasMap == m_ueMeasurementsMap.end ())
1211  {
1212  // insert new entry
1213  UeMeasurementsElement newEl;
1214  newEl.rsrpSum = rsrp_dBm;
1215  newEl.rsrpNum = 1;
1216  newEl.rsrqSum = 0;
1217  newEl.rsrqNum = 0;
1218  m_ueMeasurementsMap.insert (std::pair <uint16_t, UeMeasurementsElement> (cellId, newEl));
1219  }
1220  else
1221  {
1222  (*itMeasMap).second.rsrpSum += rsrp_dBm;
1223  (*itMeasMap).second.rsrpNum++;
1224  }
1225 
1226  /*
1227  * Collect the PSS for later processing in GenerateCtrlCqiReport()
1228  * (to be called from ChunkProcessor after RX is finished).
1229  */
1230  m_pssReceived = true;
1231  PssElement el;
1232  el.cellId = cellId;
1233  el.pssPsdSum = sum;
1234  el.nRB = nRB;
1235  m_pssList.push_back (el);
1236 
1237 } // end of void LteUePhy::ReceivePss (uint16_t cellId, Ptr<SpectrumValue> p)
1238 
1239 
1240 void
1242 {
1244 }
1245 
1246 
1247 void
1248 LteUePhy::SubframeIndication (uint32_t frameNo, uint32_t subframeNo)
1249 {
1250  NS_LOG_FUNCTION (this << frameNo << subframeNo);
1251 
1252  NS_ASSERT_MSG (frameNo > 0, "the SRS index check code assumes that frameNo starts at 1");
1253 
1254  // refresh internal variables
1255  m_rsReceivedPowerUpdated = false;
1257  m_pssReceived = false;
1258 
1259  if (m_ulConfigured)
1260  {
1261  // update uplink transmission mask according to previous UL-CQIs
1262  std::vector <int> rbMask = m_subChannelsForTransmissionQueue.at (0);
1264 
1265  // shift the queue
1266  for (uint8_t i = 1; i < m_macChTtiDelay; i++)
1267  {
1269  }
1271 
1273  {
1274 
1275  NS_ASSERT_MSG (subframeNo > 0 && subframeNo <= 10, "the SRS index check code assumes that subframeNo starts at 1");
1276  if ((((frameNo-1)*10 + (subframeNo-1)) % m_srsPeriodicity) == m_srsSubframeOffset)
1277  {
1278  NS_LOG_INFO ("frame " << frameNo << " subframe " << subframeNo << " sending SRS (offset=" << m_srsSubframeOffset << ", period=" << m_srsPeriodicity << ")");
1281  this);
1282  }
1283  }
1284 
1285  std::list<Ptr<LteControlMessage> > ctrlMsg = GetControlMessages ();
1286  // send packets in queue
1287  NS_LOG_LOGIC (this << " UE - start slot for PUSCH + PUCCH - RNTI " << m_rnti << " CELLID " << m_cellId);
1288  // send the current burts of packets
1290  if (pb)
1291  {
1293  {
1296  }
1297  m_uplinkSpectrumPhy->StartTxDataFrame (pb, ctrlMsg, UL_DATA_DURATION);
1298  }
1299  else
1300  {
1301  // send only PUCCH (ideal: fake null bandwidth signal)
1302  if (ctrlMsg.size ()>0)
1303  {
1304  NS_LOG_LOGIC (this << " UE - start TX PUCCH (NO PUSCH)");
1305  std::vector <int> dlRb;
1306 
1308  {
1310  }
1311 
1313  m_uplinkSpectrumPhy->StartTxDataFrame (pb, ctrlMsg, UL_DATA_DURATION);
1314  }
1315  else
1316  {
1317  NS_LOG_LOGIC (this << " UE - UL NOTHING TO SEND");
1318  }
1319  }
1320  } // m_configured
1321 
1322  // trigger the MAC
1323  m_uePhySapUser->SubframeIndication (frameNo, subframeNo);
1324 
1325  m_subframeNo = subframeNo;
1326  ++subframeNo;
1327  if (subframeNo > 10)
1328  {
1329  ++frameNo;
1330  subframeNo = 1;
1331  }
1332 
1333  // schedule next subframe indication
1334  Simulator::Schedule (Seconds (GetTti ()), &LteUePhy::SubframeIndication, this, frameNo, subframeNo);
1335 }
1336 
1337 
1338 void
1340 {
1341  NS_LOG_FUNCTION (this << " UE " << m_rnti << " start tx SRS, cell Id " << (uint32_t) m_cellId);
1342  NS_ASSERT (m_cellId > 0);
1343  // set the current tx power spectral density (full bandwidth)
1344  std::vector <int> dlRb;
1345  for (uint8_t i = 0; i < m_ulBandwidth; i++)
1346  {
1347  dlRb.push_back (i);
1348  }
1349 
1351  {
1353  }
1354 
1356  m_uplinkSpectrumPhy->StartTxUlSrsFrame ();
1357 }
1358 
1359 
1360 void
1362 {
1363  NS_LOG_FUNCTION (this);
1364 
1365  m_rnti = 0;
1366  m_cellId = 0;
1367  m_isConnected = false;
1368  m_transmissionMode = 0;
1369  m_srsPeriodicity = 0;
1370  m_srsConfigured = false;
1371  m_dlConfigured = false;
1372  m_ulConfigured = false;
1373  m_raPreambleId = 255; // value out of range
1374  m_raRnti = 11; // value out of range
1378  m_paLinear = 1;
1379 
1380  m_packetBurstQueue.clear ();
1381  m_controlMessagesQueue.clear ();
1383  for (int i = 0; i < m_macChTtiDelay; i++)
1384  {
1385  Ptr<PacketBurst> pb = CreateObject <PacketBurst> ();
1386  m_packetBurstQueue.push_back (pb);
1387  std::list<Ptr<LteControlMessage> > l;
1388  m_controlMessagesQueue.push_back (l);
1389  }
1390  std::vector <int> ulRb;
1392 
1394  m_downlinkSpectrumPhy->Reset ();
1395  m_uplinkSpectrumPhy->Reset ();
1396  m_pssList.clear ();
1401  m_downlinkSpectrumPhy->m_interferenceCtrl->EndRx ();
1402  m_downlinkSpectrumPhy->m_interferenceData->EndRx ();
1403 
1404 } // end of void LteUePhy::DoReset ()
1405 
1406 void
1407 LteUePhy::DoStartCellSearch (uint32_t dlEarfcn)
1408 {
1409  NS_LOG_FUNCTION (this << dlEarfcn);
1410  m_dlEarfcn = dlEarfcn;
1411  DoSetDlBandwidth (6); // configure DL for receiving PSS
1413 }
1414 
1415 void
1416 LteUePhy::DoSynchronizeWithEnb (uint16_t cellId, uint32_t dlEarfcn)
1417 {
1418  NS_LOG_FUNCTION (this << cellId << dlEarfcn);
1419  m_dlEarfcn = dlEarfcn;
1420  DoSynchronizeWithEnb (cellId);
1421 }
1422 
1423 void
1425 {
1426  NS_LOG_FUNCTION (this << cellId);
1427 
1428  if (cellId == 0)
1429  {
1430  NS_FATAL_ERROR ("Cell ID shall not be zero");
1431  }
1432 
1433  m_cellId = cellId;
1434  m_downlinkSpectrumPhy->SetCellId (cellId);
1435  m_uplinkSpectrumPhy->SetCellId (cellId);
1436 
1437  // configure DL for receiving the BCH with the minimum bandwidth
1438  DoSetDlBandwidth (6);
1439 
1440  m_dlConfigured = false;
1441  m_ulConfigured = false;
1442 
1444 }
1445 
1446 void
1447 LteUePhy::DoSetDlBandwidth (uint16_t dlBandwidth)
1448 {
1449  NS_LOG_FUNCTION (this << (uint32_t) dlBandwidth);
1450  if (m_dlBandwidth != dlBandwidth or !m_dlConfigured)
1451  {
1452  m_dlBandwidth = dlBandwidth;
1453 
1454  static const int Type0AllocationRbg[4] = {
1455  10, // RGB size 1
1456  26, // RGB size 2
1457  63, // RGB size 3
1458  110 // RGB size 4
1459  }; // see table 7.1.6.1-1 of 36.213
1460  for (int i = 0; i < 4; i++)
1461  {
1462  if (dlBandwidth < Type0AllocationRbg[i])
1463  {
1464  m_rbgSize = i + 1;
1465  break;
1466  }
1467  }
1468 
1470  m_downlinkSpectrumPhy->SetNoisePowerSpectralDensity (m_noisePsd);
1471  m_downlinkSpectrumPhy->GetChannel ()->AddRx (m_downlinkSpectrumPhy);
1472  }
1473  m_dlConfigured = true;
1474 }
1475 
1476 
1477 void
1478 LteUePhy::DoConfigureUplink (uint32_t ulEarfcn, uint16_t ulBandwidth)
1479 {
1480  m_ulEarfcn = ulEarfcn;
1481  m_ulBandwidth = ulBandwidth;
1482  m_ulConfigured = true;
1483 }
1484 
1485 void
1486 LteUePhy::DoConfigureReferenceSignalPower (int8_t referenceSignalPower)
1487 {
1488  NS_LOG_FUNCTION (this);
1489  m_powerControl->ConfigureReferenceSignalPower (referenceSignalPower);
1490 }
1491 
1492 void
1493 LteUePhy::DoSetRnti (uint16_t rnti)
1494 {
1495  NS_LOG_FUNCTION (this << rnti);
1496  m_rnti = rnti;
1497 
1500 }
1501 
1502 void
1504 {
1505  NS_LOG_FUNCTION (this << (uint16_t)txMode);
1506  m_transmissionMode = txMode;
1507  m_downlinkSpectrumPhy->SetTransmissionMode (txMode);
1508 }
1509 
1510 void
1512 {
1513  NS_LOG_FUNCTION (this << srcCi);
1516  m_srsConfigured = true;
1517 
1518  // a guard time is needed for the case where the SRS periodicity is changed dynamically at run time
1519  // if we use a static one, we can have a 0ms guard time
1521  NS_LOG_DEBUG (this << " UE SRS P " << m_srsPeriodicity << " RNTI " << m_rnti << " offset " << m_srsSubframeOffset << " cellId " << m_cellId << " CI " << srcCi);
1522 }
1523 
1524 void
1526 {
1527  NS_LOG_FUNCTION (this << pa);
1528  m_paLinear = pow (10,(pa/10));
1529 }
1530 
1531 void
1532 LteUePhy::DoSetRsrpFilterCoefficient (uint8_t rsrpFilterCoefficient)
1533 {
1534  NS_LOG_FUNCTION (this << (uint16_t) (rsrpFilterCoefficient));
1535  m_powerControl->SetRsrpFilterCoefficient (rsrpFilterCoefficient);
1536 }
1537 
1538 void
1540 {
1541  NS_LOG_FUNCTION (this);
1542  m_downlinkSpectrumPhy->m_harqPhyModule->ClearDlHarqBuffer (m_rnti); //flush HARQ buffers
1545  m_pssReceived = false;
1546  DoReset ();
1547 }
1548 
1549 void
1551 {
1552  NS_LOG_FUNCTION (this);
1553 
1555 }
1556 
1557 void
1559 {
1560  NS_LOG_FUNCTION (this);
1561  // indicates that the downlink radio link quality has to be monitored for in-sync indications
1562  m_downlinkInSync = false;
1563 }
1564 
1565 void
1566 LteUePhy::DoSetImsi (uint64_t imsi)
1567 {
1568  NS_LOG_FUNCTION (this);
1569  m_imsi = imsi;
1570 }
1571 
1572 void
1574 {
1575  NS_LOG_FUNCTION (this);
1576  m_numOfSubframes = 0;
1577  m_sinrDbFrame = 0;
1578  m_numOfFrames = 0;
1579  m_downlinkInSync = true;
1580 }
1581 
1582 void
1583 LteUePhy::RlfDetection (double sinrDb)
1584 {
1585  NS_LOG_FUNCTION (this << sinrDb);
1586  m_sinrDbFrame += sinrDb;
1587  m_numOfSubframes++;
1588  NS_LOG_LOGIC ("No of Subframes: " << m_numOfSubframes << " UE synchronized: " << m_downlinkInSync);
1589  //check for out_of_snyc indications first when UE is both DL and UL synchronized
1590  //m_downlinkInSync=true indicates that the evaluation is for out-of-sync indications
1591  if (m_downlinkInSync && m_numOfSubframes == 10)
1592  {
1598  {
1599  m_numOfFrames++; //increment the counter if a frame cannot be decoded
1600  NS_LOG_LOGIC ("No of Frames which cannot be decoded: " << m_numOfFrames);
1601  }
1602  else
1603  {
1609  NS_LOG_INFO ("Resetting frame counter at phy. Current value = " << m_numOfFrames);
1610  m_numOfFrames = 0;
1611  // Also reset the sync indicator counter at RRC
1613  }
1614  m_numOfSubframes = 0;
1615  m_sinrDbFrame = 0;
1616  }
1623  {
1624  NS_LOG_LOGIC ("At " << Simulator::Now ().GetMilliSeconds()
1625  << " ms UE PHY sending out of snyc indication to UE RRC layer");
1627  m_numOfFrames = 0;
1628  }
1629  //check for in_snyc indications when T310 timer is started
1630  //m_downlinkInSync=false indicates that the evaluation is for in-sync indications
1631  if (!m_downlinkInSync && m_numOfSubframes == 10)
1632  {
1639  {
1640  m_numOfFrames++; //increment the counter if a frame can be decoded
1641  NS_LOG_LOGIC ("No of Frames successfully decoded: " << m_numOfFrames);
1642  }
1643  else
1644  {
1650  m_numOfFrames = 0;
1651  // Also reset the sync indicator counter at RRC
1653  }
1654  m_numOfSubframes = 0;
1655  m_sinrDbFrame = 0;
1656  }
1662  {
1663  NS_LOG_LOGIC ("At " << Simulator::Now ().GetMilliSeconds()
1664  << " ms UE PHY sending in snyc indication to UE RRC layer");
1666  m_numOfFrames = 0;
1667  }
1668 }
1669 
1670 
1671 void
1673 {
1674  SetTxModeGain (1, gain);
1675 }
1676 
1677 void
1679 {
1680  SetTxModeGain (2, gain);
1681 }
1682 
1683 void
1685 {
1686  SetTxModeGain (3, gain);
1687 }
1688 
1689 void
1691 {
1692  SetTxModeGain (4, gain);
1693 }
1694 
1695 void
1697 {
1698  SetTxModeGain (5, gain);
1699 }
1700 
1701 void
1703 {
1704  SetTxModeGain (6, gain);
1705 }
1706 
1707 void
1709 {
1710  SetTxModeGain (7, gain);
1711 }
1712 
1713 
1714 void
1715 LteUePhy::SetTxModeGain (uint8_t txMode, double gain)
1716 {
1717  NS_LOG_FUNCTION (this << gain);
1718  // convert to linear
1719  double gainLin = std::pow (10.0, (gain / 10.0));
1720  if (m_txModeGain.size () < txMode)
1721  {
1722  m_txModeGain.resize (txMode);
1723  }
1724  std::vector <double> temp;
1725  temp = m_txModeGain;
1726  m_txModeGain.clear ();
1727  for (uint8_t i = 0; i < temp.size (); i++)
1728  {
1729  if (i==txMode-1)
1730  {
1731  m_txModeGain.push_back (gainLin);
1732  }
1733  else
1734  {
1735  m_txModeGain.push_back (temp.at (i));
1736  }
1737  }
1738  // forward the info to DL LteSpectrumPhy
1739  m_downlinkSpectrumPhy->SetTxModeGain (txMode, gain);
1740 }
1741 
1742 
1743 
1744 void
1746 {
1747  NS_LOG_FUNCTION (this);
1748  // get the feedback from LteSpectrumPhy and send it through ideal PUCCH to eNB
1749  Ptr<DlHarqFeedbackLteControlMessage> msg = Create<DlHarqFeedbackLteControlMessage> ();
1750  msg->SetDlHarqFeedback (m);
1751  SetControlMessages (msg);
1752 }
1753 
1754 void
1756 {
1757  m_harqPhyModule = harq;
1758 }
1759 
1760 
1763 {
1764  NS_LOG_FUNCTION (this);
1765  return m_state;
1766 }
1767 
1768 
1769 void
1771 {
1772  NS_LOG_FUNCTION (this << newState);
1773  State oldState = m_state;
1774  m_state = newState;
1775  NS_LOG_INFO (this << " cellId=" << m_cellId << " rnti=" << m_rnti
1776  << " UePhy " << ToString (oldState)
1777  << " --> " << ToString (newState));
1778  m_stateTransitionTrace (m_cellId, m_rnti, oldState, newState);
1779 }
1780 
1781 
1782 } // namespace ns3
See section 4.3.1 dlDciListElement.
Definition: ff-mac-common.h:93
void SetTxPower(double value)
Set transmit power function.
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition: simulator.h:557
uint16_t m_ulBandwidth
The UL bandwidth in number of PRBs.
Definition: lte-phy.h:269
uint16_t m_srsConfigured
SRS configured.
Definition: lte-ue-phy.h:696
virtual void DoInitialize(void)
Initialize() implementation.
Definition: object.cc:353
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
uint8_t m_txMode
the transmission Mode
Definition: lte-common.h:192
UeMemberLteUePhySapProvider class.
Definition: lte-ue-phy.cc:77
double m_qOut
The &#39;Qout&#39; attribute.
Definition: lte-ue-phy.h:832
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
virtual void ReceiveLteControlMessage(Ptr< LteControlMessage > msg)=0
Receive SendLteControlMessage (PDCCH map, CQI feedbacks) using the ideal control channel.
double m_noiseFigure
Loss (dB) in the Signal-to-Noise-Ratio due to non-idealities in the receiver.
Definition: lte-phy.h:261
See section 4.3.25 sbMeasResult.
Ptr< LteSpectrumPhy > GetUlSpectrumPhy() const
Get Uplink spectrum phy.
Definition: lte-ue-phy.cc:458
uint8_t m_componentCarrierId
component carrier ID
double pssPsdSum
PSS PSD sum.
Definition: lte-ue-phy.h:729
TracedCallback< uint16_t, Ptr< SpectrumValue > > m_reportPowerSpectralDensity
The ReportsPowerSpectralDensity trace source.
Definition: lte-ue-phy.h:813
AttributeValue implementation for Boolean.
Definition: boolean.h:36
double m_txPower
Transmission power in dBm.
Definition: lte-phy.h:249
std::vector< struct UeMeasurementsElement > m_ueMeasurementsList
UE measurement list.
virtual void GenerateMixedCqiReport(const SpectrumValue &sinr)
Create the mixed CQI report.
Definition: lte-ue-phy.cc:734
LteUePhySapUser * m_uePhySapUser
UE Phy SAP user.
Definition: lte-ue-phy.h:684
uint32_t GetId(void) const
Definition: node.cc:109
void SetTxMode5Gain(double gain)
Set transmit mode 5 gain function.
Definition: lte-ue-phy.cc:1696
void SetCellId(uint16_t cellId)
Set the cell ID function.
virtual void SendMacPdu(Ptr< Packet > p)
Send the MAC PDU to the channel.
Definition: lte-ue-phy.cc:103
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
uint8_t m_componentCarrierId
component carrier Id used to address sap
Definition: lte-phy.h:311
virtual void GenerateDataCqiReport(const SpectrumValue &sinr)
generate a CQI report based on the given SINR of Data frame (used for PUSCH CQIs) ...
Definition: lte-ue-phy.cc:728
std::list< PssElement > m_pssList
PSS list.
Definition: lte-ue-phy.h:732
void SetTxMode2Gain(double gain)
Set transmit mode 2 gain function.
Definition: lte-ue-phy.cc:1678
uint16_t cellId
cell ID
Definition: lte-ue-phy.h:728
bool m_ulConfigured
UL configured?
Definition: lte-ue-phy.h:702
std::vector< Ptr< PacketBurst > > m_packetBurstQueue
A queue of packet bursts to be sent.
Definition: lte-phy.h:289
std::vector< int > GetSubChannelsForTransmission(void)
Get a list of sub channels to use in RX.
Definition: lte-ue-phy.cc:531
virtual void GenerateCtrlCqiReport(const SpectrumValue &sinr)
generate a CQI report based on the given SINR of Ctrl frame
Definition: lte-ue-phy.cc:558
double m_qIn
The &#39;Qin&#39; attribute.
Definition: lte-ue-phy.h:825
void DoSetDlBandwidth(uint16_t dlBandwidth)
Set DL bandwidth function.
Definition: lte-ue-phy.cc:1447
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:85
TracedCallback< uint16_t, uint16_t, double, double, bool, uint8_t > m_reportUeMeasurements
The ReportUeMeasurements trace source.
Definition: lte-ue-phy.h:790
Time m_a30CqiLast
last aperiodic CQI
Definition: lte-ue-phy.h:681
double GetPuschTxPower(std::vector< int > rb)
Get PUSCH transmit power function.
void SetSubChannelsForTransmission(std::vector< int > mask)
Set a list of sub channels to use in TX.
Definition: lte-ue-phy.cc:511
double m_paLinear
PA linear.
Definition: lte-ue-phy.h:699
LteUePhySapProvider * m_uePhySapProvider
UE Phy SAP provider.
Definition: lte-ue-phy.h:683
uint8_t rsrqNum
Number of RSRQ samples.
Definition: lte-ue-phy.h:746
#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 SetTxMode6Gain(double gain)
Set transmit mode 6 gain function.
Definition: lte-ue-phy.cc:1702
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1286
Ptr< LteSpectrumPhy > m_downlinkSpectrumPhy
The downlink LteSpectrumPhy associated to this LtePhy.
Definition: lte-phy.h:238
See section 4.3.2 ulDciListElement.
Service Access Point (SAP) offered by the UE PHY to the UE RRC for control purposes.
virtual void SendLteControlMessage(Ptr< LteControlMessage > msg)
Send SendLteControlMessage (PDCCH map, CQI feedbacks) using the ideal control channel.
Definition: lte-ue-phy.cc:109
See section 4.3.24 cqiListElement.
std::vector< double > m_txModeGain
the transmit mode gain
Definition: lte-ue-phy.h:692
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:281
void DoResetPhyAfterRlf()
Reset Phy after radio link failure function.
Definition: lte-ue-phy.cc:1539
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:165
uint16_t GetNumQoutEvalSf() const
Get number of Qout evaluation subframes.
Definition: lte-ue-phy.cc:482
Summary results of measuring a specific cell. Used for layer-1 filtering.
Definition: lte-ue-phy.h:741
SpectrumValue m_dataInterferencePower
data interference power
Definition: lte-ue-phy.h:722
uint16_t GetSrsPeriodicity(uint16_t srcCi) const
Definition: lte-phy.cc:150
uint8_t GetMacChDelay(void) const
Get MAC to Channel delay.
Definition: lte-ue-phy.cc:446
void QueueSubChannelsForTransmission(std::vector< int > rbMap)
Queue subchannels for transmission function.
Definition: lte-ue-phy.cc:1241
uint8_t m_rv
the redundancy version (HARQ)
Definition: lte-common.h:196
Service Access Point (SAP) offered by the PHY to the MAC.
void SetTxModeGain(uint8_t txMode, double gain)
Set transmit mode gain function.
Definition: lte-ue-phy.cc:1715
void SetDownlinkCqiPeriodicity(Time cqiPeriodicity)
Set the periodicty for the downlink periodic wideband and aperiodic subband CQI reporting.
Definition: lte-ue-phy.cc:985
Ptr< LteUePowerControl > m_powerControl
Pointer to UE Uplink Power Control entity.
Definition: lte-ue-phy.h:669
virtual void DoSendMacPdu(Ptr< Packet > p)
Queue the MAC PDU to be sent (according to m_macChTtiDelay)
Definition: lte-ue-phy.cc:496
std::vector< int > GetSubChannelsForReception(void)
Get a list of sub channels to use in RX.
Definition: lte-ue-phy.cc:539
This class defines all functions to create spectrum model for lte.
Values::const_iterator ConstValuesBegin() const
uint8_t m_transmissionMode
the transmission mode
Definition: lte-ue-phy.h:691
void DoSetRsrpFilterCoefficient(uint8_t rsrpFilterCoefficient)
Do set RSRP filter coefficient.
Definition: lte-ue-phy.cc:1532
EventId m_sendSrsEvent
send SRS event
Definition: lte-ue-phy.h:792
void SetHarqPhyModule(Ptr< LteHarqPhy > harq)
Set the HARQ PHY module.
Definition: lte-ue-phy.cc:1755
bool m_pssReceived
PSS received?
Definition: lte-ue-phy.h:724
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
void DoSetSrsConfigurationIndex(uint16_t srcCi)
Set SRS configuration index function.
Definition: lte-ue-phy.cc:1511
phy
Definition: third.py:93
State
The states of the UE PHY entity.
Definition: lte-ue-phy.h:66
static const int Type0AllocationRbg[4]
Type 0 RGB allocation.
void DoSetTransmissionMode(uint8_t txMode)
Set transmission mode function.
Definition: lte-ue-phy.cc:1503
The attribute can be read.
Definition: type-id.h:64
UeMemberLteUePhySapProvider(LteUePhy *phy)
Constructor.
Definition: lte-ue-phy.cc:97
double GetTti(void) const
Definition: lte-phy.cc:142
Template for the implementation of the LteUeCphySapProvider as a member of an owner class of type C t...
double m_pssReceptionThreshold
The RsrqUeMeasThreshold attribute.
Definition: lte-ue-phy.h:738
void DoStartInSnycDetection()
Start in Snyc detection function.
Definition: lte-ue-phy.cc:1558
uint8_t GetRbgSize(void) const
Definition: lte-phy.cc:186
void DoResetRlfParams()
Reset radio link failure parameters.
Definition: lte-ue-phy.cc:1550
bool m_enableRlfDetection
Flag to enable/disable RLF detection.
Definition: lte-ue-phy.h:843
void DoSynchronizeWithEnb(uint16_t cellId)
Synchronize with ENB function.
Definition: lte-ue-phy.cc:1424
static Ptr< SpectrumValue > CreateUlTxPowerSpectralDensity(uint16_t earfcn, uint16_t bandwidth, double powerTx, std::vector< int > activeRbs)
create a spectrum value representing the uplink power spectral density of a signal to be transmitted...
uint8_t rsrpNum
Number of RSRP samples.
Definition: lte-ue-phy.h:744
LteUeCphySapUser * m_ueCphySapUser
UE CPhy SAP user.
Definition: lte-ue-phy.h:687
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: pointer.h:227
void DoDispose()
Destructor implementation.
Definition: lte-phy.cc:78
uint16_t m_numOfSubframes
count the number of subframes for which the downlink radio link quality is estimated ...
Definition: lte-ue-phy.h:838
AttributeValue implementation for Time.
Definition: nstime.h:1342
uint16_t m_rsrpSinrSamplePeriod
The RsrpSinrSamplePeriod attribute.
Definition: lte-ue-phy.h:777
Time NanoSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1302
uint64_t m_imsi
IMSI of the scheduled UE.
Definition: lte-common.h:190
See section 4.3.27 higherLayerSelected.
double GetNoiseFigure() const
Get noise figure.
Definition: lte-ue-phy.cc:417
Service Access Point (SAP) offered by the UE PHY to the UE RRC for control purposes.
void SetLteUePhySapUser(LteUePhySapUser *s)
Set the PHY SAP User.
Definition: lte-ue-phy.cc:381
void RlfDetection(double sinrdB)
Radio link failure detection function.
Definition: lte-ue-phy.cc:1583
Hold an unsigned integer type.
Definition: uinteger.h:44
void DoConfigureReferenceSignalPower(int8_t referenceSignalPower)
Configure reference signal power function.
Definition: lte-ue-phy.cc:1486
void SetTxMode3Gain(double gain)
Set transmit mode 3 gain function.
Definition: lte-ue-phy.cc:1684
static uint8_t TxMode2LayerNum(uint8_t txMode)
Transmit mode 2 layer number.
Definition: lte-common.cc:212
PssElement structure.
Definition: lte-ue-phy.h:726
Ptr< DlCqiLteControlMessage > CreateDlCqiFeedbackMessage(const SpectrumValue &sinr)
Create the DL CQI feedback from SINR values perceived at the physical layer with the signal received ...
Definition: lte-ue-phy.cc:842
void SetTxMode4Gain(double gain)
Set transmit mode 4 gain function.
Definition: lte-ue-phy.cc:1690
void SwitchToState(State s)
Switch the UE PHY to the given state.
Definition: lte-ue-phy.cc:1770
TracedCallback< uint16_t, uint16_t, State, State > m_stateTransitionTrace
The StateTransition trace source.
Definition: lte-ue-phy.h:710
TracedCallback< uint16_t, uint16_t, double, double, uint8_t > m_reportCurrentCellRsrpSinrTrace
The ReportCurrentCellRsrpSinr trace source.
Definition: lte-ue-phy.h:772
uint16_t GetSrsSubframeOffset(uint16_t srcCi) const
Definition: lte-phy.cc:168
void SendSrs()
Send the SRS signal in the last symbols of the frame.
Definition: lte-ue-phy.cc:1339
bool m_rsInterferencePowerUpdated
RS interference power updated?
Definition: lte-ue-phy.h:718
virtual void EnqueueDlHarqFeedback(DlInfoListElement_s mes)
Enqueue the downlink HARQ feedback generated by LteSpectrumPhy.
Definition: lte-ue-phy.cc:1745
virtual void RecvSystemInformationBlockType1(uint16_t cellId, LteRrcSap::SystemInformationBlockType1 sib1)=0
Relay an SIB1 message from the PHY entity to the RRC layer.
SpectrumValue m_ctrlSinrForRlf
the CTRL SINR used for RLF detection
Definition: lte-ue-phy.h:841
Ptr< LteSpectrumPhy > GetDlSpectrumPhy() const
Get Downlink spectrum phy.
Definition: lte-ue-phy.cc:452
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:289
std::vector< uint8_t > m_sbCqi
sb CQI
void SetTxMode7Gain(double gain)
Set transmit mode 7 gain function.
Definition: lte-ue-phy.cc:1708
TracedCallback< uint16_t, const std::vector< int > &> m_reportUlPhyResourceBlocks
The ReportUlPhyResourceBlocks trace source.
Definition: lte-ue-phy.h:806
void DoSetPa(double pa)
Set PA function.
Definition: lte-ue-phy.cc:1525
#define list
uint16_t m_dlBandwidth
The DL bandwidth in number of PRBs.
Definition: lte-phy.h:274
double ComputeAvgSinr(const SpectrumValue &sinr)
Compute average SINR among the RBs.
Definition: lte-ue-phy.cc:707
virtual void RecvMasterInformationBlock(uint16_t cellId, LteRrcSap::MasterInformationBlock mib)=0
Relay an MIB message from the PHY entity to the RRC layer.
See section 4.3.23 dlInfoListElement.
void DoReset()
Do Reset function.
Definition: lte-ue-phy.cc:1361
double rsrpSum
Sum of RSRP sample values in linear unit.
Definition: lte-ue-phy.h:743
uint16_t m_numOfQoutEvalSf
the downlink radio link quality is estimated over this period for detecting out-of-syncs ...
Definition: lte-ue-phy.h:834
static void ScheduleWithContext(uint32_t context, Time const &delay, FUNC f, Ts &&... args)
Schedule an event with the given context.
Definition: simulator.h:572
virtual void DoSendRachPreamble(uint32_t prachId, uint32_t raRnti)
Send RACH preamble function.
Definition: lte-ue-phy.cc:1001
void SetNumQoutEvalSf(uint16_t numSubframes)
Set number of Qout evaluation subframes.
Definition: lte-ue-phy.cc:464
uint8_t m_mcs
MCS for transport block.
Definition: lte-common.h:194
virtual void ReportDataInterference(const SpectrumValue &interf)
Create the mixed CQI report.
Definition: lte-ue-phy.cc:808
uint32_t m_dlEarfcn
The downlink carrier frequency.
Definition: lte-phy.h:281
void SetRsrpFilterCoefficient(uint8_t rsrpFilterCoefficient)
Set RSRP function.
bool m_enableUplinkPowerControl
The EnableUplinkPowerControl attribute.
Definition: lte-ue-phy.h:667
uint8_t m_macChTtiDelay
Delay between MAC and channel layer in terms of TTIs.
Definition: lte-phy.h:301
double GetTxPower() const
Get transmit power.
Definition: lte-ue-phy.cc:432
static const Time UL_DATA_DURATION
Duration of the data portion of a UL subframe.
Definition: lte-ue-phy.cc:61
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< LteHarqPhy > m_harqPhyModule
HARQ phy module.
Definition: lte-ue-phy.h:762
uint16_t GetNumQinEvalSf() const
Get number of Qin evaluation subframes.
Definition: lte-ue-phy.cc:489
Hold objects of type Ptr<T>.
Definition: pointer.h:36
void SetControlMessages(Ptr< LteControlMessage > m)
Definition: lte-phy.cc:217
uint64_t m_imsi
the IMSI of the UE
Definition: lte-ue-phy.h:842
virtual void DoNotifyConnectionSuccessful()
Notify PHY about the successful RRC connection establishment.
Definition: lte-ue-phy.cc:1014
uint16_t m_rsrpSinrSampleCounter
The RsrpSinrSampleCounter attribute.
Definition: lte-ue-phy.h:782
virtual void NotifyOutOfSync()=0
Send an out of sync indication to UE RRC.
uint16_t m_numOfFrames
count the number of frames for which the downlink radio link quality is estimated ...
Definition: lte-ue-phy.h:839
bool m_isConnected
set when UE RRC is in CONNECTED_NORMALLY state
Definition: lte-ue-phy.h:819
SpectrumValue m_rsReceivedPower
RS receive power.
Definition: lte-ue-phy.h:716
void DoSetImsi(uint64_t imsi)
Set IMSI.
Definition: lte-ue-phy.cc:1566
double rsrqSum
Sum of RSRQ sample values in linear unit.
Definition: lte-ue-phy.h:745
uint16_t m_srsSubframeOffset
SRS subframe offset.
Definition: lte-ue-phy.h:695
Values::const_iterator ConstValuesEnd() const
static Ptr< SpectrumValue > CreateNoisePowerSpectralDensity(uint32_t earfcn, uint16_t bandwidth, double noiseFigure)
create a SpectrumValue that models the power spectral density of AWGN
Time m_srsStartTime
SRS start time.
Definition: lte-ue-phy.h:697
uint8_t m_subframeNo
Definition: lte-ue-phy.h:713
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: nstime.h:1343
uint16_t m_size
Size of transport block.
Definition: lte-common.h:195
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:195
Ptr< LteNetDevice > GetDevice() const
Get the device where the phy layer is attached.
Definition: lte-phy.cc:100
uint16_t m_cellId
Cell identifier.
Definition: lte-phy.h:308
uint8_t m_ndi
new data indicator flag
Definition: lte-common.h:197
void SubframeIndication(uint32_t frameNo, uint32_t subframeNo)
trigger from eNB the start from a new frame
Definition: lte-ue-phy.cc:1248
virtual void DoInitialize(void)
Initialize() implementation.
Definition: lte-ue-phy.cc:363
void SetRnti(uint16_t rnti)
Set the RNTI function.
Time m_a30CqiPeriodicity
SubBand Aperiodic CQI.
Definition: lte-ue-phy.h:680
#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:88
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: double.h:42
void SetTxMode1Gain(double gain)
Set transmit mode 1 gain function.
Definition: lte-ue-phy.cc:1672
std::vector< int > m_subChannelsForTransmission
A list of sub channels to use in TX.
Definition: lte-ue-phy.h:654
void DoStartCellSearch(uint32_t dlEarfcn)
Start the cell search function.
Definition: lte-ue-phy.cc:1407
uint32_t m_raRnti
RA RNTI.
Definition: lte-ue-phy.h:765
virtual void ResetSyncIndicationCounter()=0
Reset the sync indication counter.
bool m_dlConfigured
DL configured?
Definition: lte-ue-phy.h:701
virtual void ReceiveLteControlMessageList(std::list< Ptr< LteControlMessage > > msgList)
Receive LTE control message list function.
Definition: lte-ue-phy.cc:1032
Ptr< LteNetDevice > m_netDevice
Pointer to the NetDevice where this PHY layer is attached.
Definition: lte-phy.h:232
std::vector< std::vector< int > > m_subChannelsForTransmissionQueue
subchannels for transmission queue
Definition: lte-ue-phy.h:658
std::list< Ptr< LteControlMessage > > GetControlMessages(void)
Definition: lte-phy.cc:225
static const std::string & ToString(EpcUeNas::State s)
Definition: epc-ue-nas.cc:50
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
Definition: abort.h:108
LteUeCphySapProvider * m_ueCphySapProvider
UE CPhy SAP provider.
Definition: lte-ue-phy.h:686
uint16_t nRB
number of RB
Definition: lte-ue-phy.h:730
std::map< uint16_t, UeMeasurementsElement > m_ueMeasurementsMap
Store measurement results during the last layer-1 filtering period.
Definition: lte-ue-phy.h:753
Ptr< PacketBurst > GetPacketBurst(void)
Definition: lte-phy.cc:198
uint16_t m_cellId
Cell ID of the attached Enb.
Definition: lte-common.h:189
static const std::string g_uePhyStateName[LteUePhy::NUM_STATES]
Map each of UE PHY states to its string representation.
Definition: lte-ue-phy.cc:132
State GetState() const
Get state of the UE physical layer.
Definition: lte-ue-phy.cc:1762
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Definition: log.h:265
virtual void NotifyInSync()=0
Send an in sync indication to UE RRC.
int64_t GetMilliSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:383
std::vector< int > m_subChannelsForReception
A list of sub channels to use in RX.
Definition: lte-ue-phy.h:656
Service Access Point (SAP) offered by the UE-PHY to the UE-MAC.
static const Time UL_SRS_DELAY_FROM_SUBFRAME_START
Delay from subframe start to transmission of SRS.
Definition: lte-ue-phy.cc:67
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:273
uint8_t m_layer
the layer (cw) of the transmission
Definition: lte-common.h:193
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1278
Ptr< const AttributeChecker > MakeBooleanChecker(void)
Definition: boolean.cc:121
void SetTxPower(double pow)
Set transmit power.
Definition: lte-ue-phy.cc:424
virtual void ReceivePss(uint16_t cellId, Ptr< SpectrumValue > p)
Receive PSS function.
Definition: lte-ue-phy.cc:1187
double GetPucchTxPower(std::vector< int > rb)
Get PUCCH transmit power function.
UeMeasurementsParameters structure.
uint16_t m_srsPeriodicity
SRS periodicity.
Definition: lte-ue-phy.h:694
bool m_downlinkInSync
when set, DL SINR evaluation for out-of-sync indications is conducted.
Definition: lte-ue-phy.h:837
LteUePhySapProvider * GetLteUePhySapProvider()
Get the PHY SAP provider.
Definition: lte-ue-phy.cc:388
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
Definition: event-id.cc:53
virtual void SendRachPreamble(uint32_t prachId, uint32_t raRnti)
Send a preamble on the PRACH.
Definition: lte-ue-phy.cc:115
uint32_t m_raPreambleId
RA preamble ID.
Definition: lte-ue-phy.h:764
uint8_t m_rbgSize
The RB group size according to the bandwidth.
Definition: lte-phy.h:276
void SetLteUeCphySapUser(LteUeCphySapUser *s)
Set the CPHY SAP User.
Definition: lte-ue-phy.cc:396
void SetNumQinEvalSf(uint16_t numSubframes)
Set number of Qin evaluation subframes.
Definition: lte-ue-phy.cc:473
SpectrumValue m_rsInterferencePower
RS interference power.
Definition: lte-ue-phy.h:719
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Definition: time.cc:472
friend class UeMemberLteUePhySapProvider
allow UeMemberLteUePhySapProvider class friend access
Definition: lte-ue-phy.h:58
void InitializeRlfParams()
Initialize radio link failure parameters.
Definition: lte-ue-phy.cc:1573
double GetSrsTxPower(std::vector< int > rb)
Get SRS transmit power function.
virtual void NotifyConnectionSuccessful()
Notify PHY about the successful RRC connection establishment.
Definition: lte-ue-phy.cc:121
void PhyPduReceived(Ptr< Packet > p)
PhySpectrum received a new PHY-PDU.
Definition: lte-ue-phy.cc:505
uint8_t m_ccId
component carrier id
Definition: lte-common.h:198
void SetRsrp(double value)
Set RSRP function.
virtual void DoSendLteControlMessage(Ptr< LteControlMessage > msg)
Send LTE control message function.
Definition: lte-ue-phy.cc:993
std::vector< std::list< Ptr< LteControlMessage > > > m_controlMessagesQueue
A queue of control messages to be sent.
Definition: lte-phy.h:291
bool m_rsReceivedPowerUpdated
RS receive power updated?
Definition: lte-ue-phy.h:715
Ptr< LteUePowerControl > GetUplinkPowerControl() const
Get Uplink power control.
Definition: lte-ue-phy.cc:439
void ConfigureReferenceSignalPower(int8_t referenceSignalPower)
Configure reference signal power (dBm) function.
void GenerateCqiRsrpRsrq(const SpectrumValue &sinr)
Get CQI, RSRP, and RSRQ.
Definition: lte-ue-phy.cc:579
virtual ~LteUePhy()
Definition: lte-ue-phy.cc:186
The LteSpectrumPhy models the physical layer of LTE.
Definition: lte-ue-phy.h:54
uint32_t m_ulEarfcn
The uplink carrier frequency.
Definition: lte-phy.h:286
Ptr< LteSpectrumPhy > m_uplinkSpectrumPhy
The uplink LteSpectrumPhy associated to this LtePhy.
Definition: lte-phy.h:243
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:817
PhyTransmissionStatParameters structure.
Definition: lte-common.h:186
Time m_p10CqiLast
last periodic CQI
Definition: lte-ue-phy.h:673
Parameters of the ReportUeMeasurements primitive: RSRP [dBm] and RSRQ [dB] See section 5...
LteUeCphySapProvider * GetLteUeCphySapProvider()
Get the CPHY SAP provider.
Definition: lte-ue-phy.cc:403
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
State m_state
The current UE PHY state.
Definition: lte-ue-phy.h:705
int64_t m_timestamp
in millisecond
Definition: lte-common.h:188
Set of values corresponding to a given SpectrumModel.
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
void SetMacPdu(Ptr< Packet > p)
Definition: lte-phy.cc:192
std::vector< struct HigherLayerSelected_s > m_higherLayerSelected
higher layer selected
a unique identifier for an interface.
Definition: type-id.h:58
uint16_t m_rnti
the RNTI
Definition: lte-ue-phy.h:689
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:923
double m_sinrDbFrame
the average SINR per radio frame
Definition: lte-ue-phy.h:840
bool m_dataInterferencePowerUpdated
data interference power updated?
Definition: lte-ue-phy.h:721
void DoConfigureUplink(uint32_t ulEarfcn, uint16_t ulBandwidth)
Configure UL uplink function.
Definition: lte-ue-phy.cc:1478
void SetNoiseFigure(double nf)
Set noise figure.
Definition: lte-ue-phy.cc:410
uint16_t m_numOfQinEvalSf
the downlink radio link quality is estimated over this period for detecting in-syncs ...
Definition: lte-ue-phy.h:835
TracedCallback< PhyTransmissionStatParameters > m_ulPhyTransmission
The UlPhyTransmission trace source.
Definition: lte-ue-phy.h:799
uint16_t m_rnti
C-RNTI scheduled.
Definition: lte-common.h:191
static TypeId GetTypeId(void)
Get the type ID.
Definition: lte-ue-phy.cc:203
Time m_p10CqiPeriodicity
Wideband Periodic CQI. 2, 5, 10, 16, 20, 32, 40, 64, 80 or 160 ms.
Definition: lte-ue-phy.h:672
Ptr< LteAmc > m_amc
AMC.
Definition: lte-ue-phy.h:661
The LtePhy models the physical layer of LTE.
Definition: lte-phy.h:52
void ReportUeMeasurements()
Layer-1 filtering of RSRP and RSRQ measurements and reporting to the RRC entity.
Definition: lte-ue-phy.cc:942
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:800
virtual void ReceivePhyPdu(Ptr< Packet > p)=0
Receive Phy Pdu funtion.
virtual Ptr< SpectrumValue > CreateTxPowerSpectralDensity()
Create the PSD for the TX.
Definition: lte-ue-phy.cc:547
void ReportTpc(uint8_t tpc)
Set RSRP function.
#define UL_PUSCH_TTIS_DELAY
Definition: lte-common.h:28
Ptr< SpectrumValue > m_noisePsd
Noise power spectral density for the configured bandwidth.
Definition: lte-ue-phy.h:816
void DoSetRnti(uint16_t rnti)
Set RNTI function.
Definition: lte-ue-phy.cc:1493
virtual void SubframeIndication(uint32_t frameNo, uint32_t subframeNo)=0
Trigger the start from a new frame (input from Phy layer)
virtual void ReportUeMeasurements(UeMeasurementsParameters params)=0
Send a report of RSRP and RSRQ values perceived from PSS by the PHY entity (after applying layer-1 fi...
std::vector< HarqProcessInfoElement_t > HarqProcessInfoList_t
HarqProcessInfoList_t typedef.
Definition: lte-harq-phy.h:48
void SetSubChannelsForReception(std::vector< int > mask)
Get a list of sub channels to use in RX.
Definition: lte-ue-phy.cc:523
The LteUeNetDevice class implements the UE net device.
virtual void DoDispose(void)
Destructor implementation.
Definition: lte-ue-phy.cc:192
Time m_ueMeasurementsFilterPeriod
The UeMeasurementsFilterPeriod attribute.
Definition: lte-ue-phy.h:758