This documentation is not the Latest Release.
A Discrete-Event Network Simulator
API
minstrel-wifi-manager.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2009 Duy Nguyen
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: Duy Nguyen <duy@soe.ucsc.edu>
19  */
20 
21 #ifndef MINSTREL_WIFI_MANAGER_H
22 #define MINSTREL_WIFI_MANAGER_H
23 
25 #include "wifi-mode.h"
26 #include "ns3/nstime.h"
27 #include "ns3/random-variable-stream.h"
28 
29 namespace ns3 {
30 
31 struct MinstrelWifiRemoteStation;
32 
36 struct RateInfo
37 {
43 
44  uint32_t retryCount;
45  uint32_t adjustedRetryCount;
46  uint32_t numRateAttempt;
47  uint32_t numRateSuccess;
48  uint32_t prob;
49 
54  uint32_t ewmaProb;
55 
56  uint32_t throughput;
57 };
58 
63 typedef std::vector<struct RateInfo> MinstrelRate;
68 typedef std::vector<std::vector<uint32_t> > SampleRate;
69 
70 
80 {
81 
82 public:
83  static TypeId GetTypeId (void);
85  virtual ~MinstrelWifiManager ();
86 
87  virtual void SetupPhy (Ptr<WifiPhy> phy);
88 
98  int64_t AssignStreams (int64_t stream);
99 
100 
101 private:
102  //overriden from base class
103  virtual WifiRemoteStation * DoCreateStation (void) const;
104  virtual void DoReportRxOk (WifiRemoteStation *station,
105  double rxSnr, WifiMode txMode);
106  virtual void DoReportRtsFailed (WifiRemoteStation *station);
107  virtual void DoReportDataFailed (WifiRemoteStation *station);
108  virtual void DoReportRtsOk (WifiRemoteStation *station,
109  double ctsSnr, WifiMode ctsMode, double rtsSnr);
110  virtual void DoReportDataOk (WifiRemoteStation *station,
111  double ackSnr, WifiMode ackMode, double dataSnr);
112  virtual void DoReportFinalRtsFailed (WifiRemoteStation *station);
113  virtual void DoReportFinalDataFailed (WifiRemoteStation *station);
114  virtual WifiTxVector DoGetDataTxVector (WifiRemoteStation *station, uint32_t size);
116 
117  virtual bool DoNeedDataRetransmission (WifiRemoteStation *st, Ptr<const Packet> packet, bool normally);
118 
119  virtual bool IsLowLatency (void) const;
120 
121  //for estimating the TxTime of a packet with a given mode
122  Time GetCalcTxTime (WifiMode mode) const;
129  void AddCalcTxTime (WifiMode mode, Time t);
130 
131  //update the number of retries and reset accordingly
132  void UpdateRetry (MinstrelWifiRemoteStation *station);
133 
134  //getting the next sample from Sample Table
135  uint32_t GetNextSample (MinstrelWifiRemoteStation *station);
136 
137  //find a rate to use from Minstrel Table
138  uint32_t FindRate (MinstrelWifiRemoteStation *station);
139 
140  //updating the Minstrel Table every 1/10 seconds
141  void UpdateStats (MinstrelWifiRemoteStation *station);
142 
143  //initialize Minstrel Table
144  void RateInit (MinstrelWifiRemoteStation *station);
145 
162  Time CalculateTimeUnicastPacket (Time dataTransmissionTime, uint32_t shortRetries, uint32_t longRetries);
163 
164  //initialize Sample Table
166 
167  //printing Sample Table
169 
170  //printing Minstrel Table
171  void PrintTable (MinstrelWifiRemoteStation *station);
172 
173  void CheckInit (MinstrelWifiRemoteStation *station);
174 
180  typedef std::vector<std::pair<Time,WifiMode> > TxTime;
181 
182  TxTime m_calcTxTime;
185  double m_ewmaLevel;
186  uint32_t m_sampleCol;
187  uint32_t m_pktLen;
188  uint32_t m_nsupported;
189 
190  //Provides uniform random variables.
192 };
193 
194 } //namespace ns3
195 
196 #endif /* MINSTREL_WIFI_MANAGER_H */
uint32_t m_nsupported
modes supported
void CheckInit(MinstrelWifiRemoteStation *station)
check for initializations
void PrintTable(MinstrelWifiRemoteStation *station)
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
Time perfectTxTime
Perfect transmission time calculation, or frame calculation Given a bit rate and a packet length n by...
Implementation of Minstrel Rate Control AlgorithmPorting Minstrel from Madwifi and Linux Kernel http:...
uint32_t numRateSuccess
number of successful pkts
virtual void DoReportFinalDataFailed(WifiRemoteStation *station)
This method is a pure virtual method that must be implemented by the sub-class.
hold per-remote-station state for Minstrel Wifi manager.
Time m_updateStats
how frequent do we calculate the stats (1/10 seconds)
void UpdateStats(MinstrelWifiRemoteStation *station)
uint32_t GetNextSample(MinstrelWifiRemoteStation *station)
virtual bool DoNeedDataRetransmission(WifiRemoteStation *st, Ptr< const Packet > packet, bool normally)
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
Definition: wifi-mode.h:97
uint32_t retryCount
retry limit
uint32_t FindRate(MinstrelWifiRemoteStation *station)
uint32_t m_pktLen
packet length used for calculate mode TxTime
uint32_t adjustedRetryCount
adjust the retry limit for this rate
virtual void DoReportDataOk(WifiRemoteStation *station, double ackSnr, WifiMode ackMode, double dataSnr)
This method is a pure virtual method that must be implemented by the sub-class.
virtual void DoReportRxOk(WifiRemoteStation *station, double rxSnr, WifiMode txMode)
This method is a pure virtual method that must be implemented by the sub-class.
A struct to contain all information related to a data rate.
tuple phy
Definition: third.py:86
void PrintSampleTable(MinstrelWifiRemoteStation *station)
virtual void SetupPhy(Ptr< WifiPhy > phy)
Set up PHY associated with this device since it is the object that knows the full set of transmit rat...
double m_ewmaLevel
exponential weighted moving average
virtual WifiRemoteStation * DoCreateStation(void) const
virtual WifiTxVector DoGetDataTxVector(WifiRemoteStation *station, uint32_t size)
void AddCalcTxTime(WifiMode mode, Time t)
Add transmission time for the given mode to an internal list.
virtual void DoReportFinalRtsFailed(WifiRemoteStation *station)
This method is a pure virtual method that must be implemented by the sub-class.
hold a list of per-remote-station state.
virtual WifiTxVector DoGetRtsTxVector(WifiRemoteStation *station)
uint32_t ewmaProb
EWMA calculation ewma_prob =[prob *(100 - ewma_level) + (ewma_prob_old * ewma_level)]/100.
uint32_t numRateAttempt
how many number of attempts so far
TxTime m_calcTxTime
to hold all the calculated TxTime for all modes
virtual bool IsLowLatency(void) const
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint32_t throughput
throughput of a rate
Ptr< UniformRandomVariable > m_uniformRandomVariable
void UpdateRetry(MinstrelWifiRemoteStation *station)
double m_lookAroundRate
the % to try other rates than our current rate
void InitSampleTable(MinstrelWifiRemoteStation *station)
virtual void DoReportRtsFailed(WifiRemoteStation *station)
This method is a pure virtual method that must be implemented by the sub-class.
Time GetCalcTxTime(WifiMode mode) const
virtual void DoReportDataFailed(WifiRemoteStation *station)
This method is a pure virtual method that must be implemented by the sub-class.
std::vector< struct RateInfo > MinstrelRate
Data structure for a Minstrel Rate table A vector of a struct RateInfo.
uint32_t m_sampleCol
number of sample columns
std::vector< std::pair< Time, WifiMode > > TxTime
typedef for a vector of a pair of Time, WifiMode.
virtual void DoReportRtsOk(WifiRemoteStation *station, double ctsSnr, WifiMode ctsMode, double rtsSnr)
This method is a pure virtual method that must be implemented by the sub-class.
a unique identifier for an interface.
Definition: type-id.h:58
Time CalculateTimeUnicastPacket(Time dataTransmissionTime, uint32_t shortRetries, uint32_t longRetries)
Estimate the time to transmit the given packet with the given number of retries.
void RateInit(MinstrelWifiRemoteStation *station)
std::vector< std::vector< uint32_t > > SampleRate
Data structure for a Sample Rate table A vector of a vector uint32_t.
hold per-remote-station state.
uint32_t prob
(# pkts success )/(# total pkts)