add support for block ack in MacLowTransmissionListener
authorMirko Banchi <mk.banchi@gmail.com>
Wed, 03 Feb 2010 20:34:50 +0100
changeset 5955 10fbe045901e
parent 5954 2b9e06875b69
child 5956 e9918be47f78
add support for block ack in MacLowTransmissionListener
src/devices/wifi/edca-txop-n.cc
src/devices/wifi/edca-txop-n.h
src/devices/wifi/mac-low.cc
src/devices/wifi/mac-low.h
--- a/src/devices/wifi/edca-txop-n.cc	Wed Feb 03 20:34:50 2010 +0100
+++ b/src/devices/wifi/edca-txop-n.cc	Wed Feb 03 20:34:50 2010 +0100
@@ -32,6 +32,7 @@
 #include "wifi-mac-queue.h"
 #include "msdu-aggregator.h"
 #include "mgt-headers.h"
+#include "ctrl-headers.h"
 
 NS_LOG_COMPONENT_DEFINE ("EdcaTxopN");
 
@@ -83,6 +84,9 @@
   virtual void MissedAck (void) {
     m_txop->MissedAck ();
   }
+  virtual void GotBlockAck (const CtrlBAckResponseHeader *blockAck, Mac48Address source) {
+    m_txop->GotBlockAck (blockAck, source);
+  }
   virtual void StartNext (void) {
     m_txop->StartNext ();
   }
@@ -709,4 +713,14 @@
   RestartAccessIfNeeded ();
 }
 
+void
+EdcaTxopN::GotBlockAck (const CtrlBAckResponseHeader *blockAck, Mac48Address recipient)
+{
+  MY_DEBUG ("got block ack from="<<recipient);
+  m_currentPacket = 0;
+  m_dcf->ResetCw ();
+  m_dcf->StartBackoffNow (m_rng->GetNext (0, m_dcf->GetCw ()));
+  RestartAccessIfNeeded ();
+}
+
 } //namespace ns3
--- a/src/devices/wifi/edca-txop-n.h	Wed Feb 03 20:34:50 2010 +0100
+++ b/src/devices/wifi/edca-txop-n.h	Wed Feb 03 20:34:50 2010 +0100
@@ -46,6 +46,7 @@
 class RandomStream;
 class MsduAggregator;
 class MgtAddBaResponseHeader;
+class CtrlBAckResponseHeader;
 
 
 /* This queue contains packets for a particular access class.
@@ -112,6 +113,7 @@
   void GotCts (double snr, WifiMode txMode);
   void MissedCts (void);
   void GotAck (double snr, WifiMode txMode);
+  void GotBlockAck (const CtrlBAckResponseHeader *blockAck, Mac48Address recipient);
   void GotAddBaResponse (const MgtAddBaResponseHeader *respHdr, Mac48Address recipient);
   void MissedAck (void);
   void StartNext (void);
--- a/src/devices/wifi/mac-low.cc	Wed Feb 03 20:34:50 2010 +0100
+++ b/src/devices/wifi/mac-low.cc	Wed Feb 03 20:34:50 2010 +0100
@@ -110,6 +110,10 @@
 {}
 MacLowTransmissionListener::~MacLowTransmissionListener ()
 {}
+void
+MacLowTransmissionListener::GotBlockAck (const CtrlBAckResponseHeader *blockAck,
+                                         Mac48Address source)
+{}
 MacLowDcfListener::MacLowDcfListener ()
 {}
 MacLowDcfListener::~MacLowDcfListener ()
--- a/src/devices/wifi/mac-low.h	Wed Feb 03 20:34:50 2010 +0100
+++ b/src/devices/wifi/mac-low.h	Wed Feb 03 20:34:50 2010 +0100
@@ -28,6 +28,7 @@
 #include "wifi-mode.h"
 #include "wifi-preamble.h"
 #include "wifi-remote-station-manager.h"
+#include "ctrl-headers.h"
 #include "ns3/mac48-address.h"
 #include "ns3/callback.h"
 #include "ns3/event-id.h"
@@ -76,6 +77,19 @@
    */
   virtual void MissedAck (void) = 0;
   /**
+   * \param blockAck Block ack response header
+   * \param source Address of block ack sender
+   *
+   * Invoked when ns3::MacLow receives a block ack frame.
+   * Block ack frame is received after a block ack request
+   * and contains information about the correct reception 
+   * of a set of packet for which a normal ack wasn't send.
+   * Default implementation for this method is empty. Every
+   * queue that intends to be notified by MacLow of reception
+   * of a block ack must redefine this function.
+   */
+  virtual void GotBlockAck (const CtrlBAckResponseHeader *blockAck, Mac48Address source);
+  /**
    * Invoked when ns3::MacLow wants to start a new transmission
    * as configured by MacLowTransmissionParameters::EnableNextData.
    * The listener is expected to call again MacLow::StartTransmission