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  * Authors: Duy Nguyen <duy@soe.ucsc.edu>
19  * Matías Richart <mrichart@fing.edu.uy>
20  */
21 
22 #ifndef MINSTREL_WIFI_MANAGER_H
23 #define MINSTREL_WIFI_MANAGER_H
24 
25 #include "ns3/traced-value.h"
26 #include "ns3/wifi-remote-station-manager.h"
27 #include <fstream>
28 #include <map>
29 
30 namespace ns3 {
31 
32 class UniformRandomVariable;
33 
37 struct RateInfo
38 {
44 
45  uint32_t retryCount;
46  uint32_t adjustedRetryCount;
47  uint32_t numRateAttempt;
48  uint32_t numRateSuccess;
49  uint32_t prob;
50 
54  uint32_t ewmaProb;
55  uint32_t throughput;
56 
57  uint32_t prevNumRateAttempt;
58  uint32_t prevNumRateSuccess;
59  uint64_t successHist;
60  uint64_t attemptHist;
61 
64 };
65 
70 typedef std::vector<RateInfo> MinstrelRate;
75 typedef std::vector<std::vector<uint8_t> > SampleRate;
76 
84 {
86 
93  uint8_t m_col;
94  uint8_t m_index;
95  uint16_t m_maxTpRate;
96  uint16_t m_maxTpRate2;
97  uint16_t m_maxProbRate;
98  uint8_t m_nModes;
103  uint16_t m_sampleRate;
105  uint32_t m_shortRetry;
106  uint32_t m_longRetry;
107  uint32_t m_retry;
108  uint16_t m_txrate;
112  std::ofstream m_statsFile;
113 };
114 
115 
158 {
159 public:
164  static TypeId GetTypeId (void);
166  virtual ~MinstrelWifiManager ();
167 
168  void SetupPhy (const Ptr<WifiPhy> phy) override;
169  void SetupMac (const Ptr<WifiMac> mac) override;
170  int64_t AssignStreams (int64_t stream) override;
171 
177  void UpdateRate (MinstrelWifiRemoteStation *station);
178 
184  void UpdateStats (MinstrelWifiRemoteStation *station);
185 
192  uint16_t FindRate (MinstrelWifiRemoteStation *station);
193 
201 
209 
216  uint32_t CountRetries (MinstrelWifiRemoteStation *station);
217 
224 
230  void UpdateRetry (MinstrelWifiRemoteStation *station);
231 
237  void CheckInit (MinstrelWifiRemoteStation *station);
238 
245 
246 private:
247  void DoInitialize (void) override;
248  WifiRemoteStation * DoCreateStation (void) const override;
249  void DoReportRxOk (WifiRemoteStation *station,
250  double rxSnr, WifiMode txMode) override;
251  void DoReportRtsFailed (WifiRemoteStation *station) override;
252  void DoReportDataFailed (WifiRemoteStation *station) override;
253  void DoReportRtsOk (WifiRemoteStation *station,
254  double ctsSnr, WifiMode ctsMode, double rtsSnr) override;
255  void DoReportDataOk (WifiRemoteStation *station, double ackSnr, WifiMode ackMode,
256  double dataSnr, uint16_t dataChannelWidth, uint8_t dataNss) override;
257  void DoReportFinalRtsFailed (WifiRemoteStation *station) override;
258  void DoReportFinalDataFailed (WifiRemoteStation *station) override;
260  WifiTxVector DoGetRtsTxVector (WifiRemoteStation *station) override;
261 
263  Ptr<const Packet> packet, bool normally) override;
264 
265 
272  Time GetCalcTxTime (WifiMode mode) const;
279  void AddCalcTxTime (WifiMode mode, Time t);
280 
286  void RateInit (MinstrelWifiRemoteStation *station);
287 
294  uint16_t GetNextSample (MinstrelWifiRemoteStation *station);
295 
317  Time CalculateTimeUnicastPacket (Time dataTransmissionTime, uint32_t shortRetries, uint32_t longRetries);
318 
325 
331  void PrintTable (MinstrelWifiRemoteStation *station);
332 
338  typedef std::map<WifiMode, Time> TxTime;
339 
343  uint8_t m_ewmaLevel;
344  uint8_t m_sampleCol;
345  uint32_t m_pktLen;
348 
351 
353 };
354 
355 } //namespace ns3
356 
357 #endif /* MINSTREL_WIFI_MANAGER_H */
ns3::MinstrelWifiManager::m_uniformRandomVariable
Ptr< UniformRandomVariable > m_uniformRandomVariable
Provides uniform random variables.
Definition: minstrel-wifi-manager.h:350
ns3::MinstrelWifiManager::m_currentRate
TracedValue< uint64_t > m_currentRate
Trace rate changes.
Definition: minstrel-wifi-manager.h:352
ns3::TypeId
a unique identifier for an interface.
Definition: type-id.h:59
ns3::MinstrelWifiManager::DoCreateStation
WifiRemoteStation * DoCreateStation(void) const override
Definition: minstrel-wifi-manager.cc:176
ns3::RateInfo::prob
uint32_t prob
(# packets success)/(# total packets)
Definition: minstrel-wifi-manager.h:49
ns3::RateInfo::attemptHist
uint64_t attemptHist
Aggregate of all transmission attempts.
Definition: minstrel-wifi-manager.h:60
ns3::MinstrelWifiManager::m_pktLen
uint32_t m_pktLen
packet length used for calculate mode TxTime
Definition: minstrel-wifi-manager.h:345
ns3::MinstrelWifiRemoteStation::m_maxTpRate2
uint16_t m_maxTpRate2
second highest throughput rate in bps
Definition: minstrel-wifi-manager.h:96
ns3::MinstrelWifiManager::m_ewmaLevel
uint8_t m_ewmaLevel
exponential weighted moving average
Definition: minstrel-wifi-manager.h:343
ns3::RateInfo::perfectTxTime
Time perfectTxTime
Perfect transmission time calculation, or frame calculation Given a bit rate and a packet length n by...
Definition: minstrel-wifi-manager.h:43
ns3::MinstrelWifiManager::RateInit
void RateInit(MinstrelWifiRemoteStation *station)
Initialize Minstrel Table.
Definition: minstrel-wifi-manager.cc:914
ns3::RateInfo::numRateSuccess
uint32_t numRateSuccess
number of successful packets
Definition: minstrel-wifi-manager.h:48
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::MinstrelRate
std::vector< RateInfo > MinstrelRate
Data structure for a Minstrel Rate table A vector of a struct RateInfo.
Definition: minstrel-wifi-manager.h:70
ns3::SampleRate
std::vector< std::vector< uint8_t > > SampleRate
Data structure for a Sample Rate table A vector of a vector uint8_t.
Definition: minstrel-wifi-manager.h:75
ns3::MinstrelWifiManager::DoReportRtsOk
void DoReportRtsOk(WifiRemoteStation *station, double ctsSnr, WifiMode ctsMode, double rtsSnr) override
This method is a pure virtual method that must be implemented by the sub-class.
Definition: minstrel-wifi-manager.cc:728
ns3::MinstrelWifiManager::UpdateRetry
void UpdateRetry(MinstrelWifiRemoteStation *station)
Update the number of retries and reset accordingly.
Definition: minstrel-wifi-manager.cc:844
ns3::MinstrelWifiManager::UpdatePacketCounters
void UpdatePacketCounters(MinstrelWifiRemoteStation *station)
Update packet counters.
Definition: minstrel-wifi-manager.cc:817
ns3::MinstrelWifiManager::AddCalcTxTime
void AddCalcTxTime(WifiMode mode, Time t)
Add transmission time for the given mode to an internal list.
Definition: minstrel-wifi-manager.cc:169
ns3::RateInfo::numSamplesSkipped
uint8_t numSamplesSkipped
number of samples skipped
Definition: minstrel-wifi-manager.h:62
ns3::MinstrelWifiRemoteStation::m_retry
uint32_t m_retry
total retries short + long
Definition: minstrel-wifi-manager.h:107
ns3::MinstrelWifiManager::DoGetRtsTxVector
WifiTxVector DoGetRtsTxVector(WifiRemoteStation *station) override
Definition: minstrel-wifi-manager.cc:861
ns3::MinstrelWifiManager::m_printSamples
bool m_printSamples
whether samples table should be printed.
Definition: minstrel-wifi-manager.h:347
ns3::MinstrelWifiManager::GetCalcTxTime
Time GetCalcTxTime(WifiMode mode) const
Estimate the TxTime of a packet with a given mode.
Definition: minstrel-wifi-manager.cc:160
ns3::MinstrelWifiManager::FindRate
uint16_t FindRate(MinstrelWifiRemoteStation *station)
Find a rate to use from Minstrel Table.
Definition: minstrel-wifi-manager.cc:429
ns3::MinstrelWifiRemoteStation::m_initialized
bool m_initialized
for initializing tables
Definition: minstrel-wifi-manager.h:109
ns3::WifiRemoteStationManager
hold a list of per-remote-station state.
Definition: wifi-remote-station-manager.h:121
ns3::MinstrelWifiRemoteStation::m_txrate
uint16_t m_txrate
current transmit rate in bps
Definition: minstrel-wifi-manager.h:108
ns3::WifiTxVector
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
Definition: wifi-tx-vector.h:71
ns3::MinstrelWifiManager::DoReportFinalDataFailed
void DoReportFinalDataFailed(WifiRemoteStation *station) override
This method is a pure virtual method that must be implemented by the sub-class.
Definition: minstrel-wifi-manager.cc:789
third.mac
mac
Definition: third.py:99
ns3::MinstrelWifiRemoteStation::m_isSampling
bool m_isSampling
a flag to indicate we are currently sampling
Definition: minstrel-wifi-manager.h:102
ns3::MinstrelWifiManager::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition: minstrel-wifi-manager.cc:50
ns3::MinstrelWifiRemoteStation
hold per-remote-station state for Minstrel Wifi manager.
Definition: minstrel-wifi-manager.h:84
ns3::MinstrelWifiManager::GetNextSample
uint16_t GetNextSample(MinstrelWifiRemoteStation *station)
Get the next sample from Sample Table.
Definition: minstrel-wifi-manager.cc:892
ns3::MinstrelWifiManager::m_updateStats
Time m_updateStats
how frequent do we calculate the stats
Definition: minstrel-wifi-manager.h:341
ns3::MinstrelWifiRemoteStation::m_minstrelTable
MinstrelRate m_minstrelTable
minstrel table
Definition: minstrel-wifi-manager.h:110
ns3::MinstrelWifiManager::GetRtsTxVector
WifiTxVector GetRtsTxVector(MinstrelWifiRemoteStation *station)
Get RTS transmit vector.
Definition: minstrel-wifi-manager.cc:386
ns3::MinstrelWifiManager::DoReportFinalRtsFailed
void DoReportFinalRtsFailed(WifiRemoteStation *station) override
This method is a pure virtual method that must be implemented by the sub-class.
Definition: minstrel-wifi-manager.cc:734
ns3::RateInfo::throughput
uint32_t throughput
throughput of a rate in bps
Definition: minstrel-wifi-manager.h:55
ns3::MinstrelWifiRemoteStation::m_statsFile
std::ofstream m_statsFile
stats file
Definition: minstrel-wifi-manager.h:112
ns3::MinstrelWifiRemoteStation::m_totalPacketsCount
int m_totalPacketsCount
total number of packets as of now
Definition: minstrel-wifi-manager.h:99
ns3::MinstrelWifiRemoteStation::m_sampleDeferred
bool m_sampleDeferred
a flag to indicate sample rate is on the second stage
Definition: minstrel-wifi-manager.h:104
ns3::MinstrelWifiManager::InitSampleTable
void InitSampleTable(MinstrelWifiRemoteStation *station)
Initialize Sample Table.
Definition: minstrel-wifi-manager.cc:983
ns3::Ptr< WifiPhy >
ns3::MinstrelWifiRemoteStation::m_nModes
uint8_t m_nModes
number of modes supported
Definition: minstrel-wifi-manager.h:98
ns3::RateInfo::adjustedRetryCount
uint32_t adjustedRetryCount
adjust the retry limit for this rate
Definition: minstrel-wifi-manager.h:46
ns3::MinstrelWifiRemoteStation::m_longRetry
uint32_t m_longRetry
long retries such as data packets
Definition: minstrel-wifi-manager.h:106
ns3::WifiMode
represent a single transmission mode
Definition: wifi-mode.h:48
ns3::MinstrelWifiManager::~MinstrelWifiManager
virtual ~MinstrelWifiManager()
Definition: minstrel-wifi-manager.cc:107
ns3::MinstrelWifiRemoteStation::m_maxTpRate
uint16_t m_maxTpRate
the current throughput rate in bps
Definition: minstrel-wifi-manager.h:95
ns3::MinstrelWifiManager
Implementation of Minstrel Rate Control Algorithm.
Definition: minstrel-wifi-manager.h:158
ns3::MinstrelWifiManager::DoGetDataTxVector
WifiTxVector DoGetDataTxVector(WifiRemoteStation *station) override
Definition: minstrel-wifi-manager.cc:853
ns3::MinstrelWifiManager::PrintTable
void PrintTable(MinstrelWifiRemoteStation *station)
Print Minstrel Table.
Definition: minstrel-wifi-manager.cc:1031
ns3::MinstrelWifiManager::CountRetries
uint32_t CountRetries(MinstrelWifiRemoteStation *station)
Get the number of retries.
Definition: minstrel-wifi-manager.cc:410
ns3::MinstrelWifiRemoteStation::m_sampleTable
SampleRate m_sampleTable
sample table
Definition: minstrel-wifi-manager.h:111
ns3::RateInfo::ewmaProb
uint32_t ewmaProb
EWMA calculation ewma_prob =[prob *(100 - ewma_level) + (ewma_prob_old * ewma_level)]/100.
Definition: minstrel-wifi-manager.h:54
ns3::MinstrelWifiManager::m_printStats
bool m_printStats
whether statistics table should be printed.
Definition: minstrel-wifi-manager.h:346
ns3::MinstrelWifiManager::UpdateStats
void UpdateStats(MinstrelWifiRemoteStation *station)
Update the Minstrel Table.
Definition: minstrel-wifi-manager.cc:533
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:104
ns3::MinstrelWifiManager::SetupPhy
void SetupPhy(const Ptr< WifiPhy > phy) override
Set up PHY associated with this device since it is the object that knows the full set of transmit rat...
Definition: minstrel-wifi-manager.cc:113
ns3::RateInfo::numRateAttempt
uint32_t numRateAttempt
how many number of attempts so far
Definition: minstrel-wifi-manager.h:47
ns3::MinstrelWifiRemoteStation::m_shortRetry
uint32_t m_shortRetry
short retries such as control packets
Definition: minstrel-wifi-manager.h:105
ns3::MinstrelWifiRemoteStation::m_samplePacketsCount
int m_samplePacketsCount
how many packets we have sample so far
Definition: minstrel-wifi-manager.h:100
ns3::MinstrelWifiRemoteStation::m_numSamplesDeferred
int m_numSamplesDeferred
number samples deferred
Definition: minstrel-wifi-manager.h:101
ns3::WifiRemoteStation
hold per-remote-station state.
Definition: wifi-remote-station-manager.h:62
ns3::MinstrelWifiManager::DoInitialize
void DoInitialize(void) override
Initialize() implementation.
Definition: minstrel-wifi-manager.cc:134
ns3::MinstrelWifiManager::PrintSampleTable
void PrintSampleTable(MinstrelWifiRemoteStation *station)
Print Sample Table.
Definition: minstrel-wifi-manager.cc:1015
ns3::MinstrelWifiRemoteStation::m_sampleRate
uint16_t m_sampleRate
current sample rate in bps
Definition: minstrel-wifi-manager.h:103
ns3::MinstrelWifiManager::DoReportDataOk
void DoReportDataOk(WifiRemoteStation *station, double ackSnr, WifiMode ackMode, double dataSnr, uint16_t dataChannelWidth, uint8_t dataNss) override
This method is a pure virtual method that must be implemented by the sub-class.
Definition: minstrel-wifi-manager.cc:757
ns3::MinstrelWifiRemoteStation::m_col
uint8_t m_col
To keep track of the current position in the our random sample table going row by row from 1st column...
Definition: minstrel-wifi-manager.h:93
ns3::MinstrelWifiRemoteStation::m_maxProbRate
uint16_t m_maxProbRate
rate with highest probability of success in bps
Definition: minstrel-wifi-manager.h:97
ns3::RateInfo::prevNumRateSuccess
uint32_t prevNumRateSuccess
Number of successful frames transmitted with previous rate.
Definition: minstrel-wifi-manager.h:58
ns3::MinstrelWifiManager::UpdateRate
void UpdateRate(MinstrelWifiRemoteStation *station)
Update the rate.
Definition: minstrel-wifi-manager.cc:236
ns3::MinstrelWifiManager::GetDataTxVector
WifiTxVector GetDataTxVector(MinstrelWifiRemoteStation *station)
Get data transmit vector.
Definition: minstrel-wifi-manager.cc:364
ns3::TracedValue< uint64_t >
ns3::MinstrelWifiManager::MinstrelWifiManager
MinstrelWifiManager()
Definition: minstrel-wifi-manager.cc:99
ns3::RateInfo
A struct to contain all information related to a data rate.
Definition: minstrel-wifi-manager.h:38
ns3::MinstrelWifiManager::CheckInit
void CheckInit(MinstrelWifiRemoteStation *station)
Check for initializations.
Definition: minstrel-wifi-manager.cc:203
ns3::MinstrelWifiManager::m_sampleCol
uint8_t m_sampleCol
number of sample columns
Definition: minstrel-wifi-manager.h:344
ns3::MinstrelWifiManager::SetupMac
void SetupMac(const Ptr< WifiMac > mac) override
Set up MAC associated with this device since it is the object that knows the full set of timing param...
Definition: minstrel-wifi-manager.cc:127
ns3::MinstrelWifiManager::AssignStreams
int64_t AssignStreams(int64_t stream) override
Assign a fixed random variable stream number to the random variables used by this model.
Definition: minstrel-wifi-manager.cc:152
ns3::MinstrelWifiManager::CalculateTimeUnicastPacket
Time CalculateTimeUnicastPacket(Time dataTransmissionTime, uint32_t shortRetries, uint32_t longRetries)
Estimate the time to transmit the given packet with the given number of retries.
Definition: minstrel-wifi-manager.cc:957
ns3::MinstrelWifiManager::DoReportDataFailed
void DoReportDataFailed(WifiRemoteStation *station) override
This method is a pure virtual method that must be implemented by the sub-class.
Definition: minstrel-wifi-manager.cc:742
ns3::MinstrelWifiManager::DoReportRxOk
void DoReportRxOk(WifiRemoteStation *station, double rxSnr, WifiMode txMode) override
This method is a pure virtual method that must be implemented by the sub-class.
Definition: minstrel-wifi-manager.cc:712
ns3::MinstrelWifiManager::TxTime
std::map< WifiMode, Time > TxTime
typedef for a vector of a pair of Time, WifiMode.
Definition: minstrel-wifi-manager.h:338
ns3::MinstrelWifiManager::m_calcTxTime
TxTime m_calcTxTime
to hold all the calculated TxTime for all modes
Definition: minstrel-wifi-manager.h:340
ns3::MinstrelWifiManager::DoReportRtsFailed
void DoReportRtsFailed(WifiRemoteStation *station) override
This method is a pure virtual method that must be implemented by the sub-class.
Definition: minstrel-wifi-manager.cc:719
ns3::MinstrelWifiRemoteStation::m_nextStatsUpdate
Time m_nextStatsUpdate
10 times every second
Definition: minstrel-wifi-manager.h:85
ns3::MinstrelWifiManager::m_lookAroundRate
uint8_t m_lookAroundRate
the % to try other rates than our current rate
Definition: minstrel-wifi-manager.h:342
ns3::RateInfo::sampleLimit
int sampleLimit
sample limit
Definition: minstrel-wifi-manager.h:63
ns3::RateInfo::retryCount
uint32_t retryCount
retry limit
Definition: minstrel-wifi-manager.h:45
ns3::MinstrelWifiRemoteStation::m_index
uint8_t m_index
vector index
Definition: minstrel-wifi-manager.h:94
third.phy
phy
Definition: third.py:93
ns3::RateInfo::prevNumRateAttempt
uint32_t prevNumRateAttempt
Number of transmission attempts with previous rate.
Definition: minstrel-wifi-manager.h:57
ns3::RateInfo::successHist
uint64_t successHist
Aggregate of all transmission successes.
Definition: minstrel-wifi-manager.h:59
ns3::MinstrelWifiManager::DoNeedRetransmission
bool DoNeedRetransmission(WifiRemoteStation *st, Ptr< const Packet > packet, bool normally) override
Definition: minstrel-wifi-manager.cc:869