Bug-fix LteUePhy UE Measurements PSS storage by introducing PssElement struct
authorMarco Miozzo <marco.miozzo@cttc.es>
Mon, 04 Mar 2013 11:50:24 +0100
changeset 9996 62697fe2165d
parent 9994 9bc8e1488619
child 9997 b8e98f51206d
Bug-fix LteUePhy UE Measurements PSS storage by introducing PssElement struct
src/lte/model/lte-spectrum-phy.cc
src/lte/model/lte-spectrum-phy.h
src/lte/model/lte-ue-phy.cc
src/lte/model/lte-ue-phy.h
--- a/src/lte/model/lte-spectrum-phy.cc	Fri Mar 01 09:33:18 2013 +0100
+++ b/src/lte/model/lte-spectrum-phy.cc	Mon Mar 04 11:50:24 2013 +0100
@@ -155,7 +155,7 @@
   m_ltePhyRxCtrlEndErrorCallback = MakeNullCallback< void > ();
   m_ltePhyDlHarqFeedbackCallback = MakeNullCallback< void, DlInfoListElement_s > ();
   m_ltePhyUlHarqFeedbackCallback = MakeNullCallback< void, UlInfoListElement_s > ();
-  m_ltePhyRxPssCallback = MakeNullCallback< void, uint16_t, SpectrumValue > ();
+  m_ltePhyRxPssCallback = MakeNullCallback< void, uint16_t, Ptr<SpectrumValue> > ();
   SpectrumPhy::DoDispose ();
 } 
 
@@ -765,7 +765,7 @@
                   SpectrumValue pssPsd = *params->psd;
                   if (!m_ltePhyRxPssCallback.IsNull ())
                     {
-                      m_ltePhyRxPssCallback (cellId, pssPsd);
+                      m_ltePhyRxPssCallback (cellId, params->psd);
                     }
                 }
             }
--- a/src/lte/model/lte-spectrum-phy.h	Fri Mar 01 09:33:18 2013 +0100
+++ b/src/lte/model/lte-spectrum-phy.h	Mon Mar 04 11:50:24 2013 +0100
@@ -125,7 +125,7 @@
 * This method is used by the LteSpectrumPhy to notify the UE PHY that a
 * PSS has been received
 */
