00001 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ 00002 /* 00003 * Copyright (c) 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 IDEAL_MAC_STATIONS_H 00021 #define IDEAL_MAC_STATIONS_H 00022 00023 #include <stdint.h> 00024 #include <vector> 00025 #include "wifi-mode.h" 00026 #include "wifi-remote-station-manager.h" 00027 00028 namespace ns3 { 00029 00030 /** 00031 * \brief Ideal rate control algorithm 00032 * 00033 * This class implements an 'ideal' rate control algorithm 00034 * similar to RBAR in spirit (see <i>A rate-adaptive MAC 00035 * protocol for multihop wireless networks</i> by G. Holland, 00036 * N. Vaidya, and P. Bahl.): every station keeps track of the 00037 * snr of every packet received and sends back this snr to the 00038 * original transmitter by an out-of-band mechanism. Each 00039 * transmitter keeps track of the last snr sent back by a receiver 00040 * and uses it to pick a transmission mode based on a set 00041 * of snr thresholds built from a target ber and transmission 00042 * mode-specific snr/ber curves. 00043 */ 00044 class IdealWifiManager : public WifiRemoteStationManager 00045 { 00046 public: 00047 static TypeId GetTypeId (void); 00048 IdealWifiManager (); 00049 virtual ~IdealWifiManager (); 00050 00051 virtual void SetupPhy (Ptr<WifiPhy> phy); 00052 00053 // return the min snr needed to successfully transmit 00054 // data with this mode at the specified ber. 00055 double GetSnrThreshold (WifiMode mode) const; 00056 void AddModeSnrThreshold (WifiMode mode, double ber); 00057 private: 00058 virtual class WifiRemoteStation *CreateStation (void); 00059 00060 typedef std::vector<std::pair<double,WifiMode> > Thresholds; 00061 00062 double m_ber; 00063 Thresholds m_thresholds; 00064 double m_minSnr; 00065 double m_maxSnr; 00066 }; 00067 00068 class IdealWifiRemoteStation : public WifiRemoteStation 00069 { 00070 public: 00071 IdealWifiRemoteStation (Ptr<IdealWifiManager> stations); 00072 00073 virtual ~IdealWifiRemoteStation (); 00074 00075 protected: 00076 virtual void DoReportRxOk (double rxSnr, WifiMode txMode); 00077 virtual void DoReportRtsFailed (void); 00078 virtual void DoReportDataFailed (void); 00079 virtual void DoReportRtsOk (double ctsSnr, WifiMode ctsMode, double rtsSnr); 00080 virtual void DoReportDataOk (double ackSnr, WifiMode ackMode, double dataSnr); 00081 virtual void DoReportFinalRtsFailed (void); 00082 virtual void DoReportFinalDataFailed (void); 00083 00084 private: 00085 virtual Ptr<WifiRemoteStationManager> GetManager (void) const; 00086 virtual WifiMode DoGetDataMode (uint32_t size); 00087 virtual WifiMode DoGetRtsMode (void); 00088 00089 Ptr<IdealWifiManager> m_manager; 00090 double m_lastSnr; 00091 }; 00092 00093 } // namespace ns3 00094 00095 #endif /* MAC_STA_H */