Bug-fix LteSpectrumPhy send HARQ feedback per TB basis
authormmiozzo
Tue, 18 Dec 2012 18:20:20 +0100
changeset 9587 8f669a9d4719
parent 9578 883971abe70a
child 9588 5e080e30fbe2
Bug-fix LteSpectrumPhy send HARQ feedback per TB basis
src/lte/model/lte-spectrum-phy.cc
src/lte/model/lte-spectrum-phy.h
src/lte/model/pf-ff-mac-scheduler.cc
src/lte/model/rr-ff-mac-scheduler.cc
--- a/src/lte/model/lte-spectrum-phy.cc	Tue Dec 18 12:26:39 2012 +0100
+++ b/src/lte/model/lte-spectrum-phy.cc	Tue Dec 18 18:20:20 2012 +0100
@@ -802,7 +802,7 @@
       m_expectedTbs.erase (it);
     }
   // insert new entry
-  tbInfo_t tbInfo = {ndi, size, mcs, map, harqId, rv, 0.0, downlink, false};
+  tbInfo_t tbInfo = {ndi, size, mcs, map, harqId, rv, 0.0, downlink, false, false};
   m_expectedTbs.insert (std::pair<TbId_t, tbInfo_t> (tbId,tbInfo));
 }
 
@@ -909,69 +909,73 @@
                     m_phyRxEndErrorTrace (*j);
                   }
 