-typedef Callback< void, uint16_t, SpectrumValue > LtePhyRxPssCallback;
+typedef Callback< void, uint16_t, Ptr<SpectrumValue> > LtePhyRxPssCallback;
 
 
 /**
--- a/src/lte/model/lte-ue-phy.cc	Fri Mar 01 09:33:18 2013 +0100
+++ b/src/lte/model/lte-ue-phy.cc	Mon Mar 04 11:50:24 2013 +0100
@@ -505,36 +505,33 @@
     {
       NS_ASSERT_MSG (m_rsInterferencePowerUpdated, " RS interference power info obsolete");
       // PSSs received
-      std::map <uint16_t, SpectrumValue>::iterator itPss = m_pssMap.begin ();
-      while (itPss != m_pssMap.end ())
+      std::list <PssElement>::iterator itPss = m_pssList.begin ();
+      while (itPss != m_pssList.end ())
         {
-          NS_LOG_DEBUG (this << " PSS received from eNB " << (*itPss).first);
+          NS_LOG_DEBUG (this << " PSS received from eNB " << (*itPss).cellId << " pssSum " << (*itPss).pssPsdSum << " nRB " << (*itPss).nRB);
           uint8_t rbNum = 0;
-          SpectrumValue pi = (*itPss).second;
-          Values::const_iterator itPi;
-          double rsrpSum = 0.0;
           double rsrqSum = 0.0;
-          Values::const_iterator itInt = m_rsIntereferencePower.ConstValuesBegin ();
-          Values::const_iterator itPj = m_rsIntereferencePower.ConstValuesBegin ();
-          Ptr<SpectrumValue> noisePsd = LteSpectrumValueHelper::CreateNoisePowerSpectralDensity (m_ulEarfcn, m_ulBandwidth, m_noiseFigure);
-          Values::const_iterator itN = noisePsd->ConstValuesBegin ();
-          for (itPi = pi.ConstValuesBegin (); itPi != pi.ConstValuesEnd (); itPi++, itInt++, itPj++, itN++)
+          Values::const_iterator itIntN = m_rsIntereferencePower.ConstValuesBegin ();
+          Values::const_iterator itPj = m_rsReceivedPower.ConstValuesBegin ();
+//           NS_LOG_DEBUG (this << "\t INT + N" << m_rsIntereferencePower);
+//           NS_LOG_DEBUG (this << "\t Pj " << m_rsReceivedPower);
+          for (itPj = m_rsReceivedPower.ConstValuesBegin (); itPj != m_rsReceivedPower.ConstValuesEnd (); itIntN++, itPj++)
             {
               rbNum++;
-              rsrpSum += (*itPi);
-              rsrqSum += (*itInt) + (*itPj) + (*itN);
+              rsrqSum += ((*itIntN) + (*itPj));
+//               NS_LOG_DEBUG (this << " RSRQsum " << rsrqSum);
               
             }
-
-          double rsrp_dBm = 10 * log (1000 * rsrpSum / (double)rbNum);
-          double rsrq_dB = 10 * log (rsrpSum / rsrqSum);
+          NS_ASSERT (rbNum == (*itPss).nRB);
+          double rsrp_dBm = 10 * log (1000 * (*itPss).pssPsdSum / (double)rbNum);
+          double rsrq_dB = 10 * log ((*itPss).pssPsdSum / rsrqSum);
 
           if (rsrq_dB > m_pssReceptionThreshold)
             {
               // report UE Measurements to upper layers
-              NS_LOG_DEBUG (this << " CellId " << (*itPss).first << " has RSRP " << rsrp_dBm << " and RSRQ " << rsrq_dB);
+              NS_LOG_DEBUG (this << " CellId " << (*itPss).cellId << " has RSRP " << rsrp_dBm << " and RSRQ " << rsrq_dB << " RBnum " << (uint16_t)rbNum);
               // store measurements
-              std::map <uint16_t, UeMeasurementsElement>::iterator itMeasMap =  m_UeMeasurementsMap.find ((*itPss).first);
+              std::map <uint16_t, UeMeasurementsElement>::iterator itMeasMap =  m_UeMeasurementsMap.find ((*itPss).cellId);
               if (itMeasMap == m_UeMeasurementsMap.end ())
                 {
                   // insert new entry
@@ -543,7 +540,7 @@
                   newEl.rsrpNum = 1;
                   newEl.rsrqSum = rsrq_dB;
                   newEl.rsrqNum = 1;
-                  m_UeMeasurementsMap.insert (std::pair <uint16_t, UeMeasurementsElement> ((*itPss).first, newEl));
+                  m_UeMeasurementsMap.insert (std::pair <uint16_t, UeMeasurementsElement> ((*itPss).cellId, newEl));
                 }
               else
                 {
@@ -835,11 +832,28 @@
 
 
 void
-LteUePhy::ReceivePss (uint16_t cellId, SpectrumValue p)
+LteUePhy::ReceivePss (uint16_t cellId, Ptr<SpectrumValue> p)
 {
-  NS_LOG_FUNCTION (this << cellId);
+  NS_LOG_FUNCTION (this << cellId << (*p));
+  if (!m_dlConfigured)
+    {
+      // LteUePhy not yet configured -> skip measurement
+      return;
+    }
   m_pssReceived = true;
-  m_pssMap.insert (std::pair <uint16_t, SpectrumValue> (cellId, p));
+  PssElement el;
+  el.cellId = cellId;
+  double sum = 0.0;
+  uint16_t nRB = 0;
+  Values::const_iterator itPi;
+  for (itPi = p->ConstValuesBegin (); itPi != p->ConstValuesEnd (); itPi++)
+    {
+      sum += (*itPi);
+      nRB++;
+    }
+  el.pssPsdSum = sum;
+  el.nRB = nRB;
+  m_pssList.push_back (el);
 }
 
 
--- a/src/lte/model/lte-ue-phy.h	Fri Mar 01 09:33:18 2013 +0100
+++ b/src/lte/model/lte-ue-phy.h	Mon Mar 04 11:50:24 2013 +0100
@@ -178,7 +178,7 @@
 
   // callbacks for LteSpectrumPhy
   virtual void ReceiveLteControlMessageList (std::list<Ptr<LteControlMessage> >);
-  virtual void ReceivePss (uint16_t cellId, SpectrumValue p);
+  virtual void ReceivePss (uint16_t cellId, Ptr<SpectrumValue> p);
   
   
 
@@ -290,7 +290,13 @@
   SpectrumValue m_rsIntereferencePower;
 
   bool m_pssReceived;
-  std::map <uint16_t, SpectrumValue> m_pssMap;
+  struct PssElement
+    {
+      uint16_t cellId;
+      double pssPsdSum;
+      uint16_t nRB;
+    };
+  std::list <PssElement> m_pssList;
 
   double m_pssReceptionThreshold; // on RSRQ [W]