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"
39 #include <ns3/lte-common.h>
40 #include <ns3/pointer.h>
41 
42 NS_LOG_COMPONENT_DEFINE ("LteUePhy");
43 
44 namespace ns3 {
45 
46 
47 
48 
49 // duration of data portion of UL subframe
50 // = TTI - 1 symbol for SRS - 1ns as margin to avoid overlapping simulator events
51 // (symbol duration in nanoseconds = TTI / 14 (rounded))
52 // in other words, duration of data portion of UL subframe = TTI*(13/14) -1ns
53 static const Time UL_DATA_DURATION = NanoSeconds (1e6 - 71429 - 1);
54 
55 // delay from subframe start to transmission of SRS
56 // = TTI - 1 symbol for SRS
57 static const Time UL_SRS_DELAY_FROM_SUBFRAME_START = NanoSeconds (1e6 - 71429);
58 
59 
60 
61 
63 // member SAP forwarders
65 
66 
68 {
69 public:
71 
72  // inherited from LtePhySapProvider
73  virtual void SendMacPdu (Ptr<Packet> p);
75  virtual void SendRachPreamble (uint32_t prachId, uint32_t raRnti);
76 
77 private:
79 };
80 
82 {
83 
84 }
85 
86 void
88 {
89  m_phy->DoSendMacPdu (p);
90 }
91 
92 void
94 {
96 }
97 
98 void
99 UeMemberLteUePhySapProvider::SendRachPreamble (uint32_t prachId, uint32_t raRnti)
100 {
101  m_phy->DoSendRachPreamble (prachId, raRnti);
102 }
103 
104 
106 // LteUePhy methods
108 
109 static const std::string g_uePhyStateName[LteUePhy::NUM_STATES] =
110 {
111  "CELL_SEARCH",
112  "SYNCHRONIZED"
113 };
114 
115 static inline const std::string & ToString (LteUePhy::State s)
116 {
117  return g_uePhyStateName[s];
118 }
119 
120 
121 NS_OBJECT_ENSURE_REGISTERED (LteUePhy);
122 
123 
125 {
126  NS_LOG_FUNCTION (this);
127  NS_FATAL_ERROR ("This constructor should not be called");
128 }
129 
131  : LtePhy (dlPhy, ulPhy),
132  m_p10CqiPeriocity (MilliSeconds (1)), // ideal behavior
133  m_a30CqiPeriocity (MilliSeconds (1)), // ideal behavior
134  m_uePhySapUser (0),
135  m_ueCphySapUser (0),
136  m_state (CELL_SEARCH),
137  m_subframeNo (0),
138  m_rsReceivedPowerUpdated (false),
139  m_rsInterferencePowerUpdated (false),
140  m_pssReceived (false),
141  m_ueMeasurementsFilterPeriod (MilliSeconds (200)),
142  m_ueMeasurementsFilterLast (MilliSeconds (0)),
143  m_rsrpSinrSampleCounter (0)
144 {
145  m_amc = CreateObject <LteAmc> ();
149 
150  NS_ASSERT_MSG (Simulator::Now ().GetNanoSeconds () == 0,
151  "Cannot create UE devices after simulation started");
154 
155  DoReset ();
156 }
157 
158 
160 {
161  m_txModeGain.clear ();
162 }
163 
164 void
166 {
167  NS_LOG_FUNCTION (this);
168  delete m_uePhySapProvider;
169  delete m_ueCphySapProvider;
171 }
172 
173 
174 
175 TypeId
177 {
178  static TypeId tid = TypeId ("ns3::LteUePhy")
179  .SetParent<LtePhy> ()
180  .AddConstructor<LteUePhy> ()
181  .AddAttribute ("TxPower",
182  "Transmission power in dBm",
183  DoubleValue (10.0),
184  MakeDoubleAccessor (&LteUePhy::SetTxPower,
186  MakeDoubleChecker<double> ())
187  .AddAttribute ("NoiseFigure",
188  "Loss (dB) in the Signal-to-Noise-Ratio due to non-idealities in the receiver."
189  " According to Wikipedia (http://en.wikipedia.org/wiki/Noise_figure), this is "
190  "\"the difference in decibels (dB) between"
191  " the noise output of the actual receiver to the noise output of an "
192  " ideal receiver with the same overall gain and bandwidth when the receivers "
193  " are connected to sources at the standard noise temperature T0.\" "
194  "In this model, we consider T0 = 290K.",
195  DoubleValue (9.0),
196  MakeDoubleAccessor (&LteUePhy::SetNoiseFigure,
198  MakeDoubleChecker<double> ())
199  .AddAttribute ("TxMode1Gain",
200  "Transmission mode 1 gain in dB",
201  DoubleValue (0.0),
202  MakeDoubleAccessor (&LteUePhy::SetTxMode1Gain),
203  MakeDoubleChecker<double> ())
204  .AddAttribute ("TxMode2Gain",
205  "Transmission mode 2 gain in dB",
206  DoubleValue (4.2),
207  MakeDoubleAccessor (&LteUePhy::SetTxMode2Gain),
208  MakeDoubleChecker<double> ())
209  .AddAttribute ("TxMode3Gain",
210  "Transmission mode 3 gain in dB",
211  DoubleValue (-2.8),
212  MakeDoubleAccessor (&LteUePhy::SetTxMode3Gain),
213  MakeDoubleChecker<double> ())
214  .AddAttribute ("TxMode4Gain",
215  "Transmission mode 4 gain in dB",
216  DoubleValue (0.0),
217  MakeDoubleAccessor (&LteUePhy::SetTxMode4Gain),
218  MakeDoubleChecker<double> ())
219  .AddAttribute ("TxMode5Gain",
220  "Transmission mode 5 gain in dB",
221  DoubleValue (0.0),
222  MakeDoubleAccessor (&LteUePhy::SetTxMode5Gain),
223  MakeDoubleChecker<double> ())
224  .AddAttribute ("TxMode6Gain",
225  "Transmission mode 6 gain in dB",
226  DoubleValue (0.0),
227  MakeDoubleAccessor (&LteUePhy::SetTxMode6Gain),
228  MakeDoubleChecker<double> ())
229  .AddAttribute ("TxMode7Gain",
230  "Transmission mode 7 gain in dB",
231  DoubleValue (0.0),
232  MakeDoubleAccessor (&LteUePhy::SetTxMode7Gain),
233  MakeDoubleChecker<double> ())
234  .AddTraceSource ("ReportCurrentCellRsrpSinr",
235  "RSRP and SINR statistics.",
237  .AddAttribute ("RsrpSinrSamplePeriod",
238  "The sampling period for reporting RSRP-SINR stats (default value 1)",
239  UintegerValue (1),
240  MakeUintegerAccessor (&LteUePhy::m_rsrpSinrSamplePeriod),
241  MakeUintegerChecker<uint16_t> ())
242  .AddTraceSource ("UlPhyTransmission",
243  "DL transmission PHY layer statistics.",
245  .AddAttribute ("DlSpectrumPhy",
246  "The downlink LteSpectrumPhy associated to this LtePhy",
248  PointerValue (),
249  MakePointerAccessor (&LteUePhy::GetDlSpectrumPhy),
250  MakePointerChecker <LteSpectrumPhy> ())
251  .AddAttribute ("UlSpectrumPhy",
252  "The uplink LteSpectrumPhy associated to this LtePhy",
254  PointerValue (),
255  MakePointerAccessor (&LteUePhy::GetUlSpectrumPhy),
256  MakePointerChecker <LteSpectrumPhy> ())
257  .AddAttribute ("RsrqUeMeasThreshold",
258  "Receive threshold for PSS on RSRQ [dB]",
259  DoubleValue (-1000.0),
260  MakeDoubleAccessor (&LteUePhy::m_pssReceptionThreshold),
261  MakeDoubleChecker<double> ())
262  .AddAttribute ("UeMeasurementsFilterPeriod",
263  "Time period for reporting UE measurements (default 200 ms.) ",
264  TimeValue (MilliSeconds (200)),
265  MakeTimeAccessor (&LteUePhy::m_ueMeasurementsFilterPeriod),
266  MakeTimeChecker ())
267  .AddTraceSource ("ReportUeMeasurements",
268  "Report UE measurements RSRP (dBm) and RSRQ (dB).",
270  .AddTraceSource ("StateTransition",
271  "Trace fired upon every UE PHY state transition",
273  ;
274  return tid;
275 }
276 
277 void
279 {
280  NS_LOG_FUNCTION (this);
282 }
283 
284 void
286 {
287  NS_LOG_FUNCTION (this);
288  m_uePhySapUser = s;
289 }
290 
293 {
294  NS_LOG_FUNCTION (this);
295  return (m_uePhySapProvider);
296 }
297 
298 
299 void
301 {
302  NS_LOG_FUNCTION (this);
303  m_ueCphySapUser = s;
304 }
305 
308 {
309  NS_LOG_FUNCTION (this);
310  return (m_ueCphySapProvider);
311 }
312 
313 void
315 {
316  NS_LOG_FUNCTION (this << nf);
317  m_noiseFigure = nf;
318 }
319 
320 double
322 {
323  NS_LOG_FUNCTION (this);
324  return m_noiseFigure;
325 }
326 
327 void
329 {
330  NS_LOG_FUNCTION (this << pow);
331  m_txPower = pow;
332 }
333 
334 double
336 {
337  NS_LOG_FUNCTION (this);
338  return m_txPower;
339 }
340 
341 
342 uint8_t
344 {
345  return (m_macChTtiDelay);
346 }
347 
350 {
351  return m_downlinkSpectrumPhy;
352 }
353 
356 {
357  return m_uplinkSpectrumPhy;
358 }
359 
360 void
362 {
363  NS_LOG_FUNCTION (this);
364 
365  SetMacPdu (p);
366 }
367 
368 
369 void
371 {
373 }
374 
375 void
377 {
378  NS_LOG_FUNCTION (this);
379 
381 
383  m_uplinkSpectrumPhy->SetTxPowerSpectralDensity (txPsd);
384 }
385 
386 
387 void
388 LteUePhy::SetSubChannelsForReception (std::vector <int> mask)
389 {
390  NS_LOG_FUNCTION (this);
392 }
393 
394 
395 std::vector <int>
397 {
398  NS_LOG_FUNCTION (this);
400 }
401 
402 
403 std::vector <int>
405 {
406  NS_LOG_FUNCTION (this);
408 }
409 
410 
413 {
414  NS_LOG_FUNCTION (this);
415  LteSpectrumValueHelper psdHelper;
417 
418  return psd;
419 }
420 
421 void
423 {
424  NS_LOG_FUNCTION (this);
425 
427  NS_ASSERT (m_cellId > 0);
428 
429  if (m_dlConfigured && m_ulConfigured && (m_rnti > 0))
430  {
431  // check periodic wideband CQI
433  {
434  Ptr<LteUeNetDevice> thisDevice = GetDevice ()->GetObject<LteUeNetDevice> ();
436  if (msg)
437  {
439  }
441  }
442  // check aperiodic high-layer configured subband CQI
444  {
445  Ptr<LteUeNetDevice> thisDevice = GetDevice ()->GetObject<LteUeNetDevice> ();
447  if (msg)
448  {
450  }
452  }
453  }
454 
455  // Generate PHY trace
458  {
459  NS_ASSERT_MSG (m_rsReceivedPowerUpdated, " RS received power info obsolete");
460  // RSRP evaluated as averaged received power among RBs
461  double sum = 0.0;
462  uint8_t rbNum = 0;
463  Values::const_iterator it;
465  {
466  // convert PSD [W/Hz] to linear power [W] for the single RE
467  // we consider only one RE for the RS since the channel is
468  // flat within the same RB
469  double powerTxW = ((*it) * 180000.0) / 12.0;
470  sum += powerTxW;
471  rbNum++;
472  }
473  double rsrp = (rbNum > 0) ? (sum / rbNum) : DBL_MAX;
474  // averaged SINR among RBs
475  sum = 0.0;
476  rbNum = 0;
477  for (it = sinr.ConstValuesBegin (); it != sinr.ConstValuesEnd (); it++)
478  {
479  sum += (*it);
480  rbNum++;
481  }
482  double avSinr = (rbNum > 0) ? (sum / rbNum) : DBL_MAX;
483  NS_LOG_INFO (this << " cellId " << m_cellId << " rnti " << m_rnti << " RSRP " << rsrp << " SINR " << avSinr);
484 
487  }
488 
489  if (m_pssReceived)
490  {
491  // measure instantaneous RSRQ now
492  NS_ASSERT_MSG (m_rsInterferencePowerUpdated, " RS interference power info obsolete");
493 
494  std::list <PssElement>::iterator itPss = m_pssList.begin ();
495  while (itPss != m_pssList.end ())
496  {
497  uint16_t rbNum = 0;
498  double rsrqSum = 0.0;
499 
500  Values::const_iterator itIntN = m_rsInterferencePower.ConstValuesBegin ();
501  Values::const_iterator itPj = m_rsReceivedPower.ConstValuesBegin ();
502  for (itPj = m_rsReceivedPower.ConstValuesBegin ();
504  itIntN++, itPj++)
505  {
506  rbNum++;
507  // convert PSD [W/Hz] to linear power [W] for the single RE
508  double noisePowerTxW = ((*itIntN) * 180000.0) / 12.0;
509  double intPowerTxW = ((*itPj) * 180000.0) / 12.0;
510  rsrqSum += (2 * (noisePowerTxW + intPowerTxW));
511  }
512 
513  NS_ASSERT (rbNum == (*itPss).nRB);
514  double rsrq_dB = 10 * log10 ((*itPss).pssPsdSum / rsrqSum);
515 
516  if (rsrq_dB > m_pssReceptionThreshold)
517  {
518  NS_LOG_INFO (this << " PSS RNTI " << m_rnti << " cellId " << m_cellId
519  << " has RSRQ " << rsrq_dB << " and RBnum " << rbNum);
520  // store measurements
521  std::map <uint16_t, UeMeasurementsElement>::iterator itMeasMap;
522  itMeasMap = m_ueMeasurementsMap.find ((*itPss).cellId);
523  NS_ASSERT (itMeasMap != m_ueMeasurementsMap.end ());
524  (*itMeasMap).second.rsrqSum += rsrq_dB;
525  (*itMeasMap).second.rsrqNum++;
526  }
527 
528  itPss++;
529 
530  } // end of while (itPss != m_pssList.end ())
531 
532  m_pssList.clear ();
533 
534  } // end of if (m_pssReceived)
535 
536 } // end of void LteUePhy::GenerateCtrlCqiReport (const SpectrumValue& sinr)
537 
538 void
540 {
541  // Not used by UE, CQI are based only on RS
542 }
543 
544 void
546 {
547  NS_LOG_FUNCTION (this << interf);
549  m_rsInterferencePower = interf;
550 }
551 
552 void
554 {
555  NS_LOG_FUNCTION (this << power);
557  m_rsReceivedPower = power;
558 }
559 
560 
561 
564 {
565  NS_LOG_FUNCTION (this);
566 
567 
568  // apply transmission mode gain
570  SpectrumValue newSinr = sinr;
571  newSinr *= m_txModeGain.at (m_transmissionMode);
572 
573  // CREATE DlCqiLteControlMessage
574  Ptr<DlCqiLteControlMessage> msg = Create<DlCqiLteControlMessage> ();
575  CqiListElement_s dlcqi;
576  std::vector<int> cqi;
578  {
579  cqi = m_amc->CreateCqiFeedbacks (newSinr, m_dlBandwidth);
580 
582  int nbSubChannels = cqi.size ();
583  double cqiSum = 0.0;
584  int activeSubChannels = 0;
585  // average the CQIs of the different RBs
586  for (int i = 0; i < nbSubChannels; i++)
587  {
588  if (cqi.at (i) != -1)
589  {
590  cqiSum += cqi.at (i);
591  activeSubChannels++;
592  }
593  NS_LOG_DEBUG (this << " subch " << i << " cqi " << cqi.at (i));
594  }
595  dlcqi.m_rnti = m_rnti;
596  dlcqi.m_ri = 1; // not yet used
597  dlcqi.m_cqiType = CqiListElement_s::P10; // Peridic CQI using PUCCH wideband
598  NS_ASSERT_MSG (nLayer > 0, " nLayer negative");
599  NS_ASSERT_MSG (nLayer < 3, " nLayer limit is 2s");
600  for (int i = 0; i < nLayer; i++)
601  {
602  if (activeSubChannels > 0)
603  {
604  dlcqi.m_wbCqi.push_back ((uint16_t) cqiSum / activeSubChannels);
605  }
606  else
607  {
608  // approximate with the worst case -> CQI = 1
609  dlcqi.m_wbCqi.push_back (1);
610  }
611  }
612  //NS_LOG_DEBUG (this << " Generate P10 CQI feedback " << (uint16_t) cqiSum / activeSubChannels);
613  dlcqi.m_wbPmi = 0; // not yet used
614  // dl.cqi.m_sbMeasResult others CQI report modes: not yet implemented
615  }
617  {
618  cqi = m_amc->CreateCqiFeedbacks (newSinr, GetRbgSize ());
620  int nbSubChannels = cqi.size ();
621  int rbgSize = GetRbgSize ();
622  double cqiSum = 0.0;
623  int cqiNum = 0;
624  SbMeasResult_s rbgMeas;
625  //NS_LOG_DEBUG (this << " Create A30 CQI feedback, RBG " << rbgSize << " cqiNum " << nbSubChannels << " band " << (uint16_t)m_dlBandwidth);
626  for (int i = 0; i < nbSubChannels; i++)
627  {
628  if (cqi.at (i) != -1)
629  {
630  cqiSum += cqi.at (i);
631  }
632  // else "nothing" no CQI is treated as CQI = 0 (worst case scenario)
633  cqiNum++;
634  if (cqiNum == rbgSize)
635  {
636  // average the CQIs of the different RBGs
637  //NS_LOG_DEBUG (this << " RBG CQI " << (uint16_t) cqiSum / rbgSize);
638  HigherLayerSelected_s hlCqi;
639  hlCqi.m_sbPmi = 0; // not yet used
640  for (int i = 0; i < nLayer; i++)
641  {
642  hlCqi.m_sbCqi.push_back ((uint16_t) cqiSum / rbgSize);
643  }
644  rbgMeas.m_higherLayerSelected.push_back (hlCqi);
645  cqiSum = 0.0;
646  cqiNum = 0;
647  }
648  }
649  dlcqi.m_rnti = m_rnti;
650  dlcqi.m_ri = 1; // not yet used
651  dlcqi.m_cqiType = CqiListElement_s::A30; // Aperidic CQI using PUSCH
652  //dlcqi.m_wbCqi.push_back ((uint16_t) cqiSum / nbSubChannels);
653  dlcqi.m_wbPmi = 0; // not yet used
654  dlcqi.m_sbMeasResult = rbgMeas;
655  }
656 
657  msg->SetDlCqi (dlcqi);
658  return msg;
659 }
660 
661 
662 void
664 {
665  NS_LOG_FUNCTION (this << Simulator::Now ());
666  NS_LOG_DEBUG (this << " Report UE Measurements ");
667 
669 
670  std::map <uint16_t, UeMeasurementsElement>::iterator it;
671  for (it = m_ueMeasurementsMap.begin (); it != m_ueMeasurementsMap.end (); it++)
672  {
673  double avg_rsrp = (*it).second.rsrpSum / (double)(*it).second.rsrpNum;
674  double avg_rsrq = (*it).second.rsrqSum / (double)(*it).second.rsrqNum;
675  /*
676  * In CELL_SEARCH state, this may result in avg_rsrq = 0/0 = -nan.
677  * UE RRC must take this into account when receiving measurement reports.
678  * TODO remove this shortcoming by calculating RSRQ during CELL_SEARCH
679  */
680  NS_LOG_DEBUG (this << " CellId " << (*it).first
681  << " RSRP " << avg_rsrp
682  << " (nSamples " << (uint16_t)(*it).second.rsrpNum << ")"
683  << " RSRQ " << avg_rsrq
684  << " (nSamples " << (uint16_t)(*it).second.rsrqNum << ")");
685 
687  newEl.m_cellId = (*it).first;
688  newEl.m_rsrp = avg_rsrp;
689  newEl.m_rsrq = avg_rsrq;
690  ret.m_ueMeasurementsList.push_back (newEl);
691 
692  // report to UE measurements trace
693  m_reportUeMeasurements (m_rnti, (*it).first, avg_rsrp, avg_rsrq, ((*it).first == m_cellId ? 1 : 0));
694  }
695 
696  // report to RRC
698 
699  m_ueMeasurementsMap.clear ();
701 }
702 
703 void
705 {
706  NS_LOG_FUNCTION (this << msg);
707 
708  SetControlMessages (msg);
709 }
710 
711 void
712 LteUePhy::DoSendRachPreamble (uint32_t raPreambleId, uint32_t raRnti)
713 {
714  NS_LOG_FUNCTION (this << raPreambleId);
715 
716  // unlike other control messages, RACH preamble is sent ASAP
717  Ptr<RachPreambleLteControlMessage> msg = Create<RachPreambleLteControlMessage> ();
718  msg->SetRapId (raPreambleId);
719  m_raPreambleId = raPreambleId;
720  m_raRnti = raRnti;
721  m_controlMessagesQueue.at (0).push_back (msg);
722 }
723 
724 
725 void
727 {
728  NS_LOG_FUNCTION (this);
729 
730  std::list<Ptr<LteControlMessage> >::iterator it;
731  for (it = msgList.begin (); it != msgList.end(); it++)
732  {
733  Ptr<LteControlMessage> msg = (*it);
734 
735  if (msg->GetMessageType () == LteControlMessage::DL_DCI)
736  {
737  Ptr<DlDciLteControlMessage> msg2 = DynamicCast<DlDciLteControlMessage> (msg);
738 
739  DlDciListElement_s dci = msg2->GetDci ();
740  if (dci.m_rnti != m_rnti)
741  {
742  // DCI not for me
743  continue;
744  }
745 
746  if (dci.m_resAlloc != 0)
747  {
748  NS_FATAL_ERROR ("Resource Allocation type not implemented");
749  }
750 
751  std::vector <int> dlRb;
752 
753  // translate the DCI to Spectrum framework
754  uint32_t mask = 0x1;
755  for (int i = 0; i < 32; i++)
756  {
757  if (((dci.m_rbBitmap & mask) >> i) == 1)
758  {
759  for (int k = 0; k < GetRbgSize (); k++)
760  {
761  dlRb.push_back ((i * GetRbgSize ()) + k);
762 // NS_LOG_DEBUG(this << " RNTI " << m_rnti << " RBG " << i << " DL-DCI allocated PRB " << (i*GetRbgSize()) + k);
763  }
764  }
765  mask = (mask << 1);
766  }
767 
768  // send TB info to LteSpectrumPhy
769  NS_LOG_DEBUG (this << " UE " << m_rnti << " DL-DCI " << dci.m_rnti << " bitmap " << dci.m_rbBitmap);
770  for (uint8_t i = 0; i < dci.m_tbsSize.size (); i++)
771  {
772  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 */);
773  }
774 
776 
777 
778  }
779  else if (msg->GetMessageType () == LteControlMessage::UL_DCI)
780  {
781  // set the uplink bandwidth according to the UL-CQI
782  Ptr<UlDciLteControlMessage> msg2 = DynamicCast<UlDciLteControlMessage> (msg);
783  UlDciListElement_s dci = msg2->GetDci ();
784  if (dci.m_rnti != m_rnti)
785  {
786  // DCI not for me
787  continue;
788  }
789  NS_LOG_INFO (this << " UL DCI");
790  std::vector <int> ulRb;
791  for (int i = 0; i < dci.m_rbLen; i++)
792  {
793  ulRb.push_back (i + dci.m_rbStart);
794  //NS_LOG_DEBUG (this << " UE RB " << i + dci.m_rbStart);
795  }
797  // fire trace of UL Tx PHY stats
798  HarqProcessInfoList_t harqInfoList = m_harqPhyModule->GetHarqProcessInfoUl (m_rnti, 0);
800  params.m_cellId = m_cellId;
801  params.m_imsi = 0; // it will be set by DlPhyTransmissionCallback in LteHelper
803  params.m_rnti = m_rnti;
804  params.m_txMode = 0; // always SISO for UE
805  params.m_layer = 0;
806  params.m_mcs = dci.m_mcs;
807  params.m_size = dci.m_tbSize;
808  params.m_rv = harqInfoList.size ();
809  params.m_ndi = dci.m_ndi;
810  m_ulPhyTransmission (params);
811  // pass the info to the MAC
813  }
814  else if (msg->GetMessageType () == LteControlMessage::RAR)
815  {
816  Ptr<RarLteControlMessage> rarMsg = DynamicCast<RarLteControlMessage> (msg);
817  if (rarMsg->GetRaRnti () == m_raRnti)
818  {
819  for (std::list<RarLteControlMessage::Rar>::const_iterator it = rarMsg->RarListBegin (); it != rarMsg->RarListEnd (); ++it)
820  {
821  if (it->rapId != m_raPreambleId)
822  {
823  // UL grant not for me
824  continue;
825  }
826  else
827  {
828  NS_LOG_INFO ("received RAR RNTI " << m_raRnti);
829  // set the uplink bandwidht according to the UL grant
830  std::vector <int> ulRb;
831  for (int i = 0; i < it->rarPayload.m_grant.m_rbLen; i++)
832  {
833  ulRb.push_back (i + it->rarPayload.m_grant.m_rbStart);
834  }
835 
837  // pass the info to the MAC
839  // reset RACH variables with out of range values
840  m_raPreambleId = 255;
841  m_raRnti = 11;
842  }
843  }
844  }
845  }
846  else if (msg->GetMessageType () == LteControlMessage::MIB)
847  {
848  NS_LOG_INFO ("received MIB");
849  NS_ASSERT (m_cellId > 0);
850  Ptr<MibLteControlMessage> msg2 = DynamicCast<MibLteControlMessage> (msg);
852  }
853  else if (msg->GetMessageType () == LteControlMessage::SIB1)
854  {
855  NS_LOG_INFO ("received SIB1");
856  NS_ASSERT (m_cellId > 0);
857  Ptr<Sib1LteControlMessage> msg2 = DynamicCast<Sib1LteControlMessage> (msg);
859  }
860  else
861  {
862  // pass the message to UE-MAC
864  }
865 
866  }
867 
868 
869 }
870 
871 
872 void
874 {
875  NS_LOG_FUNCTION (this << cellId << (*p));
876 
877  double sum = 0.0;
878  uint16_t nRB = 0;
879  Values::const_iterator itPi;
880  for (itPi = p->ConstValuesBegin (); itPi != p->ConstValuesEnd (); itPi++)
881  {
882  // convert PSD [W/Hz] to linear power [W] for the single RE
883  double powerTxW = ((*itPi) * 180000.0) / 12.0;
884  sum += powerTxW;
885  nRB++;
886  }
887 
888  // measure instantaneous RSRP now
889  double rsrp_dBm = 10 * log10 (1000 * (sum / (double)nRB));
890  NS_LOG_INFO (this << " PSS RNTI " << m_rnti << " cellId " << m_cellId
891  << " has RSRP " << rsrp_dBm << " and RBnum " << nRB);
892  // note that m_pssReceptionThreshold does not apply here
893 
894  // store measurements
895  std::map <uint16_t, UeMeasurementsElement>::iterator itMeasMap = m_ueMeasurementsMap.find (cellId);
896  if (itMeasMap == m_ueMeasurementsMap.end ())
897  {
898  // insert new entry
899  UeMeasurementsElement newEl;
900  newEl.rsrpSum = rsrp_dBm;
901  newEl.rsrpNum = 1;
902  newEl.rsrqSum = 0;
903  newEl.rsrqNum = 0;
904  m_ueMeasurementsMap.insert (std::pair <uint16_t, UeMeasurementsElement> (cellId, newEl));
905  }
906  else
907  {
908  (*itMeasMap).second.rsrpSum += rsrp_dBm;
909  (*itMeasMap).second.rsrpNum++;
910  }
911 
912  /*
913  * Collect the PSS for later processing in GenerateCtrlCqiReport()
914  * (to be called from ChunkProcessor after RX is finished).
915  */
916  m_pssReceived = true;
917  PssElement el;
918  el.cellId = cellId;
919  el.pssPsdSum = sum;
920  el.nRB = nRB;
921  m_pssList.push_back (el);
922 
923 } // end of void LteUePhy::ReceivePss (uint16_t cellId, Ptr<SpectrumValue> p)
924 
925 
926 void
928 {
930 }
931 
932 
933 void
934 LteUePhy::SubframeIndication (uint32_t frameNo, uint32_t subframeNo)
935 {
936  NS_LOG_FUNCTION (this << frameNo << subframeNo);
937 
938  NS_ASSERT_MSG (frameNo > 0, "the SRS index check code assumes that frameNo starts at 1");
939 
940  // refresh internal variables
941  m_rsReceivedPowerUpdated = false;
943  m_pssReceived = false;
944 
945  if (m_ulConfigured)
946  {
947  // update uplink transmission mask according to previous UL-CQIs
949 
950  // shift the queue
951  for (uint8_t i = 1; i < m_macChTtiDelay; i++)
952  {
954  }
955  m_subChannelsForTransmissionQueue.at (m_macChTtiDelay-1).clear ();
956 
958  {
959 
960  NS_ASSERT_MSG (subframeNo > 0 && subframeNo <= 10, "the SRS index check code assumes that subframeNo starts at 1");
961  if ((((frameNo-1)*10 + (subframeNo-1)) % m_srsPeriodicity) == m_srsSubframeOffset)
962  {
963  NS_LOG_INFO ("frame " << frameNo << " subframe " << subframeNo << " sending SRS (offset=" << m_srsSubframeOffset << ", period=" << m_srsPeriodicity << ")");
966  this);
967  }
968  }
969 
970  std::list<Ptr<LteControlMessage> > ctrlMsg = GetControlMessages ();
971  // send packets in queue
972  NS_LOG_LOGIC (this << " UE - start slot for PUSCH + PUCCH - RNTI " << m_rnti << " CELLID " << m_cellId);
973  // send the current burts of packets
975  if (pb)
976  {
977  m_uplinkSpectrumPhy->StartTxDataFrame (pb, ctrlMsg, UL_DATA_DURATION);
978  }
979  else
980  {
981  // send only PUCCH (ideal: fake null bandwidth signal)
982  if (ctrlMsg.size ()>0)
983  {
984  NS_LOG_LOGIC (this << " UE - start TX PUCCH (NO PUSCH)");
985  std::vector <int> dlRb;
987  m_uplinkSpectrumPhy->StartTxDataFrame (pb, ctrlMsg, UL_DATA_DURATION);
988  }
989  else
990  {
991  NS_LOG_LOGIC (this << " UE - UL NOTHING TO SEND");
992  }
993  }
994  } // m_configured
995 
996  // trigger the MAC
997  m_uePhySapUser->SubframeIndication (frameNo, subframeNo);
998 
999  m_subframeNo = subframeNo;
1000  ++subframeNo;
1001  if (subframeNo > 10)
1002  {
1003  ++frameNo;
1004  subframeNo = 1;
1005  }
1006 
1007  // schedule next subframe indication
1008  Simulator::Schedule (Seconds (GetTti ()), &LteUePhy::SubframeIndication, this, frameNo, subframeNo);
1009 }
1010 
1011 
1012 void
1014 {
1015  NS_LOG_FUNCTION (this << " UE " << m_rnti << " start tx SRS, cell Id " << (uint32_t) m_cellId);
1016  NS_ASSERT (m_cellId > 0);
1017  // set the current tx power spectral density (full bandwidth)
1018  std::vector <int> dlRb;
1019  for (uint8_t i = 0; i < m_ulBandwidth; i++)
1020  {
1021  dlRb.push_back (i);
1022  }
1024  m_uplinkSpectrumPhy->StartTxUlSrsFrame ();
1025 }
1026 
1027 
1028 void
1030 {
1031  NS_LOG_FUNCTION (this);
1032 
1033  m_rnti = 0;
1034  m_transmissionMode = 0;
1035  m_srsPeriodicity = 0;
1036  m_srsConfigured = false;
1037  m_dlConfigured = false;
1038  m_ulConfigured = false;
1039  m_raPreambleId = 255; // value out of range
1040  m_raRnti = 11; // value out of range
1044 
1045  m_packetBurstQueue.clear ();
1046  m_controlMessagesQueue.clear ();
1048  for (int i = 0; i < m_macChTtiDelay; i++)
1049  {
1050  Ptr<PacketBurst> pb = CreateObject <PacketBurst> ();
1051  m_packetBurstQueue.push_back (pb);
1052  std::list<Ptr<LteControlMessage> > l;
1053  m_controlMessagesQueue.push_back (l);
1054  }
1055  std::vector <int> ulRb;
1056  m_subChannelsForTransmissionQueue.resize (m_macChTtiDelay, ulRb);
1057 
1059  m_downlinkSpectrumPhy->Reset ();
1060  m_uplinkSpectrumPhy->Reset ();
1061 
1062 } // end of void LteUePhy::DoReset ()
1063 
1064 void
1065 LteUePhy::DoStartCellSearch (uint16_t dlEarfcn)
1066 {
1067  NS_LOG_FUNCTION (this << dlEarfcn);
1068  m_dlEarfcn = dlEarfcn;
1069  DoSetDlBandwidth (6); // configure DL for receiving PSS
1071 }
1072 
1073 void
1074 LteUePhy::DoSynchronizeWithEnb (uint16_t cellId, uint16_t dlEarfcn)
1075 {
1076  NS_LOG_FUNCTION (this << cellId << dlEarfcn);
1077  m_dlEarfcn = dlEarfcn;
1078  DoSynchronizeWithEnb (cellId);
1079 }
1080 
1081 void
1083 {
1084  NS_LOG_FUNCTION (this << cellId);
1085 
1086  if (cellId == 0)
1087  {
1088  NS_FATAL_ERROR ("Cell ID shall not be zero");
1089  }
1090 
1091  m_cellId = cellId;
1092  m_downlinkSpectrumPhy->SetCellId (cellId);
1093  m_uplinkSpectrumPhy->SetCellId (cellId);
1094 
1095  // configure DL for receiving the BCH with the minimum bandwidth
1096  DoSetDlBandwidth (6);
1097 
1098  m_dlConfigured = false;
1099  m_ulConfigured = false;
1100 
1102 }
1103 
1104 void
1105 LteUePhy::DoSetDlBandwidth (uint8_t dlBandwidth)
1106 {
1107  NS_LOG_FUNCTION (this << (uint32_t) dlBandwidth);
1108  if (m_dlBandwidth != dlBandwidth or !m_dlConfigured)
1109  {
1110  m_dlBandwidth = dlBandwidth;
1111 
1112  static const int Type0AllocationRbg[4] = {
1113  10, // RGB size 1
1114  26, // RGB size 2
1115  63, // RGB size 3
1116  110 // RGB size 4
1117  }; // see table 7.1.6.1-1 of 36.213
1118  for (int i = 0; i < 4; i++)
1119  {
1120  if (dlBandwidth < Type0AllocationRbg[i])
1121  {
1122  m_rbgSize = i + 1;
1123  break;
1124  }
1125  }
1126 
1128  m_downlinkSpectrumPhy->SetNoisePowerSpectralDensity (noisePsd);
1129  m_downlinkSpectrumPhy->GetChannel ()->AddRx (m_downlinkSpectrumPhy);
1130  }
1131  m_dlConfigured = true;
1132 }
1133 
1134 
1135 void
1136 LteUePhy::DoConfigureUplink (uint16_t ulEarfcn, uint8_t ulBandwidth)
1137 {
1138  m_ulEarfcn = ulEarfcn;
1139  m_ulBandwidth = ulBandwidth;
1140  m_ulConfigured = true;
1141 }
1142 
1143 
1144 void
1145 LteUePhy::DoSetRnti (uint16_t rnti)
1146 {
1147  NS_LOG_FUNCTION (this << rnti);
1148  m_rnti = rnti;
1149 }
1150 
1151 void
1153 {
1154  NS_LOG_FUNCTION (this << (uint16_t)txMode);
1155  m_transmissionMode = txMode;
1156  m_downlinkSpectrumPhy->SetTransmissionMode (txMode);
1157 }
1158 
1159 void
1161 {
1162  NS_LOG_FUNCTION (this << srcCi);
1165  m_srsConfigured = true;
1166 
1167  // a guard time is needed for the case where the SRS periodicity is changed dynamically at run time
1168  // if we use a static one, we can have a 0ms guard time
1169  m_srsStartTime = Simulator::Now () + MilliSeconds (0);
1170  NS_LOG_DEBUG (this << " UE SRS P " << m_srsPeriodicity << " RNTI " << m_rnti << " offset " << m_srsSubframeOffset << " cellId " << m_cellId << " CI " << srcCi);
1171 }
1172 
1173 
1174 void
1176 {
1177  SetTxModeGain (1, gain);
1178 }
1179 
1180 void
1182 {
1183  SetTxModeGain (2, gain);
1184 }
1185 
1186 void
1188 {
1189  SetTxModeGain (3, gain);
1190 }
1191 
1192 void
1194 {
1195  SetTxModeGain (4, gain);
1196 }
1197 
1198 void
1200 {
1201  SetTxModeGain (5, gain);
1202 }
1203 
1204 void
1206 {
1207  SetTxModeGain (6, gain);
1208 }
1209 
1210 void
1212 {
1213  SetTxModeGain (7, gain);
1214 }
1215 
1216 
1217 void
1218 LteUePhy::SetTxModeGain (uint8_t txMode, double gain)
1219 {
1220  NS_LOG_FUNCTION (this << gain);
1221  // convert to linear
1222  double gainLin = std::pow (10.0, (gain / 10.0));
1223  if (m_txModeGain.size () < txMode)
1224  {
1225  m_txModeGain.resize (txMode);
1226  }
1227  std::vector <double> temp;
1228  temp = m_txModeGain;
1229  m_txModeGain.clear ();
1230  for (uint8_t i = 0; i < temp.size (); i++)
1231  {
1232  if (i==txMode-1)
1233  {
1234  m_txModeGain.push_back (gainLin);
1235  }
1236  else
1237  {
1238  m_txModeGain.push_back (temp.at (i));
1239  }
1240  }
1241  // forward the info to DL LteSpectrumPhy
1242  m_downlinkSpectrumPhy->SetTxModeGain (txMode, gain);
1243 }
1244 
1245 
1246 
1247 void
1249 {
1250  NS_LOG_FUNCTION (this);
1251  // generate feedback to eNB and send it through ideal PUCCH
1252  Ptr<DlHarqFeedbackLteControlMessage> msg = Create<DlHarqFeedbackLteControlMessage> ();
1253  msg->SetDlHarqFeedback (m);
1254  SetControlMessages (msg);
1255 }
1256 
1257 void
1259 {
1260  m_harqPhyModule = harq;
1261 }
1262 
1263 
1266 {
1267  NS_LOG_FUNCTION (this);
1268  return m_state;
1269 }
1270 
1271 
1272 void
1274 {
1275  NS_LOG_FUNCTION (this << newState);
1276  State oldState = m_state;
1277  m_state = newState;
1278  NS_LOG_INFO (this << " cellId=" << m_cellId << " rnti=" << m_rnti
1279  << " UePhy " << ToString (oldState)
1280  << " --> " << ToString (newState));
1281  m_stateTransitionTrace (m_cellId, m_rnti, oldState, newState);
1282 }
1283 
1284 
1285 } // 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:321
Ptr< LteSpectrumPhy > GetUlSpectrumPhy() const
Definition: lte-ue-phy.cc:355
uint16_t m_srsConfigured
Definition: lte-ue-phy.h:301
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:79
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.
double m_txPower
Definition: lte-phy.h:220
std::vector< struct UeMeasurementsElement > m_ueMeasurementsList
uint16_t m_dlEarfcn
Definition: lte-phy.h:228
LteUePhySapUser * m_uePhySapUser
Definition: lte-ue-phy.h:289
void SetTxMode5Gain(double gain)
Definition: lte-ue-phy.cc:1199
virtual void SendMacPdu(Ptr< Packet > p)
Send the MAC PDU to the channel.
Definition: lte-ue-phy.cc:87
#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:539
std::list< PssElement > m_pssList
Definition: lte-ue-phy.h:326
void SetTxMode2Gain(double gain)
Definition: lte-ue-phy.cc:1181
bool m_ulConfigured
Definition: lte-ue-phy.h:305
uint8_t GetMacChDelay(void) const
Definition: lte-ue-phy.cc:343
void DoConfigureUplink(uint16_t ulEarfcn, uint8_t ulBandwidth)
Definition: lte-ue-phy.cc:1136
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:396
virtual void GenerateCtrlCqiReport(const SpectrumValue &sinr)
generate a CQI report based on the given SINR of Ctrl frame
Definition: lte-ue-phy.cc:422
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:351
Time m_a30CqiLast
Definition: lte-ue-phy.h:286
void SetSubChannelsForTransmission(std::vector< int > mask)
Set a list of sub channels to use in TX.
Definition: lte-ue-phy.cc:376
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:288
#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:1205
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:170
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:93
See section 4.3.24 cqiListElement.
std::vector< double > m_txModeGain
Definition: lte-ue-phy.h:297
#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
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:927
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:1218
virtual void DoSendMacPdu(Ptr< Packet > p)
Queue the MAC PDU to be sent (according to m_macChTtiDelay)
Definition: lte-ue-phy.cc:361
std::vector< int > GetSubChannelsForReception(void)
Get a list of sub channels to use in RX.
Definition: lte-ue-phy.cc:404
This class defines all functions to create spectrum model for lte.
uint8_t m_transmissionMode
Definition: lte-ue-phy.h:296
EventId m_sendSrsEvent
Definition: lte-ue-phy.h:361
void SetHarqPhyModule(Ptr< LteHarqPhy > harq)
Set the HARQ PHY module.
Definition: lte-ue-phy.cc:1258
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:319
void DoSetSrsConfigurationIndex(uint16_t srcCi)
Definition: lte-ue-phy.cc:1160
State
The states of the UE PHY entity.
Definition: lte-ue-phy.h:60
static const int Type0AllocationRbg[4]
void DoSetTransmissionMode(uint8_t txMode)
Definition: lte-ue-phy.cc:1152
The attribute can be read.
Definition: type-id.h:56
UeMemberLteUePhySapProvider(LteUePhy *phy)
Definition: lte-ue-phy.cc:81
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:328
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:359
uint16_t GetSrsSubframeOffset(uint16_t srcCi) const
Definition: lte-phy.cc:165
void DoSynchronizeWithEnb(uint16_t cellId)
Definition: lte-ue-phy.cc:1082
LteUeCphySapUser * m_ueCphySapUser
Definition: lte-ue-phy.h:292
void DoSetDlBandwidth(uint8_t ulBandwidth)
Definition: lte-ue-phy.cc:1105
void DoDispose()
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
Definition: lte-phy.cc:75
hold objects of type ns3::Time
Definition: nstime.h:1008
uint8_t GetRbgSize(void) const
Definition: lte-phy.cc:183
uint16_t m_rsrpSinrSamplePeriod
Definition: lte-ue-phy.h:352
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:285
Hold an unsigned integer type.
Definition: uinteger.h:46
void SetTxMode3Gain(double gain)
Definition: lte-ue-phy.cc:1187
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:563
void SetTxMode4Gain(double gain)
Definition: lte-ue-phy.cc:1193
void SwitchToState(State s)
Definition: lte-ue-phy.cc:1273
TracedCallback< uint16_t, uint16_t, State, State > m_stateTransitionTrace
Definition: lte-ue-phy.h:309
void SendSrs()
Send the SRS signal in the last symbols of the frame.
Definition: lte-ue-phy.cc:1013
uint16_t m_ulEarfcn
Definition: lte-phy.h:229
bool m_rsInterferencePowerUpdated
Definition: lte-ue-phy.h:316
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:1211
#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:712
uint8_t m_mcs
MCS for transport block.
Definition: lte-common.h:126
virtual void ReceiveLteDlHarqFeedback(DlInfoListElement_s mes)
PhySpectrum generated a new DL HARQ feedback.
Definition: lte-ue-phy.cc:1248
uint8_t m_macChTtiDelay
Definition: lte-phy.h:233
static const Time UL_DATA_DURATION
Definition: lte-ue-phy.cc:53
Ptr< LteHarqPhy > m_harqPhyModule
Definition: lte-ue-phy.h:342
hold objects of type Ptr
Definition: pointer.h:33
void DoStartCellSearch(uint16_t dlEarfcn)
Definition: lte-ue-phy.cc:1065
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:353
SpectrumValue m_rsReceivedPower
Definition: lte-ue-phy.h:314
double GetTxPower() const
Definition: lte-ue-phy.cc:335
uint16_t m_srsSubframeOffset
Definition: lte-ue-phy.h:300
Time m_srsStartTime
Definition: lte-ue-phy.h:302
uint8_t m_dlBandwidth
Definition: lte-phy.h:225
uint8_t m_subframeNo
Definition: lte-ue-phy.h:311
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:934
virtual void DoInitialize(void)
This method is called only once by Object::Initialize.
Definition: lte-ue-phy.cc:278
#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:1175
std::vector< int > m_subChannelsForTransmission
Definition: lte-ue-phy.h:272
Time m_p10CqiPeriocity
Wideband Periodic CQI: 2, 5, 10, 16, 20, 32, 40, 64, 80 or 160 ms.
Definition: lte-ue-phy.h:280
uint32_t m_raRnti
Definition: lte-ue-phy.h:345
bool m_dlConfigured
Definition: lte-ue-phy.h:304
std::vector< std::vector< int > > m_subChannelsForTransmissionQueue
Definition: lte-ue-phy.h:275
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:285
LteUeCphySapProvider * m_ueCphySapProvider
Definition: lte-ue-phy.h:291
std::map< uint16_t, UeMeasurementsElement > m_ueMeasurementsMap
Definition: lte-ue-phy.h:338
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:109
std::vector< int > m_subChannelsForReception
Definition: lte-ue-phy.h:273
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:57
#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
virtual void ReceiveLteControlMessageList(std::list< Ptr< LteControlMessage > >)
Definition: lte-ue-phy.cc:726
void SetTxPower(double pow)
Definition: lte-ue-phy.cc:328
virtual void ReceivePss(uint16_t cellId, Ptr< SpectrumValue > p)
Definition: lte-ue-phy.cc:873
uint16_t m_srsPeriodicity
Definition: lte-ue-phy.h:299
LteUePhySapProvider * GetLteUePhySapProvider()
Get the PHY SAP provider.
Definition: lte-ue-phy.cc:292
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:99
State GetState() const
Definition: lte-ue-phy.cc:1265
uint32_t m_raPreambleId
Definition: lte-ue-phy.h:344
uint8_t m_rbgSize
Definition: lte-phy.h:226
void SetLteUeCphySapUser(LteUeCphySapUser *s)
Set the CPHY SAP User.
Definition: lte-ue-phy.cc:300
SpectrumValue m_rsInterferencePower
Definition: lte-ue-phy.h:317
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Definition: time.cc:441
friend class UeMemberLteUePhySapProvider
Definition: lte-ue-phy.h:53
void PhyPduReceived(Ptr< Packet > p)
PhySpectrum received a new PHY-PDU.
Definition: lte-ue-phy.cc:370
Values::const_iterator ConstValuesBegin() const
virtual void DoSendLteControlMessage(Ptr< LteControlMessage > msg)
Definition: lte-ue-phy.cc:704
std::vector< std::list< Ptr< LteControlMessage > > > m_controlMessagesQueue
Definition: lte-phy.h:232
bool m_rsReceivedPowerUpdated
Definition: lte-ue-phy.h:313
virtual ~LteUePhy()
Definition: lte-ue-phy.cc:159
The LteSpectrumPhy models the physical layer of LTE.
Definition: lte-ue-phy.h:50
Ptr< LteSpectrumPhy > GetDlSpectrumPhy() const
Definition: lte-ue-phy.cc:349
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:553
Time m_p10CqiLast
SubBand Aperiodic CQI: activated by DCI format 0 or Random Access Response Grant. ...
Definition: lte-ue-phy.h:281
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:307
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:294
int64_t GetMilliSeconds(void) const
Definition: nstime.h:281
TypeId SetParent(TypeId tid)
Definition: type-id.cc:610
void SetNoiseFigure(double nf)
Definition: lte-ue-phy.cc:314
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:367
uint16_t m_rnti
C-RNTI scheduled.
Definition: lte-common.h:123
static TypeId GetTypeId(void)
Definition: lte-ue-phy.cc:176
Ptr< LteAmc > m_amc
Definition: lte-ue-phy.h:278
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:663
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:545
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:412
#define UL_PUSCH_TTIS_DELAY
Definition: lte-common.h:28
void DoSetRnti(uint16_t rnti)
Definition: lte-ue-phy.cc:1145
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:388
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:165
Time m_ueMeasurementsFilterPeriod
Definition: lte-ue-phy.h:339