Bug 2153 [wifi] - Incorrect power limits in wifi power control algorithms
authorMatias Richart <mrichart@fing.edu.uy>
Wed, 22 Jul 2015 23:14:47 +0200
changeset 11524 f0c39728e884
parent 11523 4224e7bde1e4
child 11525 7e0fee5babf8
Bug 2153 [wifi] - Incorrect power limits in wifi power control algorithms
src/wifi/model/aparf-wifi-manager.cc
src/wifi/model/aparf-wifi-manager.h
src/wifi/model/parf-wifi-manager.cc
src/wifi/model/parf-wifi-manager.h
--- a/src/wifi/model/aparf-wifi-manager.cc	Wed Jul 22 08:53:01 2015 -0700
+++ b/src/wifi/model/aparf-wifi-manager.cc	Wed Jul 22 23:14:47 2015 +0200
@@ -127,7 +127,8 @@
 void
 AparfWifiManager::SetupPhy (Ptr<WifiPhy> phy)
 {
-  m_nPower = phy->GetNTxPower ();
+  m_minPower = phy->GetTxPowerStart();
+  m_maxPower = phy->GetTxPowerEnd();
   WifiRemoteStationManager::SetupPhy (phy);
 }
 
@@ -158,7 +159,7 @@
     {
       station->m_nSupported = GetNSupported (station);
       station->m_rate = station->m_nSupported - 1;
-      station->m_power = m_nPower - 1;
+      station->m_power = m_maxPower;
       station->m_rateCrit = 0;
       m_powerChange (station->m_power, station->m_state->m_address);
       m_rateChange (station->m_rate, station->m_state->m_address);
@@ -197,7 +198,7 @@
       station->m_nFailed = 0;
       station->m_nSuccess = 0;
       station->m_pCount = 0;
-      if (station->m_power == (m_nPower - 1))
+      if (station->m_power == m_maxPower)
         {
           station->m_rateCrit = station->m_rate;
           if (station->m_rate != 0)
@@ -261,7 +262,7 @@
       station->m_nFailed = 0;
       if (station->m_rate == (station->m_state->m_operationalRateSet.size () - 1))
         {
-          if (station->m_power != 0)
+          if (station->m_power != m_minPower)
             {
               NS_LOG_DEBUG ("station=" << station << " dec power");
               station->m_power -= m_powerDec;
@@ -283,7 +284,7 @@
             {
               if (station->m_pCount == m_powerMax)
                 {
-                  station->m_power = (m_nPower - 1);
+                  station->m_power = m_maxPower;
                   m_powerChange (station->m_power, station->m_state->m_address);
                   station->m_rate = station->m_rateCrit;
                   m_rateChange (station->m_rate, station->m_state->m_address);
@@ -292,7 +293,7 @@
                 }
               else
                 {
-                  if (station->m_power != 0)
+                  if (station->m_power != m_minPower)
                     {
                       station->m_power -= m_powerDec;
                       m_powerChange (station->m_power, station->m_state->m_address);
--- a/src/wifi/model/aparf-wifi-manager.h	Wed Jul 22 08:53:01 2015 -0700
+++ b/src/wifi/model/aparf-wifi-manager.h	Wed Jul 22 23:14:47 2015 +0200
@@ -110,12 +110,18 @@
   uint32_t m_powerDec;   //!< Step size for decrement the power.
   uint32_t m_rateInc;    //!< Step size for increment the rate.
   uint32_t m_rateDec;    //!< Step size for decrement the rate.
+
   /**
-   * Number of power levels.
+   * Minimal power level.
    * Differently form rate, power levels do not depend on the remote station.
    * The levels depend only on the physical layer of the device.
    */
-  uint32_t m_nPower;
+  uint32_t m_minPower;  
+
+  /**
+   * Maximal power level.
+   */
+  uint32_t m_maxPower;
 
   /**
    * The trace source fired when the transmission power change
--- a/src/wifi/model/parf-wifi-manager.cc	Wed Jul 22 08:53:01 2015 -0700
+++ b/src/wifi/model/parf-wifi-manager.cc	Wed Jul 22 23:14:47 2015 +0200
@@ -95,7 +95,8 @@
 void
 ParfWifiManager::SetupPhy (Ptr<WifiPhy> phy)
 {
-  m_nPower = phy->GetNTxPower ();
+  m_minPower = phy->GetTxPowerStart ();
+  m_maxPower = phy->GetTxPowerEnd ();
   WifiRemoteStationManager::SetupPhy (phy);
 }
 
@@ -126,7 +127,7 @@
     {
       station->m_nSupported = GetNSupported (station);
       station->m_currentRate = station->m_nSupported - 1;
-      station->m_currentPower = m_nPower - 1;
+      station->m_currentPower = m_maxPower;
       m_powerChange (station->m_currentPower, station->m_state->m_address);
       m_rateChange (station->m_currentRate, station->m_state->m_address);
       station->m_initialized = true;
@@ -184,7 +185,7 @@
       if (station->m_nRetry == 1)
         {
           //need recovery fallback
-          if (station->m_currentPower < m_nPower - 1)
+          if (station->m_currentPower < m_maxPower)
             {
               NS_LOG_DEBUG ("station=" << station << " inc power");
               station->m_currentPower++;
@@ -200,7 +201,7 @@
       if (((station->m_nRetry - 1) % 2) == 1)
         {
           //need normal fallback
-          if (station->m_currentPower == m_nPower - 1)
+          if (station->m_currentPower == m_maxPower)
             {
               if (station->m_currentRate != 0)
                 {
@@ -264,7 +265,7 @@
   else if (station->m_nSuccess == m_successThreshold || station->m_nAttempt == m_attemptThreshold)
     {
       //we are at the maximum rate, we decrease power
-      if (station->m_currentPower != 0)
+      if (station->m_currentPower != m_minPower)
         {
           NS_LOG_DEBUG ("station=" << station << " dec power");
           station->m_currentPower--;
--- a/src/wifi/model/parf-wifi-manager.h	Wed Jul 22 08:53:01 2015 -0700
+++ b/src/wifi/model/parf-wifi-manager.h	Wed Jul 22 23:14:47 2015 +0200
@@ -91,12 +91,18 @@
 
   uint32_t m_attemptThreshold; //!< The minimum number of transmission attempts to try a new power or rate. The 'timer' threshold in the ARF algorithm.
   uint32_t m_successThreshold; //!< The minimum number of successful transmissions to try a new power or rate.
+  
   /**
-   * Number of power levels.
+   * Minimal power level.
    * In contrast to rate, power levels do not depend on the remote station.
    * The levels depend only on the physical layer of the device.
    */
-  uint32_t m_nPower;
+  uint32_t m_minPower;
+
+  /**
+   * Maximal power level.
+   */
+  uint32_t m_maxPower;
 
   /**
    * The trace source fired when the transmission power changes....