--- a/src/devices/wifi/aarf-mac-stations.cc Mon Mar 03 04:03:39 2008 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,90 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2004,2005,2006 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 "aarf-mac-stations.h"
-
-#define Min(a,b) ((a<b)?a:b)
-#define Max(a,b) ((a>b)?a:b)
-
-namespace ns3 {
-
-AarfMacStations::AarfMacStations (WifiMode defaultTxMode,
- uint32_t minTimerThreshold,
- uint32_t minSuccessThreshold,
- double successK,
- uint32_t maxSuccessThreshold,
- double timerK)
- : ArfMacStations (defaultTxMode,
- minTimerThreshold,
- minSuccessThreshold),
- m_minTimerThreshold (minTimerThreshold),
- m_minSuccessThreshold (minSuccessThreshold),
- m_successK (successK),
- m_maxSuccessThreshold (maxSuccessThreshold),
- m_timerK (timerK)
-{}
-AarfMacStations::~AarfMacStations ()
-{}
-MacStation *
-AarfMacStations::CreateStation (void)
-{
- return new AarfMacStation (this, m_minTimerThreshold,
- m_minSuccessThreshold,
- m_successK,
- m_maxSuccessThreshold,
- m_timerK);
-}
-
-
-
-
-AarfMacStation::AarfMacStation (AarfMacStations *stations,
- uint32_t minTimerThreshold,
- uint32_t minSuccessThreshold,
- double successK,
- uint32_t maxSuccessThreshold,
- double timerK)
- : ArfMacStation (stations, minTimerThreshold, minSuccessThreshold),
- 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
--- a/src/devices/wifi/aarf-mac-stations.h Mon Mar 03 04:03:39 2008 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,76 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2005,2006 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 AARF_MAC_STATIONS_H
-#define AARF_MAC_STATIONS_H
-
-#include "arf-mac-stations.h"
-
-namespace ns3 {
-
-/**
- * \brief AARF Rate control algorithm
- *
- * This class implements the AARF rate control algorithm which
- * was initially described in <i>IEEE 802.11 Rate Adaptation:
- * A Practical Approach</i>, by M. Lacage, M.H. Manshaei, and
- * T. Turletti.
- */
-class AarfMacStations : public ArfMacStations {
-public:
- AarfMacStations (WifiMode defaultTxMode,
- uint32_t minTimerThreshold,
- uint32_t minSuccessThreshold,
- double successK,
- uint32_t maxSuccessThreshold,
- double timerK);
- virtual ~AarfMacStations ();
-private:
- virtual class MacStation *CreateStation (void);
- uint32_t m_minTimerThreshold;
- uint32_t m_minSuccessThreshold;
- double m_successK;
- uint32_t m_maxSuccessThreshold;
- double m_timerK;
-};
-
-class AarfMacStation : public ArfMacStation
-{
-public:
- AarfMacStation (AarfMacStations *stations,
- uint32_t minTimerThreshold,
- uint32_t minSuccessThreshold,
- double successK,
- uint32_t maxSuccessThreshold,
- double timerK);
- virtual ~AarfMacStation ();
-
-private:
- virtual void ReportRecoveryFailure (void);
- virtual void ReportFailure (void);
-
- double m_successK;
- uint32_t m_maxSuccessThreshold;
- double m_timerK;
-};
-
-} // namespace ns3
-
-
-#endif /* AARF_MAC_STATIONS_H */
--- a/src/devices/wifi/amrr-mac-stations.cc Mon Mar 03 04:03:39 2008 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,280 +0,0 @@
-/* -*- 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 "amrr-mac-stations.h"
-#include "ns3/default-value.h"
-#include "ns3/time-default-value.h"
-#include "ns3/simulator.h"
-#include "ns3/log.h"
-
-NS_LOG_COMPONENT_DEFINE ("AmrrMacStation");
-
-namespace ns3 {
-
-static TimeDefaultValue g_updatePeriod
-("WifiAmrrUpdatePeriod",
- "The interval between decisions about rate control changes",
- Seconds (1.0));
-static NumericDefaultValue<double> g_failureRatio
-("WifiAmrrFailureRatio",
- "Ratio of erronous transmissions needed to switch to a lower rate",
- 1.0/3.0);
-static NumericDefaultValue<double> g_successRatio
-("WifiAmrrSuccessRatio",
- "Ratio of erronous transmissions needed to switch to a higher rate",
- 1.0/10.0);
-static NumericDefaultValue<uint32_t> g_maxSuccessThreshold
-("WifiAmrrMaxSuccessThreshold",
- "maximum number of consecutive success periods needed to switch to a higher rate",
- 10);
-static NumericDefaultValue<uint32_t> g_minSuccessThreshold
-("WifiAmrrMinSuccessThreshold",
- "minimum number of consecutive success periods needed to switch to a higher rate",
- 1);
-
-AmrrMacStations::AmrrMacStations (WifiMode defaultTxMode)
- : MacStations (defaultTxMode),
- m_updatePeriod (g_updatePeriod.GetValue ()),
- m_failureRatio (g_failureRatio.GetValue ()),
- m_successRatio (g_successRatio.GetValue ()),
- m_maxSuccessThreshold (g_maxSuccessThreshold.GetValue ()),
- m_minSuccessThreshold (g_minSuccessThreshold.GetValue ())
-{}
-MacStation *
-AmrrMacStations::CreateStation (void)
-{
- return new AmrrMacStation (this);
-}
-
-AmrrMacStation::AmrrMacStation (AmrrMacStations *stations)
- : m_stations (stations),
- m_nextModeUpdate (Simulator::Now () + stations->m_updatePeriod),
- m_tx_ok (0),
- m_tx_err (0),
- m_tx_retr (0),
- m_retry (0),
- m_txrate (0),
- m_successThreshold (m_stations->m_minSuccessThreshold),
- m_success (0),
- m_recovery (false)
-{}
-AmrrMacStation::~AmrrMacStation ()
-{}
-
-void
-AmrrMacStation::ReportRxOk (double rxSnr, WifiMode txMode)
-{}
-void
-AmrrMacStation::ReportRtsFailed (void)
-{}
-void
-AmrrMacStation::ReportDataFailed (void)
-{
- m_retry++;
- m_tx_retr++;
-}
-void
-AmrrMacStation::ReportRtsOk (double ctsSnr, WifiMode ctsMode, double rtsSnr)
-{}
-void
-AmrrMacStation::ReportDataOk (double ackSnr, WifiMode ackMode, double dataSnr)
-{
- m_retry = 0;
- m_tx_ok++;
-}
-void
-AmrrMacStation::ReportFinalRtsFailed (void)
-{}
-void
-AmrrMacStation::ReportFinalDataFailed (void)
-{
- m_retry = 0;
- m_tx_err++;
-}
-bool
-AmrrMacStation::IsMinRate (void) const
-{
- return (m_txrate == 0);
-}
-bool
-AmrrMacStation::IsMaxRate (void) const
-{
- NS_ASSERT (m_txrate + 1 <= GetNSupportedModes ());
- return (m_txrate + 1 == GetNSupportedModes ());
-}
-bool
-AmrrMacStation::IsSuccess (void) const
-{
- return (m_tx_retr + m_tx_err) < m_tx_ok * m_stations->m_successRatio;
-}
-bool
-AmrrMacStation::IsFailure (void) const
-{
- return (m_tx_retr + m_tx_err) > m_tx_ok * m_stations->m_failureRatio;
-}
-bool
-AmrrMacStation::IsEnough (void) const
-{
- return (m_tx_retr + m_tx_err + m_tx_ok) > 10;
-}
-void
-AmrrMacStation::ResetCnt (void)
-{
- m_tx_ok = 0;
- m_tx_err = 0;
- m_tx_retr = 0;
-}
-void
-AmrrMacStation::IncreaseRate (void)
-{
- m_txrate++;
- NS_ASSERT (m_txrate < GetNSupportedModes ());
-}
-void
-AmrrMacStation::DecreaseRate (void)
-{
- m_txrate--;
-}
-
-void
-AmrrMacStation::UpdateMode (void)
-{
- if (Simulator::Now () < m_nextModeUpdate)
- {
- return;
- }
- m_nextModeUpdate = Simulator::Now () + m_stations->m_updatePeriod;
- NS_LOG_DEBUG ("Update");
-
- bool needChange = false;
-
- if (IsSuccess () && IsEnough ())
- {
- m_success++;
- NS_LOG_DEBUG ("++ success="<<m_success<<" successThreshold="<<m_successThreshold<<
- " tx_ok="<<m_tx_ok<<" tx_err="<<m_tx_err<<" tx_retr="<<m_tx_retr<<
- " rate="<<m_txrate<<" n-supported-rates="<<GetNSupportedModes ());
- if (m_success >= m_successThreshold &&
- !IsMaxRate ())
- {
- m_recovery = true;
- m_success = 0;
- IncreaseRate ();
- needChange = true;
- }
- else
- {
- m_recovery = false;
- }
- }
- else if (IsFailure ())
- {
- m_success = 0;
- NS_LOG_DEBUG ("-- success="<<m_success<<" successThreshold="<<m_successThreshold<<
- " tx_ok="<<m_tx_ok<<" tx_err="<<m_tx_err<<" tx_retr="<<m_tx_retr<<
- " rate="<<m_txrate<<" n-supported-rates="<<GetNSupportedModes ());
- if (!IsMinRate ())
- {
- if (m_recovery)
- {
- m_successThreshold *= 2;
- m_successThreshold = std::min (m_successThreshold,
- m_stations->m_maxSuccessThreshold);
- }
- else
- {
- m_successThreshold = m_stations->m_minSuccessThreshold;
- }
- m_recovery = false;
- DecreaseRate ();
- needChange = true;
- }
- else
- {
- m_recovery = false;
- }
- }
- if (IsEnough () || needChange)
- {
- NS_LOG_DEBUG ("Reset");
- ResetCnt ();
- }
-}
-
-AmrrMacStations *
-AmrrMacStation::GetStations (void) const
-{
- return m_stations;
-}
-WifiMode
-AmrrMacStation::DoGetDataMode (uint32_t size)
-{
- UpdateMode ();
- NS_ASSERT (m_txrate < GetNSupportedModes ());
- 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)
-{
- UpdateMode ();
- // XXX: can we implement something smarter ?
- return GetSupportedMode (0);
-}
-
-} // namespace ns3
--- a/src/devices/wifi/amrr-mac-stations.h Mon Mar 03 04:03:39 2008 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,91 +0,0 @@
-/* -*- 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 AMRR_MAC_STATIONS_H
-#define AMRR_MAC_STATIONS_H
-
-#include "mac-stations.h"
-#include "ns3/nstime.h"
-
-namespace ns3 {
-
-class AmrrMacStations : public MacStations
-{
-public:
- AmrrMacStations (WifiMode defaultTxMode);
-
-private:
- friend class AmrrMacStation;
- virtual MacStation *CreateStation (void);
-
- Time m_updatePeriod;
- double m_failureRatio;
- double m_successRatio;
- uint32_t m_maxSuccessThreshold;
- uint32_t m_minSuccessThreshold;
-};
-
-/**
- */
-class AmrrMacStation : public MacStation
-{
-public:
- AmrrMacStation (AmrrMacStations *stations);
-
- virtual ~AmrrMacStation ();
-
- 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 AmrrMacStations *GetStations (void) const;
- virtual WifiMode DoGetDataMode (uint32_t size);
- virtual WifiMode DoGetRtsMode (void);
-
- void UpdateRetry (void);
- void UpdateMode (void);
- void ResetCnt (void);
- void IncreaseRate (void);
- void DecreaseRate (void);
- bool IsMinRate (void) const;
- bool IsMaxRate (void) const;
- bool IsSuccess (void) const;
- bool IsFailure (void) const;
- bool IsEnough (void) const;
-
- AmrrMacStations *m_stations;
- Time m_nextModeUpdate;
- 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;
- bool m_recovery;
-};
-
-} // namespace ns3
-
-#endif /* AMRR_MAC_STATIONS_H */
--- a/src/devices/wifi/arf-mac-stations.cc Mon Mar 03 04:03:39 2008 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,240 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2004,2005,2006 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 "mac-stations.h"
-#include "arf-mac-stations.h"
-#include "ns3/assert.h"
-#include "ns3/log.h"
-#include "ns3/default-value.h"
-
-NS_LOG_COMPONENT_DEFINE ("Arf");
-
-
-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 ()
-{}
-
-uint32_t
-ArfMacStation::GetMaxRate (void)
-{
- return GetNSupportedModes ();
-}
-uint32_t
-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)
- {
- NS_ASSERT (m_retry >= 1);
- if (NeedRecoveryFallback ())
- {
- ReportRecoveryFailure ();
- if (m_rate != GetMinRate ())
- {
- m_rate--;
- }
- }
- m_timer = 0;
- }
- else
- {
- NS_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, WifiMode txMode)
-{}
-void ArfMacStation::ReportRtsOk (double ctsSnr, WifiMode ctsMode, double rtsSnr)
-{
- NS_LOG_DEBUG ("self="<<this<<" rts ok");
-}
-void ArfMacStation::ReportDataOk (double ackSnr, WifiMode ackMode, double dataSnr)
-{
- m_timer++;
- m_success++;
- m_failed = 0;
- m_recovery = false;
- m_retry = 0;
- NS_LOG_DEBUG ("self="<<this<<" data ok success="<<m_success<<", timer="<<m_timer);
- if ((m_success == GetSuccessThreshold () ||
- m_timer == GetTimerTimeout ()) &&
- (m_rate < (GetMaxRate () - 1)))
- {
- NS_LOG_DEBUG ("self="<<this<<" inc rate");
- m_rate++;
- m_timer = 0;
- m_success = 0;
- m_recovery = true;
- }
-}
-void
-ArfMacStation::ReportFinalRtsFailed (void)
-{}
-void
-ArfMacStation::ReportFinalDataFailed (void)
-{}
-
-WifiMode
-ArfMacStation::DoGetDataMode (uint32_t size)
-{
- return GetSupportedMode (m_rate);
-}
-WifiMode
-ArfMacStation::DoGetRtsMode (void)
-{
- // XXX: we could/should implement the Arf algorithm for
- // RTS only by picking a single rate within the BasicRateSet.
- return GetSupportedMode (0);
-}
-
-void ArfMacStation::ReportRecoveryFailure (void)
-{}
-void ArfMacStation::ReportFailure (void)
-{}
-uint32_t ArfMacStation::GetMinTimerTimeout (void)
-{
- return m_minTimerTimeout;
-}
-uint32_t ArfMacStation::GetMinSuccessThreshold (void)
-{
- return m_minSuccessThreshold;
-}
-uint32_t ArfMacStation::GetTimerTimeout (void)
-{
- return m_timerTimeout;
-}
-uint32_t ArfMacStation::GetSuccessThreshold (void)
-{
- return m_successThreshold;
-}
-void ArfMacStation::SetTimerTimeout (uint32_t timerTimeout)
-{
- NS_ASSERT (timerTimeout >= m_minTimerTimeout);
- m_timerTimeout = timerTimeout;
-}
-void ArfMacStation::SetSuccessThreshold (uint32_t successThreshold)
-{
- NS_ASSERT (successThreshold >= m_minSuccessThreshold);
- m_successThreshold = successThreshold;
-}
-ArfMacStations *
-ArfMacStation::GetStations (void) const
-{
- return m_stations;
-}
-
-
-
-
-
-ArfMacStations::ArfMacStations (WifiMode defaultTxMode, uint32_t timerThreshold, uint32_t successThreshold)
- : MacStations (defaultTxMode),
- m_timerThreshold (timerThreshold),
- m_successThreshold (successThreshold)
-{}
-ArfMacStations::~ArfMacStations ()
-{}
-MacStation *
-ArfMacStations::CreateStation (void)
-{
- return new ArfMacStation (this, m_timerThreshold, m_successThreshold);
-}
-
-} // namespace ns3
--- a/src/devices/wifi/arf-mac-stations.h Mon Mar 03 04:03:39 2008 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,115 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2005,2006 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 ARF_MAC_STATIONS_H
-#define ARF_MAC_STATIONS_H
-
-#include "mac-stations.h"
-
-namespace ns3 {
-
-/**
- * \brief ARF Rate control algorithm
- *
- * This class implements the so-called ARF algorithm which was
- * initially described in <i>WaveLAN-II: A High-performance wireless
- * LAN for the unlicensed band</i>, by A. Kamerman and L. Monteban. in
- * Bell Lab Technical Journal, pages 118-133, Summer 1997.
- *
- * This implementation differs from the initial description in that it
- * uses a packet-based timer rather than a time-based timer as described
- * in XXX (I cannot find back the original paper which described how
- * the time-based timer could be easily replaced with a packet-based
- * timer.)
- */
-class ArfMacStations : public MacStations {
-public:
- ArfMacStations (WifiMode defaultTxMode, uint32_t timerThreshold, uint32_t successThreshold);
- virtual ~ArfMacStations ();
-
-private:
- virtual class MacStation *CreateStation (void);
- uint32_t m_timerThreshold;
- uint32_t m_successThreshold;
-};
-
-
-class ArfMacStation : public MacStation
-{
-public:
- ArfMacStation (ArfMacStations *stations,
- int minTimerTimeout,
- int minSuccessThreshold);
- virtual ~ArfMacStation ();
-
- 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 ArfMacStations *GetStations (void) const;
- virtual WifiMode DoGetDataMode (uint32_t size);
- virtual WifiMode DoGetRtsMode (void);
-
- uint32_t m_timer;
- uint32_t m_success;
- uint32_t m_failed;
- bool m_recovery;
- uint32_t m_retry;
-
- uint32_t m_timerTimeout;
- uint32_t m_successThreshold;
-
- uint32_t m_rate;
-
- uint32_t m_minTimerTimeout;
- uint32_t m_minSuccessThreshold;
-
- ArfMacStations *m_stations;
-
-private:
- // overriden by AarfMacStation.
- virtual void ReportRecoveryFailure (void);
- virtual void ReportFailure (void);
-
- uint32_t GetMaxRate (void);
- uint32_t GetMinRate (void);
-
- bool NeedRecoveryFallback (void);
- bool NeedNormalFallback (void);
-
-protected:
- // called by AarfMacStation.
- uint32_t GetMinTimerTimeout (void);
- uint32_t GetMinSuccessThreshold (void);
-
- uint32_t GetTimerTimeout (void);
- uint32_t GetSuccessThreshold (void);
-
- void SetTimerTimeout (uint32_t timerTimeout);
- void SetSuccessThreshold (uint32_t successThreshold);
-};
-
-} // namespace ns3
-
-#endif /* ARF_MAC_STATIONS_H */
--- a/src/devices/wifi/arf-wifi-manager.cc Mon Mar 03 04:03:39 2008 +0100
+++ b/src/devices/wifi/arf-wifi-manager.cc Mon Mar 03 04:42:16 2008 +0100
@@ -18,7 +18,6 @@
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
*/
-#include "mac-stations.h"
#include "arf-wifi-manager.h"
#include "ns3/assert.h"
#include "ns3/log.h"
--- a/src/devices/wifi/cr-mac-stations.cc Mon Mar 03 04:03:39 2008 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,100 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2004,2005 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 "mac-stations.h"
-#include "cr-mac-stations.h"
-
-#include "ns3/assert.h"
-
-namespace ns3 {
-
-CrMacStation::CrMacStation (CrMacStations *stations)
- : m_stations (stations)
-{}
-CrMacStation::~CrMacStation ()
-{}
-
-void
-CrMacStation::ReportRxOk (double rxSnr, WifiMode txMode)
-{}
-void
-CrMacStation::ReportRtsFailed (void)
-{}
-void
-CrMacStation::ReportDataFailed (void)
-{}
-void
-CrMacStation::ReportRtsOk (double ctsSnr, WifiMode ctsMode, double rtsSnr)
-{}
-void
-CrMacStation::ReportDataOk (double ackSnr, WifiMode ackMode, double dataSnr)
-{}
-void
-CrMacStation::ReportFinalRtsFailed (void)
-{}
-void
-CrMacStation::ReportFinalDataFailed (void)
-{}
-
-WifiMode
-CrMacStation::DoGetDataMode (uint32_t size)
-{
- return m_stations->GetDataMode ();
-}
-WifiMode
-CrMacStation::DoGetRtsMode (void)
-{
- return m_stations->GetCtlMode ();
-}
-CrMacStations *
-CrMacStation::GetStations (void) const
-{
- return m_stations;
-}
-
-
-
-CrMacStations::CrMacStations (WifiMode dataMode, WifiMode ctlMode)
- : MacStations (ctlMode),
- m_dataMode (dataMode),
- m_ctlMode (ctlMode)
-{}
-CrMacStations::~CrMacStations ()
-{}
-
-WifiMode
-CrMacStations::GetDataMode (void) const
-{
- return m_dataMode;
-}
-WifiMode
-CrMacStations::GetCtlMode (void) const
-{
- return m_ctlMode;
-}
-
-
-MacStation *
-CrMacStations::CreateStation (void)
-{
- return new CrMacStation (this);
-}
-
-} // namespace ns3
--- a/src/devices/wifi/cr-mac-stations.h Mon Mar 03 04:03:39 2008 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,76 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2005,2006 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 CR_MAC_STATIONS_H
-#define CR_MAC_STATIONS_H
-
-#include <stdint.h>
-
-#include "mac-stations.h"
-
-namespace ns3 {
-
-/**
- * \brief use constant rates for data and control transmissions
- *
- * This class uses always the same transmission rate for every
- * packet sent.
- */
-class CrMacStations : public MacStations
-{
-public:
- CrMacStations (WifiMode dataMode, WifiMode ctlMode);
- virtual ~CrMacStations ();
-
- WifiMode GetDataMode (void) const;
- WifiMode GetCtlMode (void) const;
-private:
- virtual class MacStation *CreateStation (void);
-
- WifiMode m_dataMode;
- WifiMode m_ctlMode;
-};
-
-
-class CrMacStation : public MacStation
-{
-public:
- CrMacStation (CrMacStations *stations);
- virtual ~CrMacStation ();
-
- 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 CrMacStations *GetStations (void) const;
- virtual WifiMode DoGetDataMode (uint32_t size);
- virtual WifiMode DoGetRtsMode (void);
- CrMacStations *m_stations;
-};
-
-} // namespace ns3
-
-
-
-#endif /* CR_MAC_STATIONS_H */
--- a/src/devices/wifi/ideal-mac-stations.cc Mon Mar 03 04:03:39 2008 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,151 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2006 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 "ideal-mac-stations.h"
-#include "ns3/assert.h"
-#include <math.h>
-
-#define noIDEAL_DEBUG 1
-
-#ifdef IDEAL_DEBUG
-#include <iostream>
-# define TRACE(x) \
-std::cout << "IDEAL TRACE " << x << std::endl;
-#else
-# define TRACE(x)
-#endif
-
-
-namespace ns3 {
-
-IdealMacStations::IdealMacStations (WifiMode defaultTxMode)
- : MacStations (defaultTxMode)
-{}
-IdealMacStations::~IdealMacStations ()
-{}
-
-MacStation *
-IdealMacStations::CreateStation (void)
-{
- return new IdealMacStation (this);
-}
-
-double
-IdealMacStations::GetSnrThreshold (WifiMode mode) const
-{
- for (Thresholds::const_iterator i = m_thresholds.begin (); i != m_thresholds.end (); i++)
- {
- if (mode == i->second)
- {
- return i->first;
- }
- }
- NS_ASSERT (false);
- return 0.0;
-}
-
-void
-IdealMacStations::AddModeSnrThreshold (WifiMode mode, double snr)
-{
- m_thresholds.push_back (std::make_pair (snr,mode));
-}
-
-IdealMacStation::IdealMacStation (IdealMacStations *stations)
- : m_stations (stations),
- m_lastSnr (0.0)
-{}
-IdealMacStation::~IdealMacStation ()
-{}
-void
-IdealMacStation::ReportRxOk (double rxSnr, WifiMode txMode)
-{}
-void
-IdealMacStation::ReportRtsFailed (void)
-{}
-void
-IdealMacStation::ReportDataFailed (void)
-{}
-void
-IdealMacStation::ReportRtsOk (double ctsSnr, WifiMode ctsMode, double rtsSnr)
-{
- TRACE ("got cts for rts snr="<<rtsSnr);
- m_lastSnr = rtsSnr;
-}
-void
-IdealMacStation::ReportDataOk (double ackSnr, WifiMode ackMode, double dataSnr)
-{
- TRACE ("got cts for rts snr="<<dataSnr);
- m_lastSnr = dataSnr;
-}
-void
-IdealMacStation::ReportFinalRtsFailed (void)
-{}
-void
-IdealMacStation::ReportFinalDataFailed (void)
-{}
-
-WifiMode
-IdealMacStation::DoGetDataMode (uint32_t size)
-{
- // We search within the Supported rate set the mode with the
- // highest snr threshold possible which is smaller than m_lastSnr
- // to ensure correct packet delivery.
- double maxThreshold = 0.0;
- WifiMode maxMode = m_stations->GetDefaultMode ();
- for (uint32_t i = 0; i < GetNSupportedModes (); i++)
- {
- WifiMode mode = GetSupportedMode (i);
- double threshold = m_stations->GetSnrThreshold (mode);
- if (threshold > maxThreshold &&
- threshold < m_lastSnr)
- {
- maxThreshold = threshold;
- maxMode = mode;
- }
- }
- return maxMode;
-}
-WifiMode
-IdealMacStation::DoGetRtsMode (void)
-{
- // We search within the Basic rate set the mode with the highest
- // snr threshold possible which is smaller than m_lastSnr to
- // ensure correct packet delivery.
- double maxThreshold = 0.0;
- WifiMode maxMode = m_stations->GetDefaultMode ();
- for (uint32_t i = 0; i < m_stations->GetNBasicModes (); i++)
- {
- WifiMode mode = m_stations->GetBasicMode (i);
- double threshold = m_stations->GetSnrThreshold (mode);
- if (threshold > maxThreshold &&
- threshold < m_lastSnr)
- {
- maxThreshold = threshold;
- maxMode = mode;
- }
- }
- return maxMode;
-}
-IdealMacStations *
-IdealMacStation::GetStations (void) const
-{
- return m_stations;
-}
-
-} // namespace ns3
--- a/src/devices/wifi/ideal-mac-stations.h Mon Mar 03 04:03:39 2008 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,89 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2006 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 IDEAL_MAC_STATIONS_H
-#define IDEAL_MAC_STATIONS_H
-
-#include <stdint.h>
-#include <vector>
-#include "mac-stations.h"
-#include "wifi-mode.h"
-
-namespace ns3 {
-
-/**
- * \brief Ideal rate control algorithm
- *
- * This class implements an 'ideal' rate control algorithm
- * similar to RBAR in spirit (see <i>A rate-adaptive MAC
- * protocol for multihop wireless networks</i> by G. Holland,
- * N. Vaidya, and P. Bahl.): every station keeps track of the
- * snr of every packet received and sends back this snr to the
- * original transmitter by an out-of-band mechanism. Each
- * transmitter keeps track of the last snr sent back by a receiver
- * and uses it to pick a transmission mode based on a set
- * of snr thresholds built from a target ber and transmission
- * mode-specific snr/ber curves.
- */
-class IdealMacStations : public MacStations {
-public:
- IdealMacStations (WifiMode defaultTxMode);
- virtual ~IdealMacStations ();
- WifiMode GetMode (double snr) const;
- // return the min snr needed to successfully transmit
- // data with this mode at the specified ber.
- double GetSnrThreshold (WifiMode mode) const;
- void AddModeSnrThreshold (WifiMode mode, double ber);
-private:
- virtual class MacStation *CreateStation (void);
-
- typedef std::vector<std::pair<double,WifiMode> > Thresholds;
-
- Thresholds m_thresholds;
- double m_minSnr;
- double m_maxSnr;
-};
-
-class IdealMacStation : public MacStation
-{
-public:
- IdealMacStation (IdealMacStations *stations);
-
- virtual ~IdealMacStation ();
-
- 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 IdealMacStations *GetStations (void) const;
- virtual WifiMode DoGetDataMode (uint32_t size);
- virtual WifiMode DoGetRtsMode (void);
-
- IdealMacStations *m_stations;
- double m_lastSnr;
-};
-
-} // namespace ns3
-
-#endif /* MAC_STA_H */
--- a/src/devices/wifi/mac-low.cc Mon Mar 03 04:03:39 2008 +0100
+++ b/src/devices/wifi/mac-low.cc Mon Mar 03 04:42:16 2008 +0100
@@ -29,7 +29,6 @@
#include "wifi-phy.h"
#include "wifi-mac-trailer.h"
#include "wifi-mac.h"
-#include "mac-stations.h"
#include "wifi-mac-parameters.h"
NS_LOG_COMPONENT_DEFINE ("MacLow");
--- a/src/devices/wifi/mac-stations.cc Mon Mar 03 04:03:39 2008 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,561 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2005,2006,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 "mac-stations.h"
-#include "wifi-default-parameters.h"
-#include "wifi-mac-parameters.h"
-#include "ns3/assert.h"
-#include "ns3/log.h"
-#include "ns3/tag.h"
-
-NS_LOG_COMPONENT_DEFINE ("MacStations");
-
-namespace ns3 {
-
-/**
- * _all_ broadcast and multicast frames are transmitted
- * at the same constant default rate because since we don't
- * have any kind of feedback from their transmission,
- * we cannot adjust the rate, so, we pick one which ensures
- * that all frames reach destination.
- */
-class NonUnicastMacStation : public MacStation
-{
-public:
- NonUnicastMacStation (MacStations *stations);
- 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 MacStations *GetStations (void) const;
- virtual WifiMode DoGetDataMode (uint32_t size);
- virtual WifiMode DoGetRtsMode (void);
- MacStations *m_stations;
-};
-
-NonUnicastMacStation::NonUnicastMacStation (MacStations *stations)
- : m_stations (stations)
-{
- RecordDisassociated ();
-}
-void
-NonUnicastMacStation::ReportRxOk (double rxSnr, WifiMode txMode)
-{
- NS_ASSERT (false);
-}
-void
-NonUnicastMacStation::ReportRtsFailed (void)
-{
- NS_ASSERT (false);
-}
-void
-NonUnicastMacStation::ReportDataFailed (void)
-{
- NS_ASSERT (false);
-}
-void
-NonUnicastMacStation::ReportRtsOk (double ctsSnr, WifiMode ctsMode, double rtsSnr)
-{
- NS_ASSERT (false);
-}
-void
-NonUnicastMacStation::ReportDataOk (double ackSnr, WifiMode ackMode, double dataSnr)
-{
- NS_ASSERT (false);
-}
-void
-NonUnicastMacStation::ReportFinalRtsFailed (void)
-{}
-void
-NonUnicastMacStation::ReportFinalDataFailed (void)
-{}
-
-WifiMode
-NonUnicastMacStation::DoGetDataMode (uint32_t size)
-{
- WifiMode mode = m_stations->GetBasicMode (0);
- NS_LOG_DEBUG ("non-unicast size="<<size<<", mode="<<mode);
- return mode;
-}
-WifiMode
-NonUnicastMacStation::DoGetRtsMode (void)
-{
- NS_ASSERT (false);
- // theoretically, no rts for broadcast/multicast packets.
- return m_stations->GetBasicMode (0);
-}
-MacStations *
-NonUnicastMacStation::GetStations (void) const
-{
- return m_stations;
-}
-
-
-} // namespace ns3
-
-namespace ns3 {
-
-MacStations::MacStations (WifiMode defaultTxMode)
- : m_defaultTxMode (defaultTxMode),
- m_nonUnicast (new NonUnicastMacStation (this)),
- m_isLowLatency (WifiDefaultParameters::GetIsLowLatency ())
-{
- Reset ();
-}
-
-MacStations::~MacStations ()
-{
- for (Stations::const_iterator i = m_stations.begin (); i != m_stations.end (); i++)
- {
- delete (*i).second;
- }
- m_stations.clear ();
- delete m_nonUnicast;
-}
-
-MacStation *
-MacStations::Lookup (Mac48Address address)
-{
- if (address.IsBroadcast () ||
- address.IsMulticast ())
- {
- return m_nonUnicast;
- }
- for (Stations::const_iterator i = m_stations.begin (); i != m_stations.end (); i++)
- {
- if ((*i).first == address)
- {
- return (*i).second;
- }
- }
- MacStation *station = CreateStation ();
- station->Reset ();
- station->SetParameters (m_parameters);
- m_stations.push_back (std::make_pair (address, station));
- return station;
-}
-
-MacStation *
-MacStations::LookupNonUnicast (void)
-{
- return m_nonUnicast;
-}
-
-WifiMode
-MacStations::GetDefaultMode (void) const
-{
- return m_defaultTxMode;
-}
-void
-MacStations::Reset (void)
-{
- for (Stations::const_iterator i = m_stations.begin (); i != m_stations.end (); i++)
- {
- delete i->second;
- }
- m_stations.clear ();
- m_basicModes.clear ();
- m_basicModes.push_back (m_defaultTxMode);
- NS_ASSERT (m_defaultTxMode.IsMandatory ());
-}
-void
-MacStations::AddBasicMode (WifiMode mode)
-{
- for (uint32_t i = 0; i < GetNBasicModes (); i++)
- {
- if (GetBasicMode (i) == mode)
- {
- return;
- }
- }
- m_basicModes.push_back (mode);
-}
-uint32_t
-MacStations::GetNBasicModes (void) const
-{
- return m_basicModes.size ();
-}
-WifiMode
-MacStations::GetBasicMode (uint32_t i) const
-{
- NS_ASSERT (i < m_basicModes.size ());
- return m_basicModes[i];
-}
-MacStations::BasicModesIterator
-MacStations::BeginBasicModes (void) const
-{
- return m_basicModes.begin ();
-}
-MacStations::BasicModesIterator
-MacStations::EndBasicModes (void) const
-{
- return m_basicModes.end ();
-}
-bool
-MacStations::IsLowLatency (void) const
-{
- return m_isLowLatency;
-}
-void
-MacStations::SetParameters (WifiMacParameters *parameters)
-{
- m_parameters = parameters;
-}
-
-
-} // namespace ns3
-
-/***************************************************************
- * Packet Mode Tagger
- ***************************************************************/
-
-namespace ns3 {
-
-class TxModeTag : public Tag
-{
-public:
- TxModeTag ();
- TxModeTag (WifiMode rtsMode, WifiMode dataMode);
- WifiMode GetRtsMode (void) const;
- WifiMode GetDataMode (void) const;
-
- static uint32_t GetUid (void);
- void Print (std::ostream &os) const;
- void Serialize (ns3::Buffer::Iterator start) const;
- uint32_t Deserialize (ns3::Buffer::Iterator start);
- uint32_t GetSerializedSize (void) const;
-private:
- WifiMode m_rtsMode;
- WifiMode m_dataMode;
-};
-
-TxModeTag::TxModeTag ()
-{}
-TxModeTag::TxModeTag (WifiMode rtsMode, WifiMode dataMode)
- : m_rtsMode (rtsMode),
- m_dataMode (dataMode)
-{}
-WifiMode
-TxModeTag::GetRtsMode (void) const
-{
- return m_rtsMode;
-}
-WifiMode
-TxModeTag::GetDataMode (void) const
-{
- return m_dataMode;
-}
-
-uint32_t
-TxModeTag::GetUid (void)
-{
- static uint32_t uid = Tag::AllocateUid<TxModeTag> ("ns3.wifi.TxModeTag");
- return uid;
-}
-void
-TxModeTag::Print (std::ostream &os) const
-{
- os << "rts="<<m_rtsMode<<" data="<<m_dataMode;
-}
-void
-TxModeTag::Serialize (ns3::Buffer::Iterator start) const
-{}
-uint32_t
-TxModeTag::Deserialize (ns3::Buffer::Iterator start)
-{
- return 0;
-}
-uint32_t
-TxModeTag::GetSerializedSize (void) const
-{
- return 0;
-}
-
-} // namespace ns3
-
-
-/***************************************************************
- * MacStation below.
- ***************************************************************/
-
-namespace ns3 {
-
-MacStation::MacStation ()
- : m_state (BRAND_NEW)
-{}
-MacStation::~MacStation ()
-{}
-
-void
-MacStation::SetParameters (WifiMacParameters *parameters)
-{
- m_parameters = parameters;
-}
-
-bool
-MacStation::IsBrandNew (void) const
-{
- return m_state == BRAND_NEW;
-}
-
-bool
-MacStation::IsAssociated (void) const
-{
- return m_state == GOT_ASSOC_TX_OK;
-}
-bool
-MacStation::IsWaitAssocTxOk (void) const
-{
- return m_state == WAIT_ASSOC_TX_OK;
-}
-void
-MacStation::RecordWaitAssocTxOk (void)
-{
- m_state = WAIT_ASSOC_TX_OK;
-}
-void
-MacStation::RecordGotAssocTxOk (void)
-{
- m_state = GOT_ASSOC_TX_OK;
-}
-void
-MacStation::RecordGotAssocTxFailed (void)
-{
- m_state = DISASSOC;
-}
-void
-MacStation::RecordDisassociated (void)
-{
- m_state = DISASSOC;
-}
-
-void
-MacStation::Reset (void)
-{
- m_modes.clear ();
- AddSupportedMode (GetStations ()->GetDefaultMode ());
-}
-void
-MacStation::AddSupportedMode (WifiMode mode)
-{
- if (IsIn (mode))
- {
- return;
- }
- m_modes.push_back (mode);
-}
-
-bool
-MacStation::IsIn (WifiMode mode) const
-{
- for (SupportedModes::const_iterator i = m_modes.begin (); i != m_modes.end (); i++)
- {
- if ((*i) == mode)
- {
- return true;
- }
- }
- return false;
-}
-
-WifiMode
-MacStation::GetControlAnswerMode (WifiMode reqMode)
-{
- /**
- * see ieee 802.11e, section 9.6:
- *
- * To allow the transmitting STA to calculate the contents of
- * the Duration/ID field, a STA responding to a received frame
- * shall transmit its Control Response frame (either CTS or ACK)
- * frames, other than the Block-Ack control frame, at the highest
- * rate in the BSSBasicRateSet parameter that is less than or equal
- * to the rate of the immediately previous frame in the frame
- * exchange sequence (as defined in 9.79.12) and that is of the
- * same modulation type as the received frame. If no rate in the
- * basic rate set meets these conditions, then the control frame
- * sent in response to a received frame shall be transmitted at
- * the highest mandatory rate of the PHY that is less than or equal
- * to the rate of the received frame, and that is of the same
- * modulation type as the received frame. In addition, the Control
- * Response frame shall be sent using the same PHY options as the
- * received frame, unless they conflict with the requirement to use
- * the BSSBasicRateSet parameter.
- */
- WifiMode mode = GetStations ()->GetDefaultMode ();
- bool found = false;
-
- // First, search the BSS Basic Rate set
- for (MacStations::BasicModesIterator i = GetStations ()->BeginBasicModes ();
- i != GetStations ()->EndBasicModes (); i++)
- {
- if (i->GetPhyRate () > mode.GetPhyRate () &&
- i->GetPhyRate () <= reqMode.GetPhyRate () &&
- i->GetModulationType () == reqMode.GetModulationType ())
- {
- mode = *i;
- found = true;
- }
- }
- // no need to search Mandatory rate set because it is included
- // within the Basic rate set.
- return mode;
-}
-
-WifiMode
-MacStation::GetCtsMode (WifiMode rtsMode)
-{
- return GetControlAnswerMode (rtsMode);
-}
-WifiMode
-MacStation::GetAckMode (WifiMode dataMode)
-{
- return GetControlAnswerMode (dataMode);
-}
-
-uint32_t
-MacStation::GetNSupportedModes (void) const
-{
- return m_modes.size ();
-}
-WifiMode
-MacStation::GetSupportedMode (uint32_t i) const
-{
- NS_ASSERT (i < m_modes.size ());
- return m_modes[i];
-}
-void
-MacStation::PrepareForQueue (Ptr<const Packet> packet, uint32_t fullPacketSize)
-{
- if (GetStations ()->IsLowLatency ())
- {
- return;
- }
- TxModeTag tag = TxModeTag (DoGetRtsMode (), DoGetDataMode (fullPacketSize));
- packet->AddTag (tag);
-}
-WifiMode
-MacStation::GetDataMode (Ptr<const Packet> packet, uint32_t fullPacketSize)
-{
- if (GetStations ()->IsLowLatency ())
- {
- return DoGetDataMode (fullPacketSize);
- }
- TxModeTag tag;
- bool found;
- found = packet->PeekTag (tag);
- NS_ASSERT (found);
- return tag.GetDataMode ();
-}
-WifiMode
-MacStation::GetRtsMode (Ptr<const Packet> packet)
-{
- if (GetStations ()->IsLowLatency ())
- {
- return DoGetRtsMode ();
- }
- TxModeTag tag;
- bool found;
- found = packet->PeekTag (tag);
- NS_ASSERT (found);
- return tag.GetRtsMode ();
-}
-
-bool
-MacStation::NeedRts (Ptr<const Packet> packet)
-{
- if (packet->GetSize () > m_parameters->GetRtsCtsThreshold ())
- {
- return true;
- }
- else
- {
- return false;
- }
-}
-uint32_t
-MacStation::GetMaxSsrc (Ptr<const Packet> packet)
-{
- return m_parameters->GetMaxSsrc ();
-}
-
-uint32_t
-MacStation::GetMaxSlrc (Ptr<const Packet> packet)
-{
- return m_parameters->GetMaxSlrc ();
-}
-
-bool
-MacStation::NeedFragmentation (Ptr<const Packet> packet)
-{
- if (packet->GetSize () > m_parameters->GetFragmentationThreshold ())
- {
- return true;
- }
- else
- {
- return false;
- }
-}
-uint32_t
-MacStation::GetNFragments (Ptr<const Packet> packet)
-{
- uint32_t nFragments = packet->GetSize () / m_parameters->GetFragmentationThreshold () + 1;
- return nFragments;
-}
-
-uint32_t
-MacStation::GetFragmentSize (Ptr<const Packet> packet, uint32_t fragmentNumber)
-{
- uint32_t nFragment = GetNFragments (packet);
- if (fragmentNumber >= nFragment)
- {
- return 0;
- }
- if (fragmentNumber == nFragment - 1)
- {
- uint32_t lastFragmentSize = packet->GetSize () % m_parameters->GetFragmentationThreshold ();
- return lastFragmentSize;
- }
- else
- {
- return m_parameters->GetFragmentationThreshold ();
- }
-}
-
-bool
-MacStation::IsLastFragment (Ptr<const Packet> packet, uint32_t fragmentNumber)
-{
- if (fragmentNumber == (GetNFragments (packet) - 1))
- {
- return true;
- }
- else
- {
- return false;
- }
-}
-
-} // namespace ns3
-
--- a/src/devices/wifi/mac-stations.h Mon Mar 03 04:03:39 2008 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,153 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2005,2006,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 MAC_STATIONS_H
-#define MAC_STATIONS_H
-
-#include <vector>
-#include <utility>
-#include "ns3/mac48-address.h"
-#include "ns3/packet.h"
-#include "wifi-mode.h"
-
-namespace ns3 {
-
-class MacStation;
-class NonUnicastMacStation;
-class WifiMacParameters;
-
-class MacStations
-{
-private:
- typedef std::vector<WifiMode> BasicModes;
-public:
- typedef BasicModes::const_iterator BasicModesIterator;
-
- MacStations (WifiMode defaultTxMode);
- virtual ~MacStations ();
- void SetParameters (WifiMacParameters *parameters);
-
- // Invoked in a STA upon dis-association
- // or in an AP upon reboot
- void Reset (void);
- // Invoked in a STA upon association to store
- // the set of rates which belong to the
- // BSSBasicRateSet of the associated AP
- // and which are supported locally.
- // Invoked in an AP to configure the BSSBasicRateSet
- void AddBasicMode (WifiMode mode);
-
- WifiMode GetDefaultMode (void) const;
- uint32_t GetNBasicModes (void) const;
- WifiMode GetBasicMode (uint32_t i) const;
- BasicModesIterator BeginBasicModes (void) const;
- BasicModesIterator EndBasicModes (void) const;
-
- bool IsLowLatency (void) const;
-
- MacStation *Lookup (Mac48Address address);
- MacStation *LookupNonUnicast (void);
-private:
- typedef std::vector <std::pair<Mac48Address, MacStation *> > Stations;
- virtual class MacStation *CreateStation (void) = 0;
- Stations m_stations;
- WifiMode m_defaultTxMode;
- NonUnicastMacStation *m_nonUnicast;
- BasicModes m_basicModes;
- bool m_isLowLatency;
- WifiMacParameters *m_parameters;
-};
-
-} // namespace ns3
-
-namespace ns3 {
-
-class MacStation {
-public:
- MacStation ();
- virtual ~MacStation ();
-
- // Invoked in an AP upon disassociation of a
- // specific STA.
- void Reset (void);
- // Invoked in a STA or AP to store the set of
- // modes supported by a destination which is
- // also supported locally.
- // The set of supported modes includes
- // the BSSBasicRateSet.
- void AddSupportedMode (WifiMode mode);
- void SetParameters (WifiMacParameters *parameters);
-
- bool IsBrandNew (void) const;
- bool IsAssociated (void) const;
- bool IsWaitAssocTxOk (void) const;
- void RecordWaitAssocTxOk (void);
- void RecordGotAssocTxOk (void);
- void RecordGotAssocTxFailed (void);
- void RecordDisassociated (void);
-
- void PrepareForQueue (Ptr<const Packet> packet, uint32_t fullPacketSize);
- WifiMode GetDataMode (Ptr<const Packet> packet, uint32_t fullPacketSize);
- WifiMode GetRtsMode (Ptr<const Packet> packet);
-
- // reception-related method
- virtual void ReportRxOk (double rxSnr, WifiMode txMode) = 0;
-
- // transmission-related methods
- virtual void ReportRtsFailed (void) = 0;
- virtual void ReportDataFailed (void) = 0;
- virtual void ReportRtsOk (double ctsSnr, WifiMode ctsMode, double rtsSnr) = 0;
- virtual void ReportDataOk (double ackSnr, WifiMode ackMode, double dataSnr) = 0;
- virtual void ReportFinalRtsFailed (void) = 0;
- virtual void ReportFinalDataFailed (void) = 0;
- virtual bool NeedRts (Ptr<const Packet> packet);
- virtual uint32_t GetMaxSsrc (Ptr<const Packet> packet);
- virtual uint32_t GetMaxSlrc (Ptr<const Packet> packet);
- virtual bool NeedFragmentation (Ptr<const Packet> packet);
- virtual uint32_t GetNFragments (Ptr<const Packet> packet);
- virtual uint32_t GetFragmentSize (Ptr<const Packet> packet, uint32_t fragmentNumber);
- virtual bool IsLastFragment (Ptr<const Packet> packet, uint32_t fragmentNumber);
-
- WifiMode GetCtsMode (WifiMode rtsMode);
- WifiMode GetAckMode (WifiMode dataMode);
-
-private:
- typedef std::vector<WifiMode> SupportedModes;
- virtual MacStations *GetStations (void) const = 0;
- virtual WifiMode DoGetDataMode (uint32_t size) = 0;
- virtual WifiMode DoGetRtsMode (void) = 0;
-protected:
- uint32_t GetNSupportedModes (void) const;
- WifiMode GetSupportedMode (uint32_t i) const;
-private:
- bool IsIn (WifiMode mode) const;
- WifiMode GetControlAnswerMode (WifiMode reqMode);
- enum {
- BRAND_NEW,
- DISASSOC,
- WAIT_ASSOC_TX_OK,
- GOT_ASSOC_TX_OK
- } m_state;
- SupportedModes m_modes;
- WifiMacParameters *m_parameters;
-};
-
-} // namespace ns3
-
-#endif /* MAC_STATIONS_H */
--- a/src/devices/wifi/onoe-mac-stations.cc Mon Mar 03 04:03:39 2008 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,232 +0,0 @@
-/* -*- 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-wifi-manager.h"
-#include "ns3/simulator.h"
-#include "ns3/log.h"
-
-NS_LOG_COMPONENT_DEFINE ("OnoeWifiRemoteStation");
-
-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);
-
-OnoeWifiManager::OnoeWifiManager (WifiMode defaultTxMode)
- : MacStations (defaultTxMode),
- m_updatePeriod (g_updatePeriod.GetValue ()),
- m_addCreditThreshold (g_addCreditThreshold.GetValue ()),
- m_raiseThreshold (g_raiseThreshold.GetValue ())
-{}
-MacStation *
-OnoeWifiManager::CreateStation (void)
-{
- return new OnoeWifiRemoteStation (this);
-}
-
-OnoeWifiRemoteStation::OnoeWifiRemoteStation (OnoeWifiManager *stations)
- : m_stations (stations),
- m_nextModeUpdate (Simulator::Now () + stations->m_updatePeriod),
- m_shortRetry (0),
- m_longRetry (0),
- m_tx_ok (0),
- m_tx_err (0),
- m_tx_retr (0),
- m_tx_upper (0),
- m_txrate (0)
-{}
-OnoeWifiRemoteStation::~OnoeWifiRemoteStation ()
-{}
-
-void
-OnoeWifiRemoteStation::ReportRxOk (double rxSnr, WifiMode txMode)
-{}
-void
-OnoeWifiRemoteStation::ReportRtsFailed (void)
-{
- m_shortRetry++;
-}
-void
-OnoeWifiRemoteStation::ReportDataFailed (void)
-{
- m_longRetry++;
-}
-void
-OnoeWifiRemoteStation::ReportRtsOk (double ctsSnr, WifiMode ctsMode, double rtsSnr)
-{}
-void
-OnoeWifiRemoteStation::ReportDataOk (double ackSnr, WifiMode ackMode, double dataSnr)
-{
- UpdateRetry ();
- m_tx_ok++;
-}
-void
-OnoeWifiRemoteStation::ReportFinalRtsFailed (void)
-{
- UpdateRetry ();
- m_tx_err++;
-}
-void
-OnoeWifiRemoteStation::ReportFinalDataFailed (void)
-{
- UpdateRetry ();
- m_tx_err++;
-}
-void
-OnoeWifiRemoteStation::UpdateRetry (void)
-{
- m_tx_retr += m_shortRetry + m_longRetry;
- m_shortRetry = 0;
- m_longRetry = 0;
-}
-void
-OnoeWifiRemoteStation::UpdateMode (void)
-{
- if (Simulator::Now () < m_nextModeUpdate)
- {
- return;
- }
- m_nextModeUpdate = Simulator::Now () + m_stations->m_updatePeriod;
- /**
- * The following 20 lines of code were copied from the Onoe
- * rate control kernel module used in the madwifi driver.
- */
-
- int dir = 0, enough;
- uint32_t nrate;
- enough = (m_tx_ok + m_tx_err >= 10);
-
- /* no packet reached -> down */
- if (m_tx_err > 0 && m_tx_ok == 0)
- dir = -1;
-
- /* all packets needs retry in average -> down */
- if (enough && m_tx_ok < m_tx_retr)
- dir = -1;
-
- /* no error and less than rate_raise% of packets need retry -> up */
- if (enough && m_tx_err == 0 &&
- m_tx_retr < (m_tx_ok * m_stations->m_addCreditThreshold) / 100)
- dir = 1;
-
- NS_LOG_DEBUG (this << " ok " << m_tx_ok << " err " << m_tx_err << " retr " << m_tx_retr <<
- " upper " << m_tx_upper << " dir " << dir);
-
- nrate = m_txrate;
- switch (dir) {
- case 0:
- if (enough && m_tx_upper > 0)
- m_tx_upper--;
- break;
- case -1:
- if (nrate > 0) {
- nrate--;
- }
- m_tx_upper = 0;
- break;
- case 1:
- /* raise rate if we hit rate_raise_threshold */
- if (++m_tx_upper < m_stations->m_raiseThreshold)
- break;
- m_tx_upper = 0;
- if (nrate + 1 < GetNSupportedModes ()) {
- nrate++;
- }
- break;
- }
-
- if (nrate != m_txrate) {
- NS_ASSERT (nrate < GetNSupportedModes ());
- m_txrate = nrate;
- m_tx_ok = m_tx_err = m_tx_retr = m_tx_upper = 0;
- } else if (enough)
- m_tx_ok = m_tx_err = m_tx_retr = 0;
-
-}
-
-OnoeWifiManager *
-OnoeWifiRemoteStation::GetStations (void) const
-{
- return m_stations;
-}
-WifiMode
-OnoeWifiRemoteStation::DoGetDataMode (uint32_t size)
-{
- UpdateMode ();
- NS_ASSERT (m_txrate < GetNSupportedModes ());
- uint32_t rateIndex;
- if (m_longRetry < 4)
- {
- rateIndex = m_txrate;
- }
- else if (m_longRetry < 6)
- {
- if (m_txrate > 0)
- {
- rateIndex = m_txrate - 1;
- }
- else
- {
- rateIndex = m_txrate;
- }
- }
- else if (m_longRetry < 8)
- {
- 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
-OnoeWifiRemoteStation::DoGetRtsMode (void)
-{
- UpdateMode ();
- // XXX: can we implement something smarter ?
- return GetSupportedMode (0);
-}
-
-} // namespace ns3
--- a/src/devices/wifi/onoe-mac-stations.h Mon Mar 03 04:03:39 2008 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,87 +0,0 @@
-/* -*- 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 "wifi-remote-station-manager.h"
-#include "ns3/nstime.h"
-
-namespace ns3 {
-
-class OnoeWifiManager : public WifiRemoteStationManager
-{
-public:
- OnoeWifiManager ();
-
-private:
- friend class OnoeWifiRemoteStation;
- virtual WifiRemoteStation *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 OnoeWifiRemoteStation : public WifiRemoteStation
-{
-public:
- OnoeWifiRemoteStation (OnoeWifiManager *stations);
-
- virtual ~OnoeWifiRemoteStation ();
-
- 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 OnoeWifiManager *GetStations (void) const;
- virtual WifiMode DoGetDataMode (uint32_t size);
- virtual WifiMode DoGetRtsMode (void);
-
- void UpdateRetry (void);
- void UpdateMode (void);
-
- OnoeWifiManager *m_stations;
- Time m_nextModeUpdate;
- uint32_t m_shortRetry;
- uint32_t m_longRetry;
- uint32_t m_tx_ok;
- uint32_t m_tx_err;
- uint32_t m_tx_retr;
- uint32_t m_tx_upper;
- uint32_t m_txrate;
-};
-
-} // namespace ns3
-
-#endif /* ONOE_MAC_STATIONS_H */
--- a/src/devices/wifi/rraa-mac-stations.cc Mon Mar 03 04:03:39 2008 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,407 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2004,2005,2006 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: Federico Maguolo <maguolof@dei.unipd.it>
- */
-
-#include "rraa-mac-stations.h"
-#include "ns3/assert.h"
-#include "ns3/log.h"
-#include "ns3/default-value.h"
-#include "ns3/simulator.h"
-
-NS_LOG_COMPONENT_DEFINE ("Rraa");
-
-namespace ns3 {
-
-static BooleanDefaultValue g_basicRraa
-("RRAA-BASIC",
- "If true the RRAA-BASIC algorithm will be used, otherwise the RRAA wil be used",
- false);
-
-static NumericDefaultValue<double> g_rraaTimeout
-("RraaTimeout",
- "Timeout for the RRAA BASIC loss estimaton block (s)",
- 0.05);
-
-static NumericDefaultValue<uint32_t> g_ewndfor54
-("ewndFor54mbps",
- "ewnd parameter for 54 Mbs data mode",
- 40);
-
-static NumericDefaultValue<uint32_t> g_ewndfor48
-("ewndFor48mbps",
- "ewnd parameter for 48 Mbs data mode",
- 40);
-
-static NumericDefaultValue<uint32_t> g_ewndfor36
-("ewndFor36mbps",
- "ewnd parameter for 36 Mbs data mode",
- 40);
-
-static NumericDefaultValue<uint32_t> g_ewndfor24
-("ewndFor24mbps",
- "ewnd parameter for 24 Mbs data mode",
- 40);
-
-static NumericDefaultValue<uint32_t> g_ewndfor18
-("ewndFor18mbps",
- "ewnd parameter for 18 Mbs data mode",
- 20);
-
-static NumericDefaultValue<uint32_t> g_ewndfor12
-("ewndFor12mbps",
- "ewnd parameter for 12 Mbs data mode",
- 20);
-
-static NumericDefaultValue<uint32_t> g_ewndfor9
-("ewndFor9mbps",
- "ewnd parameter for 9 Mbs data mode",
- 10);
-
-static NumericDefaultValue<uint32_t> g_ewndfor6
-("ewndFor6mbps",
- "ewnd parameter for 6 Mbs data mode",
- 6);
-
-static NumericDefaultValue<double> g_porifor48
-("poriFor48mbps",
- "Pori parameter for 48 Mbs data mode",
- 0.047);
-
-static NumericDefaultValue<double> g_porifor36
-("poriFor36mbps",
- "Pori parameter for 36 Mbs data mode",
- 0.115);
-
-static NumericDefaultValue<double> g_porifor24
-("poriFor24mbps",
- "Pori parameter for 24 Mbs data mode",
- 0.1681);
-
-static NumericDefaultValue<double> g_porifor18
-("poriFor18mbps",
- "Pori parameter for 18 Mbs data mode",
- 0.1325);
-
-static NumericDefaultValue<double> g_porifor12
-("poriFor12mbps",
- "Pori parameter for 12 Mbs data mode",
- 0.1861);
-
-static NumericDefaultValue<double> g_porifor9
-("poriFor9mbps",
- "Pori parameter for 9 Mbs data mode",
- 0.1434);
-
-static NumericDefaultValue<double> g_porifor6
-("poriFor6mbps",
- "Pori parameter for 6 Mbs data mode",
- 0.5);
-
-static NumericDefaultValue<double> g_pmtlfor54
-("pmtlFor54mbps",
- "Pmtl parameter for 54 Mbs data mode",
- 0.094);
-
-static NumericDefaultValue<double> g_pmtlfor48
-("pmtlFor48mbps",
- "Pmtl parameter for 48 Mbs data mode",
- 0.23);
-
-static NumericDefaultValue<double> g_pmtlfor36
-("pmtlFor36mbps",
- "Pmtl parameter for 36 Mbs data mode",
- 0.3363);
-
-static NumericDefaultValue<double> g_pmtlfor24
-("pmtlFor24mbps",
- "Pmtl parameter for 24 Mbs data mode",
- 0.265);
-
-static NumericDefaultValue<double> g_pmtlfor18
-("pmtlFor18mbps",
- "Pmtl parameter for 18 Mbs data mode",
- 0.3722);
-
-static NumericDefaultValue<double> g_pmtlfor12
-("pmtlFor12mbps",
- "Pmtl parameter for 12 Mbs data mode",
- 0.2868);
-
-static NumericDefaultValue<double> g_pmtlfor9
-("pmtlFor9mbps",
- "Pmtl parameter for 9 Mbs data mode",
- 0.3932);
-
-
-RraaMacStation::RraaMacStation (RraaMacStations *stations, Thresholds thresholds)
- : m_stations (stations)
-{
- m_initialized = false;
- m_rtsWnd = 0;
- m_rtsCounter = 0;
- m_rtsOn = false;
- m_lastFrameFail = false;
-}
-
-RraaMacStation::~RraaMacStation ()
-{}
-
-void
-RraaMacStation::ResetCountersBasic (void)
-{
- if (!m_initialized) {
- m_rate = GetMaxRate ();
- m_initialized = true;
- }
- m_failed = 0;
- m_counter = GetThresholds (m_rate).ewnd;
- m_lastReset = Simulator::Now ();
-}
-
-RraaMacStations *
-RraaMacStation::GetStations (void) const
-{
- return m_stations;
-}
-
-uint32_t
-RraaMacStation::GetMaxRate (void)
-{
- return GetNSupportedModes () - 1;
-}
-uint32_t
-RraaMacStation::GetMinRate (void)
-{
- return 0;
-}
-
-ThresholdsItem
-RraaMacStation::GetThresholds (uint32_t rate)
-{
- WifiMode mode = GetSupportedMode (rate);
- return m_stations->GetThresholds (mode);
-}
-
-
-void
-RraaMacStation::ReportRtsFailed (void)
-{}
-
-void
-RraaMacStation::ReportDataFailed (void)
-{
- m_lastFrameFail = true;
- CheckTimeout ();
- m_counter--;
- m_failed++;
- RunBasicAlgorithm ();
-}
-void
-RraaMacStation::ReportRxOk (double rxSnr, WifiMode txMode)
-{}
-void
-RraaMacStation::ReportRtsOk (double ctsSnr, WifiMode ctsMode, double rtsSnr)
-{
- NS_LOG_DEBUG ("self="<<this<<" rts ok");
-}
-void
-RraaMacStation::ReportDataOk (double ackSnr, WifiMode ackMode, double dataSnr)
-{
- m_lastFrameFail = false;
- CheckTimeout ();
- m_counter--;
- RunBasicAlgorithm ();
-}
-void
-RraaMacStation::ReportFinalRtsFailed (void)
-{}
-void
-RraaMacStation::ReportFinalDataFailed (void)
-{}
-
-WifiMode
-RraaMacStation::DoGetDataMode (uint32_t size)
-{
- if (!m_initialized)
- ResetCountersBasic ();
- return GetSupportedMode (m_rate);
-}
-WifiMode
-RraaMacStation::DoGetRtsMode (void)
-{
- return GetSupportedMode (0);
-}
-
-bool
-RraaMacStation::NeedRts (Ptr<const Packet> packet)
-{
- if (m_stations->OnlyBasic ())
- return MacStation::NeedRts (packet);
- ARts ();
- return m_rtsOn;
-}
-
-void
-RraaMacStation::CheckTimeout (void)
-{
- Time d = Simulator::Now () - m_lastReset;
- if (m_counter == 0 || d.GetSeconds () > m_stations->GetTimeout ()) {
- ResetCountersBasic ();
- }
-}
-
-void
-RraaMacStation::RunBasicAlgorithm (void)
-{
- ThresholdsItem thresholds = GetThresholds (m_rate);
- double ploss = (double) m_failed / (double) thresholds.ewnd;
- if (m_counter == 0 || ploss > thresholds.pmtl) {
- if (m_rate > GetMinRate () && ploss > thresholds.pmtl) {
- m_rate--;
- }
- else if (m_rate < GetMaxRate () && ploss < thresholds.pori) {
- m_rate++;
- }
- ResetCountersBasic ();
- }
-}
-
-void
-RraaMacStation::ARts (void)
-{
- if (!m_rtsOn && m_lastFrameFail) {
- m_rtsWnd++;
- m_rtsCounter = m_rtsWnd;
- }
- else if ((m_rtsOn && m_lastFrameFail) ||
- (!m_rtsOn && !m_lastFrameFail)) {
- m_rtsWnd = m_rtsWnd / 2;
- m_rtsCounter = m_rtsWnd;
- }
- if (m_rtsCounter > 0) {
- m_rtsOn = true;
- m_rtsCounter--;
- }
- else {
- m_rtsOn = false;
- }
-}
-
-
-
-
-RraaMacStations::RraaMacStations (WifiMode defaultTxMode)
- : MacStations (defaultTxMode)
-{
- DoConstruct ();
-}
-RraaMacStations::~RraaMacStations ()
-{}
-
-void
-RraaMacStations::DoConstruct ()
-{
- ThresholdsItem mode54 = {54000000,
- 0.0,
- g_pmtlfor54.GetValue (),
- g_ewndfor54.GetValue ()};
- ThresholdsItem mode48 = {48000000,
- g_porifor48.GetValue (),
- g_pmtlfor48.GetValue (),
- g_ewndfor48.GetValue ()};
- ThresholdsItem mode36 = {36000000,
- g_porifor36.GetValue (),
- g_pmtlfor36.GetValue (),
- g_ewndfor36.GetValue ()};
- ThresholdsItem mode24 = {24000000,
- g_porifor24.GetValue (),
- g_pmtlfor24.GetValue (),
- g_ewndfor24.GetValue ()};
- ThresholdsItem mode18 = {18000000,
- g_porifor18.GetValue (),
- g_pmtlfor18.GetValue (),
- g_ewndfor18.GetValue ()};
- ThresholdsItem mode12 = {12000000,
- g_porifor12.GetValue (),
- g_pmtlfor12.GetValue (),
- g_ewndfor12.GetValue ()};
- ThresholdsItem mode9 = {9000000,
- g_porifor9.GetValue (),
- g_pmtlfor9.GetValue (),
- g_ewndfor9.GetValue ()};
- ThresholdsItem mode6 = {6000000,
- g_porifor6.GetValue (),
- 1.0,
- g_ewndfor6.GetValue ()};
- m_thresholds.push_back (mode54);
- m_thresholds.push_back (mode48);
- m_thresholds.push_back (mode36);
- m_thresholds.push_back (mode24);
- m_thresholds.push_back (mode18);
- m_thresholds.push_back (mode12);
- m_thresholds.push_back (mode9);
- m_thresholds.push_back (mode6);
- m_basic = g_basicRraa.GetValue ();
- m_timeout = g_rraaTimeout.GetValue ();
-}
-
-MacStation *
-RraaMacStations::CreateStation (void)
-{
- return new RraaMacStation (this, m_thresholds);
-}
-
-bool
-RraaMacStations::OnlyBasic (void)
-{
- return m_basic;
-}
-
-double
-RraaMacStations::GetTimeout (void)
-{
- return m_timeout;
-}
-
-ThresholdsItem
-RraaMacStations::GetThresholds (WifiMode mode)
-{
- switch (mode.GetDataRate () / 1000000) {
- case 54:
- return m_thresholds[0];
- case 48:
- return m_thresholds[1];
- case 36:
- return m_thresholds[2];
- case 24:
- return m_thresholds[3];
- case 18:
- return m_thresholds[4];
- case 12:
- return m_thresholds[5];
- case 9:
- return m_thresholds[6];
- case 6:
- return m_thresholds[7];
- }
- NS_ASSERT("Thresholds for an unknown mode are asked");
- return m_thresholds[0];
-}
-
-} // namespace ns3
--- a/src/devices/wifi/rraa-mac-stations.h Mon Mar 03 04:03:39 2008 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,104 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2005,2006 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: Federico Maguolo <maguolof@dei.unipd.it>
- */
-#ifndef RRAA_MAC_STATIONS_H
-#define RRAA_MAC_STATIONS_H
-
-#include "ns3/nstime.h"
-#include "mac-stations.h"
-
-namespace ns3 {
-
-struct ThresholdsItem {
- uint32_t datarate;
- double pori;
- double pmtl;
- uint32_t ewnd;
-};
-
-typedef std::vector<ThresholdsItem> Thresholds;
-
-/**
- * \brief Robust Rate Adaptation Algorithm
- *
- * This is an implementation of RRAA as described in
- * "Robust rate adaptation for 802.11 wireless networks"
- * by "Starsky H. Y. Wong", "Hao Yang", "Songwu Lu", and,
- * "Vaduvur Bharghavan" published in Mobicom 06.
- */
-class RraaMacStations : public MacStations {
-public:
- RraaMacStations (WifiMode defaultTxMode);
- virtual ~RraaMacStations ();
- void DoConstruct ();
- bool OnlyBasic (void);
- double GetTimeout (void);
- ThresholdsItem GetThresholds (WifiMode mode);
-private:
- virtual class MacStation *CreateStation (void);
- Thresholds m_thresholds;
- bool m_basic;
- double m_timeout;
-};
-
-
-class RraaMacStation : public MacStation
-{
-public:
- RraaMacStation (RraaMacStations *stations, Thresholds thresholds);
- virtual ~RraaMacStation ();
-
- 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);
- virtual bool NeedRts (Ptr<const Packet> packet);
-
-private:
- virtual RraaMacStations *GetStations (void) const;
- virtual WifiMode DoGetDataMode (uint32_t size);
- virtual WifiMode DoGetRtsMode (void);
- uint32_t GetMaxRate (void);
- uint32_t GetMinRate (void);
- ThresholdsItem GetThresholds (uint32_t rate);
- void CheckTimeout (void);
- void RunBasicAlgorithm (void);
- void ARts (void);
- void ResetCountersBasic (void);
-
- uint32_t m_counter;
- uint32_t m_failed;
- uint32_t m_rtsWnd;
- uint32_t m_rtsCounter;
- Time m_lastReset;
- bool m_rtsOn;
- bool m_lastFrameFail;
- bool m_initialized;
-
- uint32_t m_rate;
-
- RraaMacStations *m_stations;
-};
-
-} // namespace ns3
-
-#endif /* RRAA_MAC_STATIONS_H */