A Discrete-Event Network Simulator
API
lte-ue-phy.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
4  *
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  */
22 
23 #include <ns3/object-factory.h>
24 #include <ns3/log.h>
25 #include <cfloat>
26 #include <cmath>
27 #include <ns3/simulator.h>
28 #include <ns3/double.h>
29 #include "lte-ue-phy.h"
30 #include "lte-enb-phy.h"
31 #include "lte-net-device.h"
32 #include "lte-ue-net-device.h"
33 #include "lte-enb-net-device.h"
35 #include "lte-amc.h"
36 #include "lte-ue-mac.h"
37 #include "ff-mac-common.h"
38 #include "lte-chunk-processor.h"
39 #include <ns3/lte-common.h>
40 #include <ns3/pointer.h>
41 #include <ns3/boolean.h>
42 #include <ns3/lte-ue-power-control.h>
43 
44 namespace ns3 {
45 
46 NS_LOG_COMPONENT_DEFINE ("LteUePhy");
47 
48 
49 
57 static const Time UL_DATA_DURATION = NanoSeconds (1e6 - 71429 - 1);
58 
63 static const Time UL_SRS_DELAY_FROM_SUBFRAME_START = NanoSeconds (1e6 - 71429);
64 
65 
66 
67 
69 // member SAP forwarders
71 
72 
74 {
75 public:
77 
78  // inherited from LtePhySapProvider
79  virtual void SendMacPdu (Ptr<Packet> p);
81  virtual void SendRachPreamble (uint32_t prachId, uint32_t raRnti);
82 
83 private:
85 };
86 
88 {
89 
90 }
91 
92 void
94 {
95  m_phy->DoSendMacPdu (p);
96 }
97 
98 void
100 {
102 }
103 
104 void
105 UeMemberLteUePhySapProvider::SendRachPreamble (uint32_t prachId, uint32_t raRnti)
106 {
107  m_phy->DoSendRachPreamble (prachId, raRnti);
108 }
109 
110 
112 // LteUePhy methods
114 
116 static const std::string g_uePhyStateName[LteUePhy::NUM_STATES] =
117 {
118  "CELL_SEARCH",
119  "SYNCHRONIZED"
120 };
121 
126 static inline const std::string & ToString (LteUePhy::State s)
127 {
128  return g_uePhyStateName[s];
129 }
130 
131 
132 NS_OBJECT_ENSURE_REGISTERED (LteUePhy);
133 
134 
136 {
137  NS_LOG_FUNCTION (this);
138  NS_FATAL_ERROR ("This constructor should not be called");
139 }
140 
142  : LtePhy (dlPhy, ulPhy),
143  m_p10CqiPeriocity (MilliSeconds (1)), // ideal behavior
144  m_a30CqiPeriocity (MilliSeconds (1)), // ideal behavior
145  m_uePhySapUser (0),
146  m_ueCphySapUser (0),
147  m_state (CELL_SEARCH),
148  m_subframeNo (0),
149  m_rsReceivedPowerUpdated (false),
150  m_rsInterferencePowerUpdated (false),
151  m_dataInterferencePowerUpdated (false),
152  m_pssReceived (false),
153  m_ueMeasurementsFilterPeriod (MilliSeconds (200)),
154  m_ueMeasurementsFilterLast (MilliSeconds (0)),
155  m_rsrpSinrSampleCounter (0)
156 {
157  m_amc = CreateObject <LteAmc> ();
158  m_powerControl = CreateObject <LteUePowerControl> ();
162 
163  NS_ASSERT_MSG (Simulator::Now ().GetNanoSeconds () == 0,
164  "Cannot create UE devices after simulation started");
167 
168  DoReset ();
169 }
170 
171 
173 {
174  m_txModeGain.clear ();
175 }
176 
177 void
179 {
180  NS_LOG_FUNCTION (this);
181  delete m_uePhySapProvider;
182  delete m_ueCphySapProvider;
184 }
185 
186 
187 
188 TypeId
190 {
191  static TypeId tid = TypeId ("ns3::LteUePhy")
192  .SetParent<LtePhy> ()
193  .AddConstructor<LteUePhy> ()
194  .AddAttribute ("TxPower",
195  "Transmission power in dBm",
196  DoubleValue (10.0),
199  MakeDoubleChecker<double> ())
200  .AddAttribute ("NoiseFigure",
201  "Loss (dB) in the Signal-to-Noise-Ratio due to non-idealities in the receiver."
202  " According to Wikipedia (http://en.wikipedia.org/wiki/Noise_figure), this is "
203  "\"the difference in decibels (dB) between"
204  " the noise output of the actual receiver to the noise output of an "
205  " ideal receiver with the same overall gain and bandwidth when the receivers "
206  " are connected to sources at the standard noise temperature T0.\" "
207  "In this model, we consider T0 = 290K.",
208  DoubleValue (9.0),
211  MakeDoubleChecker<double> ())
212  .AddAttribute ("TxMode1Gain",
213  "Transmission mode 1 gain in dB",
214  DoubleValue (0.0),
216  MakeDoubleChecker<double> ())
217  .AddAttribute ("TxMode2Gain",
218  "Transmission mode 2 gain in dB",
219  DoubleValue (4.2),
221  MakeDoubleChecker<double> ())
222  .AddAttribute ("TxMode3Gain",
223  "Transmission mode 3 gain in dB",
224  DoubleValue (-2.8),
226  MakeDoubleChecker<double> ())
227  .AddAttribute ("TxMode4Gain",
228  "Transmission mode 4 gain in dB",
229  DoubleValue (0.0),
231  MakeDoubleChecker<double> ())
232  .AddAttribute ("TxMode5Gain",
233  "Transmission mode 5 gain in dB",
234  DoubleValue (0.0),
236  MakeDoubleChecker<double> ())
237  .AddAttribute ("TxMode6Gain",
238  "Transmission mode 6 gain in dB",
239  DoubleValue (0.0),
241  MakeDoubleChecker<double> ())
242  .AddAttribute ("TxMode7Gain",
243  "Transmission mode 7 gain in dB",
244  DoubleValue (0.0),
246  MakeDoubleChecker<double> ())
247  .AddTraceSource ("ReportCurrentCellRsrpSinr",
248  "RSRP and SINR statistics.",
250  "ns3::LteUePhy::RsrpSinrTracedCallback")
251  .AddAttribute ("RsrpSinrSamplePeriod",
252  "The sampling period for reporting RSRP-SINR stats (default value 1)",
253  UintegerValue (1),
255  MakeUintegerChecker<uint16_t> ())
256  .AddTraceSource ("UlPhyTransmission",
257  "DL transmission PHY layer statistics.",
259  "ns3::PhyTransmissionStatParameters::TracedCallback")
260  .AddAttribute ("DlSpectrumPhy",
261  "The downlink LteSpectrumPhy associated to this LtePhy",
263  PointerValue (),
265  MakePointerChecker <LteSpectrumPhy> ())
266  .AddAttribute ("UlSpectrumPhy",
267  "The uplink LteSpectrumPhy associated to this LtePhy",
269  PointerValue (),
271  MakePointerChecker <LteSpectrumPhy> ())
272  .AddAttribute ("RsrqUeMeasThreshold",
273  "Receive threshold for PSS on RSRQ [dB]",
274  DoubleValue (-1000.0),
276  MakeDoubleChecker<double> ())
277  .AddAttribute ("UeMeasurementsFilterPeriod",
278  "Time period for reporting UE measurements, i.e., the"
279  "length of layer-1 filtering.",
280  TimeValue (MilliSeconds (200)),
282  MakeTimeChecker ())
283  .AddTraceSource ("ReportUeMeasurements",
284  "Report UE measurements RSRP (dBm) and RSRQ (dB).",
286  "ns3::LteUePhy::RsrpRsrqTracedCallback")
287  .AddTraceSource ("StateTransition",
288  "Trace fired upon every UE PHY state transition",
290  "ns3::LteUePhy::StateTracedCallback")
291  .AddAttribute ("EnableUplinkPowerControl",
292  "If true, Uplink Power Control will be enabled.",
293  BooleanValue (true),
296  ;
297  return tid;
298 }
299 
300 void
302 {
303  NS_LOG_FUNCTION (this);
305 }
306 
307 void
309 {
310  NS_LOG_FUNCTION (this);
311  m_uePhySapUser = s;
312 }
313 
316 {
317  NS_LOG_FUNCTION (this);
318  return (m_uePhySapProvider);
319 }
320 
321 
322 void
324 {
325  NS_LOG_FUNCTION (this);
326  m_ueCphySapUser = s;
327 }
328 
331 {
332  NS_LOG_FUNCTION (this);
333  return (m_ueCphySapProvider);
334 }
335 
336 void
338 {
339  NS_LOG_FUNCTION (this << nf);
340  m_noiseFigure = nf;
341 }
342 
343 double
345 {
346  NS_LOG_FUNCTION (this);
347  return m_noiseFigure;
348 }
349 
350 void
352 {
353  NS_LOG_FUNCTION (this << pow);
354  m_txPower = pow;
355  m_powerControl->SetTxPower (pow);
356 }
357 
358 double
360 {
361  NS_LOG_FUNCTION (this);
362  return m_txPower;
363 }
364 
367 {
368  NS_LOG_FUNCTION (this);
369  return m_powerControl;
370 }
371 
372 uint8_t
374 {
375  return (m_macChTtiDelay);
376 }
377 
380 {
381  return m_downlinkSpectrumPhy;
382 }
383 
386 {
387  return m_uplinkSpectrumPhy;
388 }
389 
390 void
392 {
393  NS_LOG_FUNCTION (this);
394 
395  SetMacPdu (p);
396 }
397 
398 
399 void
401 {
403 }
404 
405 void
407 {
408  NS_LOG_FUNCTION (this);
409 
411 
413  m_uplinkSpectrumPhy->SetTxPowerSpectralDensity (txPsd);
414 }
415 
416 
417 void
418 LteUePhy::SetSubChannelsForReception (std::vector <int> mask)
419 {
420  NS_LOG_FUNCTION (this);
422 }
423 
424 
425 std::vector <int>
427 {
428  NS_LOG_FUNCTION (this);
430 }
431 
432 
433 std::vector <int>
435 {
436  NS_LOG_FUNCTION (this);
438 }
439 
440 
443 {
444  NS_LOG_FUNCTION (this);
445  LteSpectrumValueHelper psdHelper;
447 
448  return psd;
449 }
450 
451 void
453 {
454  NS_LOG_FUNCTION (this);
455 
456  GenerateCqiRsrpRsrq (sinr);
457 }
458 
459 void
461 {
462  NS_LOG_FUNCTION (this << sinr);
463 
465  NS_ASSERT (m_cellId > 0);
466 
467  if (m_dlConfigured && m_ulConfigured && (m_rnti > 0))
468  {
469  // check periodic wideband CQI
471  {
472  Ptr<LteUeNetDevice> thisDevice = GetDevice ()->GetObject<LteUeNetDevice> ();
474  if (msg)
475  {
477  }
479  }
480  // check aperiodic high-layer configured subband CQI
482  {
483  Ptr<LteUeNetDevice> thisDevice = GetDevice ()->GetObject<LteUeNetDevice> ();
485  if (msg)
486  {
488  }
490  }
491  }
492 
493  // Generate PHY trace
496  {
497  NS_ASSERT_MSG (m_rsReceivedPowerUpdated, " RS received power info obsolete");
498  // RSRP evaluated as averaged received power among RBs
499  double sum = 0.0;
500  uint8_t rbNum = 0;
501  Values::const_iterator it;
503  {
504  // convert PSD [W/Hz] to linear power [W] for the single RE
505  // we consider only one RE for the RS since the channel is
506  // flat within the same RB
507  double powerTxW = ((*it) * 180000.0) / 12.0;
508  sum += powerTxW;
509  rbNum++;
510  }
511  double rsrp = (rbNum > 0) ? (sum / rbNum) : DBL_MAX;
512  // averaged SINR among RBs
513  sum = 0.0;
514  rbNum = 0;
515  for (it = sinr.ConstValuesBegin (); it != sinr.ConstValuesEnd (); it++)
516  {
517  sum += (*it);
518  rbNum++;
519  }
520  double avSinr = (rbNum > 0) ? (sum / rbNum) : DBL_MAX;
521  NS_LOG_INFO (this << " cellId " << m_cellId << " rnti " << m_rnti << " RSRP " << rsrp << " SINR " << avSinr);
522 
525  }
526 
527  if (m_pssReceived)
528  {
529  // measure instantaneous RSRQ now
530  NS_ASSERT_MSG (m_rsInterferencePowerUpdated, " RS interference power info obsolete");
531 
532  std::list <PssElement>::iterator itPss = m_pssList.begin ();
533  while (itPss != m_pssList.end ())
534  {
535  uint16_t rbNum = 0;
536  double rssiSum = 0.0;
537 
538  Values::const_iterator itIntN = m_rsInterferencePower.ConstValuesBegin ();
539  Values::const_iterator itPj = m_rsReceivedPower.ConstValuesBegin ();
540  for (itPj = m_rsReceivedPower.ConstValuesBegin ();
542  itIntN++, itPj++)
543  {
544  rbNum++;
545  // convert PSD [W/Hz] to linear power [W] for the single RE
546  double interfPlusNoisePowerTxW = ((*itIntN) * 180000.0) / 12.0;
547  double signalPowerTxW = ((*itPj) * 180000.0) / 12.0;
548  rssiSum += (2 * (interfPlusNoisePowerTxW + signalPowerTxW));
549  }
550 
551  NS_ASSERT (rbNum == (*itPss).nRB);
552  double rsrq_dB = 10 * log10 ((*itPss).pssPsdSum / rssiSum);
553 
554  if (rsrq_dB > m_pssReceptionThreshold)
555  {
556  NS_LOG_INFO (this << " PSS RNTI " << m_rnti << " cellId " << m_cellId
557  << " has RSRQ " << rsrq_dB << " and RBnum " << rbNum);
558  // store measurements
559  std::map <uint16_t, UeMeasurementsElement>::iterator itMeasMap;
560  itMeasMap = m_ueMeasurementsMap.find ((*itPss).cellId);
561  NS_ASSERT (itMeasMap != m_ueMeasurementsMap.end ());
562  (*itMeasMap).second.rsrqSum += rsrq_dB;
563  (*itMeasMap).second.rsrqNum++;
564  }
565 
566  itPss++;
567 
568  } // end of while (itPss != m_pssList.end ())
569 
570  m_pssList.clear ();
571 
572  } // end of if (m_pssReceived)
573 
574 } // end of void LteUePhy::GenerateCtrlCqiReport (const SpectrumValue& sinr)
575 
576 void
578 {
579  // Not used by UE, CQI are based only on RS
580 }
581 
582 void
584 {
585  NS_LOG_FUNCTION (this);
586 
588  NS_ASSERT (m_cellId > 0);
589 
592  {
593  // we have a measurement of interf + noise for the denominator
594  // of SINR = S/(I+N)
595  mixedSinr /= m_dataInterferencePower;
597  NS_LOG_LOGIC ("data interf measurement available, SINR = " << mixedSinr);
598  }
599  else
600  {
601  // we did not see any interference on data, so interference is
602  // there and we have only noise at the denominator of SINR
603  mixedSinr /= (*m_noisePsd);
604  NS_LOG_LOGIC ("no data interf measurement available, SINR = " << mixedSinr);
605  }
606 
607  /*
608  * some RBs are not used in PDSCH and their SINR is very high
609  * for example with bandwidth 25, last RB is not used
610  * it can make avgSinr value very high, what is incorrect
611  */
612  uint32_t rbgSize = GetRbgSize ();
613  uint32_t modulo = m_dlBandwidth % rbgSize;
614  double avgMixedSinr = 0;
615  uint32_t usedRbgNum = 0;
616  for(uint32_t i = 0; i < (m_dlBandwidth-1-modulo); i++)
617  {
618  usedRbgNum++;
619  avgMixedSinr+=mixedSinr[i];
620  }
621  avgMixedSinr = avgMixedSinr/usedRbgNum;
622  for(uint32_t i = 0; i < modulo; i++)
623  {
624  mixedSinr[m_dlBandwidth-1-i] = avgMixedSinr;
625  }
626 
627  GenerateCqiRsrpRsrq (mixedSinr);
628 }
629 
630 void
632 {
633  NS_LOG_FUNCTION (this << interf);
635  m_rsInterferencePower = interf;
636 }
637 
638 void
640 {
641  NS_LOG_FUNCTION (this << interf);
642 
644  m_dataInterferencePower = interf;
645 }
646 
647 void
649 {
650  NS_LOG_FUNCTION (this << power);
652  m_rsReceivedPower = power;
653 
655  {
656  double sum = 0;
657  uint32_t rbNum = 0;
658  Values::const_iterator it;
660  {
661  double powerTxW = ((*it) * 180000);
662  sum += powerTxW;
663  rbNum++;
664  }
665  double rsrp = 10 * log10 (sum) + 30;
666 
667  NS_LOG_INFO ("RSRP: " << rsrp);
668  m_powerControl->SetRsrp (rsrp);
669  }
670 }
671 
674 {
675  NS_LOG_FUNCTION (this);
676 
677 
678  // apply transmission mode gain
680  SpectrumValue newSinr = sinr;
681  newSinr *= m_txModeGain.at (m_transmissionMode);
682 
683  // CREATE DlCqiLteControlMessage
684  Ptr<DlCqiLteControlMessage> msg = Create<DlCqiLteControlMessage> ();
685  CqiListElement_s dlcqi;
686  std::vector<int> cqi;
688  {
689  cqi = m_amc->CreateCqiFeedbacks (newSinr, m_dlBandwidth);
690 
692  int nbSubChannels = cqi.size ();
693  double cqiSum = 0.0;
694  int activeSubChannels = 0;
695  // average the CQIs of the different RBs
696  for (int i = 0; i < nbSubChannels; i++)
697  {
698  if (cqi.at (i) != -1)
699  {
700  cqiSum += cqi.at (i);
701  activeSubChannels++;
702  }
703  NS_LOG_DEBUG (this << " subch " << i << " cqi " << cqi.at (i));
704  }
705  dlcqi.m_rnti = m_rnti;
706  dlcqi.m_ri = 1; // not yet used
707  dlcqi.m_cqiType = CqiListElement_s::P10; // Peridic CQI using PUCCH wideband
708  NS_ASSERT_MSG (nLayer > 0, " nLayer negative");
709  NS_ASSERT_MSG (nLayer < 3, " nLayer limit is 2s");
710  for (int i = 0; i < nLayer; i++)
711  {
712  if (activeSubChannels > 0)
713  {
714  dlcqi.m_wbCqi.push_back ((uint16_t) cqiSum / activeSubChannels);
715  }
716  else
717  {
718  // approximate with the worst case -> CQI = 1
719  dlcqi.m_wbCqi.push_back (1);
720  }
721  }
722  //NS_LOG_DEBUG (this << " Generate P10 CQI feedback " << (uint16_t) cqiSum / activeSubChannels);
723  dlcqi.m_wbPmi = 0; // not yet used
724  // dl.cqi.m_sbMeasResult others CQI report modes: not yet implemented
725  }
727  {
728  cqi = m_amc->CreateCqiFeedbacks (newSinr, GetRbgSize ());
730  int nbSubChannels = cqi.size ();
731  int rbgSize = GetRbgSize ();
732  double cqiSum = 0.0;
733  int cqiNum = 0;
734  SbMeasResult_s rbgMeas;
735  //NS_LOG_DEBUG (this << " Create A30 CQI feedback, RBG " << rbgSize << " cqiNum " << nbSubChannels << " band " << (uint16_t)m_dlBandwidth);
736  for (int i = 0; i < nbSubChannels; i++)
737  {
738  if (cqi.at (i) != -1)
739  {
740  cqiSum += cqi.at (i);
741  }
742  // else "nothing" no CQI is treated as CQI = 0 (worst case scenario)
743  cqiNum++;
744  if (cqiNum == rbgSize)
745  {
746  // average the CQIs of the different RBGs
747  //NS_LOG_DEBUG (this << " RBG CQI " << (uint16_t) cqiSum / rbgSize);
748  HigherLayerSelected_s hlCqi;
749  hlCqi.m_sbPmi = 0; // not yet used
750  for (int i = 0; i < nLayer; i++)
751  {
752  hlCqi.m_sbCqi.push_back ((uint16_t) cqiSum / rbgSize);
753  }
754  rbgMeas.m_higherLayerSelected.push_back (hlCqi);
755  cqiSum = 0.0;
756  cqiNum = 0;
757  }
758  }
759  dlcqi.m_rnti = m_rnti;
760  dlcqi.m_ri = 1; // not yet used
761  dlcqi.m_cqiType = CqiListElement_s::A30; // Aperidic CQI using PUSCH
762  //dlcqi.m_wbCqi.push_back ((uint16_t) cqiSum / nbSubChannels);
763  dlcqi.m_wbPmi = 0; // not yet used
764  dlcqi.m_sbMeasResult = rbgMeas;
765  }
766 
767  msg->SetDlCqi (dlcqi);
768  return msg;
769 }
770 
771 
772 void
774 {
775  NS_LOG_FUNCTION (this << Simulator::Now ());
776  NS_LOG_DEBUG (this << " Report UE Measurements ");
777 
779 
780  std::map <uint16_t, UeMeasurementsElement>::iterator it;
781  for (it = m_ueMeasurementsMap.begin (); it != m_ueMeasurementsMap.end (); it++)
782  {
783  double avg_rsrp = (*it).second.rsrpSum / (double)(*it).second.rsrpNum;
784  double avg_rsrq = (*it).second.rsrqSum / (double)(*it).second.rsrqNum;
785  /*
786  * In CELL_SEARCH state, this may result in avg_rsrq = 0/0 = -nan.
787  * UE RRC must take this into account when receiving measurement reports.
788  * TODO remove this shortcoming by calculating RSRQ during CELL_SEARCH
789  */
790  NS_LOG_DEBUG (this << " CellId " << (*it).first
791  << " RSRP " << avg_rsrp
792  << " (nSamples " << (uint16_t)(*it).second.rsrpNum << ")"
793  << " RSRQ " << avg_rsrq
794  << " (nSamples " << (uint16_t)(*it).second.rsrqNum << ")");
795 
797  newEl.m_cellId = (*it).first;
798  newEl.m_rsrp = avg_rsrp;
799  newEl.m_rsrq = avg_rsrq;
800  ret.m_ueMeasurementsList.push_back (newEl);
801 
802  // report to UE measurements trace
803  m_reportUeMeasurements (m_rnti, (*it).first, avg_rsrp, avg_rsrq, ((*it).first == m_cellId ? 1 : 0));
804  }
805 
806  // report to RRC
808 
809  m_ueMeasurementsMap.clear ();
811 }
812 
813 void
815 {
816  NS_LOG_FUNCTION (this << msg);
817 
818  SetControlMessages (msg);
819 }
820 
821 void
822 LteUePhy::DoSendRachPreamble (uint32_t raPreambleId, uint32_t raRnti)
823 {
824  NS_LOG_FUNCTION (this << raPreambleId);
825 
826  // unlike other control messages, RACH preamble is sent ASAP
827  Ptr<RachPreambleLteControlMessage> msg = Create<RachPreambleLteControlMessage> ();
828  msg->SetRapId (raPreambleId);
829  m_raPreambleId = raPreambleId;
830  m_raRnti = raRnti;
831  m_controlMessagesQueue.at (0).push_back (msg);
832 }
833 
834 
835 void
837 {
838  NS_LOG_FUNCTION (this);
839 
840  std::list<Ptr<LteControlMessage> >::iterator it;
841  for (it = msgList.begin (); it != msgList.end (); it++)
842  {
843  Ptr<LteControlMessage> msg = (*it);
844 
845  if (msg->GetMessageType () == LteControlMessage::DL_DCI)
846  {
847  Ptr<DlDciLteControlMessage> msg2 = DynamicCast<DlDciLteControlMessage> (msg);
848 
849  DlDciListElement_s dci = msg2->GetDci ();
850  if (dci.m_rnti != m_rnti)
851  {
852  // DCI not for me
853  continue;
854  }
855 
856  if (dci.m_resAlloc != 0)
857  {
858  NS_FATAL_ERROR ("Resource Allocation type not implemented");
859  }
860 
861  std::vector <int> dlRb;
862 
863  // translate the DCI to Spectrum framework
864  uint32_t mask = 0x1;
865  for (int i = 0; i < 32; i++)
866  {
867  if (((dci.m_rbBitmap & mask) >> i) == 1)
868  {
869  for (int k = 0; k < GetRbgSize (); k++)
870  {
871  dlRb.push_back ((i * GetRbgSize ()) + k);
872 // NS_LOG_DEBUG(this << " RNTI " << m_rnti << " RBG " << i << " DL-DCI allocated PRB " << (i*GetRbgSize()) + k);
873  }
874  }
875  mask = (mask << 1);
876  }
878  {
879  m_powerControl->ReportTpc (dci.m_tpc);
880  }
881 
882 
883  // send TB info to LteSpectrumPhy
884  NS_LOG_DEBUG (this << " UE " << m_rnti << " DL-DCI " << dci.m_rnti << " bitmap " << dci.m_rbBitmap);
885  for (uint8_t i = 0; i < dci.m_tbsSize.size (); i++)
886  {
887  m_downlinkSpectrumPhy->AddExpectedTb (dci.m_rnti, dci.m_ndi.at (i), dci.m_tbsSize.at (i), dci.m_mcs.at (i), dlRb, i, dci.m_harqProcess, dci.m_rv.at (i), true /* DL */);
888  }
889 
891 
892 
893  }
894  else if (msg->GetMessageType () == LteControlMessage::UL_DCI)
895  {
896  // set the uplink bandwidth according to the UL-CQI
897  Ptr<UlDciLteControlMessage> msg2 = DynamicCast<UlDciLteControlMessage> (msg);
898  UlDciListElement_s dci = msg2->GetDci ();
899  if (dci.m_rnti != m_rnti)
900  {
901  // DCI not for me
902  continue;
903  }
904  NS_LOG_INFO (this << " UL DCI");
905  std::vector <int> ulRb;
906  for (int i = 0; i < dci.m_rbLen; i++)
907  {
908  ulRb.push_back (i + dci.m_rbStart);
909  //NS_LOG_DEBUG (this << " UE RB " << i + dci.m_rbStart);
910  }
912  // fire trace of UL Tx PHY stats
913  HarqProcessInfoList_t harqInfoList = m_harqPhyModule->GetHarqProcessInfoUl (m_rnti, 0);
915  params.m_cellId = m_cellId;
916  params.m_imsi = 0; // it will be set by DlPhyTransmissionCallback in LteHelper
918  params.m_rnti = m_rnti;
919  params.m_txMode = 0; // always SISO for UE
920  params.m_layer = 0;
921  params.m_mcs = dci.m_mcs;
922  params.m_size = dci.m_tbSize;
923  params.m_rv = harqInfoList.size ();
924  params.m_ndi = dci.m_ndi;
925  m_ulPhyTransmission (params);
926  // pass the info to the MAC
928  }
929  else if (msg->GetMessageType () == LteControlMessage::RAR)
930  {
931  Ptr<RarLteControlMessage> rarMsg = DynamicCast<RarLteControlMessage> (msg);
932  if (rarMsg->GetRaRnti () == m_raRnti)
933  {
934  for (std::list<RarLteControlMessage::Rar>::const_iterator it = rarMsg->RarListBegin (); it != rarMsg->RarListEnd (); ++it)
935  {
936  if (it->rapId != m_raPreambleId)
937  {
938  // UL grant not for me
939  continue;
940  }
941  else
942  {
943  NS_LOG_INFO ("received RAR RNTI " << m_raRnti);
944  // set the uplink bandwidht according to the UL grant
945  std::vector <int> ulRb;
946  for (int i = 0; i < it->rarPayload.m_grant.m_rbLen; i++)
947  {
948  ulRb.push_back (i + it->rarPayload.m_grant.m_rbStart);
949  }
950 
952  // pass the info to the MAC
954  // reset RACH variables with out of range values
955  m_raPreambleId = 255;
956  m_raRnti = 11;
957  }
958  }
959  }
960  }
961  else if (msg->GetMessageType () == LteControlMessage::MIB)
962  {
963  NS_LOG_INFO ("received MIB");
964  NS_ASSERT (m_cellId > 0);
965  Ptr<MibLteControlMessage> msg2 = DynamicCast<MibLteControlMessage> (msg);
967  }
968  else if (msg->GetMessageType () == LteControlMessage::SIB1)
969  {
970  NS_LOG_INFO ("received SIB1");
971  NS_ASSERT (m_cellId > 0);
972  Ptr<Sib1LteControlMessage> msg2 = DynamicCast<Sib1LteControlMessage> (msg);
974  }
975  else
976  {
977  // pass the message to UE-MAC
979  }
980 
981  }
982 
983 
984 }
985 
986 
987 void
989 {
990  NS_LOG_FUNCTION (this << cellId << (*p));
991 
992  double sum = 0.0;
993  uint16_t nRB = 0;
994  Values::const_iterator itPi;
995  for (itPi = p->ConstValuesBegin (); itPi != p->ConstValuesEnd (); itPi++)
996  {
997  // convert PSD [W/Hz] to linear power [W] for the single RE
998  double powerTxW = ((*itPi) * 180000.0) / 12.0;
999  sum += powerTxW;
1000  nRB++;
1001  }
1002 
1003  // measure instantaneous RSRP now
1004  double rsrp_dBm = 10 * log10 (1000 * (sum / (double)nRB));
1005  NS_LOG_INFO (this << " PSS RNTI " << m_rnti << " cellId " << m_cellId
1006  << " has RSRP " << rsrp_dBm << " and RBnum " << nRB);
1007  // note that m_pssReceptionThreshold does not apply here
1008 
1009  // store measurements
1010  std::map <uint16_t, UeMeasurementsElement>::iterator itMeasMap = m_ueMeasurementsMap.find (cellId);
1011  if (itMeasMap == m_ueMeasurementsMap.end ())
1012  {
1013  // insert new entry
1014  UeMeasurementsElement newEl;
1015  newEl.rsrpSum = rsrp_dBm;
1016  newEl.rsrpNum = 1;
1017  newEl.rsrqSum = 0;
1018  newEl.rsrqNum = 0;
1019  m_ueMeasurementsMap.insert (std::pair <uint16_t, UeMeasurementsElement> (cellId, newEl));
1020  }
1021  else
1022  {
1023  (*itMeasMap).second.rsrpSum += rsrp_dBm;
1024  (*itMeasMap).second.rsrpNum++;
1025  }
1026 
1027  /*
1028  * Collect the PSS for later processing in GenerateCtrlCqiReport()
1029  * (to be called from ChunkProcessor after RX is finished).
1030  */
1031  m_pssReceived = true;
1032  PssElement el;
1033  el.cellId = cellId;
1034  el.pssPsdSum = sum;
1035  el.nRB = nRB;
1036  m_pssList.push_back (el);
1037 
1038 } // end of void LteUePhy::ReceivePss (uint16_t cellId, Ptr<SpectrumValue> p)
1039 
1040 
1041 void
1043 {
1045 }
1046 
1047 
1048 void
1049 LteUePhy::SubframeIndication (uint32_t frameNo, uint32_t subframeNo)
1050 {
1051  NS_LOG_FUNCTION (this << frameNo << subframeNo);
1052 
1053  NS_ASSERT_MSG (frameNo > 0, "the SRS index check code assumes that frameNo starts at 1");
1054 
1055  // refresh internal variables
1056  m_rsReceivedPowerUpdated = false;
1058  m_pssReceived = false;
1059 
1060  if (m_ulConfigured)
1061  {
1062  // update uplink transmission mask according to previous UL-CQIs
1063  std::vector <int> rbMask = m_subChannelsForTransmissionQueue.at (0);
1065 
1066  // shift the queue
1067  for (uint8_t i = 1; i < m_macChTtiDelay; i++)
1068  {
1070  }
1071  m_subChannelsForTransmissionQueue.at (m_macChTtiDelay-1).clear ();
1072 
1074  {
1075 
1076  NS_ASSERT_MSG (subframeNo > 0 && subframeNo <= 10, "the SRS index check code assumes that subframeNo starts at 1");
1077  if ((((frameNo-1)*10 + (subframeNo-1)) % m_srsPeriodicity) == m_srsSubframeOffset)
1078  {
1079  NS_LOG_INFO ("frame " << frameNo << " subframe " << subframeNo << " sending SRS (offset=" << m_srsSubframeOffset << ", period=" << m_srsPeriodicity << ")");
1080  m_sendSrsEvent = Simulator::Schedule (UL_SRS_DELAY_FROM_SUBFRAME_START,
1082  this);
1083  }
1084  }
1085 
1086  std::list<Ptr<LteControlMessage> > ctrlMsg = GetControlMessages ();
1087  // send packets in queue
1088  NS_LOG_LOGIC (this << " UE - start slot for PUSCH + PUCCH - RNTI " << m_rnti << " CELLID " << m_cellId);
1089  // send the current burts of packets
1091  if (pb)
1092  {
1094  {
1097  }
1098  m_uplinkSpectrumPhy->StartTxDataFrame (pb, ctrlMsg, UL_DATA_DURATION);
1099  }
1100  else
1101  {
1102  // send only PUCCH (ideal: fake null bandwidth signal)
1103  if (ctrlMsg.size ()>0)
1104  {
1105  NS_LOG_LOGIC (this << " UE - start TX PUCCH (NO PUSCH)");
1106  std::vector <int> dlRb;
1107 
1109  {
1111  }
1112 
1114  m_uplinkSpectrumPhy->StartTxDataFrame (pb, ctrlMsg, UL_DATA_DURATION);
1115  }
1116  else
1117  {
1118  NS_LOG_LOGIC (this << " UE - UL NOTHING TO SEND");
1119  }
1120  }
1121  } // m_configured
1122 
1123  // trigger the MAC
1124  m_uePhySapUser->SubframeIndication (frameNo, subframeNo);
1125 
1126  m_subframeNo = subframeNo;
1127  ++subframeNo;
1128  if (subframeNo > 10)
1129  {
1130  ++frameNo;
1131  subframeNo = 1;
1132  }
1133 
1134  // schedule next subframe indication
1135  Simulator::Schedule (Seconds (GetTti ()), &LteUePhy::SubframeIndication, this, frameNo, subframeNo);
1136 }
1137 
1138 
1139 void
1141 {
1142  NS_LOG_FUNCTION (this << " UE " << m_rnti << " start tx SRS, cell Id " << (uint32_t) m_cellId);
1143  NS_ASSERT (m_cellId > 0);
1144  // set the current tx power spectral density (full bandwidth)
1145  std::vector <int> dlRb;
1146  for (uint8_t i = 0; i < m_ulBandwidth; i++)
1147  {
1148  dlRb.push_back (i);
1149  }
1150 
1152  {
1154  }
1155 
1157  m_uplinkSpectrumPhy->StartTxUlSrsFrame ();
1158 }
1159 
1160 
1161 void
1163 {
1164  NS_LOG_FUNCTION (this);
1165 
1166  m_rnti = 0;
1167  m_transmissionMode = 0;
1168  m_srsPeriodicity = 0;
1169  m_srsConfigured = false;
1170  m_dlConfigured = false;
1171  m_ulConfigured = false;
1172  m_raPreambleId = 255; // value out of range
1173  m_raRnti = 11; // value out of range
1177  m_paLinear = 1;
1178 
1179  m_packetBurstQueue.clear ();
1180  m_controlMessagesQueue.clear ();
1182  for (int i = 0; i < m_macChTtiDelay; i++)
1183  {
1184  Ptr<PacketBurst> pb = CreateObject <PacketBurst> ();
1185  m_packetBurstQueue.push_back (pb);
1186  std::list<Ptr<LteControlMessage> > l;
1187  m_controlMessagesQueue.push_back (l);
1188  }
1189  std::vector <int> ulRb;
1190  m_subChannelsForTransmissionQueue.resize (m_macChTtiDelay, ulRb);
1191 
1193  m_downlinkSpectrumPhy->Reset ();
1194  m_uplinkSpectrumPhy->Reset ();
1195 
1196 } // end of void LteUePhy::DoReset ()
1197 
1198 void
1199 LteUePhy::DoStartCellSearch (uint16_t dlEarfcn)
1200 {
1201  NS_LOG_FUNCTION (this << dlEarfcn);
1202  m_dlEarfcn = dlEarfcn;
1203  DoSetDlBandwidth (6); // configure DL for receiving PSS
1205 }
1206 
1207 void
1208 LteUePhy::DoSynchronizeWithEnb (uint16_t cellId, uint16_t dlEarfcn)
1209 {
1210  NS_LOG_FUNCTION (this << cellId << dlEarfcn);
1211  m_dlEarfcn = dlEarfcn;
1212  DoSynchronizeWithEnb (cellId);
1213 }
1214 
1215 void
1217 {
1218  NS_LOG_FUNCTION (this << cellId);
1219 
1220  if (cellId == 0)
1221  {
1222  NS_FATAL_ERROR ("Cell ID shall not be zero");
1223  }
1224 
1225  m_cellId = cellId;
1226  m_downlinkSpectrumPhy->SetCellId (cellId);
1227  m_uplinkSpectrumPhy->SetCellId (cellId);
1228 
1229  // configure DL for receiving the BCH with the minimum bandwidth
1230  DoSetDlBandwidth (6);
1231 
1232  m_dlConfigured = false;
1233  m_ulConfigured = false;
1234 
1236 }
1237 
1238 void
1239 LteUePhy::DoSetDlBandwidth (uint8_t dlBandwidth)
1240 {
1241  NS_LOG_FUNCTION (this << (uint32_t) dlBandwidth);
1242  if (m_dlBandwidth != dlBandwidth or !m_dlConfigured)
1243  {
1244  m_dlBandwidth = dlBandwidth;
1245 
1246  static const int Type0AllocationRbg[4] = {
1247  10, // RGB size 1
1248  26, // RGB size 2
1249  63, // RGB size 3
1250  110 // RGB size 4
1251  }; // see table 7.1.6.1-1 of 36.213
1252  for (int i = 0; i < 4; i++)
1253  {
1254  if (dlBandwidth < Type0AllocationRbg[i])
1255  {
1256  m_rbgSize = i + 1;
1257  break;
1258  }
1259  }
1260 
1262  m_downlinkSpectrumPhy->SetNoisePowerSpectralDensity (m_noisePsd);
1263  m_downlinkSpectrumPhy->GetChannel ()->AddRx (m_downlinkSpectrumPhy);
1264  }
1265  m_dlConfigured = true;
1266 }
1267 
1268 
1269 void
1270 LteUePhy::DoConfigureUplink (uint16_t ulEarfcn, uint8_t ulBandwidth)
1271 {
1272  m_ulEarfcn = ulEarfcn;
1273  m_ulBandwidth = ulBandwidth;
1274  m_ulConfigured = true;
1275 }
1276 
1277 void
1278 LteUePhy::DoConfigureReferenceSignalPower (int8_t referenceSignalPower)
1279 {
1280  NS_LOG_FUNCTION (this);
1281  m_powerControl->ConfigureReferenceSignalPower (referenceSignalPower);
1282 }
1283 
1284 void
1285 LteUePhy::DoSetRnti (uint16_t rnti)
1286 {
1287  NS_LOG_FUNCTION (this << rnti);
1288  m_rnti = rnti;
1289 
1292 }
1293 
1294 void
1296 {
1297  NS_LOG_FUNCTION (this << (uint16_t)txMode);
1298  m_transmissionMode = txMode;
1299  m_downlinkSpectrumPhy->SetTransmissionMode (txMode);
1300 }
1301 
1302 void
1304 {
1305  NS_LOG_FUNCTION (this << srcCi);
1308  m_srsConfigured = true;
1309 
1310  // a guard time is needed for the case where the SRS periodicity is changed dynamically at run time
1311  // if we use a static one, we can have a 0ms guard time
1313  NS_LOG_DEBUG (this << " UE SRS P " << m_srsPeriodicity << " RNTI " << m_rnti << " offset " << m_srsSubframeOffset << " cellId " << m_cellId << " CI " << srcCi);
1314 }
1315 
1316 void
1318 {
1319  NS_LOG_FUNCTION (this << pa);
1320  m_paLinear = pow (10,(pa/10));
1321 }
1322 
1323 void
1325 {
1326  SetTxModeGain (1, gain);
1327 }
1328 
1329 void
1331 {
1332  SetTxModeGain (2, gain);
1333 }
1334 
1335 void
1337 {
1338  SetTxModeGain (3, gain);
1339 }
1340 
1341 void
1343 {
1344  SetTxModeGain (4, gain);
1345 }
1346 
1347 void
1349 {
1350  SetTxModeGain (5, gain);
1351 }
1352 
1353 void
1355 {
1356  SetTxModeGain (6, gain);
1357 }
1358 
1359 void
1361 {
1362  SetTxModeGain (7, gain);
1363 }
1364 
1365 
1366 void
1367 LteUePhy::SetTxModeGain (uint8_t txMode, double gain)
1368 {
1369  NS_LOG_FUNCTION (this << gain);
1370  // convert to linear
1371  double gainLin = std::pow (10.0, (gain / 10.0));
1372  if (m_txModeGain.size () < txMode)
1373  {
1374  m_txModeGain.resize (txMode);
1375  }
1376  std::vector <double> temp;
1377  temp = m_txModeGain;
1378  m_txModeGain.clear ();
1379  for (uint8_t i = 0; i < temp.size (); i++)
1380  {
1381  if (i==txMode-1)
1382  {
1383  m_txModeGain.push_back (gainLin);
1384  }
1385  else
1386  {
1387  m_txModeGain.push_back (temp.at (i));
1388  }
1389  }
1390  // forward the info to DL LteSpectrumPhy
1391  m_downlinkSpectrumPhy->SetTxModeGain (txMode, gain);
1392 }
1393 
1394 
1395 
1396 void
1398 {
1399  NS_LOG_FUNCTION (this);
1400  // generate feedback to eNB and send it through ideal PUCCH
1401  Ptr<DlHarqFeedbackLteControlMessage> msg = Create<DlHarqFeedbackLteControlMessage> ();
1402  msg->SetDlHarqFeedback (m);
1403  SetControlMessages (msg);
1404 }
1405 
1406 void
1408 {
1409  m_harqPhyModule = harq;
1410 }
1411 
1412 
1415 {
1416  NS_LOG_FUNCTION (this);
1417  return m_state;
1418 }
1419 
1420 
1421 void
1423 {
1424  NS_LOG_FUNCTION (this << newState);
1425  State oldState = m_state;
1426  m_state = newState;
1427  NS_LOG_INFO (this << " cellId=" << m_cellId << " rnti=" << m_rnti
1428  << " UePhy " << ToString (oldState)
1429  << " --> " << ToString (newState));
1430  m_stateTransitionTrace (m_cellId, m_rnti, oldState, newState);
1431 }
1432 
1433 
1434 } // namespace ns3
Values::const_iterator ConstValuesEnd() const
See section 4.3.1 dlDciListElement.
Definition: ff-mac-common.h:88
double GetNoiseFigure() const
Definition: lte-ue-phy.cc:344
void SetTxPower(double value)
Ptr< LteSpectrumPhy > GetUlSpectrumPhy() const
Definition: lte-ue-phy.cc:385
uint16_t m_srsConfigured
Definition: lte-ue-phy.h:374
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:95
uint8_t m_txMode
the transmission Mode
Definition: lte-common.h:124
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
virtual void ReceiveLteControlMessage(Ptr< LteControlMessage > msg)=0
Receive SendLteControlMessage (PDCCH map, CQI feedbacks) using the ideal control channel.
double m_noiseFigure
Loss (dB) in the Signal-to-Noise-Ratio due to non-idealities in the receiver.
Definition: lte-phy.h:245
See section 4.3.25 sbMeasResult.
AttributeValue implementation for Boolean.
Definition: boolean.h:34
double m_txPower
Transmission power in dBm.
Definition: lte-phy.h:233
std::vector< struct UeMeasurementsElement > m_ueMeasurementsList
uint16_t m_dlEarfcn
The downlink carrier frequency.
Definition: lte-phy.h:265
virtual void GenerateMixedCqiReport(const SpectrumValue &sinr)
Definition: lte-ue-phy.cc:583
LteUePhySapUser * m_uePhySapUser
Definition: lte-ue-phy.h:362
void SetTxMode5Gain(double gain)
Definition: lte-ue-phy.cc:1348
void SetCellId(uint16_t cellId)
virtual void SendMacPdu(Ptr< Packet > p)
Send the MAC PDU to the channel.
Definition: lte-ue-phy.cc:93
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:44
virtual void GenerateDataCqiReport(const SpectrumValue &sinr)
generate a CQI report based on the given SINR of Data frame (used for PUSCH CQIs) ...
Definition: lte-ue-phy.cc:577
std::list< PssElement > m_pssList
Definition: lte-ue-phy.h:409
void SetTxMode2Gain(double gain)
Definition: lte-ue-phy.cc:1330
bool m_ulConfigured
Definition: lte-ue-phy.h:380
uint8_t GetMacChDelay(void) const
Definition: lte-ue-phy.cc:373
void DoConfigureUplink(uint16_t ulEarfcn, uint8_t ulBandwidth)
Definition: lte-ue-phy.cc:1270
std::vector< Ptr< PacketBurst > > m_packetBurstQueue
A queue of packet bursts to be sent.
Definition: lte-phy.h:273
std::vector< int > GetSubChannelsForTransmission(void)
Get a list of sub channels to use in RX.
Definition: lte-ue-phy.cc:426
virtual void GenerateCtrlCqiReport(const SpectrumValue &sinr)
generate a CQI report based on the given SINR of Ctrl frame
Definition: lte-ue-phy.cc:452
TracedCallback< uint16_t, uint16_t, double, double > m_reportCurrentCellRsrpSinrTrace
The ReportCurrentCellRsrpSinr trace source.
Definition: lte-ue-phy.h:449
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: boolean.h:81
Time m_a30CqiLast
Definition: lte-ue-phy.h:359
double GetPuschTxPower(std::vector< int > rb)
void SetSubChannelsForTransmission(std::vector< int > mask)
Set a list of sub channels to use in TX.
Definition: lte-ue-phy.cc:406
uint16_t GetSrsPeriodicity(uint16_t srcCi) const
Definition: lte-phy.cc:146
double GetTti(void) const
Definition: lte-phy.cc:138
double m_paLinear
Definition: lte-ue-phy.h:377
LteUePhySapProvider * m_uePhySapProvider
Definition: lte-ue-phy.h:361
uint8_t rsrqNum
Number of RSRQ samples.
Definition: lte-ue-phy.h:423
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
Definition: assert.h:61
void SetTxMode6Gain(double gain)
Definition: lte-ue-phy.cc:1354
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:201
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:867
Ptr< LteSpectrumPhy > m_downlinkSpectrumPhy
The downlink LteSpectrumPhy associated to this LtePhy.
Definition: lte-phy.h:222
See section 4.3.2 ulDciListElement.
Service Access Point (SAP) offered by the UE PHY to the UE RRC for control purposes.
virtual void SendLteControlMessage(Ptr< LteControlMessage > msg)
Send SendLteControlMessage (PDCCH map, CQI feedbacks) using the ideal control channel.
Definition: lte-ue-phy.cc:99
See section 4.3.24 cqiListElement.
std::vector< double > m_txModeGain
Definition: lte-ue-phy.h:370
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:244
#define NS_FATAL_ERROR(msg)
Fatal error handling.
Definition: fatal-error.h:100
Summary results of measuring a specific cell. Used for layer-1 filtering.
Definition: lte-ue-phy.h:418
SpectrumValue m_dataInterferencePower
Definition: lte-ue-phy.h:400
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
Schedule an event to expire at the relative time "time" is reached.
Definition: simulator.h:819
void QueueSubChannelsForTransmission(std::vector< int > rbMap)
Definition: lte-ue-phy.cc:1042
uint8_t m_rv
the redundancy version (HARQ)
Definition: lte-common.h:128
Service Access Point (SAP) offered by the PHY to the MAC.
void SetTxModeGain(uint8_t txMode, double gain)
Definition: lte-ue-phy.cc:1367
State
The states of the UE PHY entity.
Definition: lte-ue-phy.h:61
Ptr< LteUePowerControl > m_powerControl
Pointer to UE Uplink Power Control entity.
Definition: lte-ue-phy.h:347
virtual void DoSendMacPdu(Ptr< Packet > p)
Queue the MAC PDU to be sent (according to m_macChTtiDelay)
Definition: lte-ue-phy.cc:391
std::vector< int > GetSubChannelsForReception(void)
Get a list of sub channels to use in RX.
Definition: lte-ue-phy.cc:434
This class defines all functions to create spectrum model for lte.
uint8_t m_transmissionMode
Definition: lte-ue-phy.h:369
EventId m_sendSrsEvent
Definition: lte-ue-phy.h:465
void SetHarqPhyModule(Ptr< LteHarqPhy > harq)
Set the HARQ PHY module.
Definition: lte-ue-phy.cc:1407
Ptr< LteNetDevice > GetDevice()
Get the device where the phy layer is attached.
Definition: lte-phy.cc:96
uint8_t m_ulBandwidth
The UL bandwidth in number of PRBs.
Definition: lte-phy.h:253
bool m_pssReceived
Definition: lte-ue-phy.h:402
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
void DoSetSrsConfigurationIndex(uint16_t srcCi)
Definition: lte-ue-phy.cc:1303
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Definition: time.cc:439
static const int Type0AllocationRbg[4]
void DoSetTransmissionMode(uint8_t txMode)
Definition: lte-ue-phy.cc:1295
The attribute can be read.
Definition: type-id.h:58
UeMemberLteUePhySapProvider(LteUePhy *phy)
Definition: lte-ue-phy.cc:87
Template for the implementation of the LteUeCphySapProvider as a member of an owner class of type C t...
double m_pssReceptionThreshold
The RsrqUeMeasThreshold attribute.
Definition: lte-ue-phy.h:415
TracedCallback< uint16_t, uint16_t, double, double, bool > m_reportUeMeasurements
The ReportUeMeasurements trace source.
Definition: lte-ue-phy.h:463
uint16_t GetSrsSubframeOffset(uint16_t srcCi) const
Definition: lte-phy.cc:164
void DoSynchronizeWithEnb(uint16_t cellId)
Definition: lte-ue-phy.cc:1216
uint8_t rsrpNum
Number of RSRP samples.
Definition: lte-ue-phy.h:421
LteUeCphySapUser * m_ueCphySapUser
Definition: lte-ue-phy.h:365
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:210
void DoSetDlBandwidth(uint8_t ulBandwidth)
Definition: lte-ue-phy.cc:1239
void DoDispose()
Destructor implementation.
Definition: lte-phy.cc:74
AttributeValue implementation for Time.
Definition: nstime.h:921
uint8_t GetRbgSize(void) const
Definition: lte-phy.cc:182
uint16_t m_rsrpSinrSamplePeriod
The RsrpSinrSamplePeriod attribute.
Definition: lte-ue-phy.h:454
Time NanoSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:883
uint64_t m_imsi
IMSI of the scheduled UE.
Definition: lte-common.h:122
See section 4.3.27 higherLayerSelected.
Service Access Point (SAP) offered by the UE PHY to the UE RRC for control purposes.
void SetLteUePhySapUser(LteUePhySapUser *s)
Set the PHY SAP User.
Definition: lte-ue-phy.cc:308
Hold an unsigned integer type.
Definition: uinteger.h:44
void DoConfigureReferenceSignalPower(int8_t referenceSignalPower)
Definition: lte-ue-phy.cc:1278
void SetTxMode3Gain(double gain)
Definition: lte-ue-phy.cc:1336
static uint8_t TxMode2LayerNum(uint8_t txMode)
Definition: lte-common.cc:169
Ptr< SampleEmitter > s
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:673
void SetTxMode4Gain(double gain)
Definition: lte-ue-phy.cc:1342
void SwitchToState(State s)
Switch the UE PHY to the given state.
Definition: lte-ue-phy.cc:1422
TracedCallback< uint16_t, uint16_t, State, State > m_stateTransitionTrace
The StateTransition trace source.
Definition: lte-ue-phy.h:388
void SendSrs()
Send the SRS signal in the last symbols of the frame.
Definition: lte-ue-phy.cc:1140
uint16_t m_ulEarfcn
The uplink carrier frequency.
Definition: lte-phy.h:270
bool m_rsInterferencePowerUpdated
Definition: lte-ue-phy.h:396
virtual void RecvSystemInformationBlockType1(uint16_t cellId, LteRrcSap::SystemInformationBlockType1 sib1)=0
Relay an SIB1 message from the PHY entity to the RRC layer.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:252
std::vector< uint8_t > m_sbCqi
void SetTxMode7Gain(double gain)
Definition: lte-ue-phy.cc:1360
Ptr< LteUePowerControl > GetUplinkPowerControl() const
Definition: lte-ue-phy.cc:366
void DoSetPa(double pa)
Definition: lte-ue-phy.cc:1317
#define list
virtual void RecvMasterInformationBlock(uint16_t cellId, LteRrcSap::MasterInformationBlock mib)=0
Relay an MIB message from the PHY entity to the RRC layer.
See section 4.3.23 dlInfoListElement.
double rsrpSum
Sum of RSRP sample values in linear unit.
Definition: lte-ue-phy.h:420
virtual void DoSendRachPreamble(uint32_t prachId, uint32_t raRnti)
Definition: lte-ue-phy.cc:822
uint8_t m_mcs
MCS for transport block.
Definition: lte-common.h:126
virtual void ReportDataInterference(const SpectrumValue &interf)
Definition: lte-ue-phy.cc:639
virtual void ReceiveLteDlHarqFeedback(DlInfoListElement_s mes)
PhySpectrum generated a new DL HARQ feedback.
Definition: lte-ue-phy.cc:1397
bool m_enableUplinkPowerControl
The EnableUplinkPowerControl attribute.
Definition: lte-ue-phy.h:345
uint8_t m_macChTtiDelay
Delay between MAC and channel layer in terms of TTIs.
Definition: lte-phy.h:285
static const Time UL_DATA_DURATION
Duration of the data portion of a UL subframe.
Definition: lte-ue-phy.cc:57
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< LteHarqPhy > m_harqPhyModule
Definition: lte-ue-phy.h:439
Hold objects of type Ptr.
Definition: pointer.h:36
void DoStartCellSearch(uint16_t dlEarfcn)
Definition: lte-ue-phy.cc:1199
void SetControlMessages(Ptr< LteControlMessage > m)
Definition: lte-phy.cc:213
Ptr< const AttributeChecker > MakeBooleanChecker(void)
Definition: boolean.cc:121
uint16_t m_rsrpSinrSampleCounter
Definition: lte-ue-phy.h:455
SpectrumValue m_rsReceivedPower
Definition: lte-ue-phy.h:394
double GetTxPower() const
Definition: lte-ue-phy.cc:359
double rsrqSum
Sum of RSRQ sample values in linear unit.
Definition: lte-ue-phy.h:422
uint16_t m_srsSubframeOffset
Definition: lte-ue-phy.h:373
Time m_srsStartTime
Definition: lte-ue-phy.h:375
uint8_t m_dlBandwidth
The DL bandwidth in number of PRBs.
Definition: lte-phy.h:258
uint8_t m_subframeNo
Definition: lte-ue-phy.h:391
static EventId ScheduleNow(MEM mem_ptr, OBJ obj)
Schedule an event to expire Now.
Definition: simulator.h:980
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:922
uint16_t m_size
Size of transport block.
Definition: lte-common.h:127
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:223
uint16_t m_cellId
Cell identifier.
Definition: lte-phy.h:292
uint8_t m_ndi
new data indicator flag
Definition: lte-common.h:129
void SubframeIndication(uint32_t frameNo, uint32_t subframeNo)
trigger from eNB the start from a new frame
Definition: lte-ue-phy.cc:1049
virtual void DoInitialize(void)
Initialize() implementation.
Definition: lte-ue-phy.cc:301
void SetRnti(uint16_t rnti)
#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:84
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: double.h:42
static Ptr< SpectrumValue > CreateTxPowerSpectralDensity(uint16_t earfcn, uint8_t bandwidth, double powerTx, std::vector< int > activeRbs)
create a spectrum value representing the power spectral density of a signal to be transmitted...
void SetTxMode1Gain(double gain)
Definition: lte-ue-phy.cc:1324
std::vector< int > m_subChannelsForTransmission
A list of sub channels to use in TX.
Definition: lte-ue-phy.h:332
Time m_p10CqiPeriocity
Wideband Periodic CQI. 2, 5, 10, 16, 20, 32, 40, 64, 80 or 160 ms.
Definition: lte-ue-phy.h:350
uint32_t m_raRnti
Definition: lte-ue-phy.h:442
bool m_dlConfigured
Definition: lte-ue-phy.h:379
std::vector< std::vector< int > > m_subChannelsForTransmissionQueue
Definition: lte-ue-phy.h:336
std::list< Ptr< LteControlMessage > > GetControlMessages(void)
Definition: lte-phy.cc:221
static const std::string & ToString(EpcUeNas::State s)
Definition: epc-ue-nas.cc:50
Time m_a30CqiPeriocity
SubBand Aperiodic CQI.
Definition: lte-ue-phy.h:358
LteUeCphySapProvider * m_ueCphySapProvider
Definition: lte-ue-phy.h:364
std::map< uint16_t, UeMeasurementsElement > m_ueMeasurementsMap
Store measurement results during the last layer-1 filtering period.
Definition: lte-ue-phy.h:430
Ptr< PacketBurst > GetPacketBurst(void)
Definition: lte-phy.cc:194
uint16_t m_cellId
Cell ID of the attached Enb.
Definition: lte-common.h:121
static const std::string g_uePhyStateName[LteUePhy::NUM_STATES]
Map each of UE PHY states to its string representation.
Definition: lte-ue-phy.cc:116
std::vector< int > m_subChannelsForReception
A list of sub channels to use in RX.
Definition: lte-ue-phy.h:334
Service Access Point (SAP) offered by the UE-PHY to the UE-MAC.
static const Time UL_SRS_DELAY_FROM_SUBFRAME_START
Delay from subframe start to transmission of SRS.
Definition: lte-ue-phy.cc:63
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:236
uint8_t m_layer
the layer (cw) of the transmission
Definition: lte-common.h:125
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:859
virtual void ReceiveLteControlMessageList(std::list< Ptr< LteControlMessage > >)
Definition: lte-ue-phy.cc:836
void SetTxPower(double pow)
Definition: lte-ue-phy.cc:351
virtual void ReceivePss(uint16_t cellId, Ptr< SpectrumValue > p)
Definition: lte-ue-phy.cc:988
double GetPucchTxPower(std::vector< int > rb)
uint16_t m_srsPeriodicity
Definition: lte-ue-phy.h:372
LteUePhySapProvider * GetLteUePhySapProvider()
Get the PHY SAP provider.
Definition: lte-ue-phy.cc:315
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
Definition: event-id.cc:53
virtual void SendRachPreamble(uint32_t prachId, uint32_t raRnti)
send a preamble on the PRACH
Definition: lte-ue-phy.cc:105
State GetState() const
Definition: lte-ue-phy.cc:1414
uint32_t m_raPreambleId
Definition: lte-ue-phy.h:441
uint8_t m_rbgSize
The RB gruop size according to the bandwidth.
Definition: lte-phy.h:260
void SetLteUeCphySapUser(LteUeCphySapUser *s)
Set the CPHY SAP User.
Definition: lte-ue-phy.cc:323
SpectrumValue m_rsInterferencePower
Definition: lte-ue-phy.h:397
friend class UeMemberLteUePhySapProvider
Definition: lte-ue-phy.h:54
double GetSrsTxPower(std::vector< int > rb)
void PhyPduReceived(Ptr< Packet > p)
PhySpectrum received a new PHY-PDU.
Definition: lte-ue-phy.cc:400
Values::const_iterator ConstValuesBegin() const
virtual void DoSendLteControlMessage(Ptr< LteControlMessage > msg)
Definition: lte-ue-phy.cc:814
std::vector< std::list< Ptr< LteControlMessage > > > m_controlMessagesQueue
A queue of control messages to be sent.
Definition: lte-phy.h:275
bool m_rsReceivedPowerUpdated
Definition: lte-ue-phy.h:393
void ConfigureReferenceSignalPower(int8_t referenceSignalPower)
void GenerateCqiRsrpRsrq(const SpectrumValue &sinr)
internal method that takes care of generating CQI reports, calculating the RSRP and RSRQ metrics...
Definition: lte-ue-phy.cc:460
virtual ~LteUePhy()
Definition: lte-ue-phy.cc:172
The LteSpectrumPhy models the physical layer of LTE.
Definition: lte-ue-phy.h:51
Ptr< LteSpectrumPhy > GetDlSpectrumPhy() const
Definition: lte-ue-phy.cc:379
Ptr< LteSpectrumPhy > m_uplinkSpectrumPhy
The uplink LteSpectrumPhy associated to this LtePhy.
Definition: lte-phy.h:227
virtual void ReportRsReceivedPower(const SpectrumValue &power)
generate a report based on the linear RS power perceived during CTRL frame NOTE: used only by UE for ...
Definition: lte-ue-phy.cc:648
Time m_p10CqiLast
Definition: lte-ue-phy.h:351
Parameters of the ReportUeMeasurements primitive: RSRP [dBm] and RSRQ [dB] See section 5...
LteUeCphySapProvider * GetLteUeCphySapProvider()
Get the CPHY SAP provider.
Definition: lte-ue-phy.cc:330
This class can be used to hold variables of floating point type such as 'double' or 'float'...
Definition: double.h:41
State m_state
The current UE PHY state.
Definition: lte-ue-phy.h:383
Set of values corresponding to a given SpectrumModel.
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: uinteger.h:45
void SetMacPdu(Ptr< Packet > p)
Definition: lte-phy.cc:188
std::vector< struct HigherLayerSelected_s > m_higherLayerSelected
a unique identifier for an interface.
Definition: type-id.h:51
uint16_t m_rnti
Definition: lte-ue-phy.h:367
int64_t GetMilliSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:331
TypeId SetParent(TypeId tid)
Definition: type-id.cc:631
bool m_dataInterferencePowerUpdated
Definition: lte-ue-phy.h:399
void SetNoiseFigure(double nf)
Definition: lte-ue-phy.cc:337
virtual void DoInitialize(void)
Initialize() implementation.
Definition: object.cc:345
TracedCallback< PhyTransmissionStatParameters > m_ulPhyTransmission
The UlPhyTransmission trace source.
Definition: lte-ue-phy.h:472
uint16_t m_rnti
C-RNTI scheduled.
Definition: lte-common.h:123
static TypeId GetTypeId(void)
Definition: lte-ue-phy.cc:189
Ptr< LteAmc > m_amc
Definition: lte-ue-phy.h:339
The LtePhy models the physical layer of LTE.
Definition: lte-phy.h:52
void ReportUeMeasurements()
Layer-1 filtering of RSRP and RSRQ measurements and reporting to the RRC entity.
Definition: lte-ue-phy.cc:773
virtual void ReportInterference(const SpectrumValue &interf)
generate a report based on the linear interference and noise power perceived during DATA frame NOTE: ...
Definition: lte-ue-phy.cc:631
virtual void ReceivePhyPdu(Ptr< Packet > p)=0
Called by the Phy to notify the MAC of the reception of a new PHY-PDU.
static Ptr< SpectrumValue > CreateNoisePowerSpectralDensity(uint16_t earfcn, uint8_t bandwidth, double noiseFigure)
create a SpectrumValue that models the power spectral density of AWGN
virtual Ptr< SpectrumValue > CreateTxPowerSpectralDensity()
Create the PSD for the TX.
Definition: lte-ue-phy.cc:442
#define UL_PUSCH_TTIS_DELAY
Definition: lte-common.h:28
Ptr< SpectrumValue > m_noisePsd
Noise power spectral density for the configured bandwidth.
Definition: lte-ue-phy.h:475
void DoSetRnti(uint16_t rnti)
Definition: lte-ue-phy.cc:1285
virtual void SubframeIndication(uint32_t frameNo, uint32_t subframeNo)=0
Trigger the start from a new frame (input from Phy layer)
virtual void ReportUeMeasurements(UeMeasurementsParameters params)=0
Send a report of RSRP and RSRQ values perceived from PSS by the PHY entity (after applying layer-1 fi...
std::vector< HarqProcessInfoElement_t > HarqProcessInfoList_t
Definition: lte-harq-phy.h:47
void SetSubChannelsForReception(std::vector< int > mask)
Get a list of sub channels to use in RX.
Definition: lte-ue-phy.cc:418
The LteUeNetDevice class implements the UE net device.
virtual void DoDispose(void)
Destructor implementation.
Definition: lte-ue-phy.cc:178
Time m_ueMeasurementsFilterPeriod
The UeMeasurementsFilterPeriod attribute.
Definition: lte-ue-phy.h:435