src/wifi/model/minstrel-wifi-manager.h
author Tom Henderson <tomh@tomh.org>
Mon, 28 Sep 2015 20:27:25 -0700
changeset 11676 05ea1489e509
parent 11450 9f4ae69f12b7
permissions -rw-r--r--
bug 2184: Integer overflow in MacLow
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
7141
072fb225b714 run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents: 7139
diff changeset
     2
/*
072fb225b714 run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents: 7139
diff changeset
     3
 * Copyright (c) 2009 Duy Nguyen
072fb225b714 run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents: 7139
diff changeset
     4
 *
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License version 2 as
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
     7
 * published by the Free Software Foundation;
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
     8
 *
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    12
 * GNU General Public License for more details.
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    13
 *
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
7141
072fb225b714 run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents: 7139
diff changeset
    17
 *
072fb225b714 run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents: 7139
diff changeset
    18
 * Author: Duy Nguyen <duy@soe.ucsc.edu>
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    19
 */
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    20
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    21
#ifndef MINSTREL_WIFI_MANAGER_H
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    22
#define MINSTREL_WIFI_MANAGER_H
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    23
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    24
#include "wifi-remote-station-manager.h"
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    25
#include "wifi-mode.h"
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    26
#include "ns3/nstime.h"
8981
7e1c95c4d1a7 Replace src/wifi usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents: 7141
diff changeset
    27
