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