23 #include <ns3/object-factory.h>
26 #include <ns3/simulator.h>
27 #include <ns3/double.h>
38 #include <ns3/lte-common.h>
39 #include <ns3/pointer.h>
124 m_rsReceivedPowerUpdated (false),
125 m_rsrpSinrSampleCounter (0)
127 m_amc = CreateObject <LteAmc> ();
133 "Cannot create UE devices after simulation started");
161 .AddConstructor<LteUePhy> ()
162 .AddAttribute (
"TxPower",
163 "Transmission power in dBm",
167 MakeDoubleChecker<double> ())
168 .AddAttribute (
"NoiseFigure",
169 "Loss (dB) in the Signal-to-Noise-Ratio due to non-idealities in the receiver."
170 " According to Wikipedia (http://en.wikipedia.org/wiki/Noise_figure), this is "
171 "\"the difference in decibels (dB) between"
172 " the noise output of the actual receiver to the noise output of an "
173 " ideal receiver with the same overall gain and bandwidth when the receivers "
174 " are connected to sources at the standard noise temperature T0.\" "
175 "In this model, we consider T0 = 290K.",
179 MakeDoubleChecker<double> ())
180 .AddAttribute (
"TxMode1Gain",
181 "Transmission mode 1 gain in dB",
184 MakeDoubleChecker<double> ())
185 .AddAttribute (
"TxMode2Gain",
186 "Transmission mode 2 gain in dB",
189 MakeDoubleChecker<double> ())
190 .AddAttribute (
"TxMode3Gain",
191 "Transmission mode 3 gain in dB",
194 MakeDoubleChecker<double> ())
195 .AddAttribute (
"TxMode4Gain",
196 "Transmission mode 4 gain in dB",
199 MakeDoubleChecker<double> ())
200 .AddAttribute (
"TxMode5Gain",
201 "Transmission mode 5 gain in dB",
204 MakeDoubleChecker<double> ())
205 .AddAttribute (
"TxMode6Gain",
206 "Transmission mode 6 gain in dB",
209 MakeDoubleChecker<double> ())
210 .AddAttribute (
"TxMode7Gain",
211 "Transmission mode 7 gain in dB",
214 MakeDoubleChecker<double> ())
215 .AddTraceSource (
"ReportCurrentCellRsrpSinr",
216 "RSRP and SINR statistics.",
218 .AddAttribute (
"RsrpSinrSamplePeriod",
219 "The sampling period for reporting RSRP-SINR stats (default value 1)",
222 MakeUintegerChecker<uint16_t> ())
223 .AddTraceSource (
"UlPhyTransmission",
224 "DL transmission PHY layer statistics.",
226 .AddAttribute (
"DlSpectrumPhy",
227 "The downlink LteSpectrumPhy associated to this LtePhy",
231 MakePointerChecker <LteSpectrumPhy> ())
232 .AddAttribute (
"UlSpectrumPhy",
233 "The uplink LteSpectrumPhy associated to this LtePhy",
237 MakePointerChecker <LteSpectrumPhy> ())
465 Values::const_iterator it;
471 double powerTxW = ((*it) * 180000.0) / 12.0;
475 double rsrp = sum / (double)rbNum;
484 double avSinr = sum / (double)rbNum;
496 std::vector<int> cqi;
502 int nbSubChannels = cqi.size ();
504 int activeSubChannels = 0;
506 for (
int i = 0; i < nbSubChannels; i++)
508 if (cqi.at (i) != -1)
510 cqiSum += cqi.at (i);
513 NS_LOG_DEBUG (
this <<
" subch " << i <<
" cqi " << cqi.at (i));
520 for (
int i = 0; i < nLayer; i++)
522 if (activeSubChannels > 0)
524 dlcqi.m_wbCqi.push_back ((uint16_t) cqiSum / activeSubChannels);
529 dlcqi.m_wbCqi.push_back (1);
540 int nbSubChannels = cqi.size ();
546 for (
int i = 0; i < nbSubChannels; i++)
548 if (cqi.at (i) != -1)
550 cqiSum += cqi.at (i);
554 if (cqiNum == rbgSize)
560 for (
int i = 0; i < nLayer; i++)
562 hlCqi.
m_sbCqi.push_back ((uint16_t) cqiSum / rbgSize);
574 dlcqi.m_sbMeasResult = rbgMeas;
577 msg->SetDlCqi (dlcqi);
598 msg->SetRapId (raPreambleId);
610 std::list<Ptr<LteControlMessage> >::iterator it;
611 for (it = msgList.begin (); it != msgList.end(); it++)
626 if (dci.m_resAlloc != 0)
631 std::vector <int> dlRb;
635 for (
int i = 0; i < 32; i++)
637 if (((dci.m_rbBitmap & mask) >> i) == 1)
641 dlRb.push_back ((i * GetRbgSize ()) + k);
649 NS_LOG_DEBUG (
this <<
" UE " <<
m_rnti <<
" DL-DCI " << dci.m_rnti <<
" bitmap " << dci.m_rbBitmap);
650 for (uint8_t i = 0; i < dci.m_tbsSize.size (); i++)
670 std::vector <int> ulRb;
671 for (
int i = 0; i < dci.m_rbLen; i++)
673 ulRb.push_back (i + dci.m_rbStart);
686 params.
m_mcs = dci.m_mcs;
687 params.
m_size = dci.m_tbSize;
688 params.
m_rv = harqInfoList.size ();
689 params.
m_ndi = dci.m_ndi;
697 if (rarMsg->GetRaRnti () ==
m_raRnti)
699 for (std::list<RarLteControlMessage::Rar>::const_iterator it = rarMsg->RarListBegin (); it != rarMsg->RarListEnd (); ++it)
710 std::vector <int> ulRb;
711 for (
int i = 0; i < it->rarPayload.m_grant.m_rbLen; i++)
713 ulRb.push_back (i + it->rarPayload.m_grant.m_rbStart);
756 NS_ASSERT_MSG (frameNo > 0,
"the SRS index check code assumes that frameNo starts at 1");
776 NS_ASSERT_MSG (subframeNo > 0 && subframeNo <= 10,
"the SRS index check code assumes that subframeNo starts at 1");
798 if (ctrlMsg.size ()>0)
800 NS_LOG_LOGIC (
this <<
" UE - start TX PUCCH (NO PUSCH)");
801 std::vector <int> dlRb;
833 std::vector <int> dlRb;
867 std::list<Ptr<LteControlMessage> > l;
870 std::vector <int> ulRb;
911 for (
int i = 0; i < 4; i++)
913 if (dlBandwidth < Type0AllocationRbg[i])
1015 double gainLin = std::pow (10.0, (gain / 10.0));
1020 std::vector <double> temp;
1023 for (uint8_t i = 0; i < temp.size (); i++)
1046 msg->SetDlHarqFeedback (m);