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