00001 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ 00002 /* 00003 * Copyright (c) 2005,2006 INRIA 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License version 2 as 00007 * published by the Free Software Foundation; 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00017 * 00018 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> 00019 */ 00020 #ifndef ARF_WIFI_MANAGER_H 00021 #define ARF_WIFI_MANAGER_H 00022 00023 #include "wifi-remote-station-manager.h" 00024 00025 namespace ns3 { 00026 00027 /** 00028 * \brief ARF Rate control algorithm 00029 * 00030 * This class implements the so-called ARF algorithm which was 00031 * initially described in <i>WaveLAN-II: A High-performance wireless 00032 * LAN for the unlicensed band</i>, by A. Kamerman and L. Monteban. in 00033 * Bell Lab Technical Journal, pages 118-133, Summer 1997. 00034 * 00035 * This implementation differs from the initial description in that it 00036 * uses a packet-based timer rather than a time-based timer as described 00037 * in XXX (I cannot find back the original paper which described how 00038 * the time-based timer could be easily replaced with a packet-based 00039 * timer.) 00040 */ 00041 class ArfWifiManager : public WifiRemoteStationManager 00042 { 00043 public: 00044 static TypeId GetTypeId (void); 00045 ArfWifiManager (); 00046 virtual ~ArfWifiManager (); 00047 00048 private: 00049 virtual class WifiRemoteStation *CreateStation (void); 00050 uint32_t m_timerThreshold; 00051 uint32_t m_successThreshold; 00052 }; 00053 00054 00055 class ArfWifiRemoteStation : public WifiRemoteStation 00056 { 00057 public: 00058 ArfWifiRemoteStation (Ptr<ArfWifiManager> stations, 00059 int minTimerTimeout, 00060 int minSuccessThreshold); 00061 virtual ~ArfWifiRemoteStation (); 00062 00063 protected: 00064 virtual void DoReportRxOk (double rxSnr, WifiMode txMode); 00065 virtual void DoReportRtsFailed (void); 00066 virtual void DoReportDataFailed (void); 00067 virtual void DoReportRtsOk (double ctsSnr, WifiMode ctsMode, double rtsSnr); 00068 virtual void DoReportDataOk (double ackSnr, WifiMode ackMode, double dataSnr); 00069 virtual void DoReportFinalRtsFailed (void); 00070 virtual void DoReportFinalDataFailed (void); 00071 00072 private: 00073 virtual Ptr<WifiRemoteStationManager> GetManager (void) const; 00074 virtual WifiMode DoGetDataMode (uint32_t size); 00075 virtual WifiMode DoGetRtsMode (void); 00076 00077 uint32_t m_timer; 00078 uint32_t m_success; 00079 uint32_t m_failed; 00080 bool m_recovery; 00081 uint32_t m_retry; 00082 00083 uint32_t m_timerTimeout; 00084 uint32_t m_successThreshold; 00085 00086 uint32_t m_rate; 00087 00088 uint32_t m_minTimerTimeout; 00089 uint32_t m_minSuccessThreshold; 00090 00091 Ptr<ArfWifiManager> m_stations; 00092 00093 private: 00094 // overriden by AarfMacStation. 00095 virtual void ReportRecoveryFailure (void); 00096 virtual void ReportFailure (void); 00097 00098 uint32_t GetMaxRate (void); 00099 uint32_t GetMinRate (void); 00100 00101 bool NeedRecoveryFallback (void); 00102 bool NeedNormalFallback (void); 00103 00104 protected: 00105 // called by AarfMacStation. 00106 uint32_t GetMinTimerTimeout (void); 00107 uint32_t GetMinSuccessThreshold (void); 00108 00109 uint32_t GetTimerTimeout (void); 00110 uint32_t GetSuccessThreshold (void); 00111 00112 void SetTimerTimeout (uint32_t timerTimeout); 00113 void SetSuccessThreshold (uint32_t successThreshold); 00114 }; 00115 00116 } // namespace ns3 00117 00118 #endif /* ARF_WIFI_MANAGER_H */