add more files to build
authorMathieu Lacage <mathieu.lacage@sophia.inria.fr>
Wed, 03 Oct 2007 13:12:26 +0200
changeset 1895 6c2d6a5631bc
parent 1894 d83a91e03101
child 1896 9861a16a8a1d
add more files to build
src/devices/wifi/aarf-mac-stations.cc
src/devices/wifi/aarf-mac-stations.h
src/devices/wifi/arf-mac-stations.cc
src/devices/wifi/arf-mac-stations.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/devices/wifi/aarf-mac-stations.cc	Wed Oct 03 13:12:26 2007 +0200
@@ -0,0 +1,73 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2004,2005,2006 INRIA
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as 
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
+ */
+
+#include "aarf-mac-stations.h"
+
+#define Min(a,b) ((a<b)?a:b)
+#define Max(a,b) ((a>b)?a:b)
+
+namespace ns3 {
+
+AarfMacStations::AarfMacStations (uint8_t nMode)
+  : ArfMacStations (nMode)
+{}
+AarfMacStations::~AarfMacStations ()
+{}
+MacStation *
+AarfMacStations::CreateStation (void)
+{
+  return new AarfMacStation (this, 2.0, 60, 2.0);
+}
+
+
+
+
+AarfMacStation::AarfMacStation (AarfMacStations *stations,   
+                                double successK,
+                                int maxSuccessThreshold,
+                                double timerK)
+  : ArfMacStation (stations, 15, 10),
+    m_successK (successK),
+    m_maxSuccessThreshold (maxSuccessThreshold),
+    m_timerK (timerK)
+{}
+
+
+AarfMacStation::~AarfMacStation ()
+{}
+
+void 
+AarfMacStation::ReportRecoveryFailure (void)
+{
+  SetSuccessThreshold ((int)(Min (GetSuccessThreshold () * m_successK,
+                                  m_maxSuccessThreshold)));
+  SetTimerTimeout ((int)(Max (GetMinTimerTimeout (),
+                              GetSuccessThreshold () * m_timerK)));
+}
+
+void 
+AarfMacStation::ReportFailure (void)
+{
+  SetTimerTimeout (GetMinTimerTimeout ());
+  SetSuccessThreshold (GetMinSuccessThreshold ());
+}
+
+}; // namespace ns3
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/devices/wifi/aarf-mac-stations.h	Wed Oct 03 13:12:26 2007 +0200
@@ -0,0 +1,57 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2005,2006 INRIA
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as 
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
+ */
+#ifndef AARF_MAC_STATIONS_H
+#define AARF_MAC_STATIONS_H
+
+#include "arf-mac-stations.h"
+
+namespace ns3 {
+
+class AarfMacStations : public ArfMacStations {
+public:
+  AarfMacStations (uint8_t nModes);
+  virtual ~AarfMacStations ();
+private:
+  virtual class MacStation *CreateStation (void);
+};
+
+class AarfMacStation : public ArfMacStation
+{
+public:
+  AarfMacStation (AarfMacStations *stations,
+                  double successK,
+                  int maxSuccessThreshold,
+                  double timerK);
+  virtual ~AarfMacStation ();
+
+private:
+  virtual void ReportRecoveryFailure (void);
+  virtual void ReportFailure (void);
+
+  double m_successK;
+  int m_maxSuccessThreshold;
+  double m_timerK;
+};
+
+}; // namespace ns3
+
+
+#endif /* AARF_MAC_STATIONS_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/devices/wifi/arf-mac-stations.cc	Wed Oct 03 13:12:26 2007 +0200
@@ -0,0 +1,234 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2004,2005,2006 INRIA
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as 
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
+ */
+
+#include "mac-stations.h"
+#include "mac-station.h"
+#include "arf-mac-stations.h"
+
+#include <cassert>
+
+namespace ns3 {
+  
+ArfMacStation::ArfMacStation (ArfMacStations *stations,
+                              int minTimerTimeout,
+                              int minSuccessThreshold)
+{
+  m_stations = stations;
+  m_minTimerTimeout = minTimerTimeout;
+  m_minSuccessThreshold = minSuccessThreshold;
+  m_successThreshold = m_minSuccessThreshold;
+  m_timerTimeout = m_minTimerTimeout;
+  m_rate = GetMinRate ();
+
+  m_success = 0;
+  m_failed = 0;
+  m_recovery = false;
+  m_retry = 0;
+  m_timer = 0;
+}
+ArfMacStation::~ArfMacStation ()
+{}
+
+int 
+ArfMacStation::GetMaxRate (void)
+{
+  return m_stations->GetNModes ();
+}
+int 
+ArfMacStation::GetMinRate (void)
+{
+  return 0;
+}
+
+bool 
+ArfMacStation::NeedRecoveryFallback (void)
+{
+  if (m_retry == 1) 
+    {
+      return true;
+    } 
+  else 
+    {
+      return false;
+    }
+}
+bool 
+ArfMacStation::NeedNormalFallback (void)
+{
+  int retryMod = (m_retry - 1) % 2;
+  if (retryMod == 1) 
+    {
+      return true;
+    } 
+  else 
+    {
+      return false;
+    }
+}
+
+
+
+void 
+ArfMacStation::ReportRtsFailed (void)
+{}
+/**
+ * It is important to realize that "recovery" mode starts after failure of
+ * the first transmission after a rate increase and ends at the first successful
+ * transmission. Specifically, recovery mode transcends retransmissions boundaries.
+ * Fundamentally, ARF handles each data transmission independently, whether it
+ * is the initial transmission of a packet or the retransmission of a packet.
+ * The fundamental reason for this is that there is a backoff between each data
+ * transmission, be it an initial transmission or a retransmission.
+ */
+void 
+ArfMacStation::ReportDataFailed (void)
+{
+  m_timer++;
+  m_failed++;
+  m_retry++;
+  m_success = 0;
+
+  if (m_recovery) 
+    {
+      assert (m_retry >= 1);
+      if (NeedRecoveryFallback ()) 
+        {
+          ReportRecoveryFailure ();
+          if (m_rate != GetMinRate ()) 
+            {
+              m_rate--;
+            }
+        }
+      m_timer = 0;
+    } 
+  else 
+    {
+      assert (m_retry >= 1);
+      if (NeedNormalFallback ()) 
+        {
+          ReportFailure ();
+          if (m_rate != GetMinRate ()) 
+            {
+              m_rate--;
+            }
+        }
+      if (m_retry >= 2) 
+        {
+          m_timer = 0;
+        }
+    }
+}
+void 
+ArfMacStation::ReportRxOk (double rxSnr, uint8_t txMode)
+{}
+void ArfMacStation::ReportRtsOk (double ctsSnr, uint8_t ctsMode, uint8_t rtsSnr)
+{
+  assert (rtsSnr == 0);
+}
+void ArfMacStation::ReportDataOk (double ackSnr, uint8_t ackMode, uint8_t dataSnr)
+{
+  assert (dataSnr == 0);
+  m_timer++;
+  m_success++;
+  m_failed = 0;
+  m_recovery = false;
+  m_retry = 0;
+  if ((m_success == GetSuccessThreshold () ||
+       m_timer == GetTimerTimeout ()) &&
+      (m_rate < (GetMaxRate () - 1))) 
+    {
+      m_rate++;
+      m_timer = 0;
+      m_success = 0;
+      m_recovery = true;
+    }
+}
+uint8_t 
+ArfMacStation::SnrToSnr (double snr)
+{
+  return 0;
+}
+uint8_t 
+ArfMacStation::GetDataMode (int size)
+{
+  return m_rate;
+}
+uint8_t 
+ArfMacStation::GetRtsMode (void)
+{
+  return 0;
+}
+
+void ArfMacStation::ReportRecoveryFailure (void)
+{}
+void ArfMacStation::ReportFailure (void)
+{}
+int ArfMacStation::GetMinTimerTimeout (void)
+{
+  return m_minTimerTimeout;
+}
+int ArfMacStation::GetMinSuccessThreshold (void)
+{
+  return m_minSuccessThreshold;
+}
+int ArfMacStation::GetTimerTimeout (void)
+{
+  return m_timerTimeout;
+}
+int ArfMacStation::GetSuccessThreshold (void)
+{
+  return m_successThreshold;
+}
+void ArfMacStation::SetTimerTimeout (int timerTimeout)
+{
+  assert (timerTimeout >= m_minTimerTimeout);
+  m_timerTimeout = timerTimeout;
+}
+void ArfMacStation::SetSuccessThreshold (int successThreshold)
+{
+  assert (successThreshold >= m_minSuccessThreshold);
+  m_successThreshold = successThreshold;
+}
+
+
+
+
+
+ArfMacStations::ArfMacStations (uint8_t nModes)
+  : m_nModes (nModes)
+{}
+ArfMacStations::~ArfMacStations ()
+{}
+MacStation *
+ArfMacStations::CreateStation (void)
+{
+  /* XXX: use mac to access user and PHY params. */
+  return new ArfMacStation (this, 15, 10);
+}
+
+uint8_t
+ArfMacStations::GetNModes (void) const
+{
+  return m_nModes;
+}
+
+
+}; // namespace ns3
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/devices/wifi/arf-mac-stations.h	Wed Oct 03 13:12:26 2007 +0200
@@ -0,0 +1,99 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2005,2006 INRIA
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as 
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
+ */
+#ifndef ARF_MAC_STATIONS_H
+#define ARF_MAC_STATIONS_H
+
+#include "mac-stations.h"
+#include "mac-station.h"
+
+namespace ns3 {
+
+class ArfMacStations : public MacStations {
+public:
+  ArfMacStations (uint8_t nModes);
+  virtual ~ArfMacStations ();
+
+  uint8_t GetNModes (void) const;
+private:
+  virtual class MacStation *CreateStation (void);
+  uint8_t m_nModes;
+};
+
+
+class ArfMacStation : public MacStation
+{
+public:
+  ArfMacStation (ArfMacStations *stations,
+                 int minTimerTimeout,
+                 int minSuccessThreshold);
+  virtual ~ArfMacStation ();
+
+  virtual void ReportRxOk (double rxSnr, uint8_t txMode);
+
+  virtual void ReportRtsFailed (void);
+  virtual void ReportDataFailed (void);
+  virtual void ReportRtsOk (double ctsSnr, uint8_t ctsMode, uint8_t rtsSnr);
+  virtual void ReportDataOk (double ackSnr, uint8_t ackMode, uint8_t dataSnr);
+  virtual uint8_t GetDataMode (int size);
+  virtual uint8_t GetRtsMode (void);
+  virtual uint8_t SnrToSnr (double snr);
+
+private:
+  ArfMacStations *m_stations;
+
+  int m_timer;
+  int m_success;
+  int m_failed;
+  bool m_recovery;
+  int m_retry;
+  
+  int m_timerTimeout;
+  int m_successThreshold;
+
+  int m_rate;
+  
+  int m_minTimerTimeout;
+  int m_minSuccessThreshold;
+  
+private:
+  virtual void ReportRecoveryFailure (void);
+  virtual void ReportFailure (void);
+
+  int GetMaxRate (void);
+  int GetMinRate (void);
+
+  bool NeedRecoveryFallback (void);
+  bool NeedNormalFallback (void);
+  
+protected:
+  int GetMinTimerTimeout (void);
+  int GetMinSuccessThreshold (void);
+  
+  int GetTimerTimeout (void);
+  int GetSuccessThreshold (void);
+  
+  void SetTimerTimeout (int timerTimeout);
+  void SetSuccessThreshold (int successThreshold);
+};
+
+}; // namespace ns3
+
+#endif /* ARF_MAC_STATIONS_H */