A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 NS_LOG_COMPONENT_DEFINE ("LteUePhy");
45 
46 namespace ns3 {
47 
48 
49 
50 
51 // duration of data portion of UL subframe
52 // = TTI - 1 symbol for SRS - 1ns as margin to avoid overlapping simulator events
53 // (symbol duration in nanoseconds = TTI / 14 (rounded))
54 // in other words, duration of data portion of UL subframe = TTI*(13/14) -1ns
55 static const Time UL_DATA_DURATION = NanoSeconds (1e6 - 71429 - 1);
56 
57 // delay from subframe start to transmission of SRS
58 // = TTI - 1 symbol for SRS
59 static const Time UL_SRS_DELAY_FROM_SUBFRAME_START = NanoSeconds (1e6 - 71429);
60 
61 
62 
63 
65 // member SAP forwarders
67 
68 
70 {
71 public:
73 
74  // inherited from LtePhySapProvider
75  virtual void SendMacPdu (Ptr<Packet> p);
77  virtual void SendRachPreamble (uint32_t prachId, uint32_t raRnti);
78 
79 private:
81 };
82 
84 {
85 
86 }
87 
88 void
90 {
91  m_phy->DoSendMacPdu (p);
92 }
93 
94 void
96 {
98 }
99 
100 void
101 UeMemberLteUePhySapProvider::SendRachPreamble (uint32_t prachId, uint32_t raRnti)
102 {
103  m_phy->DoSendRachPreamble (prachId, raRnti);
104 }
105 
106 
108 // LteUePhy methods
110 
111 static const std::string g_uePhyStateName[LteUePhy::NUM_STATES] =
112 {
113  "CELL_SEARCH",
114  "SYNCHRONIZED"
115 };
116 
117 static inline const std::string & ToString (LteUePhy::State s)
118 {
119  return g_uePhyStateName[s];
120 }
121 
122 
123 NS_OBJECT_ENSURE_REGISTERED (LteUePhy);
124 
125 
127 {
128  NS_LOG_FUNCTION (this);
129  NS_FATAL_ERROR ("This constructor should not be called");
130 }
131 
133  : LtePhy (dlPhy, ulPhy),
134  m_p10CqiPeriocity (MilliSeconds (1)), // ideal behavior
135  m_a30CqiPeriocity (MilliSeconds (1)), // ideal behavior
136  m_uePhySapUser (0),
137  m_ueCphySapUser (0),
138  m_state (CELL_SEARCH),
139  m_subframeNo (0),
140  m_rsReceivedPowerUpdated (false),
141  m_rsInterferencePowerUpdated (false),
142  m_dataInterferencePowerUpdated (false),
143  m_pssReceived (false),
144  m_ueMeasurementsFilterPeriod (MilliSeconds (200)),
145  m_ueMeasurementsFilterLast (MilliSeconds (0)),
146  m_rsrpSinrSampleCounter (0)
147 {
148  m_amc = CreateObject <LteAmc> ();
149  m_powerControl = CreateObject <LteUePowerControl> ();
153 
154  NS_ASSERT_MSG (Simulator::Now ().GetNanoSeconds () == 0,
155  "Cannot create UE devices after simulation started");
158 
159  DoReset ();
160 }
161 
162 
164 {
165  m_txModeGain.clear ();
166 }
167 
168 void
170 {
171  NS_LOG_FUNCTION (this);
172  delete m_uePhySapProvider;
173  delete m_ueCphySapProvider;
175 }
176 
177 
178 
179 TypeId
181 {
182  static TypeId tid = TypeId ("ns3::LteUePhy")
183  .SetParent<LtePhy> ()
184  .AddConstructor<LteUePhy> ()
185  .AddAttribute ("TxPower",
186  "Transmission power in dBm",
187  DoubleValue (10.0),
188  MakeDoubleAccessor (&LteUePhy::SetTxPower,
190  MakeDoubleChecker<double> ())
191  .AddAttribute ("NoiseFigure",
192  "Loss (dB) in the Signal-to-Noise-Ratio due to non-idealities in the receiver."
193  " According to Wikipedia (http://en.wikipedia.org/wiki/Noise_figure), this is "
194  "\"the difference in decibels (dB) between"
195  " the noise output of the actual receiver to the noise output of an "
196  " ideal receiver with the same overall gain and bandwidth when the receivers "
197  " are connected to sources at the standard noise temperature T0.\" "
198  "In this model, we consider T0 = 290K.",
199  DoubleValue (9.0),
200  MakeDoubleAccessor (&LteUePhy::SetNoiseFigure,
202  MakeDoubleChecker<double> ())
203  .AddAttribute ("TxMode1Gain",
204  "Transmission mode 1 gain in dB",
205  DoubleValue (0.0),
206  MakeDoubleAccessor (&LteUePhy::SetTxMode1Gain),
207  MakeDoubleChecker<double> ())
208  .AddAttribute ("TxMode2Gain",
209  "Transmission mode 2 gain in dB",
210  DoubleValue (4.2),
211  MakeDoubleAccessor (&LteUePhy::SetTxMode2Gain),
212  MakeDoubleChecker<double> ())
213  .AddAttribute ("TxMode3Gain",
214  "Transmission mode 3 gain in dB",
215  DoubleValue (-2.8),
216  MakeDoubleAccessor (&LteUePhy::SetTxMode3Gain),
217  MakeDoubleChecker<double> ())
218  .AddAttribute ("TxMode4Gain",
219  "Transmission mode 4 gain in dB",
220  DoubleValue (0.0),
221  MakeDoubleAccessor (&LteUePhy::SetTxMode4Gain),
222  MakeDoubleChecker<double> ())
223  .AddAttribute ("TxMode5Gain",
224  "Transmission mode 5 gain in dB",
225  DoubleValue (0.0),
226  MakeDoubleAccessor (&LteUePhy::SetTxMode5Gain),
227  MakeDoubleChecker<double> ())
228  .AddAttribute ("TxMode6Gain",
229  "Transmission mode 6 gain in dB",
230  DoubleValue (0.0),
231  MakeDoubleAccessor (&LteUePhy::SetTxMode6Gain),
232  MakeDoubleChecker<double> ())
233  .AddAttribute ("TxMode7Gain",
234  "Transmission mode 7 gain in dB",
235  DoubleValue (0.0),
236  MakeDoubleAccessor (&LteUePhy::SetTxMode7Gain),
237  MakeDoubleChecker<double> ())
238  .AddTraceSource ("ReportCurrentCellRsrpSinr",
239  "RSRP and SINR statistics.",
241  .AddAttribute ("RsrpSinrSamplePeriod",
242  "The sampling period for reporting RSRP-SINR stats (default value 1)",
243  UintegerValue (1),
244  MakeUintegerAccessor (&LteUePhy::m_rsrpSinrSamplePeriod),
245  MakeUintegerChecker<uint16_t> ())
246  .AddTraceSource ("UlPhyTransmission",
247  "DL transmission PHY layer statistics.",
249  .AddAttribute ("DlSpectrumPhy",
250  "The downlink LteSpectrumPhy associated to this LtePhy",
252  PointerValue (),
253  MakePointerAccessor (&LteUePhy::GetDlSpectrumPhy),
254  MakePointerChecker <LteSpectrumPhy> ())
255  .AddAttribute ("UlSpectrumPhy",
256  "The uplink LteSpectrumPhy associated to this LtePhy",
258  PointerValue (),
259  MakePointerAccessor (&LteUePhy::GetUlSpectrumPhy),
260  MakePointerChecker <LteSpectrumPhy> ())
261  .AddAttribute ("RsrqUeMeasThreshold",
262  "Receive threshold for PSS on RSRQ [dB]",
263  DoubleValue (-1000.0),
264  MakeDoubleAccessor (&LteUePhy::m_pssReceptionThreshold),
265  MakeDoubleChecker<double> ())
266  .AddAttribute ("UeMeasurementsFilterPeriod",
267  "Time period for reporting UE measurements (default 200 ms.) ",
268  TimeValue (MilliSeconds (200)),
269  MakeTimeAccessor (&LteUePhy::m_ueMeasurementsFilterPeriod),
270  MakeTimeChecker ())
271  .AddTraceSource ("ReportUeMeasurements",
272  "Report UE measurements RSRP (dBm) and RSRQ (dB).",
274  .AddTraceSource ("StateTransition",
275  "Trace fired upon every UE PHY state transition",
277  .AddAttribute ("EnableUplinkPowerControl",
278  "If true Uplink Power Control will be enabled",
279  BooleanValue (true),
280  MakeBooleanAccessor (&LteUePhy::m_enableUplinkPowerControl),
281  MakeBooleanChecker ())
282  ;
283  return tid;
284 }
285 
286 void
288 {
289  NS_LOG_FUNCTION (this);
291 }
292 
293 void
295 {
296  NS_LOG_FUNCTION (this);
297  m_uePhySapUser = s;
298 }
299 
302 {
303  NS_LOG_FUNCTION (this);
304  return (m_uePhySapProvider);
305 }
306 
307 
308 void
310 {
311  NS_LOG_FUNCTION (this);
312  m_ueCphySapUser = s;
313 }
314 
317 {
318  NS_LOG_FUNCTION (this);
319  return (m_ueCphySapProvider);
320 }
321 
322 void
324 {
325  NS_LOG_FUNCTION (this << nf);
326  m_noiseFigure = nf;
327 }
328 
329 double
331 {
332  NS_LOG_FUNCTION (this);
333  return m_noiseFigure;
334 }
335 
336 void
338 {
339  NS_LOG_FUNCTION (this << pow);
340  m_txPower = pow;
341  m_powerControl->SetTxPower (pow);
342 }
343 
344 double
346 {
347  NS_LOG_FUNCTION (this);
348  return m_txPower;
349 }
350 
353 {
354  NS_LOG_FUNCTION (this);
355  return m_powerControl;
356 }
357 
358 uint8_t
360 {
361  return (m_macChTtiDelay);
362 }
363 
366 {
367  return m_downlinkSpectrumPhy;
368 }
369 
372 {
373  return m_uplinkSpectrumPhy;
374 }
375 
376 void
378 {
379  NS_LOG_FUNCTION (this);
380 
381  SetMacPdu (p);
382 }
383 
384 
385 void
387 {
389 }
390 
391 void
393 {
394  NS_LOG_FUNCTION (this);
395 
397 
399  m_uplinkSpectrumPhy->SetTxPowerSpectralDensity (txPsd);
400 }
401 
402 
403 void
404 LteUePhy::SetSubChannelsForReception (std::vector <int> mask)
405 {
406  NS_LOG_FUNCTION (this);
408 }
409 
410 
411 std::vector <int>
413 {
414  NS_LOG_FUNCTION (this);
416 }
417 
418 
419 std::vector <int>
421 {
422  NS_LOG_FUNCTION (this);
424 }
425 
426 
429 {
430  NS_LOG_FUNCTION (this);
431  LteSpectrumValueHelper psdHelper;
433 
434  return psd;
435 }
436 
437 void
439 {
440  NS_LOG_FUNCTION (this);
441 
443  {
445  GenerateMixedCqiReport (mixedSinr);
447  return;
448  }
449 
451  NS_ASSERT (m_cellId > 0);
452 
453  if (m_dlConfigured && m_ulConfigured && (m_rnti > 0))
454  {
455  // check periodic wideband CQI
457  {
458  Ptr<LteUeNetDevice> thisDevice = GetDevice ()->GetObject<LteUeNetDevice> ();
460  if (msg)
461  {
463  }
465  }
466  // check aperiodic high-layer configured subband CQI
468  {
469  Ptr<LteUeNetDevice> thisDevice = GetDevice ()->GetObject<LteUeNetDevice> ();
471  if (msg)
472  {
474  }
476  }
477  }
478 
479  // Generate PHY trace
482  {
483  NS_ASSERT_MSG (m_rsReceivedPowerUpdated, " RS received power info obsolete");
484  // RSRP evaluated as averaged received power among RBs
485  double sum = 0.0;
486  uint8_t rbNum = 0;
487  Values::const_iterator it;
489  {
490  // convert PSD [W/Hz] to linear power [W] for the single RE
491  // we consider only one RE for the RS since the channel is
492  // flat within the same RB
493  double powerTxW = ((*it) * 180000.0) / 12.0;
494  sum += powerTxW;
495  rbNum++;
496  }
497  double rsrp = (rbNum > 0) ? (sum / rbNum) : DBL_MAX;
498  // averaged SINR among RBs
499  sum = 0.0;
500  rbNum = 0;
501  for (it = sinr.ConstValuesBegin (); it != sinr.ConstValuesEnd (); it++)
502  {
503  sum += (*it);
504  rbNum++;
505  }
506  double avSinr = (rbNum > 0) ? (sum / rbNum) : DBL_MAX;
507  NS_LOG_INFO (this << " cellId " << m_cellId << " rnti " << m_rnti << " RSRP " << rsrp << " SINR " << avSinr);
508 
511  }
512 
513  if (m_pssReceived)
514  {
515  // measure instantaneous RSRQ now
516  NS_ASSERT_MSG (m_rsInterferencePowerUpdated, " RS interference power info obsolete");
517 
518  std::list <PssElement>::iterator itPss = m_pssList.begin ();
519  while (itPss != m_pssList.end ())
520  {
521  uint16_t rbNum = 0;
522  double rsrqSum = 0.0;
523 
524  Values::const_iterator itIntN = m_rsInterferencePower.ConstValuesBegin ();
525  Values::const_iterator itPj = m_rsReceivedPower.ConstValuesBegin ();
526  for (itPj = m_rsReceivedPower.ConstValuesBegin ();
528  itIntN++, itPj++)
529  {
530  rbNum++;
531  // convert PSD [W/Hz] to linear power [W] for the single RE
532  double noisePowerTxW = ((*itIntN) * 180000.0) / 12.0;
533  double intPowerTxW = ((*itPj) * 180000.0) / 12.0;
534  rsrqSum += (2 * (noisePowerTxW + intPowerTxW));
535  }
536 
537  NS_ASSERT (rbNum == (*itPss).nRB);
538  double rsrq_dB = 10 * log10 ((*itPss).pssPsdSum / rsrqSum);
539 
540  if (rsrq_dB > m_pssReceptionThreshold)
541  {
542  NS_LOG_INFO (this << " PSS RNTI " << m_rnti << " cellId " << m_cellId
543  << " has RSRQ " << rsrq_dB << " and RBnum " << rbNum);
544  // store measurements
545  std::map <uint16_t, UeMeasurementsElement>::iterator itMeasMap;
546  itMeasMap = m_ueMeasurementsMap.find ((*itPss).cellId);
547  NS_ASSERT (itMeasMap != m_ueMeasurementsMap.end ());
548  (*itMeasMap).second.rsrqSum += rsrq_dB;
549  (*itMeasMap).second.rsrqNum++;
550  }
551 
552  itPss++;
553 
554  } // end of while (itPss != m_pssList.end ())
555 
556  m_pssList.clear ();
557 
558  } // end of if (m_pssReceived)
559 
560 } // end of void LteUePhy::GenerateCtrlCqiReport (const SpectrumValue& sinr)
561 
562 void
564 {
565  // Not used by UE, CQI are based only on RS
566 }
567 
568 void
570 {
571  NS_LOG_FUNCTION (this);
572 
574  NS_ASSERT (m_cellId > 0);
575 
576  if (m_dlConfigured && m_ulConfigured && (m_rnti > 0))
577  {
578  // check periodic wideband CQI
580  {
581  Ptr<LteUeNetDevice> thisDevice = GetDevice ()->GetObject<LteUeNetDevice> ();
583  if (msg)
584  {
586  }
588  }
589  // check aperiodic high-layer configured subband CQI
591  {
592  Ptr<LteUeNetDevice> thisDevice = GetDevice ()->GetObject<LteUeNetDevice> ();
594  if (msg)
595  {
597  }
599  }
600  }
601 
602  // Generate PHY trace
605  {
606  NS_ASSERT_MSG (m_rsReceivedPowerUpdated, " RS received power info obsolete");
607  // RSRP evaluated as averaged received power among RBs
608  double sum = 0.0;
609  uint8_t rbNum = 0;
610  Values::const_iterator it;
612  {
613  // convert PSD [W/Hz] to linear power [W] for the single RE
614  // we consider only one RE for the RS since the channel is
615  // flat within the same RB
616  double powerTxW = ((*it) * 180000.0) / 12.0;
617  sum += powerTxW;
618  rbNum++;
619  }
620  double rsrp = (rbNum > 0) ? (sum / rbNum) : DBL_MAX;
621  // averaged SINR among RBs
622  sum = 0.0;
623  rbNum = 0;
624  for (it = sinr.ConstValuesBegin (); it != sinr.ConstValuesEnd (); it++)
625  {
626  sum += (*it);
627  rbNum++;
628  }
629  double avSinr = (rbNum > 0) ? (sum / rbNum) : DBL_MAX;
630  NS_LOG_INFO (this << " cellId " << m_cellId << " rnti " << m_rnti << " RSRP " << rsrp << " SINR " << avSinr);
631 
634  }
635 
636  if (m_pssReceived)
637  {
638  // measure instantaneous RSRQ now
639  NS_ASSERT_MSG (m_rsInterferencePowerUpdated, " RS interference power info obsolete");
640 
641  std::list <PssElement>::iterator itPss = m_pssList.begin ();
642  while (itPss != m_pssList.end ())
643  {
644  uint16_t rbNum = 0;
645  double rsrqSum = 0.0;
646 
647  Values::const_iterator itIntN = m_rsInterferencePower.ConstValuesBegin ();
648  Values::const_iterator itPj = m_rsReceivedPower.ConstValuesBegin ();
649  for (itPj = m_rsReceivedPower.ConstValuesBegin ();
651  itIntN++, itPj++)
652  {
653  rbNum++;
654  // convert PSD [W/Hz] to linear power [W] for the single RE
655  double noisePowerTxW = ((*itIntN) * 180000.0) / 12.0;
656  double intPowerTxW = ((*itPj) * 180000.0) / 12.0;
657  rsrqSum += (2 * (noisePowerTxW + intPowerTxW));
658  }
659 
660  NS_ASSERT (rbNum == (*itPss).nRB);
661  double rsrq_dB = 10 * log10 ((*itPss).pssPsdSum / rsrqSum);
662 
663  if (rsrq_dB > m_pssReceptionThreshold)
664  {
665  NS_LOG_INFO (this << " PSS RNTI " << m_rnti << " cellId " << m_cellId
666  << " has RSRQ " << rsrq_dB << " and RBnum " << rbNum);
667  // store measurements
668  std::map <uint16_t, UeMeasurementsElement>::iterator itMeasMap;
669  itMeasMap = m_ueMeasurementsMap.find ((*itPss).cellId);
670  NS_ASSERT (itMeasMap != m_ueMeasurementsMap.end ());
671  (*itMeasMap).second.rsrqSum += rsrq_dB;
672  (*itMeasMap).second.rsrqNum++;
673  }
674 
675  itPss++;
676 
677  } // end of while (itPss != m_pssList.end ())
678 
679  m_pssList.clear ();
680 
681  } // end of if (m_pssReceived)
682 
683 }
684 
685 void
687 {
688  NS_LOG_FUNCTION (this << interf);
690  m_rsInterferencePower = interf;
691 }
692 
693 void
695 {
696  NS_LOG_FUNCTION (this << interf);
697 
699  m_dataInterferencePower = interf;
700 }
701 
702 void
704 {
705  NS_LOG_FUNCTION (this << power);
707  m_rsReceivedPower = power;
708 
710  {
711  double sum = 0;
712  uint32_t rbNum = 0;
713  Values::const_iterator it;
715  {
716  double powerTxW = ((*it) * 180000);
717  sum += powerTxW;
718  rbNum++;
719  }
720  double rsrp = 10 * log10 (sum) + 30;
721 
722  NS_LOG_INFO ("RSRP: " << rsrp);
723  m_powerControl->SetRsrp (rsrp);
724  }
725 }
726 
729 {
730  NS_LOG_FUNCTION (this);
731 
732 
733  // apply transmission mode gain
735  SpectrumValue newSinr = sinr;
736  newSinr *= m_txModeGain.at (m_transmissionMode);
737 
738  // CREATE DlCqiLteControlMessage
739  Ptr<DlCqiLteControlMessage> msg = Create<DlCqiLteControlMessage> ();
740  CqiListElement_s dlcqi;
741  std::vector<int> cqi;
743  {
744  cqi = m_amc->CreateCqiFeedbacks (newSinr, m_dlBandwidth);
745 
747  int nbSubChannels = cqi.size ();
748  double cqiSum = 0.0;
749  int activeSubChannels = 0;
750  // average the CQIs of the different RBs
751  for (int i = 0; i < nbSubChannels; i++)
752  {
753  if (cqi.at (i) != -1)
754  {
755  cqiSum += cqi.at (i);
756  activeSubChannels++;
757  }
758  NS_LOG_DEBUG (this << " subch " << i << " cqi " << cqi.at (i));
759  }
760  dlcqi.m_rnti = m_rnti;
761  dlcqi.m_ri = 1; // not yet used
762  dlcqi.m_cqiType = CqiListElement_s::P10; // Peridic CQI using PUCCH wideband
763  NS_ASSERT_MSG (nLayer > 0, " nLayer negative");
764  NS_ASSERT_MSG (nLayer < 3, " nLayer limit is 2s");
765  for (int i = 0; i < nLayer; i++)
766  {
767  if (activeSubChannels > 0)
768  {
769  dlcqi.m_wbCqi.push_back ((uint16_t) cqiSum / activeSubChannels);
770  }
771  else
772  {
773  // approximate with the worst case -> CQI = 1
774  dlcqi.m_wbCqi.push_back (1);
775  }
776  }
777  //NS_LOG_DEBUG (this << " Generate P10 CQI feedback " << (uint16_t) cqiSum / activeSubChannels);
778  dlcqi.m_wbPmi = 0; // not yet used
779  // dl.cqi.m_sbMeasResult others CQI report modes: not yet implemented
780  }
782  {
783  cqi = m_amc->CreateCqiFeedbacks (newSinr, GetRbgSize ());
785  int nbSubChannels = cqi.size ();
786  int rbgSize = GetRbgSize ();
787  double cqiSum = 0.0;
788  int cqiNum = 0;
789  SbMeasResult_s rbgMeas;
790  //NS_LOG_DEBUG (this << " Create A30 CQI feedback, RBG " << rbgSize << " cqiNum " << nbSubChannels << " band " << (uint16_t)m_dlBandwidth);
791  for (int i = 0; i < nbSubChannels; i++)
792  {
793  if (cqi.at (i) != -1)
794  {
795  cqiSum += cqi.at (i);
796  }
797  // else "nothing" no CQI is treated as CQI = 0 (worst case scenario)
798  cqiNum++;
799  if (cqiNum == rbgSize)
800  {
801  // average the CQIs of the different RBGs
802  //NS_LOG_DEBUG (this << " RBG CQI " << (uint16_t) cqiSum / rbgSize);
803  HigherLayerSelected_s hlCqi;
804  hlCqi.m_sbPmi = 0; // not yet used
805  for (int i = 0; i < nLayer; i++)
806  {
807  hlCqi.m_sbCqi.push_back ((uint16_t) cqiSum / rbgSize);
808  }
809  rbgMeas.m_higherLayerSelected.push_back (hlCqi);
810  cqiSum = 0.0;
811  cqiNum = 0;
812  }
813  }
814  dlcqi.m_rnti = m_rnti;
815  dlcqi.m_ri = 1; // not yet used
816  dlcqi.m_cqiType = CqiListElement_s::A30; // Aperidic CQI using PUSCH
817  //dlcqi.m_wbCqi.push_back ((uint16_t) cqiSum / nbSubChannels);
818  dlcqi.m_wbPmi = 0; // not yet used
819  dlcqi.m_sbMeasResult = rbgMeas;
820  }
821 
822  msg->SetDlCqi (dlcqi);
823  return msg;
824 }
825 
826 
827 void
829 {
830  NS_LOG_FUNCTION (this << Simulator::Now ());
831  NS_LOG_DEBUG (this << " Report UE Measurements ");
832 
834 
835  std::map <uint16_t, UeMeasurementsElement>::iterator it;
836  for (it = m_ueMeasurementsMap.begin (); it != m_ueMeasurementsMap.end (); it++)
837  {
838  double avg_rsrp = (*it).second.rsrpSum / (double)(*it).second.rsrpNum;
839  double avg_rsrq = (*it).second.rsrqSum / (double)(*it).second.rsrqNum;
840  /*
841  * In CELL_SEARCH state, this may result in avg_rsrq = 0/0 = -nan.
842  * UE RRC must take this into account when receiving measurement reports.
843  * TODO remove this shortcoming by calculating RSRQ during CELL_SEARCH
844  */
845  NS_LOG_DEBUG (this << " CellId " << (*it).first
846  << " RSRP " << avg_rsrp
847  << " (nSamples " << (uint16_t)(*it).second.rsrpNum << ")"
848  << " RSRQ " << avg_rsrq
849  << " (nSamples " << (uint16_t)(*it).second.rsrqNum << ")");
850 
852  newEl.m_cellId = (*it).first;
853  newEl.m_rsrp = avg_rsrp;
854  newEl.m_rsrq = avg_rsrq;
855  ret.m_ueMeasurementsList.push_back (newEl);
856 
857  // report to UE measurements trace
858  m_reportUeMeasurements (m_rnti, (*it).first, avg_rsrp, avg_rsrq, ((*it).first == m_cellId ? 1 : 0));
859  }
860 
861  // report to RRC
863 
864  m_ueMeasurementsMap.clear ();
866 }
867 
868 void
870 {
871  NS_LOG_FUNCTION (this << msg);
872 
873  SetControlMessages (msg);
874 }
875 
876 void
877 LteUePhy::DoSendRachPreamble (uint32_t raPreambleId, uint32_t raRnti)
878 {
879  NS_LOG_FUNCTION (this << raPreambleId);
880 
881  // unlike other control messages, RACH preamble is sent ASAP
882  Ptr<RachPreambleLteControlMessage> msg = Create<RachPreambleLteControlMessage> ();
883  msg->SetRapId (raPreambleId);
884  m_raPreambleId = raPreambleId;
885  m_raRnti = raRnti;
886  m_controlMessagesQueue.at (0).push_back (msg);
887 }
888 
889 
890 void
892 {
893  NS_LOG_FUNCTION (this);
894 
895  std::list<Ptr<LteControlMessage> >::iterator it;
896  for (it = msgList.begin (); it != msgList.end (); it++)
897  {
898  Ptr<LteControlMessage> msg = (*it);
899 
900  if (msg->GetMessageType () == LteControlMessage::DL_DCI)
901  {
902  Ptr<DlDciLteControlMessage> msg2 = DynamicCast<DlDciLteControlMessage> (msg);
903 
904  DlDciListElement_s dci = msg2->GetDci ();
905  if (dci.m_rnti != m_rnti)
906  {
907  // DCI not for me
908  continue;
909  }
910 
911  if (dci.m_resAlloc != 0)
912  {
913  NS_FATAL_ERROR ("Resource Allocation type not implemented");
914  }
915 
916  std::vector <int> dlRb;
917 
918  // translate the DCI to Spectrum framework
919  uint32_t mask = 0x1;
920  for (int i = 0; i < 32; i++)
921  {
922  if (((dci.m_rbBitmap & mask) >> i) == 1)
923  {
924  for (int k = 0; k < GetRbgSize (); k++)
925  {
926  dlRb.push_back ((i * GetRbgSize ()) + k);
927 // NS_LOG_DEBUG(this << " RNTI " << m_rnti << " RBG " << i << " DL-DCI allocated PRB " << (i*GetRbgSize()) + k);
928  }
929  }
930  mask = (mask << 1);
931  }
933  {
934  m_powerControl->ReportTpc (dci.m_tpc);
935  }
936 
937 
938  // send TB info to LteSpectrumPhy
939  NS_LOG_DEBUG (this << " UE " << m_rnti << " DL-DCI " << dci.m_rnti << " bitmap " << dci.m_rbBitmap);
940  for (uint8_t i = 0; i < dci.m_tbsSize.size (); i++)
941  {
942  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 */);
943  }
944 
946 
947 
948  }
949  else if (msg->GetMessageType () == LteControlMessage::UL_DCI)
950  {
951  // set the uplink bandwidth according to the UL-CQI
952  Ptr<UlDciLteControlMessage> msg2 = DynamicCast<UlDciLteControlMessage> (msg);
953  UlDciListElement_s dci = msg2->GetDci ();
954  if (dci.m_rnti != m_rnti)
955  {
956  // DCI not for me
957  continue;
958  }
959  NS_LOG_INFO (this << " UL DCI");
960  std::vector <int> ulRb;
961  for (int i = 0; i < dci.m_rbLen; i++)
962  {
963  ulRb.push_back (i + dci.m_rbStart);
964  //NS_LOG_DEBUG (this << " UE RB " << i + dci.m_rbStart);
965  }
967  // fire trace of UL Tx PHY stats
968  HarqProcessInfoList_t harqInfoList = m_harqPhyModule->GetHarqProcessInfoUl (m_rnti, 0);
970  params.m_cellId = m_cellId;
971  params.m_imsi = 0; // it will be set by DlPhyTransmissionCallback in LteHelper
973  params.m_rnti = m_rnti;
974  params.m_txMode = 0; // always SISO for UE
975  params.m_layer = 0;
976  params.m_mcs = dci.m_mcs;
977  params.m_size = dci.m_tbSize;
978  params.m_rv = harqInfoList.size ();
979  params.m_ndi = dci.m_ndi;
980  m_ulPhyTransmission (params);
981  // pass the info to the MAC
983  }
984  else if (msg->GetMessageType () == LteControlMessage::RAR)
985  {
986  Ptr<RarLteControlMessage> rarMsg = DynamicCast<RarLteControlMessage> (msg);
987  if (rarMsg->GetRaRnti () == m_raRnti)
988  {
989  for (std::list<RarLteControlMessage::Rar>::const_iterator it = rarMsg->RarListBegin (); it != rarMsg->RarListEnd (); ++it)
990  {
991  if (it->rapId != m_raPreambleId)
992  {
993  // UL grant not for me
994  continue;
995  }
996  else
997  {
998  NS_LOG_INFO ("received RAR RNTI " << m_raRnti);
999  // set the uplink bandwidht according to the UL grant
1000  std::vector <int> ulRb;
1001  for (int i = 0; i < it->rarPayload.m_grant.m_rbLen; i++)
1002  {
1003  ulRb.push_back (i + it->rarPayload.m_grant.m_rbStart);
1004  }
1005 
1007  // pass the info to the MAC
1009  // reset RACH variables with out of range values
1010  m_raPreambleId = 255;
1011  m_raRnti = 11;
1012  }
1013  }
1014  }
1015  }
1016  else if (msg->GetMessageType () == LteControlMessage::MIB)
1017  {
1018  NS_LOG_INFO ("received MIB");
1019  NS_ASSERT (m_cellId > 0);
1020  Ptr<MibLteControlMessage> msg2 = DynamicCast<MibLteControlMessage> (msg);
1022  }
1023  else if (msg->GetMessageType () == LteControlMessage::SIB1)
1024  {
1025  NS_LOG_INFO ("received SIB1");
1026  NS_ASSERT (m_cellId > 0);
1027  Ptr<Sib1LteControlMessage> msg2 = DynamicCast<Sib1LteControlMessage> (msg);
1029  }
1030  else
1031  {
1032  // pass the message to UE-MAC
1034  }
1035 
1036  }
1037 
1038 
1039 }
1040 
1041 
1042 void
1044 {
1045  NS_LOG_FUNCTION (this << cellId << (*p));
1046 
1047  double sum = 0.0;
1048  uint16_t nRB = 0;
1049  Values::const_iterator itPi;
1050  for (itPi = p->ConstValuesBegin (); itPi != p->ConstValuesEnd (); itPi++)
1051  {
1052  // convert PSD [W/Hz] to linear power [W] for the single RE
1053  double powerTxW = ((*itPi) * 180000.0) / 12.0;
1054  sum += powerTxW;
1055  nRB++;
1056  }
1057 
1058  // measure instantaneous RSRP now
1059  double rsrp_dBm = 10 * log10 (1000 * (sum / (double)nRB));
1060  NS_LOG_INFO (this << " PSS RNTI " << m_rnti << " cellId " << m_cellId
1061  << " has RSRP " << rsrp_dBm << " and RBnum " << nRB);
1062  // note that m_pssReceptionThreshold does not apply here
1063 
1064  // store measurements
1065  std::map <uint16_t, UeMeasurementsElement>::iterator itMeasMap = m_ueMeasurementsMap.find (cellId);
1066  if (itMeasMap == m_ueMeasurementsMap.end ())
1067  {
1068  // insert new entry
1069  UeMeasurementsElement newEl;
1070  newEl.rsrpSum = rsrp_dBm;
1071  newEl.rsrpNum = 1;
1072  newEl.rsrqSum = 0;
1073  newEl.rsrqNum = 0;
1074  m_ueMeasurementsMap.insert (std::pair <uint16_t, UeMeasurementsElement> (cellId, newEl));
1075  }
1076  else
1077  {
1078  (*itMeasMap).second.rsrpSum += rsrp_dBm;
1079  (*itMeasMap).second.rsrpNum++;
1080  }
1081 
1082  /*
1083  * Collect the PSS for later processing in GenerateCtrlCqiReport()
1084  * (to be called from ChunkProcessor after RX is finished).
1085  */
1086  m_pssReceived = true;
1087  PssElement el;
1088  el.cellId = cellId;
1089  el.pssPsdSum = sum;
1090  el.nRB = nRB;
1091  m_pssList.push_back (el);
1092 
1093 } // end of void LteUePhy::ReceivePss (uint16_t cellId, Ptr<SpectrumValue> p)
1094 
1095 
1096 void
1098 {
1100 }
1101 
1102 
1103 void
1104 LteUePhy::SubframeIndication (uint32_t frameNo, uint32_t subframeNo)
1105 {
1106  NS_LOG_FUNCTION (this << frameNo << subframeNo);
1107 
1108  NS_ASSERT_MSG (frameNo > 0, "the SRS index check code assumes that frameNo starts at 1");
1109 
1110  // refresh internal variables
1111  m_rsReceivedPowerUpdated = false;
1113  m_pssReceived = false;
1114 
1115  if (m_ulConfigured)
1116  {
1117  // update uplink transmission mask according to previous UL-CQIs
1118  std::vector <int> rbMask = m_subChannelsForTransmissionQueue.at (0);
1120 
1121  // shift the queue
1122  for (uint8_t i = 1; i < m_macChTtiDelay; i++)
1123  {
1125  }
1126  m_subChannelsForTransmissionQueue.at (m_macChTtiDelay-1).clear ();
1127 
1129  {
1130 
1131  NS_ASSERT_MSG (subframeNo > 0 && subframeNo <= 10, "the SRS index check code assumes that subframeNo starts at 1");
1132  if ((((frameNo-1)*10 + (subframeNo-1)) % m_srsPeriodicity) == m_srsSubframeOffset)
1133  {
1134  NS_LOG_INFO ("frame " << frameNo << " subframe " << subframeNo << " sending SRS (offset=" << m_srsSubframeOffset << ", period=" << m_srsPeriodicity << ")");
1137  this);
1138  }
1139  }
1140 
1141  std::list<Ptr<LteControlMessage> > ctrlMsg = GetControlMessages ();
1142  // send packets in queue
1143  NS_LOG_LOGIC (this << " UE - start slot for PUSCH + PUCCH - RNTI " << m_rnti << " CELLID " << m_cellId);
1144  // send the current burts of packets
1146  if (pb)
1147  {
1149  {
1152  }
1153  m_uplinkSpectrumPhy->StartTxDataFrame (pb, ctrlMsg, UL_DATA_DURATION);
1154  }
1155  else
1156  {
1157  // send only PUCCH (ideal: fake null bandwidth signal)
1158  if (ctrlMsg.size ()>0)
1159  {
1160  NS_LOG_LOGIC (this << " UE - start TX PUCCH (NO PUSCH)");
1161  std::vector <int> dlRb;
1162 
1164  {
1166  }
1167 
1169  m_uplinkSpectrumPhy->StartTxDataFrame (pb, ctrlMsg, UL_DATA_DURATION);
1170  }
1171  else
1172  {
1173  NS_LOG_LOGIC (this << " UE - UL NOTHING TO SEND");
1174  }
1175  }
1176  } // m_configured
1177 
1178  // trigger the MAC
1179  m_uePhySapUser->SubframeIndication (frameNo, subframeNo);
1180 
1181  m_subframeNo = subframeNo;
1182  ++subframeNo;
1183  if (subframeNo > 10)
1184  {
1185  ++frameNo;
1186  subframeNo = 1;
1187  }
1188 
1189  // schedule next subframe indication
1190  Simulator::Schedule (Seconds (GetTti ()), &LteUePhy::SubframeIndication, this, frameNo, subframeNo);
1191 }
1192 
1193 
1194 void
1196 {
1197  NS_LOG_FUNCTION (this << " UE " << m_rnti << " start tx SRS, cell Id " << (uint32_t) m_cellId);
1198  NS_ASSERT (m_cellId > 0);
1199  // set the current tx power spectral density (full bandwidth)
1200  std::vector <int> dlRb;
1201  for (uint8_t i = 0; i < m_ulBandwidth; i++)
1202  {
1203  dlRb.push_back (i);
1204  }
1205 
1207  {
1209  }
1210 
1212  m_uplinkSpectrumPhy->StartTxUlSrsFrame ();
1213 }
1214 
1215 
1216 void
1218 {
1219  NS_LOG_FUNCTION (this);
1220 
1221  m_rnti = 0;
1222  m_transmissionMode = 0;
1223  m_srsPeriodicity = 0;
1224  m_srsConfigured = false;
1225  m_dlConfigured = false;
1226  m_ulConfigured = false;
1227  m_raPreambleId = 255; // value out of range
1228  m_raRnti = 11; // value out of range
1232 
1233  m_packetBurstQueue.clear ();
1234  m_controlMessagesQueue.clear ();
1236  for (int i = 0; i < m_macChTtiDelay; i++)
1237  {
1238  Ptr<PacketBurst> pb = CreateObject <PacketBurst> ();
1239  m_packetBurstQueue.push_back (pb);
1240  std::list<Ptr<LteControlMessage> > l;
1241  m_controlMessagesQueue.push_back (l);
1242  }
1243  std::vector <int> ulRb;
1244  m_subChannelsForTransmissionQueue.resize (m_macChTtiDelay, ulRb);
1245 
1247  m_downlinkSpectrumPhy->Reset ();
1248  m_uplinkSpectrumPhy->Reset ();
1249 
1250 } // end of void LteUePhy::DoReset ()
1251 
1252 void
1253 LteUePhy::DoStartCellSearch (uint16_t dlEarfcn)
1254 {
1255  NS_LOG_FUNCTION (this << dlEarfcn);
1256  m_dlEarfcn = dlEarfcn;
1257  DoSetDlBandwidth (6); // configure DL for receiving PSS
1259 }
1260 
1261 void
1262 LteUePhy::DoSynchronizeWithEnb (uint16_t cellId, uint16_t dlEarfcn)
1263 {
1264  NS_LOG_FUNCTION (this << cellId << dlEarfcn);
1265  m_dlEarfcn = dlEarfcn;
1266  DoSynchronizeWithEnb (cellId);
1267 }
1268 
1269 void
1271 {
1272  NS_LOG_FUNCTION (this << cellId);
1273 
1274  if (cellId == 0)
1275  {
1276  NS_FATAL_ERROR ("Cell ID shall not be zero");
1277  }
1278 
1279  m_cellId = cellId;
1280  m_downlinkSpectrumPhy->SetCellId (cellId);
1281  m_uplinkSpectrumPhy->SetCellId (cellId);
1282 
1283  // configure DL for receiving the BCH with the minimum bandwidth
1284  DoSetDlBandwidth (6);
1285 
1286  m_dlConfigured = false;
1287  m_ulConfigured = false;
1288 
1290 }
1291 
1292 void
1293 LteUePhy::DoSetDlBandwidth (uint8_t dlBandwidth)
1294 {
1295  NS_LOG_FUNCTION (this << (uint32_t) dlBandwidth);
1296  if (m_dlBandwidth != dlBandwidth or !m_dlConfigured)
1297  {
1298  m_dlBandwidth = dlBandwidth;
1299 
1300  static const int Type0AllocationRbg[4] = {
1301  10, // RGB size 1
1302  26, // RGB size 2
1303  63, // RGB size 3
1304  110 // RGB size 4
1305  }; // see table 7.1.6.1-1 of 36.213
1306  for (int i = 0; i < 4; i++)
1307  {
1308  if (dlBandwidth < Type0AllocationRbg[i])
1309  {
1310  m_rbgSize = i + 1;
1311  break;
1312  }
1313  }
1314 
1316  m_downlinkSpectrumPhy->SetNoisePowerSpectralDensity (noisePsd);
1317  m_downlinkSpectrumPhy->GetChannel ()->AddRx (m_downlinkSpectrumPhy);
1318  }
1319  m_dlConfigured = true;
1320 }
1321 
1322 
1323 void
1324 LteUePhy::DoConfigureUplink (uint16_t ulEarfcn, uint8_t ulBandwidth)
1325 {
1326  m_ulEarfcn = ulEarfcn;
1327  m_ulBandwidth = ulBandwidth;
1328  m_ulConfigured = true;
1329 }
1330 
1331 void
1332 LteUePhy::DoConfigureReferenceSignalPower (int8_t referenceSignalPower)
1333 {
1334  NS_LOG_FUNCTION (this);
1335  m_powerControl->ConfigureReferenceSignalPower (referenceSignalPower);
1336 }
1337 
1338 void
1339 LteUePhy::DoSetRnti (uint16_t rnti)
1340 {
1341  NS_LOG_FUNCTION (this << rnti);
1342  m_rnti = rnti;
1343 
1346 }
1347 
1348 void
1350 {
1351  NS_LOG_FUNCTION (this << (uint16_t)txMode);
1352  m_transmissionMode = txMode;
1353  m_downlinkSpectrumPhy->SetTransmissionMode (txMode);
1354 }
1355 
1356 void
1358 {
1359  NS_LOG_FUNCTION (this << srcCi);
1362  m_srsConfigured = true;
1363 
1364  // a guard time is needed for the case where the SRS periodicity is changed dynamically at run time
1365  // if we use a static one, we can have a 0ms guard time
1367  NS_LOG_DEBUG (this << " UE SRS P " << m_srsPeriodicity << " RNTI " << m_rnti << " offset " << m_srsSubframeOffset << " cellId " << m_cellId << " CI " << srcCi);
1368 }
1369 
1370 
1371 void
1373 {
1374  SetTxModeGain (1, gain);
1375 }
1376 
1377 void
1379 {
1380  SetTxModeGain (2, gain);
1381 }
1382 
1383 void
1385 {
1386  SetTxModeGain (3, gain);
1387 }
1388 
1389 void
1391 {
1392  SetTxModeGain (4, gain);
1393 }
1394 
1395 void
1397 {
1398  SetTxModeGain (5, gain);
1399 }
1400 
1401 void
1403 {
1404  SetTxModeGain (6, gain);
1405 }
1406 
1407 void
1409 {
1410  SetTxModeGain (7, gain);
1411 }
1412 
1413 
1414 void
1415 LteUePhy::SetTxModeGain (uint8_t txMode, double gain)
1416 {
1417  NS_LOG_FUNCTION (this << gain);
1418  // convert to linear
1419  double gainLin = std::pow (10.0, (gain / 10.0));
1420  if (m_txModeGain.size () < txMode)
1421  {
1422  m_txModeGain.resize (txMode);
1423  }
1424  std::vector <double> temp;
1425  temp = m_txModeGain;
1426  m_txModeGain.clear ();
1427  for (uint8_t i = 0; i < temp.size (); i++)
1428  {
1429  if (i==txMode-1)
1430  {
1431  m_txModeGain.push_back (gainLin);
1432  }
1433  else
1434  {
1435  m_txModeGain.push_back (temp.at (i));
1436  }
1437  }
1438  // forward the info to DL LteSpectrumPhy
1439  m_downlinkSpectrumPhy->SetTxModeGain (txMode, gain);
1440 }
1441 
1442 
1443 
1444 void
1446 {
1447  NS_LOG_FUNCTION (this);
1448  // generate feedback to eNB and send it through ideal PUCCH
1449  Ptr<DlHarqFeedbackLteControlMessage> msg = Create<DlHarqFeedbackLteControlMessage> ();
1450  msg->SetDlHarqFeedback (m);
1451  SetControlMessages (msg);
1452 }
1453 
1454 void
1456 {
1457  m_harqPhyModule = harq;
1458 }
1459 
1460 
1463 {
1464  NS_LOG_FUNCTION (this);
1465  return m_state;
1466 }
1467 
1468 
1469 void
1471 {
1472  NS_LOG_FUNCTION (this << newState);
1473  State oldState = m_state;
1474  m_state = newState;
1475  NS_LOG_INFO (this << " cellId=" << m_cellId << " rnti=" << m_rnti
1476  << " UePhy " << ToString (oldState)
1477  << " --> " << ToString (newState));
1478  m_stateTransitionTrace (m_cellId, m_rnti, oldState, newState);
1479 }
1480 
1481 
1482 } // 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:330
void SetTxPower(double value)
Ptr< LteSpectrumPhy > GetUlSpectrumPhy() const
Definition: lte-ue-phy.cc:371
uint16_t m_srsConfigured
Definition: lte-ue-phy.h:314
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
Definition: lte-phy.h:221
See section 4.3.25 sbMeasResult.
Hold a bool native type.
Definition: boolean.h:38
double m_txPower
Definition: lte-phy.h:220
std::vector< struct UeMeasurementsElement > m_ueMeasurementsList
uint16_t m_dlEarfcn
Definition: lte-phy.h:228
virtual void GenerateMixedCqiReport(const SpectrumValue &sinr)
Definition: lte-ue-phy.cc:569
LteUePhySapUser * m_uePhySapUser
Definition: lte-ue-phy.h:302
void SetTxMode5Gain(double gain)
Definition: lte-ue-phy.cc:1396
void SetCellId(uint16_t cellId)
virtual void SendMacPdu(Ptr< Packet > p)
Send the MAC PDU to the channel.
Definition: lte-ue-phy.cc:89
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register the class in the ns-3 factory.
Definition: object-base.h:38
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:563
std::list< PssElement > m_pssList
Definition: lte-ue-phy.h:342
void SetTxMode2Gain(double gain)
Definition: lte-ue-phy.cc:1378
bool m_ulConfigured
Definition: lte-ue-phy.h:318
uint8_t GetMacChDelay(void) const
Definition: lte-ue-phy.cc:359
void DoConfigureUplink(uint16_t ulEarfcn, uint8_t ulBandwidth)
Definition: lte-ue-phy.cc:1324
std::vector< Ptr< PacketBurst > > m_packetBurstQueue
Definition: lte-phy.h:231
std::vector< int > GetSubChannelsForTransmission(void)
Get a list of sub channels to use in RX.
Definition: lte-ue-phy.cc:412
virtual void GenerateCtrlCqiReport(const SpectrumValue &sinr)
generate a CQI report based on the given SINR of Ctrl frame
Definition: lte-ue-phy.cc:438
TracedCallback< uint16_t, uint16_t, double, double > m_reportCurrentCellRsrpSinrTrace
Trace information regarding RSRP and average SINR (see TS 36.214) uint16_t cellId, uint16_t rnti, double rsrp, double sinr.
Definition: lte-ue-phy.h:367
Time m_a30CqiLast
Definition: lte-ue-phy.h:299
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:392
uint16_t GetSrsPeriodicity(uint16_t srcCi) const
Definition: lte-phy.cc:147
double GetTti(void) const
Definition: lte-phy.cc:139
LteUePhySapProvider * m_uePhySapProvider
Definition: lte-ue-phy.h:301
#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:1402
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:170
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:853
Ptr< LteSpectrumPhy > m_downlinkSpectrumPhy
Definition: lte-phy.h:217
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:95
See section 4.3.24 cqiListElement.
std::vector< double > m_txModeGain
Definition: lte-ue-phy.h:310
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:223
#define NS_FATAL_ERROR(msg)
fatal error handling
Definition: fatal-error.h:95
SpectrumValue m_dataInterferencePower
Definition: lte-ue-phy.h:333
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:825
void QueueSubChannelsForTransmission(std::vector< int > rbMap)
Definition: lte-ue-phy.cc:1097
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:1415
Ptr< LteUePowerControl > m_powerControl
Definition: lte-ue-phy.h:291
virtual void DoSendMacPdu(Ptr< Packet > p)
Queue the MAC PDU to be sent (according to m_macChTtiDelay)
Definition: lte-ue-phy.cc:377
std::vector< int > GetSubChannelsForReception(void)
Get a list of sub channels to use in RX.
Definition: lte-ue-phy.cc:420
This class defines all functions to create spectrum model for lte.
uint8_t m_transmissionMode
Definition: lte-ue-phy.h:309
EventId m_sendSrsEvent
Definition: lte-ue-phy.h:377
void SetHarqPhyModule(Ptr< LteHarqPhy > harq)
Set the HARQ PHY module.
Definition: lte-ue-phy.cc:1455
Ptr< LteNetDevice > GetDevice()
Get the device where the phy layer is attached.
Definition: lte-phy.cc:97
uint8_t m_ulBandwidth
Definition: lte-phy.h:224
bool m_pssReceived
Definition: lte-ue-phy.h:335
void DoSetSrsConfigurationIndex(uint16_t srcCi)
Definition: lte-ue-phy.cc:1357
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Definition: time.cc:444
State
The states of the UE PHY entity.
Definition: lte-ue-phy.h:61
static const int Type0AllocationRbg[4]
void DoSetTransmissionMode(uint8_t txMode)
Definition: lte-ue-phy.cc:1349
The attribute can be read.
Definition: type-id.h:56
UeMemberLteUePhySapProvider(LteUePhy *phy)
Definition: lte-ue-phy.cc:83
Template for the implementation of the LteUeCphySapProvider as a member of an owner class of type C t...
double m_pssReceptionThreshold
Definition: lte-ue-phy.h:344
TracedCallback< uint16_t, uint16_t, double, double, bool > m_reportUeMeasurements
Trace information regarding RSRP and RSRQ (see TS 36.214) uint16_t rnti, uint16_t cellId...
Definition: lte-ue-phy.h:375
uint16_t GetSrsSubframeOffset(uint16_t srcCi) const
Definition: lte-phy.cc:165
void DoSynchronizeWithEnb(uint16_t cellId)
Definition: lte-ue-phy.cc:1270
LteUeCphySapUser * m_ueCphySapUser
Definition: lte-ue-phy.h:305
void DoSetDlBandwidth(uint8_t ulBandwidth)
Definition: lte-ue-phy.cc:1293
void DoDispose()
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
Definition: lte-phy.cc:75
Attribute for objects of type ns3::Time.
Definition: nstime.h:912
uint8_t GetRbgSize(void) const
Definition: lte-phy.cc:183
uint16_t m_rsrpSinrSamplePeriod
Definition: lte-ue-phy.h:368
Time NanoSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:869
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:294
Hold an unsigned integer type.
Definition: uinteger.h:46
void DoConfigureReferenceSignalPower(int8_t referenceSignalPower)
Definition: lte-ue-phy.cc:1332
void SetTxMode3Gain(double gain)
Definition: lte-ue-phy.cc:1384
static uint8_t TxMode2LayerNum(uint8_t txMode)
Definition: lte-common.cc:170
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:728
void SetTxMode4Gain(double gain)
Definition: lte-ue-phy.cc:1390
void SwitchToState(State s)
Definition: lte-ue-phy.cc:1470
TracedCallback< uint16_t, uint16_t, State, State > m_stateTransitionTrace
Definition: lte-ue-phy.h:322
void SendSrs()
Send the SRS signal in the last symbols of the frame.
Definition: lte-ue-phy.cc:1195
uint16_t m_ulEarfcn
Definition: lte-phy.h:229
bool m_rsInterferencePowerUpdated
Definition: lte-ue-phy.h:329
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:233
std::vector< uint8_t > m_sbCqi
void SetTxMode7Gain(double gain)
Definition: lte-ue-phy.cc:1408
Ptr< LteUePowerControl > GetUplinkPowerControl() const
Definition: lte-ue-phy.cc:352
#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.
virtual void DoSendRachPreamble(uint32_t prachId, uint32_t raRnti)
Definition: lte-ue-phy.cc:877
uint8_t m_mcs
MCS for transport block.
Definition: lte-common.h:126
virtual void ReportDataInterference(const SpectrumValue &interf)
Definition: lte-ue-phy.cc:694
virtual void ReceiveLteDlHarqFeedback(DlInfoListElement_s mes)
PhySpectrum generated a new DL HARQ feedback.
Definition: lte-ue-phy.cc:1445
bool m_enableUplinkPowerControl
Definition: lte-ue-phy.h:290
uint8_t m_macChTtiDelay
Definition: lte-phy.h:233
static const Time UL_DATA_DURATION
Definition: lte-ue-phy.cc:55
Ptr< LteHarqPhy > m_harqPhyModule
Definition: lte-ue-phy.h:358
hold objects of type Ptr
Definition: pointer.h:33
void DoStartCellSearch(uint16_t dlEarfcn)
Definition: lte-ue-phy.cc:1253
void SetControlMessages(Ptr< LteControlMessage > m)
Definition: lte-phy.cc:214
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
uint16_t m_rsrpSinrSampleCounter
Definition: lte-ue-phy.h:369
SpectrumValue m_rsReceivedPower
Definition: lte-ue-phy.h:327
double GetTxPower() const
Definition: lte-ue-phy.cc:345
uint16_t m_srsSubframeOffset
Definition: lte-ue-phy.h:313
Time m_srsStartTime
Definition: lte-ue-phy.h:315
uint8_t m_dlBandwidth
Definition: lte-phy.h:225
uint8_t m_subframeNo
Definition: lte-ue-phy.h:324
static EventId ScheduleNow(MEM mem_ptr, OBJ obj)
Schedule an event to expire Now.
Definition: simulator.h:986
uint16_t m_size
Size of transport block.
Definition: lte-common.h:127
static Time Now(void)
Return the "current simulation time".
Definition: simulator.cc:180
uint16_t m_cellId
Definition: lte-phy.h:235
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:1104
virtual void DoInitialize(void)
This method is called only once by Object::Initialize.
Definition: lte-ue-phy.cc:287
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
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:1372
std::vector< int > m_subChannelsForTransmission
Definition: lte-ue-phy.h:282
Time m_p10CqiPeriocity
Wideband Periodic CQI: 2, 5, 10, 16, 20, 32, 40, 64, 80 or 160 ms.
Definition: lte-ue-phy.h:293
uint32_t m_raRnti
Definition: lte-ue-phy.h:361
bool m_dlConfigured
Definition: lte-ue-phy.h:317
std::vector< std::vector< int > > m_subChannelsForTransmissionQueue
Definition: lte-ue-phy.h:285
std::list< Ptr< LteControlMessage > > GetControlMessages(void)
Definition: lte-phy.cc:222
static const std::string & ToString(EpcUeNas::State s)
Definition: epc-ue-nas.cc:47
Time m_a30CqiPeriocity
Definition: lte-ue-phy.h:298
LteUeCphySapProvider * m_ueCphySapProvider
Definition: lte-ue-phy.h:304
std::map< uint16_t, UeMeasurementsElement > m_ueMeasurementsMap
Definition: lte-ue-phy.h:354
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]
Definition: lte-ue-phy.cc:111
std::vector< int > m_subChannelsForReception
Definition: lte-ue-phy.h:283
Service Access Point (SAP) offered by the UE-PHY to the UE-MAC.
static const Time UL_SRS_DELAY_FROM_SUBFRAME_START
Definition: lte-ue-phy.cc:59
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:213
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:845
virtual void ReceiveLteControlMessageList(std::list< Ptr< LteControlMessage > >)
Definition: lte-ue-phy.cc:891
void SetTxPower(double pow)
Definition: lte-ue-phy.cc:337
virtual void ReceivePss(uint16_t cellId, Ptr< SpectrumValue > p)
Definition: lte-ue-phy.cc:1043
double GetPucchTxPower(std::vector< int > rb)
uint16_t m_srsPeriodicity
Definition: lte-ue-phy.h:312
LteUePhySapProvider * GetLteUePhySapProvider()
Get the PHY SAP provider.
Definition: lte-ue-phy.cc:301
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::cancel method.
Definition: event-id.cc:47
virtual void SendRachPreamble(uint32_t prachId, uint32_t raRnti)
send a preamble on the PRACH
Definition: lte-ue-phy.cc:101
State GetState() const
Definition: lte-ue-phy.cc:1462
uint32_t m_raPreambleId
Definition: lte-ue-phy.h:360
uint8_t m_rbgSize
Definition: lte-phy.h:226
void SetLteUeCphySapUser(LteUeCphySapUser *s)
Set the CPHY SAP User.
Definition: lte-ue-phy.cc:309
SpectrumValue m_rsInterferencePower
Definition: lte-ue-phy.h:330
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:386
Values::const_iterator ConstValuesBegin() const
virtual void DoSendLteControlMessage(Ptr< LteControlMessage > msg)
Definition: lte-ue-phy.cc:869
std::vector< std::list< Ptr< LteControlMessage > > > m_controlMessagesQueue
Definition: lte-phy.h:232
bool m_rsReceivedPowerUpdated
Definition: lte-ue-phy.h:326
void ConfigureReferenceSignalPower(int8_t referenceSignalPower)
virtual ~LteUePhy()
Definition: lte-ue-phy.cc:163
The LteSpectrumPhy models the physical layer of LTE.
Definition: lte-ue-phy.h:51
Ptr< LteSpectrumPhy > GetDlSpectrumPhy() const
Definition: lte-ue-phy.cc:365
Ptr< LteSpectrumPhy > m_uplinkSpectrumPhy
Definition: lte-phy.h:218
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:703
Time m_p10CqiLast
SubBand Aperiodic CQI: activated by DCI format 0 or Random Access Response Grant. ...
Definition: lte-ue-phy.h:294
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:316
Hold a floating point type.
Definition: double.h:41
Set of values corresponding to a given SpectrumModel.
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:49
uint16_t m_rnti
Definition: lte-ue-phy.h:307
int64_t GetMilliSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:326
TypeId SetParent(TypeId tid)
Definition: type-id.cc:610
bool m_dataInterferencePowerUpdated
Definition: lte-ue-phy.h:332
void SetNoiseFigure(double nf)
Definition: lte-ue-phy.cc:323
virtual void DoInitialize(void)
This method is called only once by Object::Initialize.
Definition: object.cc:342
TracedCallback< PhyTransmissionStatParameters > m_ulPhyTransmission
Trace information regarding PHY stats from DL Tx perspective PhyTrasmissionStatParameters see lte-com...
Definition: lte-ue-phy.h:383
uint16_t m_rnti
C-RNTI scheduled.
Definition: lte-common.h:123
static TypeId GetTypeId(void)
Definition: lte-ue-phy.cc:180
Ptr< LteAmc > m_amc
Definition: lte-ue-phy.h:288
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:828
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:686
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:428
#define UL_PUSCH_TTIS_DELAY
Definition: lte-common.h:28
void DoSetRnti(uint16_t rnti)
Definition: lte-ue-phy.cc:1339
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:404
The LteUeNetDevice class implements the UE net device.
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
Definition: lte-ue-phy.cc:169
Time m_ueMeasurementsFilterPeriod
Definition: lte-ue-phy.h:355