--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/devices/wifi/onoe-mac-stations.cc Thu Dec 13 08:39:08 2007 +0100
@@ -0,0 +1,130 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2003,2007 INRIA
+ *
+ * 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 "onoe-mac-stations.h"
+#include "ns3/default-value.h"
+#include "ns3/time-default-value.h"
+#include "ns3/simulator.h"
+
+namespace ns3 {
+
+static TimeDefaultValue g_updatePeriod
+("WifiOnoeUpdatePeriod",
+ "The interval between decisions about rate control changes",
+ Seconds (1.0));
+static NumericDefaultValue<uint32_t> g_addCreditThreshold
+("WifiOnoeAddCreditThreshold",
+ "Add credit threshold",
+ 10);
+static NumericDefaultValue<uint32_t> g_raiseThreshold
+("WifiOnoeRaiseThreshold",
+ "Raise threshold",
+ 10);
+
+OnoeMacStations::OnoeMacStations (WifiMode defaultTxMode)
+ : MacStations (defaultTxMode),
+ m_updatePeriod (g_updatePeriod.GetValue ()),
+ m_addCreditThreshold (g_addCreditThreshold.GetValue ()),
+ m_raiseThreshold (g_raiseThreshold.GetValue ())
+{}
+MacStation *
+OnoeMacStations::CreateStation (void)
+{
+ return new OnoeMacStation (this);
+}
+
+OnoeMacStation::OnoeMacStation (OnoeMacStations *stations)
+ : m_stations (stations),
+ m_nextModeUpdate (Simulator::Now () + stations->m_updatePeriod)
+{}
+OnoeMacStation::~OnoeMacStation ()
+{}
+
+void
+OnoeMacStation::ReportRxOk (double rxSnr, WifiMode txMode)
+{}
+void
+OnoeMacStation::ReportRtsFailed (void)
+{
+ m_shortRetry++;
+}
+void
+OnoeMacStation::ReportDataFailed (void)
+{
+ m_longRetry++;
+}
+void
+OnoeMacStation::ReportRtsOk (double ctsSnr, WifiMode ctsMode, double rtsSnr)
+{}
+void
+OnoeMacStation::ReportDataOk (double ackSnr, WifiMode ackMode, double dataSnr)
+{
+ UpdateRetry ();
+ m_tx_ok++;
+}
+void
+OnoeMacStation::ReportFinalRtsFailed (void)
+{
+ UpdateRetry ();
+ m_tx_err++;
+}
+void
+OnoeMacStation::ReportFinalDataFailed (void)
+{
+ UpdateRetry ();
+ m_tx_err++;
+}
+void
+OnoeMacStation::UpdateRetry (void)
+{
+ m_tx_retr += m_shortRetry + m_longRetry;
+ m_shortRetry = 0;
+ m_longRetry = 0;
+}
+void
+OnoeMacStation::UpdateMode (void)
+{
+ if (Simulator::Now () < m_nextModeUpdate)
+ {
+ return;
+ }
+}
+
+OnoeMacStations *
+OnoeMacStation::GetStations (void) const
+{
+ return m_stations;
+}
+WifiMode
+OnoeMacStation::DoGetDataMode (uint32_t size)
+{
+ UpdateMode ();
+ // XXX
+ return GetSupportedMode (0);
+}
+WifiMode
+OnoeMacStation::DoGetRtsMode (void)
+{
+ UpdateMode ();
+ // XXX: can we implement something smarter ?
+ return GetSupportedMode (0);
+}
+
+} // namespace ns3
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/devices/wifi/onoe-mac-stations.h Thu Dec 13 08:39:08 2007 +0100
@@ -0,0 +1,85 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2003,2007 INRIA
+ *
+ * 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 ONOE_MAC_STATIONS_H
+#define ONOE_MAC_STATIONS_H
+
+#include "mac-stations.h"
+#include "ns3/nstime.h"
+
+namespace ns3 {
+
+class OnoeMacStations : public MacStations
+{
+public:
+ OnoeMacStations (WifiMode defaultTxMode);
+
+private:
+ friend class OnoeMacStation;
+ virtual MacStation *CreateStation (void);
+
+ Time m_updatePeriod;
+ uint32_t m_addCreditThreshold;
+ uint32_t m_raiseThreshold;
+};
+
+/**
+ * \brief an implementation of rate control algorithm developed
+ * by Atsushi Onoe
+ *
+ * This algorithm is well known because it has been used as the default
+ * rate control algorithm for the madwifi driver. I am not aware of
+ * any publication or reference about this algorithm beyond the madwifi
+ * source code.
+ */
+class OnoeMacStation : public MacStation
+{
+public:
+ OnoeMacStation (OnoeMacStations *stations);
+
+ virtual ~OnoeMacStation ();
+
+ virtual void ReportRxOk (double rxSnr, WifiMode txMode);
+ virtual void ReportRtsFailed (void);
+ virtual void ReportDataFailed (void);
+ virtual void ReportRtsOk (double ctsSnr, WifiMode ctsMode, double rtsSnr);
+ virtual void ReportDataOk (double ackSnr, WifiMode ackMode, double dataSnr);
+ virtual void ReportFinalRtsFailed (void);
+ virtual void ReportFinalDataFailed (void);
+
+private:
+ virtual OnoeMacStations *GetStations (void) const;
+ virtual WifiMode DoGetDataMode (uint32_t size);
+ virtual WifiMode DoGetRtsMode (void);
+
+ void UpdateRetry (void);
+ void UpdateMode (void);
+
+ OnoeMacStations *m_stations;
+ uint32_t m_shortRetry;
+ uint32_t m_longRetry;
+ Time m_nextModeUpdate;
+ uint32_t m_tx_ok;
+ uint32_t m_tx_err;
+ uint32_t m_tx_retr;
+};
+
+} // namespace ns3
+
+#endif /* ONOE_MAC_STATIONS_H */
--- a/src/devices/wifi/wifi-default-parameters.cc Wed Dec 12 13:36:16 2007 +0100
+++ b/src/devices/wifi/wifi-default-parameters.cc Thu Dec 13 08:39:08 2007 +0100
@@ -64,6 +64,7 @@
CONSTANT_RATE, "ConstantRate",
AARF, "Aarf",
IDEAL, "Ideal",
+ ONOE, "Onoe",
0, (void *)0);
static NumericDefaultValue<uint32_t> g_arfSuccessThreshold
--- a/src/devices/wifi/wifi-default-parameters.h Wed Dec 12 13:36:16 2007 +0100
+++ b/src/devices/wifi/wifi-default-parameters.h Thu Dec 13 08:39:08 2007 +0100
@@ -34,6 +34,7 @@
CONSTANT_RATE,
ARF,
AARF,
+ ONOE,
IDEAL
};
enum PhyModeParameter {
--- a/src/devices/wifi/wifi-net-device.cc Wed Dec 12 13:36:16 2007 +0100
+++ b/src/devices/wifi/wifi-net-device.cc Thu Dec 13 08:39:08 2007 +0100
@@ -40,6 +40,7 @@
#include "aarf-mac-stations.h"
#include "ideal-mac-stations.h"
#include "cr-mac-stations.h"
+#include "onoe-mac-stations.h"
namespace ns3 {
@@ -211,6 +212,9 @@
}
m_stations = ideal;
} break;
+ case WifiDefaultParameters::ONOE: {
+ m_stations = new OnoeMacStations (m_phy->GetMode (0));
+ } break;
default:
// NOTREACHED
NS_ASSERT (false);
--- a/src/devices/wifi/wscript Wed Dec 12 13:36:16 2007 +0100
+++ b/src/devices/wifi/wscript Thu Dec 13 08:39:08 2007 +0100
@@ -34,6 +34,7 @@
'random-stream.cc',
'dcf-manager.cc',
'dcf-manager-test.cc',
+ 'onoe-mac-stations.cc',
]
headers = bld.create_obj('ns3header')
headers.source = [