src/devices/wifi/aarf-mac-stations.cc
changeset 1895 6c2d6a5631bc
child 1918 fee53ba3f388
--- /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