-                // send HARQ feedback
-                if (!(*itTb).second.downlink)
+                // send HARQ feedback (if not already done for this TB)
+                if (!(*itTb).second.harqFeedbackSent)
                   {
-                    UlInfoListElement_s harqUlInfo;
-                    harqUlInfo.m_rnti = tbId.m_rnti;
-                    if ((*itTb).second.corrupt)
+                    (*itTb).second.harqFeedbackSent = true;
+                    if (!(*itTb).second.downlink)
                       {
-                        harqUlInfo.m_receptionStatus = UlInfoListElement_s::NotOk;
-                        NS_LOG_DEBUG (this << " RNTI " << tbId.m_rnti << " send UL-HARQ-NACK");
-                        m_harqPhyModule->UpdateUlHarqProcessStatus (tbId.m_rnti, (*itTb).second.mi, (*itTb).second.size, (*itTb).second.size / EffectiveCodingRate [(*itTb).second.mcs]);
+                        UlInfoListElement_s harqUlInfo;
+                        harqUlInfo.m_rnti = tbId.m_rnti;
+                        if ((*itTb).second.corrupt)
+                          {
+                            harqUlInfo.m_receptionStatus = UlInfoListElement_s::NotOk;
+                            NS_LOG_DEBUG (this << " RNTI " << tbId.m_rnti << " send UL-HARQ-NACK");
+                            m_harqPhyModule->UpdateUlHarqProcessStatus (tbId.m_rnti, (*itTb).second.mi, (*itTb).second.size, (*itTb).second.size / EffectiveCodingRate [(*itTb).second.mcs]);
+                          }
+                        else
+                          {
+                            harqUlInfo.m_receptionStatus = UlInfoListElement_s::Ok;
+                            NS_LOG_DEBUG (this << " RNTI " << tbId.m_rnti << " send UL-HARQ-ACK");
+                            m_harqPhyModule->ResetUlHarqProcessStatus (tbId.m_rnti, (*itTb).second.harqProcessId);
+                          }
+                          if (!m_ltePhyUlHarqFeedbackCallback.IsNull ())
+                            {
+                              m_ltePhyUlHarqFeedbackCallback (harqUlInfo);
+                            }
                       }
                     else
                       {
-                        harqUlInfo.m_receptionStatus = UlInfoListElement_s::Ok;
-                        NS_LOG_DEBUG (this << " RNTI " << tbId.m_rnti << " send UL-HARQ-ACK");
-                        m_harqPhyModule->ResetUlHarqProcessStatus (tbId.m_rnti, (*itTb).second.harqProcessId);
-                      }
-                      if (!m_ltePhyUlHarqFeedbackCallback.IsNull ())
-                        {
-                          m_ltePhyUlHarqFeedbackCallback (harqUlInfo);
-                        }
-                  }
-                else
-                  {
-                    std::map <uint16_t, DlInfoListElement_s>::iterator itHarq = harqDlInfoMap.find (tbId.m_rnti);
-                    if (itHarq==harqDlInfoMap.end ())
-                      {
-                        DlInfoListElement_s harqDlInfo;
-                        harqDlInfo.m_harqStatus.resize (m_layersNum, DlInfoListElement_s::NACK);
-                        harqDlInfo.m_rnti = tbId.m_rnti;
-                        harqDlInfo.m_harqProcessId = (*itTb).second.harqProcessId;
-                        if ((*itTb).second.corrupt)
+                        std::map <uint16_t, DlInfoListElement_s>::iterator itHarq = harqDlInfoMap.find (tbId.m_rnti);
+                        if (itHarq==harqDlInfoMap.end ())
                           {
-                            harqDlInfo.m_harqStatus.at (tbId.m_layer) = DlInfoListElement_s::NACK;
-                            NS_LOG_DEBUG (this << " RNTI " << tbId.m_rnti << " harqId " << (uint16_t)(*itTb).second.harqProcessId << " layer " <<(uint16_t)tbId.m_layer << " send DL-HARQ-NACK");
-                            m_harqPhyModule->UpdateDlHarqProcessStatus ((*itTb).second.harqProcessId, tbId.m_layer, (*itTb).second.mi, (*itTb).second.size, (*itTb).second.size / EffectiveCodingRate [(*itTb).second.mcs]);
+                            DlInfoListElement_s harqDlInfo;
+                            harqDlInfo.m_harqStatus.resize (m_layersNum, DlInfoListElement_s::NACK);
+                            harqDlInfo.m_rnti = tbId.m_rnti;
+                            harqDlInfo.m_harqProcessId = (*itTb).second.harqProcessId;
+                            if ((*itTb).second.corrupt)
+                              {
+                                harqDlInfo.m_harqStatus.at (tbId.m_layer) = DlInfoListElement_s::NACK;
+                                NS_LOG_DEBUG (this << " RNTI " << tbId.m_rnti << " harqId " << (uint16_t)(*itTb).second.harqProcessId << " layer " <<(uint16_t)tbId.m_layer << " send DL-HARQ-NACK");
+                                m_harqPhyModule->UpdateDlHarqProcessStatus ((*itTb).second.harqProcessId, tbId.m_layer, (*itTb).second.mi, (*itTb).second.size, (*itTb).second.size / EffectiveCodingRate [(*itTb).second.mcs]);
+                              }
+                            else
+                              {
+
+                                harqDlInfo.m_harqStatus.at (tbId.m_layer) = DlInfoListElement_s::ACK;
+                                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");
+                                m_harqPhyModule->ResetDlHarqProcessStatus ((*itTb).second.harqProcessId);
+                              }
+                            harqDlInfoMap.insert (std::pair <uint16_t, DlInfoListElement_s> (tbId.m_rnti, harqDlInfo));
                           }
                         else
-                          {
-                            
-                            harqDlInfo.m_harqStatus.at (tbId.m_layer) = DlInfoListElement_s::ACK;
-                            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");
-                            m_harqPhyModule->ResetDlHarqProcessStatus ((*itTb).second.harqProcessId);
-                          }
-                        harqDlInfoMap.insert (std::pair <uint16_t, DlInfoListElement_s> (tbId.m_rnti, harqDlInfo));
-                      }
-                    else
-                    {
-                      if ((*itTb).second.corrupt)
                         {
-                          (*itHarq).second.m_harqStatus.at (tbId.m_layer) = DlInfoListElement_s::NACK;
-                          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");
-                          m_harqPhyModule->UpdateDlHarqProcessStatus ((*itTb).second.harqProcessId, tbId.m_layer, (*itTb).second.mi, (*itTb).second.size, (*itTb).second.size / EffectiveCodingRate [(*itTb).second.mcs]);
+                          if ((*itTb).second.corrupt)
+                            {
+                              (*itHarq).second.m_harqStatus.at (tbId.m_layer) = DlInfoListElement_s::NACK;
+                              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");
+                              m_harqPhyModule->UpdateDlHarqProcessStatus ((*itTb).second.harqProcessId, tbId.m_layer, (*itTb).second.mi, (*itTb).second.size, (*itTb).second.size / EffectiveCodingRate [(*itTb).second.mcs]);
+                            }
+                          else
+                            {
+                              NS_ASSERT_MSG (tbId.m_layer < (*itHarq).second.m_harqStatus.size (), " layer " << (uint16_t)tbId.m_layer);
+                              (*itHarq).second.m_harqStatus.at (tbId.m_layer) = DlInfoListElement_s::ACK;
+                              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");
+                              m_harqPhyModule->ResetDlHarqProcessStatus ((*itTb).second.harqProcessId);
+                            }
                         }
-                      else
-                        {
-                          NS_ASSERT_MSG (tbId.m_layer < (*itHarq).second.m_harqStatus.size (), " layer " << (uint16_t)tbId.m_layer);
-                          (*itHarq).second.m_harqStatus.at (tbId.m_layer) = DlInfoListElement_s::ACK;
-                          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");
-                          m_harqPhyModule->ResetDlHarqProcessStatus ((*itTb).second.harqProcessId);
-                        }
-                    }
-                  } // end if ((*itTb).second.downlink) HARQ
+                      } // end if ((*itTb).second.downlink) HARQ
+                  } // end if (!(*itTb).second.harqFeedbackSent)
               }
           }
       }
--- a/src/lte/model/lte-spectrum-phy.h	Tue Dec 18 12:26:39 2012 +0100
+++ b/src/lte/model/lte-spectrum-phy.h	Tue Dec 18 18:20:20 2012 +0100
@@ -69,6 +69,7 @@
   double mi;
   bool downlink;
   bool corrupt;
