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: Federico Maguolo <maguolof@dei.unipd.it> 00019 */ 00020 #ifndef RRAA_WIFI_MANAGER_H 00021 #define RRAA_WIFI_MANAGER_H 00022 00023 #include "ns3/nstime.h" 00024 #include "wifi-remote-station-manager.h" 00025 00026 namespace ns3 { 00027 00028 struct ThresholdsItem { 00029 uint32_t datarate; 00030 double pori; 00031 double pmtl; 00032 uint32_t ewnd; 00033 }; 00034 00035 typedef std::vector<ThresholdsItem> Thresholds; 00036 00037 /** 00038 * \brief Robust Rate Adaptation Algorithm 00039 * 00040 * This is an implementation of RRAA as described in 00041 * "Robust rate adaptation for 802.11 wireless networks" 00042 * by "Starsky H. Y. Wong", "Hao Yang", "Songwu Lu", and, 00043 * "Vaduvur Bharghavan" published in Mobicom 06. 00044 */ 00045 class RraaWifiManager : public WifiRemoteStationManager 00046 { 00047 public: 00048 static TypeId GetTypeId (void); 00049 00050 RraaWifiManager (); 00051 virtual ~RraaWifiManager (); 00052 bool OnlyBasic (void); 00053 Time GetTimeout (void) const; 00054 ThresholdsItem GetThresholds (WifiMode mode) const; 00055 private: 00056 virtual class WifiRemoteStation *CreateStation (void); 00057 bool m_basic; 00058 Time m_timeout; 00059 uint32_t m_ewndfor54; 00060 uint32_t m_ewndfor48; 00061 uint32_t m_ewndfor36; 00062 uint32_t m_ewndfor24; 00063 uint32_t m_ewndfor18; 00064 uint32_t m_ewndfor12; 00065 uint32_t m_ewndfor9; 00066 uint32_t m_ewndfor6; 00067 double m_porifor48; 00068 double m_porifor36; 00069 double m_porifor24; 00070 double m_porifor18; 00071 double m_porifor12; 00072 double m_porifor9; 00073 double m_porifor6; 00074 double m_pmtlfor54; 00075 double m_pmtlfor48; 00076 double m_pmtlfor36; 00077 double m_pmtlfor24; 00078 double m_pmtlfor18; 00079 double m_pmtlfor12; 00080 double m_pmtlfor9; 00081 }; 00082 00083 00084 class RraaWifiRemoteStation : public WifiRemoteStation 00085 { 00086 public: 00087 RraaWifiRemoteStation (Ptr<RraaWifiManager> stations); 00088 virtual ~RraaWifiRemoteStation (); 00089 00090 virtual bool NeedRts (Ptr<const Packet> packet); 00091 protected: 00092 virtual void DoReportRxOk (double rxSnr, WifiMode txMode); 00093 virtual void DoReportRtsFailed (void); 00094 virtual void DoReportDataFailed (void); 00095 virtual void DoReportRtsOk (double ctsSnr, WifiMode ctsMode, double rtsSnr); 00096 virtual void DoReportDataOk (double ackSnr, WifiMode ackMode, double dataSnr); 00097 virtual void DoReportFinalRtsFailed (void); 00098 virtual void DoReportFinalDataFailed (void); 00099 00100 private: 00101 virtual Ptr<WifiRemoteStationManager> GetManager (void) const; 00102 virtual WifiMode DoGetDataMode (uint32_t size); 00103 virtual WifiMode DoGetRtsMode (void); 00104 uint32_t GetMaxRate (void); 00105 uint32_t GetMinRate (void); 00106 ThresholdsItem GetThresholds (uint32_t rate); 00107 void CheckTimeout (void); 00108 void RunBasicAlgorithm (void); 00109 void ARts (void); 00110 void ResetCountersBasic (void); 00111 00112 uint32_t m_counter; 00113 uint32_t m_failed; 00114 uint32_t m_rtsWnd; 00115 uint32_t m_rtsCounter; 00116 Time m_lastReset; 00117 bool m_rtsOn; 00118 bool m_lastFrameFail; 00119 bool m_initialized; 00120 00121 uint32_t m_rate; 00122 00123 Ptr<RraaWifiManager> m_stations; 00124 }; 00125 00126 } // namespace ns3 00127 00128 #endif /* RRAA_WIFI_MANAGER_H */