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 
22 
23 #ifndef MINSTREL_WIFI_MANAGER_H
24 #define MINSTREL_WIFI_MANAGER_H
25 
27 #include "wifi-mode.h"
28 #include "ns3/nstime.h"
29 #include "ns3/random-variable-stream.h"
30 
31 namespace ns3 {
32 
33 struct MinstrelWifiRemoteStation;
34 
38 struct RateInfo
39 {
45 
46 
47  uint32_t retryCount;
48  uint32_t adjustedRetryCount;
49  uint32_t numRateAttempt;
50  uint32_t numRateSuccess;
51  uint32_t prob;
52 
57  uint32_t ewmaProb;
58 
59  uint32_t throughput;
60 };
61 
66 typedef std::vector<struct RateInfo> MinstrelRate;
67 
72 typedef std::vector<std::vector<uint32_t> > SampleRate;
73 
74 
84 {
85 
86 public:
87  static TypeId GetTypeId (void);
89  virtual ~MinstrelWifiManager ();
90 
91  virtual void SetupPhy (Ptr<WifiPhy> phy);
92 
101  int64_t AssignStreams (int64_t stream);
102 
103 private:
104  // overriden from base class
105  virtual WifiRemoteStation * DoCreateStation (void) const;
106  virtual void DoReportRxOk (WifiRemoteStation *station,
107  double rxSnr, WifiMode txMode);
108  virtual void DoReportRtsFailed (WifiRemoteStation *station);
109  virtual void DoReportDataFailed (WifiRemoteStation *station);
110  virtual void DoReportRtsOk (WifiRemoteStation *station,
111  double ctsSnr, WifiMode ctsMode, double rtsSnr);
112  virtual void DoReportDataOk (WifiRemoteStation *station,
113  double ackSnr, WifiMode ackMode, double dataSnr);
114  virtual void DoReportFinalRtsFailed (WifiRemoteStation *station);
115  virtual void DoReportFinalDataFailed (WifiRemoteStation *station);
116  virtual WifiTxVector DoGetDataTxVector (WifiRemoteStation *station, uint32_t size);
118 
119  virtual bool DoNeedDataRetransmission (WifiRemoteStation *st, Ptr<const Packet> packet, bool normally);
120 
121  virtual bool IsLowLatency (void) const;
122 
124  Time GetCalcTxTime (WifiMode mode) const;
131  void AddCalcTxTime (WifiMode mode, Time t);
132 
134  void UpdateRetry (MinstrelWifiRemoteStation *station);
135 
137  uint32_t GetNextSample (MinstrelWifiRemoteStation *station);
138 
140  uint32_t FindRate (MinstrelWifiRemoteStation *station);
141 
143  void UpdateStats (MinstrelWifiRemoteStation *station);
144 
146  void RateInit (MinstrelWifiRemoteStation *station);
147 
164  Time CalculateTimeUnicastPacket (Time dataTransmissionTime, uint32_t shortRetries, uint32_t longRetries);
165 
168 
171 
173  void PrintTable (MinstrelWifiRemoteStation *station);
174 
175  void CheckInit (MinstrelWifiRemoteStation *station);
176 
182  typedef std::vector<std::pair<Time,WifiMode> > TxTime;
183 
184  TxTime m_calcTxTime;
187  double m_ewmaLevel;
188  uint32_t m_sampleCol;
189  uint32_t m_pktLen;
190  uint32_t m_nsupported;
191 
194 };
195 
196 } // namespace ns3
197 
198 #endif /* MINSTREL_WIFI_MANAGER_H */
uint32_t m_nsupported
modes supported
void CheckInit(MinstrelWifiRemoteStation *station)
check for initializations
void PrintTable(MinstrelWifiRemoteStation *station)
printing Minstrel Table
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)
updating the Minstrel Table every 1/10 seconds
uint32_t GetNextSample(MinstrelWifiRemoteStation *station)
getting the next sample from Sample Table
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:93
uint32_t retryCount
retry limit
uint32_t FindRate(MinstrelWifiRemoteStation *station)
find a rate to use from Minstrel Table
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.
void PrintSampleTable(MinstrelWifiRemoteStation *station)
printing Sample Table
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
Provides uniform random variables.
void UpdateRetry(MinstrelWifiRemoteStation *station)
update the number of retries and reset accordingly
double m_lookAroundRate
the % to try other rates than our current rate
void InitSampleTable(MinstrelWifiRemoteStation *station)
initialize Sample Table
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
for estimating the TxTime of a packet with a given mode
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:57
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)
initialize Minstrel Table
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)