From c3d5b77c96715243e1543056f218e7836d7dfdcd Mon Sep 17 00:00:00 2001 From: Mathieu Lacage Date: Mon, 3 Mar 2008 04:42:16 +0100 Subject: [PATCH] renamed files --- src/devices/wifi/aarf-mac-stations.cc | 90 ---- src/devices/wifi/aarf-mac-stations.h | 76 ---- src/devices/wifi/amrr-mac-stations.cc | 280 ------------ src/devices/wifi/amrr-mac-stations.h | 91 ---- src/devices/wifi/arf-mac-stations.cc | 240 ----------- src/devices/wifi/arf-mac-stations.h | 115 ----- src/devices/wifi/arf-wifi-manager.cc | 1 - src/devices/wifi/cr-mac-stations.cc | 100 ----- src/devices/wifi/cr-mac-stations.h | 76 ---- src/devices/wifi/ideal-mac-stations.cc | 151 ------- src/devices/wifi/ideal-mac-stations.h | 89 ---- src/devices/wifi/mac-low.cc | 1 - src/devices/wifi/mac-stations.cc | 561 ------------------------- src/devices/wifi/mac-stations.h | 153 ------- src/devices/wifi/onoe-mac-stations.cc | 232 ---------- src/devices/wifi/onoe-mac-stations.h | 87 ---- src/devices/wifi/rraa-mac-stations.cc | 407 ------------------ src/devices/wifi/rraa-mac-stations.h | 104 ----- 18 files changed, 2854 deletions(-) delete mode 100644 src/devices/wifi/aarf-mac-stations.cc delete mode 100644 src/devices/wifi/aarf-mac-stations.h delete mode 100644 src/devices/wifi/amrr-mac-stations.cc delete mode 100644 src/devices/wifi/amrr-mac-stations.h delete mode 100644 src/devices/wifi/arf-mac-stations.cc delete mode 100644 src/devices/wifi/arf-mac-stations.h delete mode 100644 src/devices/wifi/cr-mac-stations.cc delete mode 100644 src/devices/wifi/cr-mac-stations.h delete mode 100644 src/devices/wifi/ideal-mac-stations.cc delete mode 100644 src/devices/wifi/ideal-mac-stations.h delete mode 100644 src/devices/wifi/mac-stations.cc delete mode 100644 src/devices/wifi/mac-stations.h delete mode 100644 src/devices/wifi/onoe-mac-stations.cc delete mode 100644 src/devices/wifi/onoe-mac-stations.h delete mode 100644 src/devices/wifi/rraa-mac-stations.cc delete mode 100644 src/devices/wifi/rraa-mac-stations.h diff --git a/src/devices/wifi/aarf-mac-stations.cc b/src/devices/wifi/aarf-mac-stations.cc deleted file mode 100644 index 88ae5f726..000000000 --- a/src/devices/wifi/aarf-mac-stations.cc +++ /dev/null @@ -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 - */ - -#include "aarf-mac-stations.h" - -#define Min(a,b) ((ab)?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 diff --git a/src/devices/wifi/aarf-mac-stations.h b/src/devices/wifi/aarf-mac-stations.h deleted file mode 100644 index f5e9c2dce..000000000 --- a/src/devices/wifi/aarf-mac-stations.h +++ /dev/null @@ -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 - */ -#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 IEEE 802.11 Rate Adaptation: - * A Practical Approach, 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 */ diff --git a/src/devices/wifi/amrr-mac-stations.cc b/src/devices/wifi/amrr-mac-stations.cc deleted file mode 100644 index d6e42cef5..000000000 --- a/src/devices/wifi/amrr-mac-stations.cc +++ /dev/null @@ -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 - */ - -#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 g_failureRatio -("WifiAmrrFailureRatio", - "Ratio of erronous transmissions needed to switch to a lower rate", - 1.0/3.0); -static NumericDefaultValue g_successRatio -("WifiAmrrSuccessRatio", - "Ratio of erronous transmissions needed to switch to a higher rate", - 1.0/10.0); -static NumericDefaultValue g_maxSuccessThreshold -("WifiAmrrMaxSuccessThreshold", - "maximum number of consecutive success periods needed to switch to a higher rate", - 10); -static NumericDefaultValue 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="< 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 diff --git a/src/devices/wifi/amrr-mac-stations.h b/src/devices/wifi/amrr-mac-stations.h deleted file mode 100644 index 6b4b8415c..000000000 --- a/src/devices/wifi/amrr-mac-stations.h +++ /dev/null @@ -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 - */ -#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 */ diff --git a/src/devices/wifi/arf-mac-stations.cc b/src/devices/wifi/arf-mac-stations.cc deleted file mode 100644 index 5ac04373d..000000000 --- a/src/devices/wifi/arf-mac-stations.cc +++ /dev/null @@ -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 - */ - -#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="<= 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 diff --git a/src/devices/wifi/arf-mac-stations.h b/src/devices/wifi/arf-mac-stations.h deleted file mode 100644 index 019b1933c..000000000 --- a/src/devices/wifi/arf-mac-stations.h +++ /dev/null @@ -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 - */ -#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 WaveLAN-II: A High-performance wireless - * LAN for the unlicensed band, 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 */ diff --git a/src/devices/wifi/arf-wifi-manager.cc b/src/devices/wifi/arf-wifi-manager.cc index a881080a1..0570db816 100644 --- a/src/devices/wifi/arf-wifi-manager.cc +++ b/src/devices/wifi/arf-wifi-manager.cc @@ -18,7 +18,6 @@ * Author: Mathieu Lacage */ -#include "mac-stations.h" #include "arf-wifi-manager.h" #include "ns3/assert.h" #include "ns3/log.h" diff --git a/src/devices/wifi/cr-mac-stations.cc b/src/devices/wifi/cr-mac-stations.cc deleted file mode 100644 index d7e1aa5d3..000000000 --- a/src/devices/wifi/cr-mac-stations.cc +++ /dev/null @@ -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 - */ - -#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 diff --git a/src/devices/wifi/cr-mac-stations.h b/src/devices/wifi/cr-mac-stations.h deleted file mode 100644 index 3a994e8b5..000000000 --- a/src/devices/wifi/cr-mac-stations.h +++ /dev/null @@ -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 - */ -#ifndef CR_MAC_STATIONS_H -#define CR_MAC_STATIONS_H - -#include - -#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 */ diff --git a/src/devices/wifi/ideal-mac-stations.cc b/src/devices/wifi/ideal-mac-stations.cc deleted file mode 100644 index 5a037eb0e..000000000 --- a/src/devices/wifi/ideal-mac-stations.cc +++ /dev/null @@ -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 - */ -#include "ideal-mac-stations.h" -#include "ns3/assert.h" -#include - -#define noIDEAL_DEBUG 1 - -#ifdef IDEAL_DEBUG -#include -# 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="< - */ -#ifndef IDEAL_MAC_STATIONS_H -#define IDEAL_MAC_STATIONS_H - -#include -#include -#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 A rate-adaptive MAC - * protocol for multihop wireless networks 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 > 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 */ diff --git a/src/devices/wifi/mac-low.cc b/src/devices/wifi/mac-low.cc index 372bf4121..a0f280b1d 100644 --- a/src/devices/wifi/mac-low.cc +++ b/src/devices/wifi/mac-low.cc @@ -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"); diff --git a/src/devices/wifi/mac-stations.cc b/src/devices/wifi/mac-stations.cc deleted file mode 100644 index b96cf66eb..000000000 --- a/src/devices/wifi/mac-stations.cc +++ /dev/null @@ -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 - */ - -#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="< - */ -#ifndef MAC_STATIONS_H -#define MAC_STATIONS_H - -#include -#include -#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 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 > 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 packet, uint32_t fullPacketSize); - WifiMode GetDataMode (Ptr packet, uint32_t fullPacketSize); - WifiMode GetRtsMode (Ptr 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 packet); - virtual uint32_t GetMaxSsrc (Ptr packet); - virtual uint32_t GetMaxSlrc (Ptr packet); - virtual bool NeedFragmentation (Ptr packet); - virtual uint32_t GetNFragments (Ptr packet); - virtual uint32_t GetFragmentSize (Ptr packet, uint32_t fragmentNumber); - virtual bool IsLastFragment (Ptr packet, uint32_t fragmentNumber); - - WifiMode GetCtsMode (WifiMode rtsMode); - WifiMode GetAckMode (WifiMode dataMode); - -private: - typedef std::vector 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 */ diff --git a/src/devices/wifi/onoe-mac-stations.cc b/src/devices/wifi/onoe-mac-stations.cc deleted file mode 100644 index 6a2cc6fd3..000000000 --- a/src/devices/wifi/onoe-mac-stations.cc +++ /dev/null @@ -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 - */ - -#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 g_addCreditThreshold -("WifiOnoeAddCreditThreshold", - "Add credit threshold", - 10); -static NumericDefaultValue 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 diff --git a/src/devices/wifi/onoe-mac-stations.h b/src/devices/wifi/onoe-mac-stations.h deleted file mode 100644 index cf5b7b3f5..000000000 --- a/src/devices/wifi/onoe-mac-stations.h +++ /dev/null @@ -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 - */ -#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 */ diff --git a/src/devices/wifi/rraa-mac-stations.cc b/src/devices/wifi/rraa-mac-stations.cc deleted file mode 100644 index c8d1bdfa7..000000000 --- a/src/devices/wifi/rraa-mac-stations.cc +++ /dev/null @@ -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 - */ - -#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 g_rraaTimeout -("RraaTimeout", - "Timeout for the RRAA BASIC loss estimaton block (s)", - 0.05); - -static NumericDefaultValue g_ewndfor54 -("ewndFor54mbps", - "ewnd parameter for 54 Mbs data mode", - 40); - -static NumericDefaultValue g_ewndfor48 -("ewndFor48mbps", - "ewnd parameter for 48 Mbs data mode", - 40); - -static NumericDefaultValue g_ewndfor36 -("ewndFor36mbps", - "ewnd parameter for 36 Mbs data mode", - 40); - -static NumericDefaultValue g_ewndfor24 -("ewndFor24mbps", - "ewnd parameter for 24 Mbs data mode", - 40); - -static NumericDefaultValue g_ewndfor18 -("ewndFor18mbps", - "ewnd parameter for 18 Mbs data mode", - 20); - -static NumericDefaultValue g_ewndfor12 -("ewndFor12mbps", - "ewnd parameter for 12 Mbs data mode", - 20); - -static NumericDefaultValue g_ewndfor9 -("ewndFor9mbps", - "ewnd parameter for 9 Mbs data mode", - 10); - -static NumericDefaultValue g_ewndfor6 -("ewndFor6mbps", - "ewnd parameter for 6 Mbs data mode", - 6); - -static NumericDefaultValue g_porifor48 -("poriFor48mbps", - "Pori parameter for 48 Mbs data mode", - 0.047); - -static NumericDefaultValue g_porifor36 -("poriFor36mbps", - "Pori parameter for 36 Mbs data mode", - 0.115); - -static NumericDefaultValue g_porifor24 -("poriFor24mbps", - "Pori parameter for 24 Mbs data mode", - 0.1681); - -static NumericDefaultValue g_porifor18 -("poriFor18mbps", - "Pori parameter for 18 Mbs data mode", - 0.1325); - -static NumericDefaultValue g_porifor12 -("poriFor12mbps", - "Pori parameter for 12 Mbs data mode", - 0.1861); - -static NumericDefaultValue g_porifor9 -("poriFor9mbps", - "Pori parameter for 9 Mbs data mode", - 0.1434); - -static NumericDefaultValue g_porifor6 -("poriFor6mbps", - "Pori parameter for 6 Mbs data mode", - 0.5); - -static NumericDefaultValue g_pmtlfor54 -("pmtlFor54mbps", - "Pmtl parameter for 54 Mbs data mode", - 0.094); - -static NumericDefaultValue g_pmtlfor48 -("pmtlFor48mbps", - "Pmtl parameter for 48 Mbs data mode", - 0.23); - -static NumericDefaultValue g_pmtlfor36 -("pmtlFor36mbps", - "Pmtl parameter for 36 Mbs data mode", - 0.3363); - -static NumericDefaultValue g_pmtlfor24 -("pmtlFor24mbps", - "Pmtl parameter for 24 Mbs data mode", - 0.265); - -static NumericDefaultValue g_pmtlfor18 -("pmtlFor18mbps", - "Pmtl parameter for 18 Mbs data mode", - 0.3722); - -static NumericDefaultValue g_pmtlfor12 -("pmtlFor12mbps", - "Pmtl parameter for 12 Mbs data mode", - 0.2868); - -static NumericDefaultValue 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="< 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 diff --git a/src/devices/wifi/rraa-mac-stations.h b/src/devices/wifi/rraa-mac-stations.h deleted file mode 100644 index da967155f..000000000 --- a/src/devices/wifi/rraa-mac-stations.h +++ /dev/null @@ -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 - */ -#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 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 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 */