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-common.h"
30 #include "lte-net-device.h"
32 #include "lte-ue-net-device.h"
33 #include "lte-ue-power-control.h"
34 
35 #include <ns3/boolean.h>
36 #include <ns3/double.h>
37 #include <ns3/log.h>
38 #include <ns3/node.h>
39 #include <ns3/object-factory.h>
40 #include <ns3/pointer.h>
41 #include <ns3/simulator.h>
42 
43 #include <cfloat>
44 #include <cmath>
45 
46 namespace ns3
47 {
48 
49 NS_LOG_COMPONENT_DEFINE("LteUePhy");
50 
58 static const Time UL_DATA_DURATION = NanoSeconds(1e6 - 71429 - 1);
59 
65 
67 // member SAP forwarders
69 
72 {
73  public:
80 
81  // inherited from LtePhySapProvider
82  void SendMacPdu(Ptr<Packet> p) override;
84  void SendRachPreamble(uint32_t prachId, uint32_t raRnti) override;
85  void NotifyConnectionSuccessful() override;
86 
87  private:
89 };
90 
92  : m_phy(phy)
93 {
94 }
95 
96 void
98 {
99  m_phy->DoSendMacPdu(p);
100 }
101 
102 void
104 {
106 }
107 
108 void
109 UeMemberLteUePhySapProvider::SendRachPreamble(uint32_t prachId, uint32_t raRnti)
110 {
111  m_phy->DoSendRachPreamble(prachId, raRnti);
112 }
113 
114 void
116 {
118 }
119 
121 // LteUePhy methods
123 
125 static const std::string g_uePhyStateName[LteUePhy::NUM_STATES] = {
126  "CELL_SEARCH",
127  "SYNCHRONIZED",
128 };
129 
134 static inline const std::string&
136 {
137  return g_uePhyStateName[s];
138 }
139 
141 
143 {
144  NS_LOG_FUNCTION(this);
145  NS_FATAL_ERROR("This constructor should not be called");
146 }
147 
149  : LtePhy(dlPhy, ulPhy),
150  m_uePhySapUser(nullptr),
151  m_ueCphySapUser(nullptr),
152  m_state(CELL_SEARCH),
153  m_subframeNo(0),
154  m_rsReceivedPowerUpdated(false),
155  m_rsInterferencePowerUpdated(false),
156  m_dataInterferencePowerUpdated(false),
157  m_pssReceived(false),
158  m_ueMeasurementsFilterPeriod(MilliSeconds(200)),
159  m_ueMeasurementsFilterLast(MilliSeconds(0)),
160  m_rsrpSinrSampleCounter(0),
161  m_imsi(0)
162 {
163  m_amc = CreateObject<LteAmc>();
164  m_powerControl = CreateObject<LteUePowerControl>();
168 
169  NS_ASSERT_MSG(Simulator::Now().GetNanoSeconds() == 0,
170  "Cannot create UE devices after simulation started");
172 
173  DoReset();
174 }
175 
177 {
178  m_txModeGain.clear();
179 }
180 
181 void
183 {
184  NS_LOG_FUNCTION(this);
185  delete m_uePhySapProvider;
186  delete m_ueCphySapProvider;
188 }
189 
190 TypeId
192 {
193  static TypeId tid =
194  TypeId("ns3::LteUePhy")
195  .SetParent<LtePhy>()
196  .SetGroupName("Lte")
197  .AddConstructor<LteUePhy>()
198  .AddAttribute("TxPower",
199  "Transmission power in dBm",
200  DoubleValue(10.0),
202  MakeDoubleChecker<double>())
203  .AddAttribute(
204  "NoiseFigure",
205  "Loss (dB) in the Signal-to-Noise-Ratio due to non-idealities in the receiver."
206  " According to Wikipedia (http://en.wikipedia.org/wiki/Noise_figure), this is "
207  "\"the difference in decibels (dB) between"
208  " the noise output of the actual receiver to the noise output of an "
209  " ideal receiver with the same overall gain and bandwidth when the receivers "
210  " are connected to sources at the standard noise temperature T0.\" "
211  "In this model, we consider T0 = 290K.",
212  DoubleValue(9.0),
214  MakeDoubleChecker<double>())
215  .AddAttribute("TxMode1Gain",
216  "Transmission mode 1 gain in dB",
217  DoubleValue(0.0),
219  MakeDoubleChecker<double>())
220  .AddAttribute("TxMode2Gain",
221  "Transmission mode 2 gain in dB",
222  DoubleValue(4.2),
224  MakeDoubleChecker<double>())
225  .AddAttribute("TxMode3Gain",
226  "Transmission mode 3 gain in dB",
227  DoubleValue(-2.8),
229  MakeDoubleChecker<double>())
230  .AddAttribute("TxMode4Gain",
231  "Transmission mode 4 gain in dB",
232  DoubleValue(0.0),
234  MakeDoubleChecker<double>())
235  .AddAttribute("TxMode5Gain",
236  "Transmission mode 5 gain in dB",
237  DoubleValue(0.0),
239  MakeDoubleChecker<double>())
240  .AddAttribute("TxMode6Gain",
241  "Transmission mode 6 gain in dB",
242  DoubleValue(0.0),
244  MakeDoubleChecker<double>())
245  .AddAttribute("TxMode7Gain",
246  "Transmission mode 7 gain in dB",
247  DoubleValue(0.0),
249  MakeDoubleChecker<double>())
250  .AddTraceSource("ReportCurrentCellRsrpSinr",
251  "RSRP and SINR statistics.",
253  "ns3::LteUePhy::RsrpSinrTracedCallback")
254  .AddAttribute("RsrpSinrSamplePeriod",
255  "The sampling period for reporting RSRP-SINR stats (default value 1)",
256  UintegerValue(1),
258  MakeUintegerChecker<uint16_t>())
259  .AddTraceSource("ReportUlPhyResourceBlocks",
260  "UL transmission PHY layer resource blocks.",
262  "ns3::LteUePhy::UlPhyResourceBlocksTracedCallback")
263  .AddTraceSource("ReportPowerSpectralDensity",
264  "Power Spectral Density data.",
266  "ns3::LteUePhy::PowerSpectralDensityTracedCallback")
267  .AddTraceSource("UlPhyTransmission",
268  "DL transmission PHY layer statistics.",
270  "ns3::PhyTransmissionStatParameters::TracedCallback")
271  .AddAttribute("DlSpectrumPhy",
272  "The downlink LteSpectrumPhy associated to this LtePhy",
274  PointerValue(),
276  MakePointerChecker<LteSpectrumPhy>())
277  .AddAttribute("UlSpectrumPhy",
278  "The uplink LteSpectrumPhy associated to this LtePhy",
280  PointerValue(),
282  MakePointerChecker<LteSpectrumPhy>())
283  .AddAttribute("RsrqUeMeasThreshold",
284  "Receive threshold for PSS on RSRQ [dB]",
285  DoubleValue(-1000.0),
287  MakeDoubleChecker<double>())
288  .AddAttribute("UeMeasurementsFilterPeriod",
289  "Time period for reporting UE measurements, i.e., the"
290  "length of layer-1 filtering.",
291  TimeValue(MilliSeconds(200)),
293  MakeTimeChecker())
294  .AddAttribute("DownlinkCqiPeriodicity",
295  "Periodicity in milliseconds for reporting the"
296  "wideband and subband downlink CQIs to the eNB",
299  MakeTimeChecker())
300  .AddTraceSource("ReportUeMeasurements",
301  "Report UE measurements RSRP (dBm) and RSRQ (dB).",
303  "ns3::LteUePhy::RsrpRsrqTracedCallback")
304  .AddTraceSource("StateTransition",
305  "Trace fired upon every UE PHY state transition",
307  "ns3::LteUePhy::StateTracedCallback")
308  .AddAttribute("EnableUplinkPowerControl",
309  "If true, Uplink Power Control will be enabled.",
310  BooleanValue(true),
313  .AddAttribute("Qout",
314  "corresponds to 10% block error rate of a hypothetical PDCCH transmission"
315  "taking into account the PCFICH errors with transmission parameters."
316  "see 3GPP TS 36.213 4.2.1 and TS 36.133 7.6",
317  DoubleValue(-5),
319  MakeDoubleChecker<double>())
320  .AddAttribute("Qin",
321  "corresponds to 2% block error rate of a hypothetical PDCCH transmission"
322  "taking into account the PCFICH errors with transmission parameters."
323  "see 3GPP TS 36.213 4.2.1 and TS 36.133 7.6",
324  DoubleValue(-3.9),
326  MakeDoubleChecker<double>())
327  .AddAttribute(
328  "NumQoutEvalSf",
329  "This specifies the total number of consecutive subframes"
330  "which corresponds to the Qout evaluation period",
331  UintegerValue(200), // see 3GPP 3GPP TS 36.133 7.6.2.1
333  MakeUintegerChecker<uint16_t>())
334  .AddAttribute(
335  "NumQinEvalSf",
336  "This specifies the total number of consecutive subframes"
337  "which corresponds to the Qin evaluation period",
338  UintegerValue(100), // see 3GPP 3GPP TS 36.133 7.6.2.1
340  MakeUintegerChecker<uint16_t>())
341  .AddAttribute("EnableRlfDetection",
342  "If true, RLF detection will be enabled.",
343  BooleanValue(true),
346  return tid;
347 }
348 
349 void
351 {
352  NS_LOG_FUNCTION(this);
353 
354  NS_ABORT_MSG_IF(!m_netDevice, "LteNetDevice is not available in LteUePhy");
355  Ptr<Node> node = m_netDevice->GetNode();
356  NS_ABORT_MSG_IF(!node, "Node is not available in the LteNetDevice of LteUePhy");
357  uint32_t nodeId = node->GetId();
358 
359  // ScheduleWithContext() is needed here to set context for logs,
360  // because Initialize() is called outside of Node::AddDevice().
361 
363 
365 }
366 
367 void
369 {
370  NS_LOG_FUNCTION(this);
371  m_uePhySapUser = s;
372 }
373 
376 {
377  NS_LOG_FUNCTION(this);
378  return m_uePhySapProvider;
379 }
380 
381 void
383 {
384  NS_LOG_FUNCTION(this);
385  m_ueCphySapUser = s;
386 }
387 
390 {
391  NS_LOG_FUNCTION(this);
392  return m_ueCphySapProvider;
393 }
394 
395 void
397 {
398  NS_LOG_FUNCTION(this << nf);
399  m_noiseFigure = nf;
400 }
401 
402 double
404 {
405  NS_LOG_FUNCTION(this);
406  return m_noiseFigure;
407 }
408 
409 void
411 {
412  NS_LOG_FUNCTION(this << pow);
413  m_txPower = pow;
415 }
416 
417 double
419 {
420  NS_LOG_FUNCTION(this);
421  return m_txPower;
422 }
423 
426 {
427  NS_LOG_FUNCTION(this);
428  return m_powerControl;
429 }
430 
431 uint8_t
433 {
434  return m_macChTtiDelay;
435 }
436 
439 {
440  return m_downlinkSpectrumPhy;
441 }
442 
445 {
446  return m_uplinkSpectrumPhy;
447 }
448 
449 void
450 LteUePhy::SetNumQoutEvalSf(uint16_t numSubframes)
451 {
452  NS_LOG_FUNCTION(this << numSubframes);
453  NS_ABORT_MSG_IF(numSubframes % 10 != 0,
454  "Number of subframes used for Qout "
455  "evaluation must be multiple of 10");
456  m_numOfQoutEvalSf = numSubframes;
457 }
458 
459 void
460 LteUePhy::SetNumQinEvalSf(uint16_t numSubframes)
461 {
462  NS_LOG_FUNCTION(this << numSubframes);
463  NS_ABORT_MSG_IF(numSubframes % 10 != 0,
464  "Number of subframes used for Qin "
465  "evaluation must be multiple of 10");
466  m_numOfQinEvalSf = numSubframes;
467 }
468 
469 uint16_t
471 {
472  NS_LOG_FUNCTION(this);
473  return m_numOfQoutEvalSf;
474 }
475 
476 uint16_t
478 {
479  NS_LOG_FUNCTION(this);
480  return m_numOfQinEvalSf;
481 }
482 
483 void
485 {
486  NS_LOG_FUNCTION(this);
487 
488  SetMacPdu(p);
489 }
490 
491 void
493 {
495 }
496 
497 void
499 {
500  NS_LOG_FUNCTION(this);
501 
503 
505  m_uplinkSpectrumPhy->SetTxPowerSpectralDensity(txPsd);
506 }
507 
508 void
510 {
511  NS_LOG_FUNCTION(this);
513 }
514 
515 std::vector<int>
517 {
518  NS_LOG_FUNCTION(this);
520 }
521 
522 std::vector<int>
524 {
525  NS_LOG_FUNCTION(this);
527 }
528 
531 {
532  NS_LOG_FUNCTION(this);
533  Ptr<SpectrumValue> psd =
536  m_txPower,
539 
540  return psd;
541 }
542 
543 void
545 {
546  NS_LOG_FUNCTION(this);
556  if (m_cellId == 0)
557  {
558  return;
559  }
560  m_ctrlSinrForRlf = sinr;
561  GenerateCqiRsrpRsrq(sinr);
562 }
563 
564 void
566 {
567  NS_LOG_FUNCTION(this << sinr);
568 
570  NS_ASSERT(m_cellId > 0);
571 
572  if (m_dlConfigured && m_ulConfigured && (m_rnti > 0))
573  {
574  // check periodic wideband CQI
576  {
577  NS_LOG_DEBUG("Reporting P10 CQI at : " << Simulator::Now().As(Time::MS)
578  << ". Last reported at : "
579  << m_p10CqiLast.As(Time::MS));
580  Ptr<LteUeNetDevice> thisDevice = GetDevice()->GetObject<LteUeNetDevice>();
582  if (msg)
583  {
585  }
587  }
588  // check aperiodic high-layer configured subband CQI
590  {
591  NS_LOG_DEBUG("Reporting A30 CQI at : " << Simulator::Now().As(Time::MS)
592  << ". Last reported at : "
593  << m_a30CqiLast.As(Time::MS));
594  Ptr<LteUeNetDevice> thisDevice = GetDevice()->GetObject<LteUeNetDevice>();
596  if (msg)
597  {
599  }
601  }
602  }
603 
604  // Generate PHY trace
607  {
608  NS_ASSERT_MSG(m_rsReceivedPowerUpdated, " RS received power info obsolete");
609  // RSRP evaluated as averaged received power among RBs
610  double sum = 0.0;
611  uint8_t rbNum = 0;
612  for (auto it = m_rsReceivedPower.ConstValuesBegin();
614  it++)
615  {
616  // convert PSD [W/Hz] to linear power [W] for the single RE
617  // we consider only one RE for the RS since the channel is
618  // flat within the same RB
619  double powerTxW = ((*it) * 180000.0) / 12.0;
620  sum += powerTxW;
621  rbNum++;
622  }
623  double rsrp = (rbNum > 0) ? (sum / rbNum) : DBL_MAX;
624  // averaged SINR among RBs
625  double avSinr = ComputeAvgSinr(sinr);
626 
627  NS_LOG_INFO(this << " cellId " << m_cellId << " rnti " << m_rnti << " RSRP " << rsrp
628  << " SINR " << avSinr << " ComponentCarrierId "
629  << (uint16_t)m_componentCarrierId);
630  // trigger RLF detection only when UE has an active RRC connection
631  // and RLF detection attribute is set to true
633  {
634  double avrgSinrForRlf = ComputeAvgSinr(m_ctrlSinrForRlf);
635  RlfDetection(10 * log10(avrgSinrForRlf));
636  }
637 
639  m_rnti,
640  rsrp,
641  avSinr,
642  (uint16_t)m_componentCarrierId);
644  }
645 
646  if (m_pssReceived)
647  {
648  // measure instantaneous RSRQ now
649  NS_ASSERT_MSG(m_rsInterferencePowerUpdated, " RS interference power info obsolete");
650 
651  auto itPss = m_pssList.begin();
652  while (itPss != m_pssList.end())
653  {
654  uint16_t rbNum = 0;
655  double rssiSum = 0.0;
656 
657  auto itIntN = m_rsInterferencePower.ConstValuesBegin();
658  auto itPj = m_rsReceivedPower.ConstValuesBegin();
659  for (itPj = m_rsReceivedPower.ConstValuesBegin();
661  itIntN++, itPj++)
662  {
663  rbNum++;
664  // convert PSD [W/Hz] to linear power [W] for the single RE
665  double interfPlusNoisePowerTxW = ((*itIntN) * 180000.0) / 12.0;
666  double signalPowerTxW = ((*itPj) * 180000.0) / 12.0;
667  rssiSum += (2 * (interfPlusNoisePowerTxW + signalPowerTxW));
668  }
669 
670  NS_ASSERT(rbNum == (*itPss).nRB);
671  double rsrq_dB = 10 * log10((*itPss).pssPsdSum / rssiSum);
672 
673  if (rsrq_dB > m_pssReceptionThreshold)
674  {
675  NS_LOG_INFO(this << " PSS RNTI " << m_rnti << " cellId " << m_cellId << " has RSRQ "
676  << rsrq_dB << " and RBnum " << rbNum);
677  // store measurements
678  auto itMeasMap = m_ueMeasurementsMap.find((*itPss).cellId);
679  if (itMeasMap != m_ueMeasurementsMap.end())
680  {
681  (*itMeasMap).second.rsrqSum += rsrq_dB;
682  (*itMeasMap).second.rsrqNum++;
683  }
684  else
685  {
686  NS_LOG_WARN("race condition of bug 2091 occurred");
687  }
688  }
689 
690  itPss++;
691 
692  } // end of while (itPss != m_pssList.end ())
693 
694  m_pssList.clear();
695 
696  } // end of if (m_pssReceived)
697 
698 } // end of void LteUePhy::GenerateCtrlCqiReport (const SpectrumValue& sinr)
699 
700 double
702 {
703  NS_LOG_FUNCTION(this);
704 
705  // averaged SINR among RBs
706  double sum = 0.0;
707  uint8_t rbNum = 0;
708 
709  for (auto it = sinr.ConstValuesBegin(); it != sinr.ConstValuesEnd(); it++)
710  {
711  sum += (*it);
712  rbNum++;
713  }
714 
715  double avrgSinr = (rbNum > 0) ? (sum / rbNum) : DBL_MAX;
716 
717  return avrgSinr;
718 }
719 
720 void
722 {
723  // Not used by UE, CQI are based only on RS
724 }
725 
726 void
728 {
729  NS_LOG_FUNCTION(this);
730 
740  if (m_cellId == 0)
741  {
742  return;
743  }
744 
746  // NOTE: The SINR received by this method is
747  // based on CTRL, which is not used to compute
748  // PDSCH (i.e., data) based SINR. It is used
749  // for RLF detection.
750  m_ctrlSinrForRlf = sinr;
751 
754  {
755  // we have a measurement of interf + noise for the denominator
756  // of SINR = S/(I+N)
757  mixedSinr /= m_dataInterferencePower;
759  NS_LOG_LOGIC("data interf measurement available, SINR = " << mixedSinr);
760  }
761  else
762  {
763  // we did not see any interference on data, so interference is
764  // there and we have only noise at the denominator of SINR
765  mixedSinr /= (*m_noisePsd);
766  NS_LOG_LOGIC("no data interf measurement available, SINR = " << mixedSinr);
767  }
768 
769  /*
770  * some RBs are not used in PDSCH and their SINR is very high
771  * for example with bandwidth 25, last RB is not used
772  * it can make avgSinr value very high, what is incorrect
773  */
774  uint32_t rbgSize = GetRbgSize();
775  uint32_t modulo = m_dlBandwidth % rbgSize;
776  double avgMixedSinr = 0;
777  uint32_t usedRbgNum = 0;
778  for (uint32_t i = 0; i < (m_dlBandwidth - 1 - modulo); i++)
779  {
780  usedRbgNum++;
781  avgMixedSinr += mixedSinr[i];
782  }
783  avgMixedSinr = avgMixedSinr / usedRbgNum;
784  for (uint32_t i = 0; i < modulo; i++)
785  {
786  mixedSinr[m_dlBandwidth - 1 - i] = avgMixedSinr;
787  }
788 
789  GenerateCqiRsrpRsrq(mixedSinr);
790 }
791 
792 void
794 {
795  NS_LOG_FUNCTION(this << interf);
797  m_rsInterferencePower = interf;
798 }
799 
800 void
802 {
803  NS_LOG_FUNCTION(this << interf);
804 
806  m_dataInterferencePower = interf;
807 }
808 
809 void
811 {
812  NS_LOG_FUNCTION(this << power);
814  m_rsReceivedPower = power;
815 
817  {
818  double sum = 0;
819  for (auto it = m_rsReceivedPower.ConstValuesBegin();
821  it++)
822  {
823  double powerTxW = ((*it) * 180000);
824  sum += powerTxW;
825  }
826  double rsrp = 10 * log10(sum) + 30;
827 
828  NS_LOG_INFO("RSRP: " << rsrp);
829  m_powerControl->SetRsrp(rsrp);
830  }
831 }
832 
835 {
836  NS_LOG_FUNCTION(this);
837 
838  // apply transmission mode gain
840  SpectrumValue newSinr = sinr;
841  newSinr *= m_txModeGain.at(m_transmissionMode);
842 
843  // CREATE DlCqiLteControlMessage
844  Ptr<DlCqiLteControlMessage> msg = Create<DlCqiLteControlMessage>();
845  CqiListElement_s dlcqi;
846  std::vector<int> cqi;
848  {
849  cqi = m_amc->CreateCqiFeedbacks(newSinr, m_dlBandwidth);
850 
852  auto nbSubChannels = cqi.size();
853  double cqiSum = 0.0;
854  int activeSubChannels = 0;
855  // average the CQIs of the different RBs
856  for (std::size_t i = 0; i < nbSubChannels; i++)
857  {
858  if (cqi.at(i) != -1)
859  {
860  cqiSum += cqi.at(i);
861  activeSubChannels++;
862  }
863  NS_LOG_DEBUG(this << " subch " << i << " cqi " << cqi.at(i));
864  }
865  dlcqi.m_rnti = m_rnti;
866  dlcqi.m_ri = 1; // not yet used
867  dlcqi.m_cqiType = CqiListElement_s::P10; // Periodic CQI using PUCCH wideband
868  NS_ASSERT_MSG(nLayer > 0, " nLayer negative");
869  NS_ASSERT_MSG(nLayer < 3, " nLayer limit is 2s");
870  for (uint8_t i = 0; i < nLayer; i++)
871  {
872  if (activeSubChannels > 0)
873  {
874  dlcqi.m_wbCqi.push_back((uint16_t)cqiSum / activeSubChannels);
875  }
876  else
877  {
878  // approximate with the worst case -> CQI = 1
879  dlcqi.m_wbCqi.push_back(1);
880  }
881  }
882  // NS_LOG_DEBUG (this << " Generate P10 CQI feedback " << (uint16_t) cqiSum /
883  // activeSubChannels);
884  dlcqi.m_wbPmi = 0; // not yet used
885  // dl.cqi.m_sbMeasResult others CQI report modes: not yet implemented
886  }
888  {
889  cqi = m_amc->CreateCqiFeedbacks(newSinr, GetRbgSize());
891  auto nbSubChannels = cqi.size();
892  int rbgSize = GetRbgSize();
893  double cqiSum = 0.0;
894  int cqiNum = 0;
895  SbMeasResult_s rbgMeas;
896  // NS_LOG_DEBUG (this << " Create A30 CQI feedback, RBG " << rbgSize << " cqiNum " <<
897  // nbSubChannels << " band " << (uint16_t)m_dlBandwidth);
898  for (std::size_t i = 0; i < nbSubChannels; i++)
899  {
900  if (cqi.at(i) != -1)
901  {
902  cqiSum += cqi.at(i);
903  }
904  // else "nothing" no CQI is treated as CQI = 0 (worst case scenario)
905  cqiNum++;
906  if (cqiNum == rbgSize)
907  {
908  // average the CQIs of the different RBGs
909  // NS_LOG_DEBUG (this << " RBG CQI " << (uint16_t) cqiSum / rbgSize);
910  HigherLayerSelected_s hlCqi;
911  hlCqi.m_sbPmi = 0; // not yet used
912  for (uint8_t i = 0; i < nLayer; i++)
913  {
914  hlCqi.m_sbCqi.push_back((uint16_t)cqiSum / rbgSize);
915  }
916  rbgMeas.m_higherLayerSelected.push_back(hlCqi);
917  cqiSum = 0.0;
918  cqiNum = 0;
919  }
920  }
921  dlcqi.m_rnti = m_rnti;
922  dlcqi.m_ri = 1; // not yet used
923  dlcqi.m_cqiType = CqiListElement_s::A30; // Aperidic CQI using PUSCH
924  // dlcqi.m_wbCqi.push_back ((uint16_t) cqiSum / nbSubChannels);
925  dlcqi.m_wbPmi = 0; // not yet used
926  dlcqi.m_sbMeasResult = rbgMeas;
927  }
928 
929  msg->SetDlCqi(dlcqi);
930  return msg;
931 }
932 
933 void
935 {
936  NS_LOG_FUNCTION(this << Simulator::Now());
937  NS_LOG_DEBUG(this << " Report UE Measurements ");
938 
940 
941  for (auto it = m_ueMeasurementsMap.begin(); it != m_ueMeasurementsMap.end(); it++)
942  {
943  double avg_rsrp = (*it).second.rsrpSum / (double)(*it).second.rsrpNum;
944  double avg_rsrq = (*it).second.rsrqSum / (double)(*it).second.rsrqNum;
945  /*
946  * In CELL_SEARCH state, this may result in avg_rsrq = 0/0 = -nan.
947  * UE RRC must take this into account when receiving measurement reports.
948  * TODO remove this shortcoming by calculating RSRQ during CELL_SEARCH
949  */
950  NS_LOG_DEBUG(this << " CellId " << (*it).first << " RSRP " << avg_rsrp << " (nSamples "
951  << (uint16_t)(*it).second.rsrpNum << ")"
952  << " RSRQ " << avg_rsrq << " (nSamples " << (uint16_t)(*it).second.rsrqNum
953  << ")"
954  << " ComponentCarrierID " << (uint16_t)m_componentCarrierId);
955 
957  newEl.m_cellId = (*it).first;
958  newEl.m_rsrp = avg_rsrp;
959  newEl.m_rsrq = avg_rsrq;
960  ret.m_ueMeasurementsList.push_back(newEl);
961  ret.m_componentCarrierId = m_componentCarrierId;
962 
963  // report to UE measurements trace
965  (*it).first,
966  avg_rsrp,
967  avg_rsrq,
968  (*it).first == m_cellId,
970  }
971 
972  // report to RRC
974 
975  m_ueMeasurementsMap.clear();
977 }
978 
979 void
981 {
982  NS_LOG_FUNCTION(this << cqiPeriodicity);
983  m_a30CqiPeriodicity = cqiPeriodicity;
984  m_p10CqiPeriodicity = cqiPeriodicity;
985 }
986 
987 void
989 {
990  NS_LOG_FUNCTION(this << msg);
991 
992  SetControlMessages(msg);
993 }
994 
995 void
996 LteUePhy::DoSendRachPreamble(uint32_t raPreambleId, uint32_t raRnti)
997 {
998  NS_LOG_FUNCTION(this << raPreambleId);
999 
1000  // unlike other control messages, RACH preamble is sent ASAP
1001  Ptr<RachPreambleLteControlMessage> msg = Create<RachPreambleLteControlMessage>();
1002  msg->SetRapId(raPreambleId);
1003  m_raPreambleId = raPreambleId;
1004  m_raRnti = raRnti;
1005  m_controlMessagesQueue.at(0).emplace_back(msg);
1006 }
1007 
1008 void
1010 {
1016  if (m_componentCarrierId == 0)
1017  {
1018  m_isConnected = true;
1019  // Initialize the parameters for radio link failure detection
1021  }
1022 }
1023 
1024 void
1026 {
1027  NS_LOG_FUNCTION(this);
1028 
1029  NS_LOG_DEBUG(this << " I am rnti = " << m_rnti << " and I received msgs "
1030  << (uint16_t)msgList.size());
1031  for (auto it = msgList.begin(); it != msgList.end(); it++)
1032  {
1033  Ptr<LteControlMessage> msg = (*it);
1034 
1035  if (msg->GetMessageType() == LteControlMessage::DL_DCI)
1036  {
1037  Ptr<DlDciLteControlMessage> msg2 = DynamicCast<DlDciLteControlMessage>(msg);
1038 
1039  DlDciListElement_s dci = msg2->GetDci();
1040  if (dci.m_rnti != m_rnti)
1041  {
1042  // DCI not for me
1043  continue;
1044  }
1045 
1046  if (dci.m_resAlloc != 0)
1047  {
1048  NS_FATAL_ERROR("Resource Allocation type not implemented");
1049  }
1050 
1051  std::vector<int> dlRb;
1052 
1053  // translate the DCI to Spectrum framework
1054  uint32_t mask = 0x1;
1055  for (int i = 0; i < 32; i++)
1056  {
1057  if (((dci.m_rbBitmap & mask) >> i) == 1)
1058  {
1059  for (int k = 0; k < GetRbgSize(); k++)
1060  {
1061  dlRb.push_back((i * GetRbgSize()) + k);
1062  // NS_LOG_DEBUG(this << " RNTI " << m_rnti << " RBG " << i << "
1063  // DL-DCI allocated PRB " << (i*GetRbgSize()) + k);
1064  }
1065  }
1066  mask = (mask << 1);
1067  }
1069  {
1071  }
1072 
1073  // send TB info to LteSpectrumPhy
1074  NS_LOG_DEBUG(this << " UE " << m_rnti << " DL-DCI " << dci.m_rnti << " bitmap "
1075  << dci.m_rbBitmap);
1076  for (std::size_t i = 0; i < dci.m_tbsSize.size(); i++)
1077  {
1078  m_downlinkSpectrumPhy->AddExpectedTb(dci.m_rnti,
1079  dci.m_ndi.at(i),
1080  dci.m_tbsSize.at(i),
1081  dci.m_mcs.at(i),
1082  dlRb,
1083  i,
1084  dci.m_harqProcess,
1085  dci.m_rv.at(i),
1086  true /* DL */);
1087  }
1088 
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  ulRb.reserve(dci.m_rbLen);
1104  for (int i = 0; i < dci.m_rbLen; i++)
1105  {
1106  ulRb.push_back(i + dci.m_rbStart);
1107  // NS_LOG_DEBUG (this << " UE RB " << i + dci.m_rbStart);
1108  }
1111  // fire trace of UL Tx PHY stats
1112  HarqProcessInfoList_t harqInfoList = m_harqPhyModule->GetHarqProcessInfoUl(m_rnti, 0);
1114  params.m_cellId = m_cellId;
1115  params.m_imsi = 0; // it will be set by DlPhyTransmissionCallback in LteHelper
1117  params.m_rnti = m_rnti;
1118  params.m_txMode = 0; // always SISO for UE
1119  params.m_layer = 0;
1120  params.m_mcs = dci.m_mcs;
1121  params.m_size = dci.m_tbSize;
1122  params.m_rv = harqInfoList.size();
1123  params.m_ndi = dci.m_ndi;
1124  params.m_ccId = m_componentCarrierId;
1126  // pass the info to the MAC
1128  }
1129  else if (msg->GetMessageType() == LteControlMessage::RAR)
1130  {
1131  Ptr<RarLteControlMessage> rarMsg = DynamicCast<RarLteControlMessage>(msg);
1132  if (rarMsg->GetRaRnti() == m_raRnti)
1133  {
1134  for (auto it = rarMsg->RarListBegin(); it != rarMsg->RarListEnd(); ++it)
1135  {
1136  if (it->rapId != m_raPreambleId)
1137  {
1138  // UL grant not for me
1139  continue;
1140  }
1141  else
1142  {
1143  NS_LOG_INFO("received RAR RNTI " << m_raRnti);
1144  // set the uplink bandwidth according to the UL grant
1145  std::vector<int> ulRb;
1146  ulRb.reserve(it->rarPayload.m_grant.m_rbLen);
1147  for (int i = 0; i < it->rarPayload.m_grant.m_rbLen; i++)
1148  {
1149  ulRb.push_back(i + it->rarPayload.m_grant.m_rbStart);
1150  }
1151 
1153  // pass the info to the MAC
1155  // reset RACH variables with out of range values
1156  m_raPreambleId = 255;
1157  m_raRnti = 11;
1158  }
1159  }
1160  }
1161  }
1162  else if (msg->GetMessageType() == LteControlMessage::MIB)
1163  {
1164  NS_LOG_INFO("received MIB");
1165  NS_ASSERT(m_cellId > 0);
1166  Ptr<MibLteControlMessage> msg2 = DynamicCast<MibLteControlMessage>(msg);
1168  }
1169  else if (msg->GetMessageType() == LteControlMessage::SIB1)
1170  {
1171  NS_LOG_INFO("received SIB1");
1172  NS_ASSERT(m_cellId > 0);
1173  Ptr<Sib1LteControlMessage> msg2 = DynamicCast<Sib1LteControlMessage>(msg);
1175  }
1176  else
1177  {
1178  // pass the message to UE-MAC
1180  }
1181  }
1182 }
1183 
1184 void
1186 {
1187  NS_LOG_FUNCTION(this << cellId << (*p));
1188 
1189  double sum = 0.0;
1190  uint16_t nRB = 0;
1191  for (auto itPi = p->ConstValuesBegin(); itPi != p->ConstValuesEnd(); itPi++)
1192  {
1193  // convert PSD [W/Hz] to linear power [W] for the single RE
1194  double powerTxW = ((*itPi) * 180000.0) / 12.0;
1195  sum += powerTxW;
1196  nRB++;
1197  }
1198 
1199  // measure instantaneous RSRP now
1200  double rsrp_dBm = 10 * log10(1000 * (sum / (double)nRB));
1201  NS_LOG_INFO(this << " PSS RNTI " << m_rnti << " cellId " << m_cellId << " has RSRP " << rsrp_dBm
1202  << " and RBnum " << nRB);
1203  // note that m_pssReceptionThreshold does not apply here
1204 
1205  // store measurements
1206  auto itMeasMap = m_ueMeasurementsMap.find(cellId);
1207  if (itMeasMap == m_ueMeasurementsMap.end())
1208  {
1209  // insert new entry
1210  UeMeasurementsElement newEl;
1211  newEl.rsrpSum = rsrp_dBm;
1212  newEl.rsrpNum = 1;
1213  newEl.rsrqSum = 0;
1214  newEl.rsrqNum = 0;
1215  m_ueMeasurementsMap.insert(std::pair<uint16_t, UeMeasurementsElement>(cellId, newEl));
1216  }
1217  else
1218  {
1219  (*itMeasMap).second.rsrpSum += rsrp_dBm;
1220  (*itMeasMap).second.rsrpNum++;
1221  }
1222 
1223  /*
1224  * Collect the PSS for later processing in GenerateCtrlCqiReport()
1225  * (to be called from ChunkProcessor after RX is finished).
1226  */
1227  m_pssReceived = true;
1228  PssElement el;
1229  el.cellId = cellId;
1230  el.pssPsdSum = sum;
1231  el.nRB = nRB;
1232  m_pssList.push_back(el);
1233 
1234 } // end of void LteUePhy::ReceivePss (uint16_t cellId, Ptr<SpectrumValue> p)
1235 
1236 void
1238 {
1240 }
1241 
1242 void
1243 LteUePhy::SubframeIndication(uint32_t frameNo, uint32_t subframeNo)
1244 {
1245  NS_LOG_FUNCTION(this << frameNo << subframeNo);
1246 
1247  NS_ASSERT_MSG(frameNo > 0, "the SRS index check code assumes that frameNo starts at 1");
1248 
1249  // refresh internal variables
1250  m_rsReceivedPowerUpdated = false;
1252  m_pssReceived = false;
1253 
1254  if (m_ulConfigured)
1255  {
1256  // update uplink transmission mask according to previous UL-CQIs
1257  std::vector<int> rbMask = m_subChannelsForTransmissionQueue.at(0);
1259 
1260  // shift the queue
1261  for (uint8_t i = 1; i < m_macChTtiDelay; i++)
1262  {
1264  }
1266 
1268  {
1269  NS_ASSERT_MSG(subframeNo > 0 && subframeNo <= 10,
1270  "the SRS index check code assumes that subframeNo starts at 1");
1271  if ((((frameNo - 1) * 10 + (subframeNo - 1)) % m_srsPeriodicity) == m_srsSubframeOffset)
1272  {
1273  NS_LOG_INFO("frame " << frameNo << " subframe " << subframeNo
1274  << " sending SRS (offset=" << m_srsSubframeOffset
1275  << ", period=" << m_srsPeriodicity << ")");
1276  m_sendSrsEvent =
1278  }
1279  }
1280 
1281  std::list<Ptr<LteControlMessage>> ctrlMsg = GetControlMessages();
1282  // send packets in queue
1283  NS_LOG_LOGIC(this << " UE - start slot for PUSCH + PUCCH - RNTI " << m_rnti << " CELLID "
1284  << m_cellId);
1285  // send the current burts of packets
1287  if (pb)
1288  {
1290  {
1293  }
1294  m_uplinkSpectrumPhy->StartTxDataFrame(pb, ctrlMsg, UL_DATA_DURATION);
1295  }
1296  else
1297  {
1298  // send only PUCCH (ideal: fake null bandwidth signal)
1299  if (!ctrlMsg.empty())
1300  {
1301  NS_LOG_LOGIC(this << " UE - start TX PUCCH (NO PUSCH)");
1302  std::vector<int> dlRb;
1303 
1305  {
1307  }
1308 
1310  m_uplinkSpectrumPhy->StartTxDataFrame(pb, ctrlMsg, UL_DATA_DURATION);
1311  }
1312  else
1313  {
1314  NS_LOG_LOGIC(this << " UE - UL NOTHING TO SEND");
1315  }
1316  }
1317  } // m_configured
1318 
1319  // trigger the MAC
1320  m_uePhySapUser->SubframeIndication(frameNo, subframeNo);
1321 
1322  m_subframeNo = subframeNo;
1323  ++subframeNo;
1324  if (subframeNo > 10)
1325  {
1326  ++frameNo;
1327  subframeNo = 1;
1328  }
1329 
1330  // schedule next subframe indication
1333  this,
1334  frameNo,
1335  subframeNo);
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 (uint16_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 void
1361 {
1362  NS_LOG_FUNCTION(this);
1363 
1364  m_rnti = 0;
1365  m_cellId = 0;
1366  m_isConnected = false;
1367  m_transmissionMode = 0;
1368  m_srsPeriodicity = 0;
1369  m_srsConfigured = false;
1370  m_dlConfigured = false;
1371  m_ulConfigured = false;
1372  m_raPreambleId = 255; // value out of range
1373  m_raRnti = 11; // value out of range
1377  m_paLinear = 1;
1378 
1379  m_rsReceivedPowerUpdated = false;
1382 
1383  m_packetBurstQueue.clear();
1384  m_controlMessagesQueue.clear();
1386  for (int i = 0; i < m_macChTtiDelay; i++)
1387  {
1388  Ptr<PacketBurst> pb = CreateObject<PacketBurst>();
1389  m_packetBurstQueue.push_back(pb);
1390  std::list<Ptr<LteControlMessage>> l;
1391  m_controlMessagesQueue.push_back(l);
1392  }
1393  std::vector<int> ulRb;
1395 
1397  m_downlinkSpectrumPhy->Reset();
1398  m_uplinkSpectrumPhy->Reset();
1399  m_pssList.clear();
1404  m_downlinkSpectrumPhy->m_interferenceCtrl->EndRx();
1405  m_downlinkSpectrumPhy->m_interferenceData->EndRx();
1406 
1407 } // end of void LteUePhy::DoReset ()
1408 
1409 void
1411 {
1412  NS_LOG_FUNCTION(this << dlEarfcn);
1413  m_dlEarfcn = dlEarfcn;
1414  DoSetDlBandwidth(6); // configure DL for receiving PSS
1416 }
1417 
1418 void
1419 LteUePhy::DoSynchronizeWithEnb(uint16_t cellId, uint32_t dlEarfcn)
1420 {
1421  NS_LOG_FUNCTION(this << cellId << dlEarfcn);
1422  m_dlEarfcn = dlEarfcn;
1423  DoSynchronizeWithEnb(cellId);
1424 }
1425 
1426 void
1428 {
1429  NS_LOG_FUNCTION(this << cellId);
1430 
1431  if (cellId == 0)
1432  {
1433  NS_FATAL_ERROR("Cell ID shall not be zero");
1434  }
1435 
1436  m_cellId = cellId;
1437  m_downlinkSpectrumPhy->SetCellId(cellId);
1438  m_uplinkSpectrumPhy->SetCellId(cellId);
1439 
1440  // configure DL for receiving the BCH with the minimum bandwidth
1441  DoSetDlBandwidth(6);
1442 
1443  m_dlConfigured = false;
1444  m_ulConfigured = false;
1445 
1447 }
1448 
1449 uint16_t
1451 {
1452  return m_cellId;
1453 }
1454 
1455 uint32_t
1457 {
1458  return m_dlEarfcn;
1459 }
1460 
1461 void
1462 LteUePhy::DoSetDlBandwidth(uint16_t dlBandwidth)
1463 {
1464  NS_LOG_FUNCTION(this << (uint32_t)dlBandwidth);
1465  if (m_dlBandwidth != dlBandwidth or !m_dlConfigured)
1466  {
1467  m_dlBandwidth = dlBandwidth;
1468 
1469  static const int Type0AllocationRbg[4] = {
1470  10, // RGB size 1
1471  26, // RGB size 2
1472  63, // RGB size 3
1473  110, // RGB size 4
1474  }; // see table 7.1.6.1-1 of 36.213
1475  for (int i = 0; i < 4; i++)
1476  {
1477  if (dlBandwidth < Type0AllocationRbg[i])
1478  {
1479  m_rbgSize = i + 1;
1480  break;
1481  }
1482  }
1483 
1485  m_dlBandwidth,
1486  m_noiseFigure);
1487  m_downlinkSpectrumPhy->SetNoisePowerSpectralDensity(m_noisePsd);
1488  m_downlinkSpectrumPhy->GetChannel()->AddRx(m_downlinkSpectrumPhy);
1489  }
1490  m_dlConfigured = true;
1491 }
1492 
1493 void
1494 LteUePhy::DoConfigureUplink(uint32_t ulEarfcn, uint16_t ulBandwidth)
1495 {
1496  m_ulEarfcn = ulEarfcn;
1497  m_ulBandwidth = ulBandwidth;
1498  m_ulConfigured = true;
1499 }
1500 
1501 void
1502 LteUePhy::DoConfigureReferenceSignalPower(int8_t referenceSignalPower)
1503 {
1504  NS_LOG_FUNCTION(this);
1505  m_powerControl->ConfigureReferenceSignalPower(referenceSignalPower);
1506 }
1507 
1508 void
1509 LteUePhy::DoSetRnti(uint16_t rnti)
1510 {
1511  NS_LOG_FUNCTION(this << rnti);
1512  m_rnti = rnti;
1513 
1516 }
1517 
1518 void
1520 {
1521  NS_LOG_FUNCTION(this << (uint16_t)txMode);
1522  m_transmissionMode = txMode;
1523  m_downlinkSpectrumPhy->SetTransmissionMode(txMode);
1524 }
1525 
1526 void
1528 {
1529  NS_LOG_FUNCTION(this << srcCi);
1532  m_srsConfigured = true;
1533 
1534  // a guard time is needed for the case where the SRS periodicity is changed dynamically at run
1535  // time if we use a static one, we can have a 0ms guard time
1537  NS_LOG_DEBUG(this << " UE SRS P " << m_srsPeriodicity << " RNTI " << m_rnti << " offset "
1538  << m_srsSubframeOffset << " cellId " << m_cellId << " CI " << srcCi);
1539 }
1540 
1541 void
1543 {
1544  NS_LOG_FUNCTION(this << pa);
1545  m_paLinear = pow(10, (pa / 10));
1546 }
1547 
1548 void
1549 LteUePhy::DoSetRsrpFilterCoefficient(uint8_t rsrpFilterCoefficient)
1550 {
1551  NS_LOG_FUNCTION(this << (uint16_t)(rsrpFilterCoefficient));
1552  m_powerControl->SetRsrpFilterCoefficient(rsrpFilterCoefficient);
1553 }
1554 
1555 void
1557 {
1558  NS_LOG_FUNCTION(this);
1559  m_downlinkSpectrumPhy->m_harqPhyModule->ClearDlHarqBuffer(m_rnti); // flush HARQ buffers
1562  m_pssReceived = false;
1563  DoReset();
1564 }
1565 
1566 void
1568 {
1569  NS_LOG_FUNCTION(this);
1570 
1572 }
1573 
1574 void
1576 {
1577  NS_LOG_FUNCTION(this);
1578  // indicates that the downlink radio link quality has to be monitored for in-sync indications
1579  m_downlinkInSync = false;
1580 }
1581 
1582 void
1583 LteUePhy::DoSetImsi(uint64_t imsi)
1584 {
1585  NS_LOG_FUNCTION(this);
1586  m_imsi = imsi;
1587 }
1588 
1589 void
1591 {
1592  NS_LOG_FUNCTION(this);
1593  m_numOfSubframes = 0;
1594  m_sinrDbFrame = 0;
1595  m_numOfFrames = 0;
1596  m_downlinkInSync = true;
1597 }
1598 
1599 void
1601 {
1602  NS_LOG_FUNCTION(this << sinrDb);
1603  m_sinrDbFrame += sinrDb;
1604  m_numOfSubframes++;
1605  NS_LOG_LOGIC("No of Subframes: " << m_numOfSubframes
1606  << " UE synchronized: " << m_downlinkInSync);
1607  // check for out_of_sync indications first when UE is both DL and UL synchronized
1608  // m_downlinkInSync=true indicates that the evaluation is for out-of-sync indications
1609  if (m_downlinkInSync && m_numOfSubframes == 10)
1610  {
1616  {
1617  m_numOfFrames++; // increment the counter if a frame cannot be decoded
1618  NS_LOG_LOGIC("No of Frames which cannot be decoded: " << m_numOfFrames);
1619  }
1620  else
1621  {
1627  NS_LOG_INFO("Resetting frame counter at phy. Current value = " << m_numOfFrames);
1628  m_numOfFrames = 0;
1629  // Also reset the sync indicator counter at RRC
1631  }
1632  m_numOfSubframes = 0;
1633  m_sinrDbFrame = 0;
1634  }
1641  {
1642  NS_LOG_LOGIC("At " << Simulator::Now().As(Time::MS)
1643  << " ms UE PHY sending out of sync indication to UE RRC layer");
1645  m_numOfFrames = 0;
1646  }
1647  // check for in_sync indications when T310 timer is started
1648  // m_downlinkInSync=false indicates that the evaluation is for in-sync indications
1649  if (!m_downlinkInSync && m_numOfSubframes == 10)
1650  {
1657  {
1658  m_numOfFrames++; // increment the counter if a frame can be decoded
1659  NS_LOG_LOGIC("No of Frames successfully decoded: " << m_numOfFrames);
1660  }
1661  else
1662  {
1668  m_numOfFrames = 0;
1669  // Also reset the sync indicator counter at RRC
1671  }
1672  m_numOfSubframes = 0;
1673  m_sinrDbFrame = 0;
1674  }
1680  {
1681  NS_LOG_LOGIC("At " << Simulator::Now().As(Time::MS)
1682  << " ms UE PHY sending in sync indication to UE RRC layer");
1684  m_numOfFrames = 0;
1685  }
1686 }
1687 
1688 void
1690 {
1691  SetTxModeGain(1, gain);
1692 }
1693 
1694 void
1696 {
1697  SetTxModeGain(2, gain);
1698 }
1699 
1700 void
1702 {
1703  SetTxModeGain(3, gain);
1704 }
1705 
1706 void
1708 {
1709  SetTxModeGain(4, gain);
1710 }
1711 
1712 void
1714 {
1715  SetTxModeGain(5, gain);
1716 }
1717 
1718 void
1720 {
1721  SetTxModeGain(6, gain);
1722 }
1723 
1724 void
1726 {
1727  SetTxModeGain(7, gain);
1728 }
1729 
1730 void
1731 LteUePhy::SetTxModeGain(uint8_t txMode, double gain)
1732 {
1733  NS_LOG_FUNCTION(this << gain);
1734  if (txMode > 0)
1735  {
1736  // convert to linear
1737  double gainLin = std::pow(10.0, (gain / 10.0));
1738  if (m_txModeGain.size() < txMode)
1739  {
1740  m_txModeGain.resize(txMode);
1741  }
1742  m_txModeGain.at(txMode - 1) = gainLin;
1743  }
1744  // forward the info to DL LteSpectrumPhy
1745  m_downlinkSpectrumPhy->SetTxModeGain(txMode, gain);
1746 }
1747 
1748 void
1750 {
1751  NS_LOG_FUNCTION(this);
1752  // get the feedback from LteSpectrumPhy and send it through ideal PUCCH to eNB
1753  Ptr<DlHarqFeedbackLteControlMessage> msg = Create<DlHarqFeedbackLteControlMessage>();
1754  msg->SetDlHarqFeedback(m);
1755  SetControlMessages(msg);
1756 }
1757 
1758 void
1760 {
1761  m_harqPhyModule = harq;
1762 }
1763 
1766 {
1767  NS_LOG_FUNCTION(this);
1768  return m_state;
1769 }
1770 
1771 void
1773 {
1774  NS_LOG_FUNCTION(this << newState);
1775  State oldState = m_state;
1776  m_state = newState;
1777  NS_LOG_INFO(this << " cellId=" << m_cellId << " rnti=" << m_rnti << " UePhy "
1778  << ToString(oldState) << " --> " << ToString(newState));
1779  m_stateTransitionTrace(m_cellId, m_rnti, oldState, newState);
1780 }
1781 
1782 } // namespace ns3
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:51
double m_txPower
Transmission power in dBm.
Definition: lte-phy.h:241
uint8_t GetRbgSize() const
Definition: lte-phy.cc:180
void DoDispose() override
Destructor implementation.
Definition: lte-phy.cc:76
uint16_t GetSrsPeriodicity(uint16_t srcCi) const
Definition: lte-phy.cc:144
std::vector< Ptr< PacketBurst > > m_packetBurstQueue
A queue of packet bursts to be sent.
Definition: lte-phy.h:281
uint16_t m_ulBandwidth
The UL bandwidth in number of PRBs.
Definition: lte-phy.h:261
Ptr< PacketBurst > GetPacketBurst()
Definition: lte-phy.cc:192
Ptr< LteNetDevice > GetDevice() const
Get the device where the phy layer is attached.
Definition: lte-phy.cc:97
uint8_t m_componentCarrierId
component carrier Id used to address sap
Definition: lte-phy.h:303
double m_noiseFigure
Loss (dB) in the Signal-to-Noise-Ratio due to non-idealities in the receiver.
Definition: lte-phy.h:253
uint32_t m_ulEarfcn
The uplink carrier frequency.
Definition: lte-phy.h:278
uint16_t m_dlBandwidth
The DL bandwidth in number of PRBs.
Definition: lte-phy.h:266
Ptr< LteSpectrumPhy > m_downlinkSpectrumPhy
The downlink LteSpectrumPhy associated to this LtePhy.
Definition: lte-phy.h:230
void SetMacPdu(Ptr< Packet > p)
Definition: lte-phy.cc:186
std::list< Ptr< LteControlMessage > > GetControlMessages()
Definition: lte-phy.cc:218
uint16_t GetSrsSubframeOffset(uint16_t srcCi) const
Definition: lte-phy.cc:162
Ptr< LteNetDevice > m_netDevice
Pointer to the NetDevice where this PHY layer is attached.
Definition: lte-phy.h:224
uint16_t m_cellId
Cell identifier.
Definition: lte-phy.h:300
void SetControlMessages(Ptr< LteControlMessage > m)
Definition: lte-phy.cc:210
uint32_t m_dlEarfcn
The downlink carrier frequency.
Definition: lte-phy.h:273
Ptr< LteSpectrumPhy > m_uplinkSpectrumPhy
The uplink LteSpectrumPhy associated to this LtePhy.
Definition: lte-phy.h:235
double GetTti() const
Definition: lte-phy.cc:137
std::vector< std::list< Ptr< LteControlMessage > > > m_controlMessagesQueue
A queue of control messages to be sent.
Definition: lte-phy.h:283
uint8_t m_rbgSize
The RB group size according to the bandwidth.
Definition: lte-phy.h:268
uint8_t m_macChTtiDelay
Delay between MAC and channel layer in terms of TTIs.
Definition: lte-phy.h:293
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:52
void SetTxMode1Gain(double gain)
Set transmit mode 1 gain function.
Definition: lte-ue-phy.cc:1689
SpectrumValue m_dataInterferencePower
data interference power
Definition: lte-ue-phy.h:727
void SetSubChannelsForTransmission(std::vector< int > mask)
Set a list of sub channels to use in TX.
Definition: lte-ue-phy.cc:498
void DoInitialize() override
Initialize() implementation.
Definition: lte-ue-phy.cc:350
friend class MemberLteUeCphySapProvider< LteUePhy >
allow MemberLteUeCphySapProvider<LteUePhy> class friend access
Definition: lte-ue-phy.h:56
void SetHarqPhyModule(Ptr< LteHarqPhy > harq)
Set the HARQ PHY module.
Definition: lte-ue-phy.cc:1759
void DoSetDlBandwidth(uint16_t dlBandwidth)
Set DL bandwidth function.
Definition: lte-ue-phy.cc:1462
uint16_t GetNumQinEvalSf() const
Get number of Qin evaluation subframes.
Definition: lte-ue-phy.cc:477
void SetTxMode3Gain(double gain)
Set transmit mode 3 gain function.
Definition: lte-ue-phy.cc:1701
uint16_t m_numOfQinEvalSf
the downlink radio link quality is estimated over this period for detecting in-syncs
Definition: lte-ue-phy.h:842
LteUePhySapUser * m_uePhySapUser
UE Phy SAP user.
Definition: lte-ue-phy.h:689
uint16_t DoGetCellId()
Get cell ID.
Definition: lte-ue-phy.cc:1450
uint16_t m_rsrpSinrSampleCounter
The RsrpSinrSampleCounter attribute.
Definition: lte-ue-phy.h:789
virtual void ReportDataInterference(const SpectrumValue &interf)
Create the mixed CQI report.
Definition: lte-ue-phy.cc:801
void QueueSubChannelsForTransmission(std::vector< int > rbMap)
Queue subchannels for transmission function.
Definition: lte-ue-phy.cc:1237
void DoConfigureUplink(uint32_t ulEarfcn, uint16_t ulBandwidth)
Configure UL uplink function.
Definition: lte-ue-phy.cc:1494
virtual void ReceivePss(uint16_t cellId, Ptr< SpectrumValue > p)
Receive PSS function.
Definition: lte-ue-phy.cc:1185
uint16_t m_srsPeriodicity
SRS periodicity.
Definition: lte-ue-phy.h:699
void DoResetPhyAfterRlf()
Reset Phy after radio link failure function.
Definition: lte-ue-phy.cc:1556
virtual void DoNotifyConnectionSuccessful()
Notify PHY about the successful RRC connection establishment.
Definition: lte-ue-phy.cc:1009
bool m_dlConfigured
DL configured?
Definition: lte-ue-phy.h:706
LteUePhySapProvider * GetLteUePhySapProvider()
Get the PHY SAP provider.
Definition: lte-ue-phy.cc:375
Time m_srsStartTime
SRS start time.
Definition: lte-ue-phy.h:702
double GetNoiseFigure() const
Get noise figure.
Definition: lte-ue-phy.cc:403
Time m_p10CqiLast
last periodic CQI
Definition: lte-ue-phy.h:678
std::map< uint16_t, UeMeasurementsElement > m_ueMeasurementsMap
Store measurement results during the last layer-1 filtering period.
Definition: lte-ue-phy.h:760
TracedCallback< uint16_t, Ptr< SpectrumValue > > m_reportPowerSpectralDensity
The ReportsPowerSpectralDensity trace source.
Definition: lte-ue-phy.h:820
LteUePhySapProvider * m_uePhySapProvider
UE Phy SAP provider.
Definition: lte-ue-phy.h:688
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:810
uint16_t GetNumQoutEvalSf() const
Get number of Qout evaluation subframes.
Definition: lte-ue-phy.cc:470
bool m_rsInterferencePowerUpdated
RS interference power updated?
Definition: lte-ue-phy.h:723
void DoSendMacPdu(Ptr< Packet > p) override
Queue the MAC PDU to be sent (according to m_macChTtiDelay)
Definition: lte-ue-phy.cc:484
Ptr< SpectrumValue > m_noisePsd
Noise power spectral density for the configured bandwidth.
Definition: lte-ue-phy.h:822
void GenerateCtrlCqiReport(const SpectrumValue &sinr) override
generate a CQI report based on the given SINR of Ctrl frame
Definition: lte-ue-phy.cc:544
uint32_t DoGetDlEarfcn()
Get DL EARFCN.
Definition: lte-ue-phy.cc:1456
double ComputeAvgSinr(const SpectrumValue &sinr)
Compute average SINR among the RBs.
Definition: lte-ue-phy.cc:701
void SetLteUePhySapUser(LteUePhySapUser *s)
Set the PHY SAP User.
Definition: lte-ue-phy.cc:368
virtual void DoSendRachPreamble(uint32_t prachId, uint32_t raRnti)
Send RACH preamble function.
Definition: lte-ue-phy.cc:996
void DoStartCellSearch(uint32_t dlEarfcn)
Start the cell search function.
Definition: lte-ue-phy.cc:1410
void SetTxMode6Gain(double gain)
Set transmit mode 6 gain function.
Definition: lte-ue-phy.cc:1719
LteUeCphySapProvider * m_ueCphySapProvider
UE CPhy SAP provider.
Definition: lte-ue-phy.h:691
Ptr< SpectrumValue > CreateTxPowerSpectralDensity() override
Create the PSD for the TX.
Definition: lte-ue-phy.cc:530
std::vector< std::vector< int > > m_subChannelsForTransmissionQueue
subchannels for transmission queue
Definition: lte-ue-phy.h:664
void DoReset()
Do Reset function.
Definition: lte-ue-phy.cc:1360
void SetNumQoutEvalSf(uint16_t numSubframes)
Set number of Qout evaluation subframes.
Definition: lte-ue-phy.cc:450
State m_state
The current UE PHY state.
Definition: lte-ue-phy.h:710
bool m_pssReceived
PSS received?
Definition: lte-ue-phy.h:729
TracedCallback< uint16_t, uint16_t, double, double, uint8_t > m_reportCurrentCellRsrpSinrTrace
The ReportCurrentCellRsrpSinr trace source.
Definition: lte-ue-phy.h:779
void DoSetImsi(uint64_t imsi)
Set IMSI.
Definition: lte-ue-phy.cc:1583
void SetTxMode2Gain(double gain)
Set transmit mode 2 gain function.
Definition: lte-ue-phy.cc:1695
void DoSetRsrpFilterCoefficient(uint8_t rsrpFilterCoefficient)
Do set RSRP filter coefficient.
Definition: lte-ue-phy.cc:1549
~LteUePhy() override
Definition: lte-ue-phy.cc:176
uint8_t GetMacChDelay() const
Get MAC to Channel delay.
Definition: lte-ue-phy.cc:432
Ptr< LteUePowerControl > m_powerControl
Pointer to UE Uplink Power Control entity.
Definition: lte-ue-phy.h:674
void DoConfigureReferenceSignalPower(int8_t referenceSignalPower)
Configure reference signal power function.
Definition: lte-ue-phy.cc:1502
std::list< PssElement > m_pssList
PSS list.
Definition: lte-ue-phy.h:739
void SubframeIndication(uint32_t frameNo, uint32_t subframeNo)
trigger from eNB the start from a new frame
Definition: lte-ue-phy.cc:1243
Ptr< LteUePowerControl > GetUplinkPowerControl() const
Get Uplink power control.
Definition: lte-ue-phy.cc:425
void RlfDetection(double sinrdB)
Radio link failure detection function.
Definition: lte-ue-phy.cc:1600
std::vector< double > m_txModeGain
the transmit mode gain
Definition: lte-ue-phy.h:697
State GetState() const
Get state of the UE physical layer.
Definition: lte-ue-phy.cc:1765
SpectrumValue m_rsReceivedPower
RS receive power.
Definition: lte-ue-phy.h:721
void DoSynchronizeWithEnb(uint16_t cellId)
Synchronize with ENB function.
Definition: lte-ue-phy.cc:1427
void DoSetSrsConfigurationIndex(uint16_t srcCi)
Set SRS configuration index function.
Definition: lte-ue-phy.cc:1527
uint16_t m_srsSubframeOffset
SRS subframe offset.
Definition: lte-ue-phy.h:700
uint8_t m_subframeNo
Definition: lte-ue-phy.h:718
uint16_t m_rsrpSinrSamplePeriod
The RsrpSinrSamplePeriod attribute.
Definition: lte-ue-phy.h:784
uint64_t m_imsi
the IMSI of the UE
Definition: lte-ue-phy.h:853
uint16_t m_rnti
the RNTI
Definition: lte-ue-phy.h:694
bool m_enableUplinkPowerControl
The EnableUplinkPowerControl attribute.
Definition: lte-ue-phy.h:672
Ptr< LteSpectrumPhy > GetDlSpectrumPhy() const
Get Downlink spectrum phy.
Definition: lte-ue-phy.cc:438
void SetTxMode5Gain(double gain)
Set transmit mode 5 gain function.
Definition: lte-ue-phy.cc:1713
void DoSetTransmissionMode(uint8_t txMode)
Set transmission mode function.
Definition: lte-ue-phy.cc:1519
bool m_enableRlfDetection
Flag to enable/disable RLF detection.
Definition: lte-ue-phy.h:854
Time m_a30CqiLast
last aperiodic CQI
Definition: lte-ue-phy.h:686
void GenerateCqiRsrpRsrq(const SpectrumValue &sinr)
Get CQI, RSRP, and RSRQ.
Definition: lte-ue-phy.cc:565
SpectrumValue m_rsInterferencePower
RS interference power.
Definition: lte-ue-phy.h:724
void DoResetRlfParams()
Reset radio link failure parameters.
Definition: lte-ue-phy.cc:1567
void SetDownlinkCqiPeriodicity(Time cqiPeriodicity)
Set the periodicty for the downlink periodic wideband and aperiodic subband CQI reporting.
Definition: lte-ue-phy.cc:980
Ptr< LteHarqPhy > m_harqPhyModule
HARQ phy module.
Definition: lte-ue-phy.h:769
EventId m_sendSrsEvent
send SRS event
Definition: lte-ue-phy.h:799
double m_qIn
The 'Qin' attribute.
Definition: lte-ue-phy.h:831
virtual void ReceiveLteControlMessageList(std::list< Ptr< LteControlMessage >> msgList)
Receive LTE control message list function.
Definition: lte-ue-phy.cc:1025
void SetNoiseFigure(double nf)
Set noise figure.
Definition: lte-ue-phy.cc:396
friend class UeMemberLteUePhySapProvider
allow UeMemberLteUePhySapProvider class friend access
Definition: lte-ue-phy.h:54
void DoSetPa(double pa)
Set PA function.
Definition: lte-ue-phy.cc:1542
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:834
LteUeCphySapUser * m_ueCphySapUser
UE CPhy SAP user.
Definition: lte-ue-phy.h:692
void SetNumQinEvalSf(uint16_t numSubframes)
Set number of Qin evaluation subframes.
Definition: lte-ue-phy.cc:460
void SetLteUeCphySapUser(LteUeCphySapUser *s)
Set the CPHY SAP User.
Definition: lte-ue-phy.cc:382
double m_sinrDbFrame
the average SINR per radio frame
Definition: lte-ue-phy.h:851
TracedCallback< uint16_t, uint16_t, State, State > m_stateTransitionTrace
The StateTransition trace source.
Definition: lte-ue-phy.h:715
void DoDispose() override
Destructor implementation.
Definition: lte-ue-phy.cc:182
void SetSubChannelsForReception(std::vector< int > mask)
Get a list of sub channels to use in RX.
Definition: lte-ue-phy.cc:509
bool m_rsReceivedPowerUpdated
RS receive power updated?
Definition: lte-ue-phy.h:720
void SwitchToState(State s)
Switch the UE PHY to the given state.
Definition: lte-ue-phy.cc:1772
TracedCallback< uint16_t, uint16_t, double, double, bool, uint8_t > m_reportUeMeasurements
The ReportUeMeasurements trace source.
Definition: lte-ue-phy.h:797
double m_paLinear
PA linear.
Definition: lte-ue-phy.h:704
TracedCallback< PhyTransmissionStatParameters > m_ulPhyTransmission
The UlPhyTransmission trace source.
Definition: lte-ue-phy.h:806
bool m_isConnected
set when UE RRC is in CONNECTED_NORMALLY state
Definition: lte-ue-phy.h:825
Ptr< LteAmc > m_amc
AMC.
Definition: lte-ue-phy.h:666
std::vector< int > m_subChannelsForReception
A list of sub channels to use in RX.
Definition: lte-ue-phy.h:661
void InitializeRlfParams()
Initialize radio link failure parameters.
Definition: lte-ue-phy.cc:1590
std::vector< int > GetSubChannelsForTransmission()
Get a list of sub channels to use in RX.
Definition: lte-ue-phy.cc:516
void PhyPduReceived(Ptr< Packet > p)
PhySpectrum received a new PHY-PDU.
Definition: lte-ue-phy.cc:492
LteUeCphySapProvider * GetLteUeCphySapProvider()
Get the CPHY SAP provider.
Definition: lte-ue-phy.cc:389
bool m_ulConfigured
UL configured?
Definition: lte-ue-phy.h:707
SpectrumValue m_ctrlSinrForRlf
the CTRL SINR used for RLF detection
Definition: lte-ue-phy.h:852
Time m_ueMeasurementsFilterPeriod
The UeMeasurementsFilterPeriod attribute.
Definition: lte-ue-phy.h:765
bool m_srsConfigured
SRS configured.
Definition: lte-ue-phy.h:701
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:721
uint16_t m_numOfFrames
count the number of frames for which the downlink radio link quality is estimated
Definition: lte-ue-phy.h:849
bool m_downlinkInSync
when set, DL SINR evaluation for out-of-sync indications is conducted.
Definition: lte-ue-phy.h:845
uint16_t m_numOfQoutEvalSf
the downlink radio link quality is estimated over this period for detecting out-of-syncs
Definition: lte-ue-phy.h:840
void SetTxMode7Gain(double gain)
Set transmit mode 7 gain function.
Definition: lte-ue-phy.cc:1725
void DoSetRnti(uint16_t rnti)
Set RNTI function.
Definition: lte-ue-phy.cc:1509
static TypeId GetTypeId()
Get the type ID.
Definition: lte-ue-phy.cc:191
double GetTxPower() const
Get transmit power.
Definition: lte-ue-phy.cc:418
virtual void EnqueueDlHarqFeedback(DlInfoListElement_s mes)
Enqueue the downlink HARQ feedback generated by LteSpectrumPhy.
Definition: lte-ue-phy.cc:1749
std::vector< int > m_subChannelsForTransmission
A list of sub channels to use in TX.
Definition: lte-ue-phy.h:659
Time m_p10CqiPeriodicity
Wideband Periodic CQI. 2, 5, 10, 16, 20, 32, 40, 64, 80 or 160 ms.
Definition: lte-ue-phy.h:677
bool m_dataInterferencePowerUpdated
data interference power updated?
Definition: lte-ue-phy.h:726
void SetTxPower(double pow)
Set transmit power.
Definition: lte-ue-phy.cc:410
State
The states of the UE PHY entity.
Definition: lte-ue-phy.h:63
uint16_t m_numOfSubframes
count the number of subframes for which the downlink radio link quality is estimated
Definition: lte-ue-phy.h:847
void SetTxMode4Gain(double gain)
Set transmit mode 4 gain function.
Definition: lte-ue-phy.cc:1707
virtual void DoSendLteControlMessage(Ptr< LteControlMessage > msg)
Send LTE control message function.
Definition: lte-ue-phy.cc:988
Time m_a30CqiPeriodicity
SubBand Aperiodic CQI.
Definition: lte-ue-phy.h:685
TracedCallback< uint16_t, const std::vector< int > & > m_reportUlPhyResourceBlocks
The ReportUlPhyResourceBlocks trace source.
Definition: lte-ue-phy.h:813
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:793
std::vector< int > GetSubChannelsForReception()
Get a list of sub channels to use in RX.
Definition: lte-ue-phy.cc:523
Ptr< LteSpectrumPhy > GetUlSpectrumPhy() const
Get Uplink spectrum phy.
Definition: lte-ue-phy.cc:444
void ReportUeMeasurements()
Layer-1 filtering of RSRP and RSRQ measurements and reporting to the RRC entity.
Definition: lte-ue-phy.cc:934
double m_pssReceptionThreshold
The RsrqUeMeasThreshold attribute.
Definition: lte-ue-phy.h:745
uint32_t m_raPreambleId
RA preamble ID.
Definition: lte-ue-phy.h:771
double m_qOut
The 'Qout' attribute.
Definition: lte-ue-phy.h:838
void DoStartInSyncDetection()
Start in Sync detection function.
Definition: lte-ue-phy.cc:1575
void SendSrs()
Send the SRS signal in the last symbols of the frame.
Definition: lte-ue-phy.cc:1339
virtual void GenerateMixedCqiReport(const SpectrumValue &sinr)
Create the mixed CQI report.
Definition: lte-ue-phy.cc:727
uint8_t m_transmissionMode
the transmission mode
Definition: lte-ue-phy.h:696
void SetTxModeGain(uint8_t txMode, double gain)
Set transmit mode gain function.
Definition: lte-ue-phy.cc:1731
uint32_t m_raRnti
RA RNTI.
Definition: lte-ue-phy.h:772
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:359
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:571
static void ScheduleWithContext(uint32_t context, const Time &delay, FUNC f, Ts &&... args)
Schedule an event with the given context.
Definition: simulator.h:588
static Time Now()
Return the current simulation virtual time.
Definition: simulator.cc:208
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:408
TimeWithUnit As(const Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
Definition: time.cc:415
@ MS
millisecond
Definition: nstime.h:117
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:59
@ ATTR_GET
The attribute can be read.
Definition: type-id.h:64
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:931
UeMemberLteUePhySapProvider class.
Definition: lte-ue-phy.cc:72
void SendRachPreamble(uint32_t prachId, uint32_t raRnti) override
Send a preamble on the PRACH.
Definition: lte-ue-phy.cc:109
void NotifyConnectionSuccessful() override
Notify PHY about the successful RRC connection establishment.
Definition: lte-ue-phy.cc:115
void SendLteControlMessage(Ptr< LteControlMessage > msg) override
Send SendLteControlMessage (PDCCH map, CQI feedbacks) using the ideal control channel.
Definition: lte-ue-phy.cc:103
void SendMacPdu(Ptr< Packet > p) override
Send the MAC PDU to the channel.
Definition: lte-ue-phy.cc:97
UeMemberLteUePhySapProvider(LteUePhy *phy)
Constructor.
Definition: lte-ue-phy.cc:91
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
#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:1362
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1326
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1338
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:125
Ptr< const AttributeChecker > MakeBooleanChecker()
Definition: boolean.cc:124
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Definition: nstime.h:1414
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Definition: pointer.h:227
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:58
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Definition: time.cc:533
static const Time UL_SRS_DELAY_FROM_SUBFRAME_START
Delay from subframe start to transmission of SRS.
Definition: lte-ue-phy.cc:64
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Definition: boolean.h:86
std::vector< HarqProcessInfoElement_t > HarqProcessInfoList_t
HarqProcessInfoList_t typedef.
Definition: lte-harq-phy.h:44
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Definition: double.h:43
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Definition: uinteger.h:46
static const int Type0AllocationRbg[4]
Type 0 RGB allocation.
phy
Definition: third.py:89
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.
PssElement structure.
Definition: lte-ue-phy.h:733
uint16_t cellId
cell ID
Definition: lte-ue-phy.h:734
double pssPsdSum
PSS PSD sum.
Definition: lte-ue-phy.h:735
uint16_t nRB
number of RB
Definition: lte-ue-phy.h:736
Summary results of measuring a specific cell. Used for layer-1 filtering.
Definition: lte-ue-phy.h:749
double rsrqSum
Sum of RSRQ sample values in linear unit.
Definition: lte-ue-phy.h:752
uint8_t rsrpNum
Number of RSRP samples.
Definition: lte-ue-phy.h:751
double rsrpSum
Sum of RSRP sample values in linear unit.
Definition: lte-ue-phy.h:750
uint8_t rsrqNum
Number of RSRQ samples.
Definition: lte-ue-phy.h:753
PhyTransmissionStatParameters structure.
Definition: lte-common.h:188
See section 4.3.25 sbMeasResult.
std::vector< struct HigherLayerSelected_s > m_higherLayerSelected
higher layer selected
See section 4.3.2 ulDciListElement.