00001 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ 00002 /* 00003 * Copyright (c) 2003,2007 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 AMRR_WIFI_MANAGER_H 00021 #define AMRR_WIFI_MANAGER_H 00022 00023 #include "wifi-remote-station-manager.h" 00024 #include "ns3/nstime.h" 00025 00026 namespace ns3 { 00027 00028 /** 00029 * \brief AMRR Rate control algorithm 00030 * 00031 * This class implements the AMRR rate control algorithm which 00032 * was initially described in <i>IEEE 802.11 Rate Adaptation: 00033 * A Practical Approach</i>, by M. Lacage, M.H. Manshaei, and 00034 * T. Turletti. 00035 */ 00036 class AmrrWifiManager : public WifiRemoteStationManager 00037 { 00038 public: 00039 static TypeId GetTypeId (void); 00040 00041 AmrrWifiManager (); 00042 00043 private: 00044 friend class AmrrWifiRemoteStation; 00045 virtual WifiRemoteStation *CreateStation (void); 00046 00047 Time m_updatePeriod; 00048 double m_failureRatio; 00049 double m_successRatio; 00050 uint32_t m_maxSuccessThreshold; 00051 uint32_t m_minSuccessThreshold; 00052 }; 00053 00054 /** 00055 */ 00056 class AmrrWifiRemoteStation : public WifiRemoteStation 00057 { 00058 public: 00059 AmrrWifiRemoteStation (Ptr<AmrrWifiManager> stations); 00060 00061 virtual ~AmrrWifiRemoteStation (); 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 void UpdateRetry (void); 00078 void UpdateMode (void); 00079 void ResetCnt (void); 00080 void IncreaseRate (void); 00081 void DecreaseRate (void); 00082 bool IsMinRate (void) const; 00083 bool IsMaxRate (void) const; 00084 bool IsSuccess (void) const; 00085 bool IsFailure (void) const; 00086 bool IsEnough (void) const; 00087 00088 Ptr<AmrrWifiManager> m_stations; 00089 Time m_nextModeUpdate; 00090 uint32_t m_tx_ok; 00091 uint32_t m_tx_err; 00092 uint32_t m_tx_retr; 00093 uint32_t m_retry; 00094 uint32_t m_txrate; 00095 uint32_t m_successThreshold; 00096 uint32_t m_success; 00097 bool m_recovery; 00098 }; 00099 00100 } // namespace ns3 00101 00102 #endif /* AMRR_WIFI_MANAGER_H */