#include "ns3/random-variable-stream.h"
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    28
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    29
namespace ns3 {
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    30
6340
fe24c9edacb6 fixed bug 924
Quincy Tse <quincy.tse@gmail.com>
parents: 6339
diff changeset
    31
struct MinstrelWifiRemoteStation;
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    32
6337
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6065
diff changeset
    33
/**
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6065
diff changeset
    34
 * A struct to contain all information related to a data rate
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6065
diff changeset
    35
 */
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6065
diff changeset
    36
struct RateInfo
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6065
diff changeset
    37
{
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6065
diff changeset
    38
  /**
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6065
diff changeset
    39
   * Perfect transmission time calculation, or frame calculation
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6065
diff changeset
    40
   * Given a bit rate and a packet length n bytes
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6065
diff changeset
    41
   */
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6065
diff changeset
    42
  Time perfectTxTime;
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6065
diff changeset
    43
11450
9f4ae69f12b7 cleanup wifi module
Sébastien Deronne <sebastien.deronne@gmail.com>
parents: 11083
diff changeset
    44
  uint32_t retryCount;          ///< retry limit
6337
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6065
diff changeset
    45
  uint32_t adjustedRetryCount;  ///< adjust the retry limit for this rate
11450
9f4ae69f12b7 cleanup wifi module
Sébastien Deronne <sebastien.deronne@gmail.com>
parents: 11083
diff changeset
    46
  uint32_t numRateAttempt;      ///< how many number of attempts so far
9f4ae69f12b7 cleanup wifi module
Sébastien Deronne <sebastien.deronne@gmail.com>
parents: 11083
diff changeset
    47
  uint32_t numRateSuccess;      ///< number of successful pkts
9f4ae69f12b7 cleanup wifi module
Sébastien Deronne <sebastien.deronne@gmail.com>
parents: 11083
diff changeset
    48
  uint32_t prob;                ///< (# pkts success )/(# total pkts)
6337
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6065
diff changeset
    49
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6065
diff changeset
    50
  /**
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6065
diff changeset
    51
   * EWMA calculation
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6065
diff changeset
    52
   * ewma_prob =[prob *(100 - ewma_level) + (ewma_prob_old * ewma_level)]/100
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6065
diff changeset
    53
   */
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6065
diff changeset
    54
  uint32_t ewmaProb;
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6065
diff changeset
    55
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6065
diff changeset
    56
  uint32_t throughput;  ///< throughput of a rate
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6065
diff changeset
    57
};
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6065
diff changeset
    58
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6065
diff changeset
    59
/**
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6065
diff changeset
    60
 * Data structure for a Minstrel Rate table
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6065
diff changeset
    61
 * A vector of a struct RateInfo
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6065
diff changeset
    62
 */
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6065
diff changeset
    63
typedef std::vector<struct RateInfo> MinstrelRate;
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6065
diff changeset
    64
/**
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6065
diff changeset
    65
 * Data structure for a Sample Rate table
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6065
diff changeset
    66
 * A vector of a vector uint32_t
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6065
diff changeset
    67
 */
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6065
diff changeset
    68
typedef std::vector<std::vector<uint32_t> > SampleRate;
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6065
diff changeset
    69
92c95748a915 Fixed Bug 802 and Bug 919
Duy Nguyen <duy@soe.ucsc.edu>
parents: 6065
diff changeset
    70
7139
79dd02ed46ec doxygen wifi module grouping all wifi classes
Nicola Baldo <nbaldo@cttc.es>
parents: 6852
diff changeset
    71
/**
79dd02ed46ec doxygen wifi module grouping all wifi classes
Nicola Baldo <nbaldo@cttc.es>
parents: 6852
diff changeset
    72
 * \author Duy Nguyen
7141
072fb225b714 run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents: 7139
diff changeset
    73
 * \brief Implementation of Minstrel Rate Control Algorithm
7139
79dd02ed46ec doxygen wifi module grouping all wifi classes
Nicola Baldo <nbaldo@cttc.es>
parents: 6852
diff changeset
    74
 * \ingroup wifi
79dd02ed46ec doxygen wifi module grouping all wifi classes
Nicola Baldo <nbaldo@cttc.es>
parents: 6852
diff changeset
    75
 *
7141
072fb225b714 run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents: 7139
diff changeset
    76
 * Porting Minstrel from Madwifi and Linux Kernel
7139
79dd02ed46ec doxygen wifi module grouping all wifi classes
Nicola Baldo <nbaldo@cttc.es>
parents: 6852
diff changeset
    77
 * http://linuxwireless.org/en/developers/Documentation/mac80211/RateControl/minstrel
79dd02ed46ec doxygen wifi module grouping all wifi classes
Nicola Baldo <nbaldo@cttc.es>
parents: 6852
diff changeset
    78
 */
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    79
class MinstrelWifiManager : public WifiRemoteStationManager
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    80
{
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    81
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    82
public:
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    83
  static TypeId GetTypeId (void);
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    84
  MinstrelWifiManager ();
7141
072fb225b714 run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents: 7139
diff changeset
    85
  virtual ~MinstrelWifiManager ();
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    86
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    87
  virtual void SetupPhy (Ptr<WifiPhy> phy);
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
    88
11450
9f4ae69f12b7 cleanup wifi module
Sébastien Deronne <sebastien.deronne@gmail.com>
parents: 11083
diff changeset
    89
  /**
9f4ae69f12b7 cleanup wifi module
Sébastien Deronne <sebastien.deronne@gmail.com>
parents: 11083
diff changeset
    90
   * Assign a fixed random variable stream number to the random variables
9f4ae69f12b7 cleanup wifi module
Sébastien Deronne <sebastien.deronne@gmail.com>
parents: 11083
diff changeset
    91
   * used by this model.  Return the number of streams (possibly zero) that
9f4ae69f12b7 cleanup wifi module
Sébastien Deronne <sebastien.deronne@gmail.com>
parents: 11083
diff changeset
    92
   * have been assigned.
9f4ae69f12b7 cleanup wifi module
Sébastien Deronne <sebastien.deronne@gmail.com>
parents: 11083
diff changeset
    93
   *
9f4ae69f12b7 cleanup wifi module
Sébastien Deronne <sebastien.deronne@gmail.com>
parents: 11083
diff changeset
    94
   * \param stream first stream index to use
9f4ae69f12b7 cleanup wifi module
Sébastien Deronne <sebastien.deronne@gmail.com>
parents: 11083
diff changeset
    95
   *
9f4ae69f12b7 cleanup wifi module
Sébastien Deronne <sebastien.deronne@gmail.com>
parents: 11083
diff changeset
    96
   * \return the number of stream indices assigned by this model
9f4ae69f12b7 cleanup wifi module
Sébastien Deronne <sebastien.deronne@gmail.com>
parents: 11083
diff changeset
    97
   */
8981
7e1c95c4d1a7 Replace src/wifi usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents: 7141
diff changeset
    98
  int64_t AssignStreams (int64_t stream);
7e1c95c4d1a7 Replace src/wifi usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents: 7141
diff changeset
    99
11450
9f4ae69f12b7 cleanup wifi module
Sébastien Deronne <sebastien.deronne@gmail.com>
parents: 11083
diff changeset
   100
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4703
diff changeset
   101
private:
11450
9f4ae69f12b7 cleanup wifi module
Sébastien Deronne <sebastien.deronne@gmail.com>
parents: 11083
diff changeset
   102
  //overriden from base class
7141
072fb225b714 run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents: 7139
diff changeset
   103
  virtual WifiRemoteStation * DoCreateStation (void) const;
072fb225b714 run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents: 7139
diff changeset
   104
  virtual void DoReportRxOk (WifiRemoteStation *station,
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4703
diff changeset
   105
                             double rxSnr, WifiMode txMode);
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4703
diff changeset
   106
  virtual void DoReportRtsFailed (WifiRemoteStation *station);
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4703
diff changeset
   107
  virtual void DoReportDataFailed (WifiRemoteStation *station);
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4703
diff changeset
   108
  virtual void DoReportRtsOk (WifiRemoteStation *station,
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4703
diff changeset
   109
                              double ctsSnr, WifiMode ctsMode, double rtsSnr);
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4703
diff changeset
   110
  virtual void DoReportDataOk (WifiRemoteStation *station,
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4703
diff changeset
   111
                               double ackSnr, WifiMode ackMode, double dataSnr);
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4703
diff changeset
   112
  virtual void DoReportFinalRtsFailed (WifiRemoteStation *station);
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4703
diff changeset
   113
  virtual void DoReportFinalDataFailed (WifiRemoteStation *station);
11059
2fe905238013 bug 1726: minstrel rate manager doesn't save state (patch contributions also due to Jonathan Ling and Matías Richart)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 10483
diff changeset
   114
  virtual WifiTxVector DoGetDataTxVector (WifiRemoteStation *station, uint32_t size);
10139
17a71cd49da3 partial 802.11n support
Ghada Badawy <gbadawy@gmail.com>
parents: 8981
diff changeset
   115
  virtual WifiTxVector DoGetRtsTxVector (WifiRemoteStation *station);
11059
2fe905238013 bug 1726: minstrel rate manager doesn't save state (patch contributions also due to Jonathan Ling and Matías Richart)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 10483
diff changeset
   116
2fe905238013 bug 1726: minstrel rate manager doesn't save state (patch contributions also due to Jonathan Ling and Matías Richart)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 10483
diff changeset
   117
  virtual bool DoNeedDataRetransmission (WifiRemoteStation *st, Ptr<const Packet> packet, bool normally);
2fe905238013 bug 1726: minstrel rate manager doesn't save state (patch contributions also due to Jonathan Ling and Matías Richart)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 10483
diff changeset
   118
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4703
diff changeset
   119
  virtual bool IsLowLatency (void) const;
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4703
diff changeset
   120
11450
9f4ae69f12b7 cleanup wifi module
Sébastien Deronne <sebastien.deronne@gmail.com>
parents: 11083
diff changeset
   121
  //for estimating the TxTime of a packet with a given mode
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   122
  Time GetCalcTxTime (WifiMode mode) const;
10483
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 10218
diff changeset
   123
  /**
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 10218
diff changeset
   124
   * Add transmission time for the given mode to an internal list.
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 10218
diff changeset
   125
   *
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 10218
diff changeset
   126
   * \param mode Wi-Fi mode
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 10218
diff changeset
   127
   * \param t transmission time
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 10218
diff changeset
   128
   */
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   129
  void AddCalcTxTime (WifiMode mode, Time t);
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   130
11450
9f4ae69f12b7 cleanup wifi module
Sébastien Deronne <sebastien.deronne@gmail.com>
parents: 11083
diff changeset
   131
  //update the number of retries and reset accordingly
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4703
diff changeset
   132
  void UpdateRetry (MinstrelWifiRemoteStation *station);
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4703
diff changeset
   133
11450
9f4ae69f12b7 cleanup wifi module
Sébastien Deronne <sebastien.deronne@gmail.com>
parents: 11083
diff changeset
   134
  //getting the next sample from Sample Table
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4703
diff changeset
   135
  uint32_t GetNextSample (MinstrelWifiRemoteStation *station);
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4703
diff changeset
   136
11450
9f4ae69f12b7 cleanup wifi module
Sébastien Deronne <sebastien.deronne@gmail.com>
parents: 11083
diff changeset
   137
  //find a rate to use from Minstrel Table
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4703
diff changeset
   138
  uint32_t FindRate (MinstrelWifiRemoteStation *station);
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4703
diff changeset
   139
11450
9f4ae69f12b7 cleanup wifi module
Sébastien Deronne <sebastien.deronne@gmail.com>
parents: 11083
diff changeset
   140
  //updating the Minstrel Table every 1/10 seconds
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4703
diff changeset
   141
  void UpdateStats (MinstrelWifiRemoteStation *station);
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4703
diff changeset
   142
11450
9f4ae69f12b7 cleanup wifi module
Sébastien Deronne <sebastien.deronne@gmail.com>
parents: 11083
diff changeset
   143
  //initialize Minstrel Table
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4703
diff changeset
   144
  void RateInit (MinstrelWifiRemoteStation *station);
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4703
diff changeset
   145
11059
2fe905238013 bug 1726: minstrel rate manager doesn't save state (patch contributions also due to Jonathan Ling and Matías Richart)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 10483
diff changeset
   146
  /**
2fe905238013 bug 1726: minstrel rate manager doesn't save state (patch contributions also due to Jonathan Ling and Matías Richart)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 10483
diff changeset
   147
   * Estimate the time to transmit the given packet with the given number of retries.
2fe905238013 bug 1726: minstrel rate manager doesn't save state (patch contributions also due to Jonathan Ling and Matías Richart)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 10483
diff changeset
   148
   * This function is "roughly" the function "calc_usecs_unicast_packet" in minstrel.c
2fe905238013 bug 1726: minstrel rate manager doesn't save state (patch contributions also due to Jonathan Ling and Matías Richart)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 10483
diff changeset
   149
   * in the madwifi implementation.
2fe905238013 bug 1726: minstrel rate manager doesn't save state (patch contributions also due to Jonathan Ling and Matías Richart)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 10483
diff changeset
   150
   *
2fe905238013 bug 1726: minstrel rate manager doesn't save state (patch contributions also due to Jonathan Ling and Matías Richart)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 10483
diff changeset
   151
   * The basic idea is that, we try to estimate the "average" time used to transmit the
2fe905238013 bug 1726: minstrel rate manager doesn't save state (patch contributions also due to Jonathan Ling and Matías Richart)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 10483
diff changeset
   152
   * packet for the given number of retries while also accounting for the 802.11 congestion
2fe905238013 bug 1726: minstrel rate manager doesn't save state (patch contributions also due to Jonathan Ling and Matías Richart)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 10483
diff changeset
   153
   * window change. The original code in the madwifi seems to estimate the number of backoff
2fe905238013 bug 1726: minstrel rate manager doesn't save state (patch contributions also due to Jonathan Ling and Matías Richart)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 10483
diff changeset
   154
   * slots as the half of the current CW size.
2fe905238013 bug 1726: minstrel rate manager doesn't save state (patch contributions also due to Jonathan Ling and Matías Richart)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 10483
diff changeset
   155
   *
2fe905238013 bug 1726: minstrel rate manager doesn't save state (patch contributions also due to Jonathan Ling and Matías Richart)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 10483
diff changeset
   156
   * There are four main parts:
2fe905238013 bug 1726: minstrel rate manager doesn't save state (patch contributions also due to Jonathan Ling and Matías Richart)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 10483
diff changeset
   157
   *  - wait for DIFS (sense idle channel)
2fe905238013 bug 1726: minstrel rate manager doesn't save state (patch contributions also due to Jonathan Ling and Matías Richart)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 10483
diff changeset
   158
   *  - ACK timeouts
2fe905238013 bug 1726: minstrel rate manager doesn't save state (patch contributions also due to Jonathan Ling and Matías Richart)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 10483
diff changeset
   159
   *  - DATA transmission
2fe905238013 bug 1726: minstrel rate manager doesn't save state (patch contributions also due to Jonathan Ling and Matías Richart)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 10483
diff changeset
   160
   *  - backoffs according to CW
2fe905238013 bug 1726: minstrel rate manager doesn't save state (patch contributions also due to Jonathan Ling and Matías Richart)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 10483
diff changeset
   161
   */
2fe905238013 bug 1726: minstrel rate manager doesn't save state (patch contributions also due to Jonathan Ling and Matías Richart)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 10483
diff changeset
   162
  Time CalculateTimeUnicastPacket (Time dataTransmissionTime, uint32_t shortRetries, uint32_t longRetries);
2fe905238013 bug 1726: minstrel rate manager doesn't save state (patch contributions also due to Jonathan Ling and Matías Richart)
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 10483
diff changeset
   163
11450
9f4ae69f12b7 cleanup wifi module
Sébastien Deronne <sebastien.deronne@gmail.com>
parents: 11083
diff changeset
   164
  //initialize Sample Table
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4703
diff changeset
   165
  void InitSampleTable (MinstrelWifiRemoteStation *station);
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4703
diff changeset
   166
11450
9f4ae69f12b7 cleanup wifi module
Sébastien Deronne <sebastien.deronne@gmail.com>
parents: 11083
diff changeset
   167
  //printing Sample Table
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4703
diff changeset
   168
  void PrintSampleTable (MinstrelWifiRemoteStation *station);
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4703
diff changeset
   169
11450
9f4ae69f12b7 cleanup wifi module
Sébastien Deronne <sebastien.deronne@gmail.com>
parents: 11083
diff changeset
   170
  //printing Minstrel Table
6065
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4703
diff changeset
   171
  void PrintTable (MinstrelWifiRemoteStation *station);
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4703
diff changeset
   172
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4703
diff changeset
   173
  void CheckInit (MinstrelWifiRemoteStation *station);  ///< check for initializations
0f012e7d9128 bug 602
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4703
diff changeset
   174
10483
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 10218
diff changeset
   175
  /**
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 10218
diff changeset
   176
   * typedef for a vector of a pair of Time, WifiMode.
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 10218
diff changeset
   177
   * (Essentially a list for WifiMode and its corresponding transmission time
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 10218
diff changeset
   178
   * to transmit a reference packet.
e3a02ed14587 [doxygen] wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 10218
diff changeset
   179
   */
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   180
  typedef std::vector<std::pair<Time,WifiMode> > TxTime;
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   181
11450
9f4ae69f12b7 cleanup wifi module
Sébastien Deronne <sebastien.deronne@gmail.com>
parents: 11083
diff changeset
   182
  TxTime m_calcTxTime;      ///< to hold all the calculated TxTime for all modes
9f4ae69f12b7 cleanup wifi module
Sébastien Deronne <sebastien.deronne@gmail.com>
parents: 11083
diff changeset
   183
  Time m_updateStats;       ///< how frequent do we calculate the stats (1/10 seconds)
7141
072fb225b714 run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents: 7139
diff changeset
   184
  double m_lookAroundRate;  ///< the % to try other rates than our current rate
11450
9f4ae69f12b7 cleanup wifi module
Sébastien Deronne <sebastien.deronne@gmail.com>
parents: 11083
diff changeset
   185
  double m_ewmaLevel;       ///< exponential weighted moving average
9f4ae69f12b7 cleanup wifi module
Sébastien Deronne <sebastien.deronne@gmail.com>
parents: 11083
diff changeset
   186
  uint32_t m_sampleCol;     ///< number of sample columns
9f4ae69f12b7 cleanup wifi module
Sébastien Deronne <sebastien.deronne@gmail.com>
parents: 11083
diff changeset
   187
  uint32_t m_pktLen;        ///< packet length used for calculate mode TxTime
9f4ae69f12b7 cleanup wifi module
Sébastien Deronne <sebastien.deronne@gmail.com>
parents: 11083
diff changeset
   188
  uint32_t m_nsupported;    ///< modes supported
8981
7e1c95c4d1a7 Replace src/wifi usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents: 7141
diff changeset
   189
11450
9f4ae69f12b7 cleanup wifi module
Sébastien Deronne <sebastien.deronne@gmail.com>
parents: 11083
diff changeset
   190
  //Provides uniform random variables.
8981
7e1c95c4d1a7 Replace src/wifi usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents: 7141
diff changeset
   191
  Ptr<UniformRandomVariable> m_uniformRandomVariable;
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   192
};
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   193
11450
9f4ae69f12b7 cleanup wifi module
Sébastien Deronne <sebastien.deronne@gmail.com>
parents: 11083
diff changeset
   194
} //namespace ns3
4703
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   195
e1259e2fdaad add an implementation of the minstrel rate control algorithm
Duy Nguyen <duy@soe.ucsc.edu>
parents:
diff changeset
   196
#endif /* MINSTREL_WIFI_MANAGER_H */