Update SRS-CQI management in RR and PF Schedulers
authorMarco Miozzo <marco.miozzo@cttc.es>
Wed, 04 Jul 2012 12:22:21 +0200
changeset 9042 ae924de31cbd
parent 9041 f04376f2d4ac
child 9043 9130e2dbe601
Update SRS-CQI management in RR and PF Schedulers
src/lte/model/ff-mac-scheduler.cc
src/lte/model/ff-mac-scheduler.h
src/lte/model/pf-ff-mac-scheduler.cc
src/lte/model/rr-ff-mac-scheduler.cc
src/lte/test/lte-test-interference.cc
src/lte/test/lte-test-phy-error-model.cc
src/lte/test/test-lte-antenna.cc
--- a/src/lte/model/ff-mac-scheduler.cc	Fri Jun 29 11:51:22 2012 +0200
+++ b/src/lte/model/ff-mac-scheduler.cc	Wed Jul 04 12:22:21 2012 +0200
@@ -32,7 +32,7 @@
 
 
 FfMacScheduler::FfMacScheduler ()
-: m_ulCqiFilter (ALL)
+: m_ulCqiFilter (ALL_UL_CQI)
 {
   NS_LOG_FUNCTION (this);
 }
@@ -56,11 +56,11 @@
     .SetParent<Object> ()
     .AddAttribute ("UlCqiFilter",
                    "The filter to apply on UL CQIs received",
-                   EnumValue (FfMacScheduler::ALL),
+                   EnumValue (FfMacScheduler::ALL_UL_CQI),
                    MakeEnumAccessor (&FfMacScheduler::m_ulCqiFilter),
-                   MakeEnumChecker (FfMacScheduler::SRS, "SRS",
-                                    FfMacScheduler::PUSCH, "PUSCH",
-                                    FfMacScheduler::ALL, "ALL"))
+                   MakeEnumChecker (FfMacScheduler::SRS_UL_CQI, "SRS_UL_CQI",
+                                    FfMacScheduler::PUSCH_UL_CQI, "PUSCH_UL_CQI",
+                                    FfMacScheduler::ALL_UL_CQI, "ALL_UL_CQI"))
     ;
   return tid;
 }
