31 #include "minstrel-wifi-manager.h"
33 #include "ns3/simulator.h"
35 #include "ns3/uinteger.h"
36 #include "ns3/double.h"
37 #include "ns3/wifi-mac.h"
38 #include "ns3/assert.h"
82 MinstrelWifiManager::GetTypeId (
void)
86 .AddConstructor<MinstrelWifiManager> ()
87 .AddAttribute (
"UpdateStatistics",
88 "The interval between updating statistics table ",
92 .AddAttribute (
"LookAroundRate",
93 "the percentage to try other rates",
96 MakeDoubleChecker<double> ())
97 .AddAttribute (
"EWMA",
101 MakeDoubleChecker<double> ())
102 .AddAttribute (
"SegmentSize",
103 "The largest allowable segment size packet",
106 MakeDoubleChecker <double> ())
107 .AddAttribute (
"SampleColumn",
108 "The number of columns used for sampling",
111 MakeDoubleChecker <double> ())
112 .AddAttribute (
"PacketLength",
113 "The packet length used for calculating mode TxTime",
116 MakeDoubleChecker <double> ())
121 MinstrelWifiManager::MinstrelWifiManager ()
128 MinstrelWifiManager::~MinstrelWifiManager ()
133 MinstrelWifiManager::SetupPhy (Ptr<WifiPhy> phy)
135 uint32_t nModes = phy->GetNModes ();
136 for (uint32_t i = 0; i < nModes; i++)
138 WifiMode mode = phy->GetMode (i);
139 AddCalcTxTime (mode, phy->CalculateTxDuration (
m_pktLen, mode, WIFI_PREAMBLE_LONG));
141 WifiRemoteStationManager::SetupPhy (phy);
158 if (mode == i->second)
168 MinstrelWifiManager::AddCalcTxTime (
WifiMode mode,
Time t)
180 station->m_index = 0;
225 MinstrelWifiManager::DoReportRtsFailed (WifiRemoteStation *st)
227 MinstrelWifiRemoteStation *station = (MinstrelWifiRemoteStation *)st;
228 NS_LOG_DEBUG (
"DoReportRtsFailed m_txrate=" << station->m_txrate);
230 station->m_shortRetry++;
234 MinstrelWifiManager::DoReportRtsOk (WifiRemoteStation *st,
double ctsSnr, WifiMode ctsMode,
double rtsSnr)
240 MinstrelWifiManager::DoReportFinalRtsFailed (WifiRemoteStation *st)
242 MinstrelWifiRemoteStation *station = (MinstrelWifiRemoteStation *)st;
383 double ackSnr,
WifiMode ackMode,
double dataSnr)
411 MinstrelWifiManager::DoReportFinalDataFailed (WifiRemoteStation *st)
413 MinstrelWifiRemoteStation *station = (MinstrelWifiRemoteStation *) st;
414 NS_LOG_DEBUG (
"DoReportFinalDataFailed m_txrate=" << station->m_txrate);
416 station->m_isSampling =
false;
417 station->m_sampleRateSlower =
false;
426 station->m_txrate =
FindRate (station);
451 return GetSupported (station, station->
m_txrate);
460 return GetSupported (station, 0);
478 station->m_index = 0;
667 uint32_t max_prob = 0, index_max_prob = 0, max_tp = 0, index_max_tp = 0, index_max_tp2 = 0;
705 if (index_max_tp > station->
m_txrate)
710 NS_LOG_DEBUG (
"max tp=" << index_max_tp <<
"\nmax tp2=" << index_max_tp2 <<
"\nmax prob=" << index_max_prob);
743 station->
m_col = station->m_index = 0;
751 for (uint32_t i = 0; i < numSampleRates; i++ )
759 newIndex = (i + uv) % numSampleRates;
778 for (uint32_t i = 0; i < numSampleRates; i++)
784 std::cout << std::endl;
795 std::cout <<
"index(" << i <<
") = " <<
m_minstrelTable[i].perfectTxTime <<
"\n";
uint32_t m_nsupported
modes supported
void CheckInit(MinstrelWifiRemoteStation *station)
check for initializations
void PrintTable(MinstrelWifiRemoteStation *station)
printing Minstrel Table
virtual WifiMode DoGetRtsMode(WifiRemoteStation *station)
#define NS_LOG_FUNCTION(parameters)
void SetStream(int64_t stream)
Specifies the stream number for this RNG stream.
virtual WifiMode DoGetDataMode(WifiRemoteStation *station, uint32_t size)
Implementation of Minstrel Rate Control AlgorithmPorting Minstrel from Madwifi and Linux Kernel http:...
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
#define NS_ASSERT(condition)
uint32_t m_segmentSize
largest allowable segment size
#define NS_LOG_COMPONENT_DEFINE(name)
uint32_t m_sampleRate
current sample rate
uint32_t GetNextSample(MinstrelWifiRemoteStation *station)
getting the next sample from Sample Table
uint32_t m_txrate
current transmit rate
SampleRate m_sampleTable
sample table
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
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 m_currentRate
current rate we are using
bool m_isSampling
a flag to indicate we are currently sampling
int64_t GetMicroSeconds(void) const
int m_sampleCount
how many packets we have sample so far
hold objects of type ns3::Time
void PrintSampleTable(MinstrelWifiRemoteStation *station)
printing Sample Table
double m_ewmaLevel
exponential weighted moving average
virtual WifiRemoteStation * DoCreateStation(void) const
hold a list of per-remote-station state.
uint32_t m_longRetry
long retries such as data packets
bool m_initialized
for initializing tables
TxTime m_calcTxTime
to hold all the calculated TxTime for all modes
virtual bool IsLowLatency(void) const
int64_t AssignStreams(int64_t stream)
uint32_t m_maxTpRate2
second highest throughput rate
uint32_t m_retry
total retries short + long
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
uint32_t m_maxProbRate
rate with highest prob of success
Time Seconds(double seconds)
create ns3::Time instances in units of seconds.
uint32_t m_maxTpRate
the current throughput rate
#define NS_LOG_DEBUG(msg)
Time GetCalcTxTime(WifiMode mode) const
for estimating the TxTime of a packet with a given mode
virtual void DoReportDataFailed(WifiRemoteStation *station)
std::vector< struct RateInfo > MinstrelRate
uint32_t m_sampleCol
number of sample columns
uint32_t m_shortRetry
short retries such as control packts
Hold an floating point type.
bool m_sampleRateSlower
a flag to indicate sample rate is slower
int m_packetCount
total number of packets as of now
a unique identifier for an interface.
MinstrelRate m_minstrelTable
minstrel table
void RateInit(MinstrelWifiRemoteStation *station)
initialize Minstrel Table
uint32_t m_err
retry errors
TypeId SetParent(TypeId tid)
std::vector< std::vector< uint32_t > > SampleRate
hold per-remote-station state.
Time m_nextStatsUpdate
10 times every second