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++)
 
  189     .AddTraceSource (
"TxStart",
 
  190                      "Trace fired when a new transmission is started",
 
  192     .AddTraceSource (
"TxEnd",
 
  193                      "Trace fired when a previosuly started transmission is finished",
 
  195     .AddTraceSource (
"RxStart",
 
  196                      "Trace fired when the start of a signal is detected",
 
  198     .AddTraceSource (
"RxEndOk",
 
  199                      "Trace fired when a previosuly started RX terminates successfully",
 
  201     .AddTraceSource (
"RxEndError",
 
  202                      "Trace fired when a previosuly started RX terminates with an error",
 
  204     .AddAttribute (
"DataErrorModelEnabled",
 
  205                     "Activate/Deactivate the error model of data (TBs of PDSCH and PUSCH) [by default is active].",
 
  208                     MakeBooleanChecker ())
 
  209     .AddAttribute (
"CtrlErrorModelEnabled",
 
  210                     "Activate/Deactivate the error model of control (PCFICH-PDCCH decodification) [by default is active].",
 
  213                     MakeBooleanChecker ())
 
  214     .AddTraceSource (
"DlPhyReception",
 
  215                      "DL reception PHY layer statistics.",
 
  217     .AddTraceSource (
"UlPhyReception",
 
  218                      "DL reception PHY layer statistics.",
 
  421       NS_FATAL_ERROR (
"cannot TX while RX: according to FDD channel acces, the physical layer for transmission cannot be used for reception");
 
  425       NS_FATAL_ERROR (
"cannot TX while already TX: the MAC should avoid this");
 
  445       txParams->duration = duration;
 
  446       txParams->txPhy = GetObject<SpectrumPhy> ();
 
  449       txParams->packetBurst = pb;
 
  450       txParams->ctrlMsgList = ctrlMsgList;
 
  477       NS_FATAL_ERROR (
"cannot TX while RX: according to FDD channel acces, the physical layer for transmission cannot be used for reception");
 
  481       NS_FATAL_ERROR (
"cannot TX while already TX: the MAC should avoid this");
 
  502       txParams->txPhy = GetObject<SpectrumPhy> ();
 
  506       txParams->ctrlMsgList = ctrlMsgList;
 
  533       NS_FATAL_ERROR (
"cannot TX while RX: according to FDD channel acces, the physical layer for transmission cannot be used for reception");
 
  537       NS_FATAL_ERROR (
"cannot TX while already TX: the MAC should avoid this");
 
  558       txParams->txPhy = GetObject<SpectrumPhy> ();
 
  609   Time duration = spectrumRxParams->duration;
 
  614   if (lteDataRxParams != 0)
 
  623       if ((lteDlCtrlRxParams!=0)||(lteUlSrsRxParams!=0))
 
  645         NS_FATAL_ERROR (
"cannot RX while TX: according to FDD channel access, the physical layer for transmission cannot be used for reception");
 
  661               NS_LOG_LOGIC (
this << 
" synchronized with this signal (cellId=" << params->cellId << 
")");
 
  669                   NS_LOG_LOGIC (
this << 
" scheduling EndRx with delay " << params->duration.GetSeconds () << 
"s");
 
  684               if (params->packetBurst)
 
  691                 NS_LOG_DEBUG (
this << 
" insert msgs " << params->ctrlMsgList.size ());
 
  698               NS_LOG_LOGIC (
this << 
" not in sync with this signal (cellId="  
  699               << params->cellId  << 
", m_cellId=" << 
m_cellId << 
")");
 
  721       NS_FATAL_ERROR (
"cannot RX while TX: according to FDD channel access, the physical layer for transmission cannot be used for reception");
 
  738         if (lteDlCtrlRxParams!=0)
 
  740             cellId = lteDlCtrlRxParams->cellId;
 
  746             cellId = lteUlSrsRxParams->cellId;
 
  751           NS_LOG_LOGIC (
this << 
" synchronized with this signal (cellId=" << cellId << 
")");
 
  759             NS_LOG_LOGIC (
this << 
" scheduling EndRx with delay " << params->duration);
 
  788           NS_LOG_LOGIC (
this << 
" not in sync with this signal (cellId="  
  789           << cellId  << 
", m_cellId=" << 
m_cellId << 
")");
 
  812 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)
 
  814   NS_LOG_FUNCTION (
this << 
" rnti: " << rnti << 
" NDI " << (uint16_t)ndi << 
" size " << size << 
" mcs " << (uint16_t)mcs << 
" layer " << (uint16_t)layer << 
" rv " << (uint16_t)rv);
 
  818   expectedTbs_t::iterator it;
 
  826   tbInfo_t tbInfo = {ndi, size, mcs, map, harqId, rv, 0.0, downlink, 
false, 
false};
 
  827   m_expectedTbs.insert (std::pair<TbId_t, tbInfo_t> (tbId,tbInfo));
 
  857           if ((*itTb).second.ndi == 0)
 
  860               uint16_t ulHarqId = 0;
 
  861               if ((*itTb).second.downlink)
 
  871           (*itTb).second.mi = tbStats.
mi;
 
  873           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);
 
  879           params.
m_rnti = (*itTb).first.m_rnti;
 
  881           params.
m_layer =  (*itTb).first.m_layer;
 
  882           params.
m_mcs = (*itTb).second.mcs;
 
  883           params.
m_size = (*itTb).second.size;
 
  884           params.
m_rv = (*itTb).second.rv;
 
  885           params.
m_ndi = (*itTb).second.ndi;
 
  887           if ((*itTb).second.downlink)
 
  895               params.
m_rv = harqInfoList.size ();
 
  902     std::map <uint16_t, DlInfoListElement_s> harqDlInfoMap;
 
  910             (*j)->PeekPacketTag (tag);
 
  918                 if (!(*itTb).second.corrupt)
 
  934                 if (!(*itTb).second.harqFeedbackSent)
 
  936                     (*itTb).second.harqFeedbackSent = 
true;
 
  937                     if (!(*itTb).second.downlink)
 
  941                         harqUlInfo.
m_tpc = 0;
 
  942                         if ((*itTb).second.corrupt)
 
  961                         std::map <uint16_t, DlInfoListElement_s>::iterator itHarq = harqDlInfoMap.find (tbId.
m_rnti);
 
  962                         if (itHarq==harqDlInfoMap.end ())
 
  968                             if ((*itTb).second.corrupt)
 
  971                                 NS_LOG_DEBUG (
this << 
" RNTI " << tbId.
m_rnti << 
" harqId " << (uint16_t)(*itTb).second.harqProcessId << 
" layer " <<(uint16_t)tbId.
m_layer << 
" send DL-HARQ-NACK");
 
  978                                 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");
 
  981                             harqDlInfoMap.insert (std::pair <uint16_t, DlInfoListElement_s> (tbId.
m_rnti, harqDlInfo));
 
  985                           if ((*itTb).second.corrupt)
 
  988                               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");
 
  995                               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");
 
 1006   std::map <uint16_t, DlInfoListElement_s>::iterator itHarq;
 
 1007   for (itHarq = harqDlInfoMap.begin (); itHarq != harqDlInfoMap.end (); itHarq++)
 
 1055       NS_LOG_DEBUG (
this << 
" PCFICH-PDCCH Decodification, errorRate " << errorRate << 
" error " << error);
 
 1132   NS_LOG_FUNCTION (
this << 
" txmode " << (uint16_t)txMode << 
" gain " << gain);
 
 1134   gain = std::pow (10.0, (gain / 10.0));
 
 1139   std::vector <double> temp;
 
 1142   for (uint8_t i = 0; i < temp.size (); i++)