--- a/src/lte/model/ff-mac-scheduler.h	Fri Jun 29 11:51:22 2012 +0200
+++ b/src/lte/model/ff-mac-scheduler.h	Wed Jul 04 12:22:21 2012 +0200
@@ -51,9 +51,9 @@
   */
   enum UlCqiFilter_t
   {
-    SRS,
-    PUSCH,
-    ALL
+    SRS_UL_CQI,
+    PUSCH_UL_CQI,
+    ALL_UL_CQI
   };
   /**
   * constructor
--- a/src/lte/model/pf-ff-mac-scheduler.cc	Fri Jun 29 11:51:22 2012 +0200
+++ b/src/lte/model/pf-ff-mac-scheduler.cc	Wed Jul 04 12:22:21 2012 +0200
@@ -1049,7 +1049,7 @@
   // retrieve the allocation for this subframe
   switch (m_ulCqiFilter)
     {
-      case FfMacScheduler::SRS:
+      case FfMacScheduler::SRS_UL_CQI:
         {
           // filter all the CQIs that are not SRS based
           if (params.m_ulCqi.m_type!=UlCqi_s::SRS)
@@ -1058,7 +1058,7 @@
               }
         }
       break;
-      case FfMacScheduler::PUSCH:
+      case FfMacScheduler::PUSCH_UL_CQI:
         {
           // filter all the CQIs that are not SRS based
           if (params.m_ulCqi.m_type!=UlCqi_s::PUSCH)
@@ -1066,64 +1066,128 @@
               return;
             }
         }
-      case FfMacScheduler::ALL:
+      case FfMacScheduler::ALL_UL_CQI:
       break;
       
       default:
         NS_FATAL_ERROR ("Unknown UL CQI type");
     }
 
-  std::map <uint16_t, std::vector <uint16_t> >::iterator itMap;
-  std::map <uint16_t, std::vector <double> >::iterator itCqi;
-  itMap = m_allocationMaps.find (params.m_sfnSf);
-  if (itMap == m_allocationMaps.end ())
-    {
-      NS_LOG_DEBUG (this << " Does not find info on allocation, size : " << m_allocationMaps.size ());
-      return;
-    }
-  for (uint32_t i = 0; i < (*itMap).second.size (); i++)
-    {
-      // convert from fixed point notation Sxxxxxxxxxxx.xxx to double
-//       NS_LOG_INFO (this << " i " << i << " size " << params.m_ulCqi.m_sinr.size () << " mapSIze " << (*itMap).second.size ());
-      double sinr = LteFfConverter::fpS11dot3toDouble (params.m_ulCqi.m_sinr.at (i));
-      //NS_LOG_DEBUG (this << " UE " << (*itMap).second.at (i) << " SINRfp " << params.m_ulCqi.m_sinr.at (i) << " sinrdb " << sinr);
-      itCqi = m_ueCqi.find ((*itMap).second.at (i));
-      if (itCqi == m_ueCqi.end ())
+  switch (params.m_ulCqi.m_type)
+  {
+    case UlCqi_s::PUSCH:
+      {
+        std::map <uint16_t, std::vector <uint16_t> >::iterator itMap;
+        std::map <uint16_t, std::vector <double> >::iterator itCqi;
+        itMap = m_allocationMaps.find (params.m_sfnSf);
+        if (itMap == m_allocationMaps.end ())
+          {
+            NS_LOG_DEBUG (this << " Does not find info on allocation, size : " << m_allocationMaps.size ());
+            return;
+          }
+        for (uint32_t i = 0; i < (*itMap).second.size (); i++)
+          {
+            // convert from fixed point notation Sxxxxxxxxxxx.xxx to double
+      //       NS_LOG_INFO (this << " i " << i << " size " << params.m_ulCqi.m_sinr.size () << " mapSIze " << (*itMap).second.size ());
+            double sinr = LteFfConverter::fpS11dot3toDouble (params.m_ulCqi.m_sinr.at (i));
+            //NS_LOG_DEBUG (this << " UE " << (*itMap).second.at (i) << " SINRfp " << params.m_ulCqi.m_sinr.at (i) << " sinrdb " << sinr);
+            itCqi = m_ueCqi.find ((*itMap).second.at (i));
+            if (itCqi == m_ueCqi.end ())
+              {
+                // create a new entry
+                std::vector <double> newCqi;
+                for (uint32_t j = 0; j < m_cschedCellConfig.m_ulBandwidth; j++)
+                  {
+                    if (i == j)
+                      {
+                        newCqi.push_back (sinr);
+                      }
+                    else
+                      {
+                        // initialize with NO_SINR value.
+                        newCqi.push_back (NO_SINR);
+                      }
+
+                  }
+                m_ueCqi.insert (std::pair <uint16_t, std::vector <double> > ((*itMap).second.at (i), newCqi));
+                // generate correspondent timer
+                m_ueCqiTimers.insert (std::pair <uint16_t, uint32_t > ((*itMap).second.at (i), m_cqiTimersThreshold));
+              }
+            else
+              {
+                // update the value
+                (*itCqi).second.at (i) = sinr;
+                // update correspondent timer
+                std::map <uint16_t, uint32_t>::iterator itTimers;
+                itTimers = m_ueCqiTimers.find ((*itMap).second.at (i));
+                (*itTimers).second = m_cqiTimersThreshold;
+                
+              }
+
+          }
+        // remove obsolete info on allocation
+        m_allocationMaps.erase (itMap);
+      }
+      break;
+    case UlCqi_s::SRS:
+      {
+        // get the RNTI from vendor specific parameters
+        uint16_t rnti;
+        NS_ASSERT (params.m_vendorSpecificList.size () > 0);
+        for (uint16_t i = 0; i < params.m_vendorSpecificList.size (); i++)
+          {
+            if (params.m_vendorSpecificList.at (i).m_type == SRS_CQI_RNTI_VSP)
+              {
+                Ptr<SrsCqiRntiVsp> vsp = DynamicCast<SrsCqiRntiVsp> (params.m_vendorSpecificList.at (i).m_value);
+                rnti = vsp->GetRnti ();
+              }
+          }
+        std::map <uint16_t, std::vector <double> >::iterator itCqi;
+        itCqi = m_ueCqi.find (rnti);
+        if (itCqi == m_ueCqi.end ())
+          {
+            // create a new entry
+            std::vector <double> newCqi;
+            for (uint32_t j = 0; j < m_cschedCellConfig.m_ulBandwidth; j++)
+            {
+              double sinr = LteFfConverter::fpS11dot3toDouble (params.m_ulCqi.m_sinr.at (j));
+              newCqi.push_back (sinr);
+              NS_LOG_DEBUG (this << " RNTI " << rnti << " new SRS-CQI for RB  " << j << " value " << sinr);
+              
+            }
+            m_ueCqi.insert (std::pair <uint16_t, std::vector <double> > (rnti, newCqi));
+            // generate correspondent timer
+            m_ueCqiTimers.insert (std::pair <uint16_t, uint32_t > (rnti, m_cqiTimersThreshold));
+          }
+        else
         {
-          // create a new entry
-          std::vector <double> newCqi;
+          // update the values
           for (uint32_t j = 0; j < m_cschedCellConfig.m_ulBandwidth; j++)
             {
-              if (i == j)
-                {
-                  newCqi.push_back (sinr);
-                }
-              else
-                {
-                  // initialize with NO_SINR value.
-                  newCqi.push_back (NO_SINR);
-                }
-
+              double sinr = LteFfConverter::fpS11dot3toDouble (params.m_ulCqi.m_sinr.at (j));
+              (*itCqi).second.at (j) = sinr;
+              NS_LOG_DEBUG (this << " RNTI " << rnti << " update SRS-CQI for RB  " << j << " value " << sinr);
             }
-          m_ueCqi.insert (std::pair <uint16_t, std::vector <double> > ((*itMap).second.at (i), newCqi));
-          // generate correspondent timer
-          m_ueCqiTimers.insert (std::pair <uint16_t, uint32_t > ((*itMap).second.at (i), m_cqiTimersThreshold));
-        }
-      else
-        {
-          // update the value
-          (*itCqi).second.at (i) = sinr;
           // update correspondent timer
           std::map <uint16_t, uint32_t>::iterator itTimers;
-          itTimers = m_ueCqiTimers.find ((*itMap).second.at (i));
+          itTimers = m_ueCqiTimers.find (rnti);
           (*itTimers).second = m_cqiTimersThreshold;
           
         }
-
-    }
-  // remove obsolete info on allocation
-  m_allocationMaps.erase (itMap);
-
+        
+        
+      }
+      break;
+    case UlCqi_s::PUCCH_1:
+    case UlCqi_s::PUCCH_2:
+    case UlCqi_s::PRACH:
+      {
+        NS_FATAL_ERROR ("PfFfMacScheduler supports only PUSCH and SRS UL-CQIs");
+      }
+      break;
+    default:
+      NS_FATAL_ERROR ("Unknown type of UL-CQI");
+  }
   return;
 }
 
--- a/src/lte/model/rr-ff-mac-scheduler.cc	Fri Jun 29 11:51:22 2012 +0200
+++ b/src/lte/model/rr-ff-mac-scheduler.cc	Wed Jul 04 12:22:21 2012 +0200
@@ -25,6 +25,7 @@
 #include <ns3/rr-ff-mac-scheduler.h>
 #include <ns3/simulator.h>
 #include <ns3/lte-common.h>
+#include <ns3/lte-vendor-specific-parameters.h>
 
 NS_LOG_COMPONENT_DEFINE ("RrFfMacScheduler");
 
@@ -852,7 +853,7 @@
 //     NS_LOG_DEBUG (this << " Actual sfn " << frameNo << " sbfn " << subframeNo << " sfnSf "  << sfnSf);
   switch (m_ulCqiFilter)
     {
-      case FfMacScheduler::SRS:
+      case FfMacScheduler::SRS_UL_CQI:
         {
           // filter all the CQIs that are not SRS based
           if (params.m_ulCqi.m_type!=UlCqi_s::SRS)
@@ -861,7 +862,7 @@
             }
         }
       break;
-      case FfMacScheduler::PUSCH:
+      case FfMacScheduler::PUSCH_UL_CQI:
         {
           // filter all the CQIs that are not SRS based
             if (params.m_ulCqi.m_type!=UlCqi_s::PUSCH)
@@ -869,62 +870,127 @@
               return;
             }
         }
-      case FfMacScheduler::ALL:
+      case FfMacScheduler::ALL_UL_CQI:
         break;
         
       default:
         NS_FATAL_ERROR ("Unknown UL CQI type");
     }
-  // retrieve the allocation for this subframe
-  std::map <uint16_t, std::vector <uint16_t> >::iterator itMap;
-  std::map <uint16_t, std::vector <double> >::iterator itCqi;
-  itMap = m_allocationMaps.find (params.m_sfnSf);
-  if (itMap == m_allocationMaps.end ())
-    {
-      NS_LOG_DEBUG (this << " Does not find info on allocation");
-      return;
-    }
-  for (uint32_t i = 0; i < (*itMap).second.size (); i++)
+    switch (params.m_ulCqi.m_type)
     {
-      // convert from fixed point notation Sxxxxxxxxxxx.xxx to double
-      double sinr = LteFfConverter::fpS11dot3toDouble (params.m_ulCqi.m_sinr.at (i));
-//       NS_LOG_DEBUG (this << " RB " << i << "UE " << (*itMap).second.at (i) << " SINRfp " << params.m_ulCqi.m_sinr.at (i) << " sinrdb " << sinr);
-      itCqi = m_ueCqi.find ((*itMap).second.at (i));
-      if (itCqi == m_ueCqi.end ())
+      case UlCqi_s::PUSCH:
         {
-          // create a new entry
-          std::vector <double> newCqi;
-          for (uint32_t j = 0; j < m_cschedCellConfig.m_ulBandwidth; j++)
+          std::map <uint16_t, std::vector <uint16_t> >::iterator itMap;
+          std::map <uint16_t, std::vector <double> >::iterator itCqi;
+          itMap = m_allocationMaps.find (params.m_sfnSf);
+          if (itMap == m_allocationMaps.end ())
+            {
+              NS_LOG_DEBUG (this << " Does not find info on allocation, size : " << m_allocationMaps.size ());
+              return;
+            }
+          for (uint32_t i = 0; i < (*itMap).second.size (); i++)
             {
-              if (i == j)
+              // convert from fixed point notation Sxxxxxxxxxxx.xxx to double
+              //       NS_LOG_INFO (this << " i " << i << " size " << params.m_ulCqi.m_sinr.size () << " mapSIze " << (*itMap).second.size ());
+              double sinr = LteFfConverter::fpS11dot3toDouble (params.m_ulCqi.m_sinr.at (i));
+              //NS_LOG_DEBUG (this << " UE " << (*itMap).second.at (i) << " SINRfp " << params.m_ulCqi.m_sinr.at (i) << " sinrdb " << sinr);
+              itCqi = m_ueCqi.find ((*itMap).second.at (i));
+              if (itCqi == m_ueCqi.end ())
                 {
-                  newCqi.push_back (sinr);
+                  // create a new entry
+                  std::vector <double> newCqi;
+                  for (uint32_t j = 0; j < m_cschedCellConfig.m_ulBandwidth; j++)
+                    {
+                      if (i == j)
+                        {
+                          newCqi.push_back (sinr);
+                        }
+                      else
+                        {
+                          // initialize with NO_SINR value.
+                          newCqi.push_back (30.0);
+                        }
+                      
+                    }
+                  m_ueCqi.insert (std::pair <uint16_t, std::vector <double> > ((*itMap).second.at (i), newCqi));
+                  // generate correspondent timer
+                  m_ueCqiTimers.insert (std::pair <uint16_t, uint32_t > ((*itMap).second.at (i), m_cqiTimersThreshold));
                 }
               else
                 {
-                  // initialize with maximum value according to the fixed point notation
-                  newCqi.push_back (30.0);
+                  // update the value
+                  (*itCqi).second.at (i) = sinr;
+                  // update correspondent timer
+                  std::map <uint16_t, uint32_t>::iterator itTimers;
+                  itTimers = m_ueCqiTimers.find ((*itMap).second.at (i));
+                  (*itTimers).second = m_cqiTimersThreshold;
+                  
                 }
-
+              
             }
-          m_ueCqi.insert (std::pair <uint16_t, std::vector <double> > ((*itMap).second.at (i), newCqi));
-          // generate correspondent timer
-          m_ueCqiTimers.insert (std::pair <uint16_t, uint32_t > ((*itMap).second.at (i), m_cqiTimersThreshold));
+          // remove obsolete info on allocation
+          m_allocationMaps.erase (itMap);
         }
-      else
+      break;
+      case UlCqi_s::SRS:
         {
-          // update the value
-          (*itCqi).second.at (i) = sinr;
-          // update correspondent timer
-          std::map <uint16_t, uint32_t>::iterator itTimers;
-          itTimers = m_ueCqiTimers.find ((*itMap).second.at (i));
-          (*itTimers).second = m_cqiTimersThreshold;
+          // get the RNTI from vendor specific parameters
+          uint16_t rnti;
+          NS_ASSERT (params.m_vendorSpecificList.size () > 0);
+          for (uint16_t i = 0; i < params.m_vendorSpecificList.size (); i++)
+            {
+              if (params.m_vendorSpecificList.at (i).m_type == SRS_CQI_RNTI_VSP)
+                {
+                  Ptr<SrsCqiRntiVsp> vsp = DynamicCast<SrsCqiRntiVsp> (params.m_vendorSpecificList.at (i).m_value);
+                  rnti = vsp->GetRnti ();
+                }
+            }
+          std::map <uint16_t, std::vector <double> >::iterator itCqi;
+          itCqi = m_ueCqi.find (rnti);
+          if (itCqi == m_ueCqi.end ())
+            {
+              // create a new entry
+              std::vector <double> newCqi;
+              for (uint32_t j = 0; j < m_cschedCellConfig.m_ulBandwidth; j++)
+                {
+                  double sinr = LteFfConverter::fpS11dot3toDouble (params.m_ulCqi.m_sinr.at (j));
+                  newCqi.push_back (sinr);
+                  NS_LOG_DEBUG (this << " RNTI " << rnti << " new SRS-CQI for RB  " << j << " value " << sinr);
+                  
+                }
+              m_ueCqi.insert (std::pair <uint16_t, std::vector <double> > (rnti, newCqi));
+              // generate correspondent timer
+              m_ueCqiTimers.insert (std::pair <uint16_t, uint32_t > (rnti, m_cqiTimersThreshold));
+            }
+          else
+            {
+              // update the values
+              for (uint32_t j = 0; j < m_cschedCellConfig.m_ulBandwidth; j++)
+                {
+                  double sinr = LteFfConverter::fpS11dot3toDouble (params.m_ulCqi.m_sinr.at (j));
+                  (*itCqi).second.at (j) = sinr;
+                  NS_LOG_DEBUG (this << " RNTI " << rnti << " update SRS-CQI for RB  " << j << " value " << sinr);
+                }
+              // update correspondent timer
+              std::map <uint16_t, uint32_t>::iterator itTimers;
+              itTimers = m_ueCqiTimers.find (rnti);
+              (*itTimers).second = m_cqiTimersThreshold;
+              
+            }
+          
+          
         }
-
+      break;
+      case UlCqi_s::PUCCH_1:
+      case UlCqi_s::PUCCH_2:
+      case UlCqi_s::PRACH:
+        {
+          NS_FATAL_ERROR ("PfFfMacScheduler supports only PUSCH and SRS UL-CQIs");
+        }
+      break;
+      default:
+        NS_FATAL_ERROR ("Unknown type of UL-CQI");
     }
-  // remove obsolete info on allocation
-  m_allocationMaps.erase (itMap);
-
   return;
 }
 
--- a/src/lte/test/lte-test-interference.cc	Fri Jun 29 11:51:22 2012 +0200
+++ b/src/lte/test/lte-test-interference.cc	Wed Jul 04 12:22:21 2012 +0200
@@ -27,6 +27,7 @@
 
 #include "ns3/mobility-helper.h"
 #include "ns3/lte-helper.h"
+#include "ns3/ff-mac-scheduler.h"
 
 #include "ns3/lte-enb-phy.h"
 #include "ns3/lte-enb-net-device.h"
@@ -153,6 +154,7 @@
   NetDeviceContainer ueDevs1;
   NetDeviceContainer ueDevs2;
   lteHelper->SetSchedulerType ("ns3::RrFfMacScheduler");
+  lteHelper->SetSchedulerAttribute ("UlCqiFilter", EnumValue (FfMacScheduler::PUSCH_UL_CQI));
   enbDevs = lteHelper->InstallEnbDevice (enbNodes);
   ueDevs1 = lteHelper->InstallUeDevice (ueNodes1);
   ueDevs2 = lteHelper->InstallUeDevice (ueNodes2);
--- a/src/lte/test/lte-test-phy-error-model.cc	Fri Jun 29 11:51:22 2012 +0200
+++ b/src/lte/test/lte-test-phy-error-model.cc	Wed Jul 04 12:22:21 2012 +0200
@@ -47,6 +47,7 @@
 #include <ns3/boolean.h>
 #include <ns3/enum.h>
 #include <ns3/unused.h>
+#include <ns3/ff-mac-scheduler.h>
 
 
 NS_LOG_COMPONENT_DEFINE ("LenaTestPhyErrorModel");
@@ -184,6 +185,7 @@
   NetDeviceContainer enbDevs;
   NetDeviceContainer ueDevs;
   lena->SetSchedulerType ("ns3::RrFfMacScheduler");
+  lena->SetSchedulerAttribute ("UlCqiFilter", EnumValue (FfMacScheduler::PUSCH_UL_CQI));
   
   enbDevs = lena->InstallEnbDevice (enbNodes);
   ueDevs = lena->InstallUeDevice (ueNodes);
--- a/src/lte/test/test-lte-antenna.cc	Fri Jun 29 11:51:22 2012 +0200
+++ b/src/lte/test/test-lte-antenna.cc	Wed Jul 04 12:22:21 2012 +0200
@@ -23,6 +23,7 @@
 #include "ns3/log.h"
 #include "ns3/string.h"
 #include "ns3/double.h"
+#include "ns3/enum.h"
 #include "ns3/test.h"
 #include "ns3/mobility-helper.h"
 #include "ns3/lte-helper.h"
@@ -31,6 +32,7 @@
 #include "ns3/lte-ue-net-device.h"
 #include "ns3/lte-enb-phy.h"
 #include "ns3/lte-enb-net-device.h"
+#include "ns3/ff-mac-scheduler.h"
 
 #include "lte-test-sinr-chunk-processor.h"
 
@@ -117,6 +119,7 @@
   NetDeviceContainer enbDevs;
   NetDeviceContainer ueDevs;
   lteHelper->SetSchedulerType ("ns3::RrFfMacScheduler");
+  lteHelper->SetSchedulerAttribute ("UlCqiFilter", EnumValue (FfMacScheduler::PUSCH_UL_CQI));
   lteHelper->SetEnbAntennaModelType ("ns3::CosineAntennaModel");
   lteHelper->SetEnbAntennaModelAttribute ("Orientation", DoubleValue (m_orientationDegrees));
   lteHelper->SetEnbAntennaModelAttribute ("Beamwidth",   DoubleValue (m_beamwidthDegrees));