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"
41 #define Min(a,b) ((a < b) ? a : b)
93 .AddConstructor<MinstrelWifiManager> ()
94 .AddAttribute (
"UpdateStatistics",
95 "The interval between updating statistics table ",
99 .AddAttribute (
"LookAroundRate",
100 "the percentage to try other rates",
103 MakeDoubleChecker<double> ())
104 .AddAttribute (
"EWMA",
108 MakeDoubleChecker<double> ())
109 .AddAttribute (
"SampleColumn",
110 "The number of columns used for sampling",
113 MakeDoubleChecker <double> ())
114 .AddAttribute (
"PacketLength",
115 "The packet length used for calculating mode TxTime",
118 MakeDoubleChecker <double> ())
138 for (uint32_t i = 0; i < nModes; i++)
162 if (mode == i->second)
387 double ackSnr,
WifiMode ackMode,
double dataSnr)
608 txTime = Seconds (1);
671 uint32_t max_prob = 0, index_max_prob = 0, max_tp = 0, index_max_tp = 0, index_max_tp2 = 0;
709 if (index_max_tp > station->
m_txrate)
714 NS_LOG_DEBUG (
"max tp=" << index_max_tp <<
"\nmax tp2=" << index_max_tp2 <<
"\nmax prob=" << index_max_prob);
755 for (uint32_t i = 0; i < numSampleRates; i++ )
763 newIndex = (i + uv) % numSampleRates;
782 for (uint32_t i = 0; i < numSampleRates; i++)
788 std::cout << std::endl;
799 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
uint32_t GetNSupported(const WifiRemoteStation *station) const
Return the number of modes supported by the given station.
Simulation virtual time values and global simulation resolution.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
void SetStream(int64_t stream)
Specifies the stream number for this RNG stream.
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register the class in the ns-3 factory.
Implementation of Minstrel Rate Control AlgorithmPorting Minstrel from Madwifi and Linux Kernel http:...
virtual uint32_t GetNModes(void) const =0
The WifiPhy::GetNModes() and WifiPhy::GetMode() methods are used (e.g., by a WifiRemoteStationManager...
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
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific 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
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...
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
uint32_t GetNumberOfReceiveAntennas(const WifiRemoteStation *station) const
Return the number of receive antenna the station has.
WifiMode GetSupported(const WifiRemoteStation *station, uint32_t i) const
Return whether mode associated with the specified station at the specified index. ...
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
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.
bool GetStbc(const WifiRemoteStation *station) const
Return whether the given station supports space-time block coding (STBC).
uint32_t m_col
To keep track of the current position in the our random sample table going row by row from 1st column...
int64x64_t Min(const int64x64_t &a, const int64x64_t &b)
Minimum.
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
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 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)
Assign a fixed random variable stream number to the random variables used by this model...
uint32_t m_maxTpRate2
second highest throughput rate
virtual WifiMode GetMode(uint32_t mode) const =0
The WifiPhy::GetNModes() and WifiPhy::GetMode() methods are used (e.g., by a WifiRemoteStationManager...
bool GetShortGuardInterval(const WifiRemoteStation *station) const
Return whether the given station supports short guard interval.
static Time Now(void)
Return the "current simulation time".
uint32_t m_retry
total retries short + long
Ptr< UniformRandomVariable > m_uniformRandomVariable
Provides uniform random variables.
void SetMode(WifiMode mode)
Sets the selected payload transmission mode.
void UpdateRetry(MinstrelWifiRemoteStation *station)
update the number of retries and reset accordingly
double m_lookAroundRate
the % to try other rates than our current rate
static TypeId GetTypeId(void)
uint8_t GetDefaultTxPowerLevel(void) const
void InitSampleTable(MinstrelWifiRemoteStation *station)
initialize Sample Table
uint32_t m_maxProbRate
rate with highest prob of success
static Time CalculateTxDuration(uint32_t size, WifiTxVector txvector, enum WifiPreamble preamble)
uint32_t GetLongRetryCount(const WifiRemoteStation *station) const
Return the long retry limit of the given station.
virtual void DoReportRtsFailed(WifiRemoteStation *station)
This method is a pure virtual method that must be implemented by the sub-class.
uint32_t m_maxTpRate
the current throughput rate
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
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.
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
uint32_t GetShortRetryCount(const WifiRemoteStation *station) const
Return the short retry limit of the given station.
uint32_t m_sampleCol
number of sample columns
uint32_t GetNumberOfTransmitAntennas(void)
virtual ~MinstrelWifiManager()
uint32_t m_shortRetry
short retries such as control packts
Hold a floating point type.
bool m_sampleRateSlower
a flag to indicate sample rate is slower
int m_packetCount
total number of packets as of now
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.
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
Data structure for a Sample Rate table A vector of a vector uint32_t.
hold per-remote-station state.
Time m_nextStatsUpdate
10 times every second