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