+  bool harqFeedbackSent;
 };
 
 typedef std::map<TbId_t, tbInfo_t> expectedTbs_t;
--- a/src/lte/model/pf-ff-mac-scheduler.cc	Tue Dec 18 12:26:39 2012 +0100
+++ b/src/lte/model/pf-ff-mac-scheduler.cc	Tue Dec 18 18:20:20 2012 +0100
@@ -724,7 +724,7 @@
       m_dlInfoListBuffered.clear ();
     }
   std::vector <struct DlInfoListElement_s> dlInfoListUntxed;
-  for (uint8_t i = 0; i < m_dlInfoListBuffered.size (); i++)
+  for (uint16_t i = 0; i < m_dlInfoListBuffered.size (); i++)
     {
       std::set <uint16_t>::iterator itRnti = rntiAllocated.find (m_dlInfoListBuffered.at (i).m_rnti);
       if (itRnti != rntiAllocated.end ())
@@ -1373,7 +1373,7 @@
 void
 PfFfMacScheduler::DoSchedUlTriggerReq (const struct FfMacSchedSapProvider::SchedUlTriggerReqParameters& params)
 {
-  NS_LOG_FUNCTION (this << " UL - Frame no. " << (params.m_sfnSf >> 4) << " subframe no. " << (0xF & params.m_sfnSf));
+  NS_LOG_FUNCTION (this << " UL - Frame no. " << (params.m_sfnSf >> 4) << " subframe no. " << (0xF & params.m_sfnSf) << " size " << params.m_ulInfoList.size ());
 
   RefreshUlCqiMaps ();
 
@@ -1410,8 +1410,9 @@
         {
           (*itProcId).second = ((*itProcId).second + 1) % HARQ_PROC_NUM;
         }
-      for (uint8_t i = 0; i < params.m_ulInfoList.size (); i++)
-        {
+
+      for (uint16_t i = 0; i < params.m_ulInfoList.size (); i++)
+        {        
           if (params.m_ulInfoList.at (i).m_receptionStatus == UlInfoListElement_s::NotOk)
             {
               // retx correspondent block: retrieve the UL-DCI
@@ -1422,7 +1423,7 @@
                   NS_LOG_ERROR ("No info find in HARQ buffer for UE (might change eNB) " << rnti);
                 }
               uint8_t harqId = (uint8_t)((*itProcId).second - HARQ_PERIOD) % HARQ_PROC_NUM;
-              NS_LOG_INFO (this << " UL-HARQ retx RNTI " << rnti << " harqId " << (uint16_t)harqId);
+              NS_LOG_INFO (this << " UL-HARQ retx RNTI " << rnti << " harqId " << (uint16_t)harqId << " i " << i << " size "  << params.m_ulInfoList.size ());
               std::map <uint16_t, UlHarqProcessesDciBuffer_t>::iterator itHarq = m_ulHarqProcessesDciBuffer.find (rnti);
               if (itHarq == m_ulHarqProcessesDciBuffer.end ())
                 {
@@ -1436,7 +1437,7 @@
                 }
               if ((*itStat).second.at (harqId) >= 3)
                 {
-                  NS_LOG_DEBUG ("Max number of retransmissions reached (UL)-> drop process");
+                  NS_LOG_INFO ("Max number of retransmissions reached (UL)-> drop process");
                   continue;
                 }
               bool free = true;
@@ -1473,10 +1474,13 @@
               ret.m_dciList.push_back (dci);
               rntiAllocated.insert (dci.m_rnti);
             }
+            else
+            {
+              NS_LOG_INFO (this << " HARQ-ACK feedback from RNTI " << params.m_ulInfoList.at (i).m_rnti);
+            }
         }
     }
 
-
   std::map <uint16_t,uint32_t>::iterator it;
   int nflows = 0;
 
--- a/src/lte/model/rr-ff-mac-scheduler.cc	Tue Dec 18 12:26:39 2012 +0100
+++ b/src/lte/model/rr-ff-mac-scheduler.cc	Tue Dec 18 18:20:20 2012 +0100
@@ -686,7 +686,7 @@
       m_dlInfoListBuffered.clear ();
     }
   std::vector <struct DlInfoListElement_s> dlInfoListUntxed;
-  for (uint8_t i = 0; i < m_dlInfoListBuffered.size (); i++)
+  for (uint16_t i = 0; i < m_dlInfoListBuffered.size (); i++)
     {
       std::set <uint16_t>::iterator itRnti = rntiAllocated.find (m_dlInfoListBuffered.at (i).m_rnti);
       if (itRnti != rntiAllocated.end ())
@@ -1253,7 +1253,7 @@
         {
           (*itProcId).second = ((*itProcId).second + 1) % HARQ_PROC_NUM;
         }
-      for (uint8_t i = 0; i < params.m_ulInfoList.size (); i++)
+      for (uint16_t i = 0; i < params.m_ulInfoList.size (); i++)
         {
           if (params.m_ulInfoList.at (i).m_receptionStatus == UlInfoListElement_s::NotOk)
             {