implement the MRR portion of AMRR
authorMathieu Lacage <mathieu.lacage@sophia.inria.fr>
Thu, 13 Dec 2007 15:07:08 +0100
changeset 2276 26e3bc114fdd
parent 2275 f1ae27b37d8f
child 2277 51c66e7993c0
implement the MRR portion of AMRR
src/devices/wifi/amrr-mac-stations.cc
src/devices/wifi/amrr-mac-stations.h
--- a/src/devices/wifi/amrr-mac-stations.cc	Thu Dec 13 15:04:11 2007 +0100
+++ b/src/devices/wifi/amrr-mac-stations.cc	Thu Dec 13 15:07:08 2007 +0100
@@ -81,6 +81,7 @@
 void 
 AmrrMacStation::ReportDataFailed (void)
 {
+  m_retry++;
   m_tx_retr++;
 }
 void 
@@ -89,6 +90,7 @@
 void 
 AmrrMacStation::ReportDataOk (double ackSnr, WifiMode ackMode, double dataSnr)
 {
+  m_retry = 0;
   m_tx_ok++;
 }
 void 
@@ -97,6 +99,7 @@
 void 
 AmrrMacStation::ReportFinalDataFailed (void)
 {
+  m_retry = 0;
   m_tx_err++;
 }
 bool
@@ -208,7 +211,46 @@
 {
   UpdateMode ();
   NS_ASSERT (m_txrate < GetNSupportedModes ());
-  return GetSupportedMode (m_txrate);
+  uint32_t rateIndex;
+  if (m_retry < 1)
+    {
+      rateIndex = m_txrate;
+    }
+  else if (m_retry < 2)
+    {
+      if (m_txrate > 0)
+        {
+          rateIndex = m_txrate - 1;
+        }
+      else
+        {
+          rateIndex = m_txrate;
+        }
+    }
+  else if (m_retry < 3)
+    {
+      if (m_txrate > 1)
+        {
+          rateIndex = m_txrate - 2;
+        }
+      else
+        {
+          rateIndex = m_txrate;
+        }
+    }
+  else
+    {
+      if (m_txrate > 2)
+        {
+          rateIndex = m_txrate - 3;
+        }
+      else
+        {
+          rateIndex = m_txrate;
+        }
+    }
+
+  return GetSupportedMode (rateIndex);
 }
 WifiMode 
 AmrrMacStation::DoGetRtsMode (void)
--- a/src/devices/wifi/amrr-mac-stations.h	Thu Dec 13 15:04:11 2007 +0100
+++ b/src/devices/wifi/amrr-mac-stations.h	Thu Dec 13 15:07:08 2007 +0100
@@ -79,6 +79,7 @@
   uint32_t m_tx_ok;
   uint32_t m_tx_err;
   uint32_t m_tx_retr;
+  uint32_t m_retry;
   uint32_t m_txrate;
   uint32_t m_successThreshold;
   uint32_t m_success;