24 #include <ns3/object-factory.h>
27 #include <ns3/simulator.h>
28 #include <ns3/trace-source-accessor.h>
29 #include <ns3/antenna-model.h>
36 #include <ns3/lte-mi-error-model.h>
37 #include <ns3/lte-radio-bearer-tag.h>
38 #include <ns3/boolean.h>
39 #include <ns3/double.h>
40 #include <ns3/config.h>
117 m_transmissionMode (0),
121 m_random = CreateObject<UniformRandomVariable> ();
127 for (uint8_t i = 0; i < 7; i++)
190 .AddTraceSource (
"TxStart",
191 "Trace fired when a new transmission is started",
193 .AddTraceSource (
"TxEnd",
194 "Trace fired when a previosuly started transmission is finished",
196 .AddTraceSource (
"RxStart",
197 "Trace fired when the start of a signal is detected",
199 .AddTraceSource (
"RxEndOk",
200 "Trace fired when a previosuly started RX terminates successfully",
202 .AddTraceSource (
"RxEndError",
203 "Trace fired when a previosuly started RX terminates with an error",
205 .AddAttribute (
"DataErrorModelEnabled",
206 "Activate/Deactivate the error model of data (TBs of PDSCH and PUSCH) [by default is active].",
209 MakeBooleanChecker ())
210 .AddAttribute (
"CtrlErrorModelEnabled",
211 "Activate/Deactivate the error model of control (PCFICH-PDCCH decodification) [by default is active].",
214 MakeBooleanChecker ())
215 .AddTraceSource (
"DlPhyReception",
216 "DL reception PHY layer statistics.",
218 .AddTraceSource (
"UlPhyReception",
219 "DL reception PHY layer statistics.",
430 NS_FATAL_ERROR (
"cannot TX while RX: according to FDD channel acces, the physical layer for transmission cannot be used for reception");
434 NS_FATAL_ERROR (
"cannot TX while already TX: the MAC should avoid this");
454 txParams->duration = duration;
455 txParams->txPhy = GetObject<SpectrumPhy> ();
458 txParams->packetBurst = pb;
459 txParams->ctrlMsgList = ctrlMsgList;
487 NS_FATAL_ERROR (
"cannot TX while RX: according to FDD channel acces, the physical layer for transmission cannot be used for reception");
491 NS_FATAL_ERROR (
"cannot TX while already TX: the MAC should avoid this");
512 txParams->txPhy = GetObject<SpectrumPhy> ();
517 txParams->ctrlMsgList = ctrlMsgList;
544 NS_FATAL_ERROR (
"cannot TX while RX: according to FDD channel acces, the physical layer for transmission cannot be used for reception");
548 NS_FATAL_ERROR (
"cannot TX while already TX: the MAC should avoid this");
569 txParams->txPhy = GetObject<SpectrumPhy> ();
620 Time duration = spectrumRxParams->duration;
625 if (lteDataRxParams != 0)
634 if ((lteDlCtrlRxParams!=0)||(lteUlSrsRxParams!=0))
656 NS_FATAL_ERROR (
"cannot RX while TX: according to FDD channel access, the physical layer for transmission cannot be used for reception");
672 NS_LOG_LOGIC (
this <<
" synchronized with this signal (cellId=" << params->cellId <<
")");
680 NS_LOG_LOGIC (
this <<
" scheduling EndRx with delay " << params->duration.GetSeconds () <<
"s");
695 if (params->packetBurst)
702 NS_LOG_DEBUG (
this <<
" insert msgs " << params->ctrlMsgList.size ());
709 NS_LOG_LOGIC (
this <<
" not in sync with this signal (cellId="
710 << params->cellId <<
", m_cellId=" <<
m_cellId <<
")");
732 NS_FATAL_ERROR (
"cannot RX while TX: according to FDD channel access, the physical layer for transmission cannot be used for reception");
749 if (lteDlCtrlRxParams!=0)
751 cellId = lteDlCtrlRxParams->cellId;
757 cellId = lteUlSrsRxParams->cellId;
763 if (lteDlCtrlRxParams->pss ==
true)
774 NS_LOG_LOGIC (
this <<
" synchronized with this signal (cellId=" << cellId <<
")");
782 NS_LOG_LOGIC (
this <<
" scheduling EndRx with delay " << params->duration);
811 NS_LOG_LOGIC (
this <<
" not in sync with this signal (cellId="
812 << cellId <<
", m_cellId=" <<
m_cellId <<
")");
835 LteSpectrumPhy::AddExpectedTb (uint16_t rnti, uint8_t ndi, uint16_t size, uint8_t mcs, std::vector<int> map, uint8_t layer, uint8_t harqId,uint8_t rv,
bool downlink)
837 NS_LOG_FUNCTION (
this <<
" rnti: " << rnti <<
" NDI " << (uint16_t)ndi <<
" size " << size <<
" mcs " << (uint16_t)mcs <<
" layer " << (uint16_t)layer <<
" rv " << (uint16_t)rv);
841 expectedTbs_t::iterator it;
849 tbInfo_t tbInfo = {ndi, size, mcs, map, harqId, rv, 0.0, downlink,
false,
false};
850 m_expectedTbs.insert (std::pair<TbId_t, tbInfo_t> (tbId,tbInfo));
880 if ((*itTb).second.ndi == 0)
883 uint16_t ulHarqId = 0;
884 if ((*itTb).second.downlink)
894 (*itTb).second.mi = tbStats.
mi;
896 NS_LOG_DEBUG (
this <<
"RNTI " << (*itTb).first.m_rnti <<
" size " << (*itTb).second.size <<
" mcs " << (uint32_t)(*itTb).second.mcs <<
" bitmap " << (*itTb).second.rbBitmap.size () <<
" layer " << (uint16_t)(*itTb).first.m_layer <<
" TBLER " << tbStats.
tbler <<
" corrupted " << (*itTb).second.corrupt);
902 params.
m_rnti = (*itTb).first.m_rnti;
904 params.
m_layer = (*itTb).first.m_layer;
905 params.
m_mcs = (*itTb).second.mcs;
906 params.
m_size = (*itTb).second.size;
907 params.
m_rv = (*itTb).second.rv;
908 params.
m_ndi = (*itTb).second.ndi;
910 if ((*itTb).second.downlink)
918 params.
m_rv = harqInfoList.size ();
925 std::map <uint16_t, DlInfoListElement_s> harqDlInfoMap;
933 (*j)->PeekPacketTag (tag);
941 if (!(*itTb).second.corrupt)
957 if (!(*itTb).second.harqFeedbackSent)
959 (*itTb).second.harqFeedbackSent =
true;
960 if (!(*itTb).second.downlink)
964 harqUlInfo.
m_tpc = 0;
965 if ((*itTb).second.corrupt)
984 std::map <uint16_t, DlInfoListElement_s>::iterator itHarq = harqDlInfoMap.find (tbId.
m_rnti);
985 if (itHarq==harqDlInfoMap.end ())
991 if ((*itTb).second.corrupt)
994 NS_LOG_DEBUG (
this <<
" RNTI " << tbId.
m_rnti <<
" harqId " << (uint16_t)(*itTb).second.harqProcessId <<
" layer " <<(uint16_t)tbId.
m_layer <<
" send DL-HARQ-NACK");
1001 NS_LOG_DEBUG (
this <<
" RNTI " << tbId.
m_rnti <<
" harqId " << (uint16_t)(*itTb).second.harqProcessId <<
" layer " <<(uint16_t)tbId.
m_layer <<
" size " << (*itTb).second.size <<
" send DL-HARQ-ACK");
1004 harqDlInfoMap.insert (std::pair <uint16_t, DlInfoListElement_s> (tbId.
m_rnti, harqDlInfo));
1008 if ((*itTb).second.corrupt)
1011 NS_LOG_DEBUG (
this <<
" RNTI " << tbId.
m_rnti <<
" harqId " << (uint16_t)(*itTb).second.harqProcessId <<
" layer " <<(uint16_t)tbId.
m_layer <<
" size " << (*itHarq).second.m_harqStatus.size () <<
" send DL-HARQ-NACK");
1018 NS_LOG_DEBUG (
this <<
" RNTI " << tbId.
m_rnti <<
" harqId " << (uint16_t)(*itTb).second.harqProcessId <<
" layer " << (uint16_t)tbId.
m_layer <<
" size " << (*itHarq).second.m_harqStatus.size () <<
" send DL-HARQ-ACK");
1029 std::map <uint16_t, DlInfoListElement_s>::iterator itHarq;
1030 for (itHarq = harqDlInfoMap.begin (); itHarq != harqDlInfoMap.end (); itHarq++)
1078 NS_LOG_DEBUG (
this <<
" PCFICH-PDCCH Decodification, errorRate " << errorRate <<
" error " << error);
1161 NS_LOG_FUNCTION (
this <<
" txmode " << (uint16_t)txMode <<
" gain " << gain);
1163 gain = std::pow (10.0, (gain / 10.0));
1168 std::vector <double> temp;
1171 for (uint8_t i = 0; i < temp.size (); i++)