23 #include <ns3/object-factory.h>
27 #include <ns3/simulator.h>
28 #include <ns3/double.h>
39 #include <ns3/lte-common.h>
40 #include <ns3/pointer.h>
121 m_p10CqiPeriocity (MilliSeconds (1)),
122 m_a30CqiPeriocity (MilliSeconds (1)),
126 m_rsReceivedPowerUpdated (false),
127 m_rsInterferencePowerUpdated (false),
128 m_pssReceived (false),
129 m_ueMeasurementsFilterPeriod (MilliSeconds (200)),
130 m_ueMeasurementsFilterLast (MilliSeconds (0)),
131 m_rsrpSinrSampleCounter (0)
133 m_amc = CreateObject <LteAmc> ();
139 "Cannot create UE devices after simulation started");
168 .AddConstructor<LteUePhy> ()
169 .AddAttribute (
"TxPower",
170 "Transmission power in dBm",
174 MakeDoubleChecker<double> ())
175 .AddAttribute (
"NoiseFigure",
176 "Loss (dB) in the Signal-to-Noise-Ratio due to non-idealities in the receiver."
177 " According to Wikipedia (http://en.wikipedia.org/wiki/Noise_figure), this is "
178 "\"the difference in decibels (dB) between"
179 " the noise output of the actual receiver to the noise output of an "
180 " ideal receiver with the same overall gain and bandwidth when the receivers "
181 " are connected to sources at the standard noise temperature T0.\" "
182 "In this model, we consider T0 = 290K.",
186 MakeDoubleChecker<double> ())
187 .AddAttribute (
"TxMode1Gain",
188 "Transmission mode 1 gain in dB",
191 MakeDoubleChecker<double> ())
192 .AddAttribute (
"TxMode2Gain",
193 "Transmission mode 2 gain in dB",
196 MakeDoubleChecker<double> ())
197 .AddAttribute (
"TxMode3Gain",
198 "Transmission mode 3 gain in dB",
201 MakeDoubleChecker<double> ())
202 .AddAttribute (
"TxMode4Gain",
203 "Transmission mode 4 gain in dB",
206 MakeDoubleChecker<double> ())
207 .AddAttribute (
"TxMode5Gain",
208 "Transmission mode 5 gain in dB",
211 MakeDoubleChecker<double> ())
212 .AddAttribute (
"TxMode6Gain",
213 "Transmission mode 6 gain in dB",
216 MakeDoubleChecker<double> ())
217 .AddAttribute (
"TxMode7Gain",
218 "Transmission mode 7 gain in dB",
221 MakeDoubleChecker<double> ())
222 .AddTraceSource (
"ReportCurrentCellRsrpSinr",
223 "RSRP and SINR statistics.",
225 .AddAttribute (
"RsrpSinrSamplePeriod",
226 "The sampling period for reporting RSRP-SINR stats (default value 1)",
229 MakeUintegerChecker<uint16_t> ())
230 .AddTraceSource (
"UlPhyTransmission",
231 "DL transmission PHY layer statistics.",
233 .AddAttribute (
"DlSpectrumPhy",
234 "The downlink LteSpectrumPhy associated to this LtePhy",
238 MakePointerChecker <LteSpectrumPhy> ())
239 .AddAttribute (
"UlSpectrumPhy",
240 "The uplink LteSpectrumPhy associated to this LtePhy",
244 MakePointerChecker <LteSpectrumPhy> ())
245 .AddAttribute (
"RsrqUeMeasThreshold",
246 "Receive threshold for PSS on RSRQ [dB]",
249 MakeDoubleChecker<double> ())
250 .AddAttribute (
"UeMeasurementsFilterPeriod",
251 "Time period for reporting UE measurements (default 200 ms.) ",
255 .AddTraceSource (
"ReportUeMeasurements",
256 "Report UE measurements RSRP (dBm) and RSRQ (dB).",
449 Values::const_iterator it;
455 double powerTxW = ((*it) * 180000.0) / 12.0;
459 double rsrp = (rbNum > 0) ? (sum / rbNum) : DBL_MAX;
468 double avSinr = (rbNum > 0) ? (sum / rbNum) : DBL_MAX;
481 std::list <PssElement>::iterator itPss =
m_pssList.begin ();
485 double rsrqSum = 0.0;
492 double noisePowerTxW = ((*itIntN) * 180000.0) / 12.0;
493 double intPowerTxW = ((*itPj) * 180000.0) / 12.0;
494 rsrqSum += (2 * (noisePowerTxW + intPowerTxW));
497 double rsrp_dBm = 10 * log10 (1000 * ((*itPss).pssPsdSum / (
double)rbNum));
498 double rsrq_dB = 10 * log10 ((*itPss).pssPsdSum / rsrqSum);
503 NS_LOG_INFO (
this <<
" PSS received from CellId " << (*itPss).cellId <<
" has RSRP " << rsrp_dBm <<
" and RSRQ " << rsrq_dB <<
" RBnum " << (uint16_t)rbNum);
505 std::map <uint16_t, UeMeasurementsElement>::iterator itMeasMap =
m_UeMeasurementsMap.find ((*itPss).cellId);
514 m_UeMeasurementsMap.insert (std::pair <uint16_t, UeMeasurementsElement> ((*itPss).cellId, newEl));
518 (*itMeasMap).second.rsrpSum += rsrp_dBm;
519 (*itMeasMap).second.rsrpNum++;
520 (*itMeasMap).second.rsrqSum += rsrq_dB;
521 (*itMeasMap).second.rsrqNum++;
572 std::vector<int> cqi;
578 int nbSubChannels = cqi.size ();
580 int activeSubChannels = 0;
582 for (
int i = 0; i < nbSubChannels; i++)
584 if (cqi.at (i) != -1)
586 cqiSum += cqi.at (i);
589 NS_LOG_DEBUG (
this <<
" subch " << i <<
" cqi " << cqi.at (i));
596 for (
int i = 0; i < nLayer; i++)
598 if (activeSubChannels > 0)
600 dlcqi.m_wbCqi.push_back ((uint16_t) cqiSum / activeSubChannels);
605 dlcqi.m_wbCqi.push_back (1);
616 int nbSubChannels = cqi.size ();
622 for (
int i = 0; i < nbSubChannels; i++)
624 if (cqi.at (i) != -1)
626 cqiSum += cqi.at (i);
630 if (cqiNum == rbgSize)
636 for (
int i = 0; i < nLayer; i++)
638 hlCqi.
m_sbCqi.push_back ((uint16_t) cqiSum / rbgSize);
650 dlcqi.m_sbMeasResult = rbgMeas;
653 msg->SetDlCqi (dlcqi);
664 std::map <uint16_t, UeMeasurementsElement>::iterator it;
667 double avg_rsrp = (*it).second.rsrpSum / (double)(*it).second.rsrpNum;
668 double avg_rsrq = (*it).second.rsrqSum / (
double)(*it).second.rsrqNum;
669 NS_LOG_DEBUG (
this <<
" CellId " << (*it).first <<
" RSRP " << avg_rsrp <<
" (nSamples " << (*it).second.rsrpNum <<
") RSRQ " << avg_rsrq <<
" (nSamples " << (*it).second.rsrpNum <<
")");
700 msg->SetRapId (raPreambleId);
712 std::list<Ptr<LteControlMessage> >::iterator it;
713 for (it = msgList.begin (); it != msgList.end(); it++)
728 if (dci.m_resAlloc != 0)
733 std::vector <int> dlRb;
737 for (
int i = 0; i < 32; i++)
739 if (((dci.m_rbBitmap & mask) >> i) == 1)
743 dlRb.push_back ((i * GetRbgSize ()) + k);
751 NS_LOG_DEBUG (
this <<
" UE " <<
m_rnti <<
" DL-DCI " << dci.m_rnti <<
" bitmap " << dci.m_rbBitmap);
752 for (uint8_t i = 0; i < dci.m_tbsSize.size (); i++)
772 std::vector <int> ulRb;
773 for (
int i = 0; i < dci.m_rbLen; i++)
775 ulRb.push_back (i + dci.m_rbStart);
788 params.
m_mcs = dci.m_mcs;
789 params.
m_size = dci.m_tbSize;
790 params.
m_rv = harqInfoList.size ();
791 params.
m_ndi = dci.m_ndi;
799 if (rarMsg->GetRaRnti () ==
m_raRnti)
801 for (std::list<RarLteControlMessage::Rar>::const_iterator it = rarMsg->RarListBegin (); it != rarMsg->RarListEnd (); ++it)
812 std::vector <int> ulRb;
813 for (
int i = 0; i < it->rarPayload.m_grant.m_rbLen; i++)
815 ulRb.push_back (i + it->rarPayload.m_grant.m_rbStart);
860 Values::const_iterator itPi;
864 double powerTxW = ((*itPi) * 180000.0) / 12.0;
886 NS_ASSERT_MSG (frameNo > 0,
"the SRS index check code assumes that frameNo starts at 1");
908 NS_ASSERT_MSG (subframeNo > 0 && subframeNo <= 10,
"the SRS index check code assumes that subframeNo starts at 1");
930 if (ctrlMsg.size ()>0)
932 NS_LOG_LOGIC (
this <<
" UE - start TX PUCCH (NO PUSCH)");
933 std::vector <int> dlRb;
965 std::vector <int> dlRb;
999 std::list<Ptr<LteControlMessage> > l;
1002 std::vector <int> ulRb;
1043 for (
int i = 0; i < 4; i++)
1045 if (dlBandwidth < Type0AllocationRbg[i])
1147 double gainLin = std::pow (10.0, (gain / 10.0));
1152 std::vector <double> temp;
1155 for (uint8_t i = 0; i < temp.size (); i++)
1178 msg->SetDlHarqFeedback (m);