src/devices/wifi/rraa-wifi-manager.h
changeset 2544 2e6e1a6e0d94
parent 2351 84e79f06621c
child 2784 49006cbbfac7
equal deleted inserted replaced
2543:401bfe8c0176 2544:2e6e1a6e0d94
       
     1 /* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
       
     2 /*
       
     3  * Copyright (c) 2005,2006 INRIA
       
     4  *
       
     5  * This program is free software; you can redistribute it and/or modify
       
     6  * it under the terms of the GNU General Public License version 2 as 
       
     7  * published by the Free Software Foundation;
       
     8  *
       
     9  * This program is distributed in the hope that it will be useful,
       
    10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    12  * GNU General Public License for more details.
       
    13  *
       
    14  * You should have received a copy of the GNU General Public License
       
    15  * along with this program; if not, write to the Free Software
       
    16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
       
    17  *
       
    18  * Author: Federico Maguolo <maguolof@dei.unipd.it>
       
    19  */
       
    20 #ifndef RRAA_WIFI_MANAGER_H
       
    21 #define RRAA_WIFI_MANAGER_H
       
    22 
       
    23 #include "ns3/nstime.h"
       
    24 #include "wifi-remote-station-manager.h"
       
    25 
       
    26 namespace ns3 {
       
    27 
       
    28 struct ThresholdsItem {
       
    29   uint32_t datarate;
       
    30   double pori;
       
    31   double pmtl;
       
    32   uint32_t ewnd;
       
    33 };
       
    34 
       
    35 typedef std::vector<ThresholdsItem> Thresholds;
       
    36 
       
    37 /**
       
    38  * \brief Robust Rate Adaptation Algorithm
       
    39  *
       
    40  * This is an implementation of RRAA as described in
       
    41  * "Robust rate adaptation for 802.11 wireless networks"
       
    42  * by "Starsky H. Y. Wong", "Hao Yang", "Songwu Lu", and,
       
    43  * "Vaduvur Bharghavan" published in Mobicom 06.
       
    44  */
       
    45 class RraaWifiManager : public WifiRemoteStationManager 
       
    46 {
       
    47 public:
       
    48   static TypeId GetTypeId (void);
       
    49 
       
    50   RraaWifiManager ();
       
    51   virtual ~RraaWifiManager ();
       
    52   bool OnlyBasic (void);
       
    53   Time GetTimeout (void) const;
       
    54   ThresholdsItem GetThresholds (WifiMode mode) const;
       
    55 private:
       
    56   virtual class WifiRemoteStation *CreateStation (void);  
       
    57   bool m_basic;
       
    58   Time m_timeout;
       
    59   uint32_t m_ewndfor54;
       
    60   uint32_t m_ewndfor48;
       
    61   uint32_t m_ewndfor36;
       
    62   uint32_t m_ewndfor24;
       
    63   uint32_t m_ewndfor18;
       
    64   uint32_t m_ewndfor12;
       
    65   uint32_t m_ewndfor9;
       
    66   uint32_t m_ewndfor6;
       
    67   double m_porifor48;
       
    68   double m_porifor36;
       
    69   double m_porifor24;
       
    70   double m_porifor18;
       
    71   double m_porifor12;
       
    72   double m_porifor9;
       
    73   double m_porifor6;
       
    74   double m_pmtlfor54;
       
    75   double m_pmtlfor48;
       
    76   double m_pmtlfor36;
       
    77   double m_pmtlfor24;
       
    78   double m_pmtlfor18;
       
    79   double m_pmtlfor12;
       
    80   double m_pmtlfor9;
       
    81 };
       
    82 
       
    83 
       
    84 class RraaWifiRemoteStation : public WifiRemoteStation
       
    85 {
       
    86 public:
       
    87   RraaWifiRemoteStation (Ptr<RraaWifiManager> stations);
       
    88   virtual ~RraaWifiRemoteStation ();
       
    89 
       
    90   virtual void ReportRxOk (double rxSnr, WifiMode txMode);
       
    91   virtual void ReportRtsFailed (void);
       
    92   virtual void ReportDataFailed (void);
       
    93   virtual void ReportRtsOk (double ctsSnr, WifiMode ctsMode, double rtsSnr);
       
    94   virtual void ReportDataOk (double ackSnr, WifiMode ackMode, double dataSnr);
       
    95   virtual void ReportFinalRtsFailed (void);
       
    96   virtual void ReportFinalDataFailed (void);
       
    97   virtual bool NeedRts (Ptr<const Packet> packet);
       
    98 
       
    99 private:
       
   100   virtual Ptr<WifiRemoteStationManager> GetManager (void) const;
       
   101   virtual WifiMode DoGetDataMode (uint32_t size);
       
   102   virtual WifiMode DoGetRtsMode (void);
       
   103   uint32_t GetMaxRate (void);
       
   104   uint32_t GetMinRate (void);
       
   105   ThresholdsItem GetThresholds (uint32_t rate);
       
   106   void CheckTimeout (void);
       
   107   void RunBasicAlgorithm (void);
       
   108   void ARts (void);
       
   109   void ResetCountersBasic (void);
       
   110 
       
   111   uint32_t m_counter;
       
   112   uint32_t m_failed;
       
   113   uint32_t m_rtsWnd;
       
   114   uint32_t m_rtsCounter;
       
   115   Time m_lastReset;
       
   116   bool m_rtsOn;
       
   117   bool m_lastFrameFail;
       
   118   bool m_initialized;
       
   119 
       
   120   uint32_t m_rate;
       
   121 
       
   122   Ptr<RraaWifiManager> m_stations;
       
   123 };
       
   124 
       
   125 } // namespace ns3
       
   126 
       
   127 #endif /* RRAA_WIFI_MANAGER_H */