39#include "ns3/packet.h"
40#include "ns3/random-variable-stream.h"
41#include "ns3/simulator.h"
42#include "ns3/wifi-mac.h"
43#include "ns3/wifi-phy.h"
47#define Min(a, b) ((a < b) ? a : b)
48#define Max(a, b) ((a > b) ? a : b)
81 TypeId(
"ns3::MinstrelHtWifiManager")
83 .AddConstructor<MinstrelHtWifiManager>()
85 .AddAttribute(
"UpdateStatistics",
86 "The interval between updating statistics table",
90 .AddAttribute(
"LegacyUpdateStatistics",
91 "The interval between updating statistics table (for legacy Minstrel)",
95 .AddAttribute(
"LookAroundRate",
96 "The percentage to try other rates (for legacy Minstrel)",
99 MakeUintegerChecker<uint8_t>(0, 100))
100 .AddAttribute(
"EWMA",
104 MakeUintegerChecker<uint8_t>(0, 100))
105 .AddAttribute(
"SampleColumn",
106 "The number of columns used for sampling",
109 MakeUintegerChecker<uint8_t>())
110 .AddAttribute(
"PacketLength",
111 "The packet length used for calculating mode TxTime (bytes)",
114 MakeUintegerChecker<uint32_t>())
115 .AddAttribute(
"UseLatestAmendmentOnly",
116 "Use only the latest amendment when it is supported by both peers",
120 .AddAttribute(
"PrintStats",
121 "Control the printing of the statistics table",
125 .AddTraceSource(
"Rate",
126 "Traced value for rate changes (b/s)",
128 "ns3::TracedValueCallback::Uint64");
160 int64_t numStreamsAssigned = 0;
162 numStreamsAssigned++;
164 return numStreamsAssigned;
226 for (uint16_t chWidth = 20; chWidth <=
MAX_HT_WIDTH; chWidth *= 2)
228 for (
int gi = 800; gi >= 400;)
245 && (
GetPhy()->GetMaxSupportedTxSpatialStreams() >=
255 WifiMode mode = htMcsList[deviceIndex];
273 NS_LOG_DEBUG(
"Initialized group " << +groupId <<
": (" << +streams <<
","
274 << gi <<
"," << chWidth <<
")");
284 for (uint16_t chWidth = 20; chWidth <=
MAX_VHT_WIDTH; chWidth *= 2)
286 for (
int gi = 800; gi >= 400;)
303 && (
GetPhy()->GetMaxSupportedTxSpatialStreams() >=
336 NS_LOG_DEBUG(
"Initialized group " << +groupId <<
": (" << +streams
337 <<
"," << gi <<
"," << chWidth
349 for (uint16_t chWidth = 20; chWidth <=
MAX_HE_WIDTH; chWidth *= 2)
351 for (
int gi = 3200; gi >= 800;)
367 && (
GetPhy()->GetMaxSupportedTxSpatialStreams() >=
400 NS_LOG_DEBUG(
"Initialized group " << +groupId <<
": (" << +streams
401 <<
"," << gi <<
"," << chWidth
434 NS_LOG_FUNCTION(
this << phy << +streams << gi << chWidth << mode << mpduType);
460 m_minstrelGroups[groupId].ratesFirstMpduTxTimeTable.insert(std::make_pair(mode, t));
632 .m_ratesTable[rateId]
643 uint16_t dataChannelWidth,
646 NS_LOG_FUNCTION(
this << st << ackSnr << ackMode << dataSnr << dataChannelWidth << +dataNss);
659 <<
" (before update).");
672 <<
" (after update).");
686 station->
m_groupsTable[groupId].m_ratesTable[rateId].numRateSuccess++;
687 station->
m_groupsTable[groupId].m_ratesTable[rateId].numRateAttempt++;
695 <<
" (after update).");
764 uint16_t nSuccessfulMpdus,
765 uint16_t nFailedMpdus,
768 uint16_t dataChannelWidth,
771 NS_LOG_FUNCTION(
this << st << nSuccessfulMpdus << nFailedMpdus << rxSnr << dataSnr
772 << dataChannelWidth << +dataNss);
784 <<
" SuccMpdus=" << nSuccessfulMpdus
785 <<
" FailedMpdus=" << nFailedMpdus);
788 station->
m_ampduLen += nSuccessfulMpdus + nFailedMpdus;
794 station->
m_groupsTable[groupId].m_ratesTable[rateId].numRateSuccess += nSuccessfulMpdus;
795 station->
m_groupsTable[groupId].m_ratesTable[rateId].numRateAttempt +=
796 nSuccessfulMpdus + nFailedMpdus;
870 station->
m_groupsTable[maxTpGroupId].m_ratesTable[maxTpRateId].retryCount)
878 (station->
m_groupsTable[maxTpGroupId].m_ratesTable[maxTpRateId].retryCount +
879 station->
m_groupsTable[maxTp2GroupId].m_ratesTable[maxTp2RateId].retryCount))
887 (station->
m_groupsTable[maxTpGroupId].m_ratesTable[maxTpRateId].retryCount +
888 station->
m_groupsTable[maxTp2GroupId].m_ratesTable[maxTp2RateId].retryCount +
889 station->
m_groupsTable[maxProbGroupId].m_ratesTable[maxProbRateId].retryCount))
896 NS_FATAL_ERROR(
"Max retries reached and m_longRetry not cleared properly. longRetry= "
907 1 + station->
m_groupsTable[maxTpGroupId].m_ratesTable[maxTp2RateId].retryCount)
915 1 + station->
m_groupsTable[maxTpGroupId].m_ratesTable[maxTp2RateId].retryCount +
916 station->
m_groupsTable[maxProbGroupId].m_ratesTable[maxProbRateId].retryCount)
923 NS_FATAL_ERROR(
"Max retries reached and m_longRetry not cleared properly. longRetry= "
940 uint16_t nSuccessfulMpdus,
941 uint16_t nFailedMpdus)
972 if (group.
chWidth <= allowedWidth)
974 NS_LOG_DEBUG(
"Channel width is not greater than allowed width, nothing to do");
983 uint16_t width = group.
chWidth / 2;
987 if (width > allowedWidth)
1017 NS_ABORT_MSG_IF(width < 20,
"No rate compatible with the allowed width found");
1051 uint8_t mcsIndex = station->
m_groupsTable[groupId].m_ratesTable[rateId].mcsIndex;
1053 NS_LOG_DEBUG(
"DoGetDataMode rateId= " << +rateId <<
" groupId= " << +groupId
1130 uint8_t mcsIndex = station->
m_groupsTable[groupId].m_ratesTable[rateId].mcsIndex;
1137 bool rateFound =
false;
1139 for (uint8_t i = 0; i < nBasicRates; i++)
1142 if (rate <= lastDataRate)
1152 for (
const auto& mode : phy->GetModeList())
1154 uint64_t rate = mode.GetDataRate(20);
1155 if (rate <= lastDataRate)
1207 <<
" Max retries: " << maxRetries);
1213 <<
" Max retries: " << maxRetries);
1230 return station->
m_groupsTable[maxTpGroupId].m_ratesTable[maxTpRateId].retryCount +
1231 station->
m_groupsTable[maxTp2GroupId].m_ratesTable[maxTp2RateId].retryCount +
1232 station->
m_groupsTable[maxProbGroupId].m_ratesTable[maxProbRateId].retryCount;
1236 return 1 + station->
m_groupsTable[maxTpGroupId].m_ratesTable[maxTp2RateId].retryCount +
1237 station->
m_groupsTable[maxProbGroupId].m_ratesTable[maxProbRateId].retryCount;
1246 uint8_t index = station->
m_groupsTable[sampleGroup].m_index;
1249 uint16_t rateIndex =
GetIndex(sampleGroup, sampleIndex);
1307 uint8_t sampleGroupId =
GetGroupId(sampleIdx);
1308 uint8_t sampleRateId =
GetRateId(sampleIdx);
1312 station->
m_groupsTable[sampleGroupId].m_ratesTable[sampleRateId].supported)
1322 station->
m_groupsTable[sampleGroupId].m_ratesTable[sampleRateId];
1326 <<
" SampleRate= " << sampleIdx
1327 <<
" SampleProb= " << sampleRateInfo.
ewmaProb);
1347 Time maxTp2Duration =
1348 station->
m_groupsTable[maxTp2GroupId].m_ratesTable[maxTp2RateId].perfectTxTime;
1350 .m_ratesTable[maxProbRateId]
1354 << sampleDuration <<
" maxTp2Duration= " << maxTp2Duration
1355 <<
" maxProbDuration= " << maxProbDuration <<
" sampleStreams= "
1356 << +sampleStreams <<
" maxTpStreams= " << +maxTpStreams);
1357 if (sampleDuration < maxTp2Duration ||
1358 (sampleStreams < maxTpStreams && sampleDuration < maxProbDuration))
1367 <<
"sampleRate=" << sampleIdx);
1383 <<
"sampleRate=" << sampleIdx);
1445 station->
m_groupsTable[j].m_ratesTable[i].retryUpdated =
false;
1454 << station->
m_groupsTable[j].m_ratesTable[i].numRateSuccess);
1457 if (station->
m_groupsTable[j].m_ratesTable[i].numRateAttempt > 0)
1459 station->
m_groupsTable[j].m_ratesTable[i].numSamplesSkipped = 0;
1465 (100 * station->
m_groupsTable[j].m_ratesTable[i].numRateSuccess) /
1471 if (station->
m_groupsTable[j].m_ratesTable[i].successHist == 0)
1473 station->
m_groupsTable[j].m_ratesTable[i].ewmaProb = tempProb;
1487 station->
m_groupsTable[j].m_ratesTable[i].ewmaProb = tempProb;
1500 station->
m_groupsTable[j].m_ratesTable[i].numSamplesSkipped++;
1504 station->
m_groupsTable[j].m_ratesTable[i].prevNumRateSuccess =
1506 station->
m_groupsTable[j].m_ratesTable[i].prevNumRateAttempt =
1508 station->
m_groupsTable[j].m_ratesTable[i].numRateSuccess = 0;
1509 station->
m_groupsTable[j].m_ratesTable[i].numRateAttempt = 0;
1511 if (station->
m_groupsTable[j].m_ratesTable[i].throughput != 0)
1558 Time txTime = station->
m_groupsTable[groupId].m_ratesTable[rateId].perfectTxTime;
1583 uint8_t maxGPGroupId;
1584 uint8_t maxGPRateId;
1594 tmpProb = station->
m_groupsTable[tmpGroupId].m_ratesTable[tmpRateId].ewmaProb;
1595 tmpTh = station->
m_groupsTable[tmpGroupId].m_ratesTable[tmpRateId].throughput;
1599 currentTh = station->
m_groupsTable[groupId].m_ratesTable[rateId].throughput;
1600 if (currentTh > tmpTh)
1607 maxGPTh = station->
m_groupsTable[maxGPGroupId].m_ratesTable[maxGPRateId].throughput;
1609 if (currentTh > maxGPTh)
1642 uint8_t maxTpGroupId;
1643 uint8_t maxTpRateId;
1644 uint8_t maxTp2GroupId;
1645 uint8_t maxTp2RateId;
1653 prob = station->
m_groupsTable[groupId].m_ratesTable[rateId].ewmaProb;
1654 th = station->
m_groupsTable[groupId].m_ratesTable[rateId].throughput;
1658 maxTpProb = station->
m_groupsTable[maxTpGroupId].m_ratesTable[maxTpRateId].ewmaProb;
1659 maxTpTh = station->
m_groupsTable[maxTpGroupId].m_ratesTable[maxTpRateId].throughput;
1663 maxTp2Prob = station->
m_groupsTable[maxTp2GroupId].m_ratesTable[maxTp2RateId].ewmaProb;
1664 maxTp2Th = station->
m_groupsTable[maxTp2GroupId].m_ratesTable[maxTp2RateId].throughput;
1666 if (th > maxTpTh || (th == maxTpTh && prob > maxTpProb))
1671 else if (th > maxTp2Th || (th == maxTp2Th && prob > maxTp2Prob))
1682 maxTpTh = station->
m_groupsTable[maxTpGroupId].m_ratesTable[maxTpRateId].throughput;
1686 maxTp2Prob = group->
m_ratesTable[maxTp2RateId].ewmaProb;
1687 maxTp2Th = station->
m_groupsTable[maxTp2GroupId].m_ratesTable[maxTp2RateId].throughput;
1689 if (th > maxTpTh || (th == maxTpTh && prob > maxTpProb))
1694 else if (th > maxTp2Th || (th == maxTp2Th && prob > maxTp2Prob))
1711 bool noSupportedGroupFound =
true;
1712 for (uint8_t groupId = 0; groupId <
m_numGroups; groupId++)
1774 noSupportedGroupFound =
false;
1783 station->
m_groupsTable[groupId].m_ratesTable[i].supported =
false;
1788 for (uint8_t i = 0; i < station->
m_nModes; i++)
1824 station->
m_groupsTable[groupId].m_ratesTable[rateId].supported =
true;
1825 station->
m_groupsTable[groupId].m_ratesTable[rateId].mcsIndex =
1827 station->
m_groupsTable[groupId].m_ratesTable[rateId].numRateAttempt = 0;
1828 station->
m_groupsTable[groupId].m_ratesTable[rateId].numRateSuccess = 0;
1829 station->
m_groupsTable[groupId].m_ratesTable[rateId].prob = 0;
1830 station->
m_groupsTable[groupId].m_ratesTable[rateId].ewmaProb = 0;
1831 station->
m_groupsTable[groupId].m_ratesTable[rateId].prevNumRateAttempt = 0;
1832 station->
m_groupsTable[groupId].m_ratesTable[rateId].prevNumRateSuccess = 0;
1833 station->
m_groupsTable[groupId].m_ratesTable[rateId].numSamplesSkipped = 0;
1834 station->
m_groupsTable[groupId].m_ratesTable[rateId].successHist = 0;
1835 station->
m_groupsTable[groupId].m_ratesTable[rateId].attemptHist = 0;
1836 station->
m_groupsTable[groupId].m_ratesTable[rateId].throughput = 0;
1837 station->
m_groupsTable[groupId].m_ratesTable[rateId].perfectTxTime =
1839 station->
m_groupsTable[groupId].m_ratesTable[rateId].retryCount = 0;
1840 station->
m_groupsTable[groupId].m_ratesTable[rateId].adjustedRetryCount = 0;
1848 if (noSupportedGroupFound)
1863 if (!station->
m_groupsTable[groupId].m_ratesTable[rateId].retryUpdated)
1884 if (station->
m_groupsTable[groupId].m_ratesTable[rateId].ewmaProb < 1)
1886 station->
m_groupsTable[groupId].m_ratesTable[rateId].retryCount = 1;
1890 station->
m_groupsTable[groupId].m_ratesTable[rateId].retryCount = 2;
1891 station->
m_groupsTable[groupId].m_ratesTable[rateId].retryUpdated =
true;
1897 station->
m_groupsTable[groupId].m_ratesTable[rateId].mcsIndex)) +
1901 station->
m_groupsTable[groupId].m_ratesTable[rateId].mcsIndex)) *
1905 cwTime = (cw / 2) * slotTime;
1906 cw =
Min((cw + 1) * 2, cwMax);
1907 cwTime += (cw / 2) * slotTime;
1908 cw =
Min((cw + 1) * 2, cwMax);
1911 txTime = cwTime + 2 * (dataTxTime + ackTime);
1917 cwTime = (cw / 2) * slotTime;
1918 cw =
Min((cw + 1) * 2, cwMax);
1921 txTime += cwTime + ackTime + dataTxTime;
1923 (++station->
m_groupsTable[groupId].m_ratesTable[rateId].retryCount < 7));
1938 diff = currentProb - ewmaProb;
1939 incr = (100 - weight) * diff / 100;
1940 tmp = oldEwmsd * oldEwmsd;
1941 tmp = weight * (tmp + diff * incr) / 100;
1959 for (uint8_t i = 0; i < numSampleRates; i++)
1966 newIndex = (i + uv) % numSampleRates;
1983 std::ostringstream tmp;
1985 station->
m_statsFile.open(tmp.str(), std::ios::out);
1989 <<
" best ____________rate__________ ________statistics________ "
1990 "________last_______ ______sum-of________\n"
1991 <<
" mode guard # rate [name idx airtime max_tp] [avg(tp) avg(prob) sd(prob)] "
1992 "[prob.|retry|suc|att] [#success | #attempts]\n";
1998 station->
m_statsFile <<
"\nTotal packet count:: ideal "
2015 for (uint8_t i = 0; i < numRates; i++)
2027 uint16_t idx =
GetIndex(groupId, i);
2028 if (idx == maxTpRate)
2036 if (idx == maxTpRate2)
2044 if (idx == maxProbRate)
2055 of << std::setw(4) <<
" MCS" << (group.
streams - 1) * 8 + i;
2059 of << std::setw(7) <<
" MCS" << +i <<
"/" <<
static_cast<int>(group.
streams);
2062 of <<
" " << std::setw(3) << +idx <<
" ";
2071 << std::setw(7) << station->
m_groupsTable[groupId].m_ratesTable[i].throughput / 100
2072 <<
" " << std::setw(7) << station->
m_groupsTable[groupId].m_ratesTable[i].ewmaProb
2073 <<
" " << std::setw(7) << station->
m_groupsTable[groupId].m_ratesTable[i].ewmsdProb
2074 <<
" " << std::setw(7) << station->
m_groupsTable[groupId].m_ratesTable[i].prob
2075 <<
" " << std::setw(2) << station->
m_groupsTable[groupId].m_ratesTable[i].retryCount
2076 <<
" " << std::setw(3)
2077 << station->
m_groupsTable[groupId].m_ratesTable[i].prevNumRateSuccess <<
" "
2078 << std::setw(3) << station->
m_groupsTable[groupId].m_ratesTable[i].prevNumRateAttempt
2079 <<
" " << std::setw(9)
2080 << station->
m_groupsTable[groupId].m_ratesTable[i].successHist <<
" "
2081 << std::setw(9) << station->
m_groupsTable[groupId].m_ratesTable[i].attemptHist
2116 uint8_t giIndex = (gi == 400) ? 1 : 0;
2117 uint8_t widthIndex = (chWidth == 40) ? 1 : 0;
2126 uint8_t giIndex = (gi == 400) ? 1 : 0;
2132 else if (chWidth == 80)
2136 else if (chWidth == 40)
2159 else if (gi == 1600)
2172 else if (chWidth == 80)
2176 else if (chWidth == 40)
2199 uint8_t groupId = 0;
2201 while (groupId < m_numGroups && !station->m_groupsTable[groupId].m_supported)
2205 while (rateId < m_numRates && !station->m_groupsTable[groupId].m_ratesTable[rateId].supported)
2210 station->
m_groupsTable[groupId].m_ratesTable[rateId].supported);
2220 while (rateId < m_numRates && !station->m_groupsTable[groupId].m_ratesTable[rateId].supported)
2225 station->
m_groupsTable[groupId].m_ratesTable[rateId].supported);
2235 heMcsList.push_back(mode);
2246 vhtMcsList.push_back(mode);
2257 htMcsList.push_back(mode);
AttributeValue implementation for Boolean.
Implementation of Minstrel-HT Rate Control Algorithm.
static TypeId GetTypeId()
Get the type ID.
uint32_t CountRetries(MinstrelHtWifiRemoteStation *station)
Count retries.
uint32_t m_frameLength
Frame length used to calculate modes TxTime in bytes.
void InitSampleTable(MinstrelHtWifiRemoteStation *station)
Initialize Sample Table.
bool m_printStats
If statistics table should be printed.
int64_t AssignStreams(int64_t stream) override
Assign a fixed random variable stream number to the random variables used by this model.
void DoReportRxOk(WifiRemoteStation *station, double rxSnr, WifiMode txMode) override
This method is a pure virtual method that must be implemented by the sub-class.
bool DoNeedRetransmission(WifiRemoteStation *st, Ptr< const Packet > packet, bool normally) override
WifiTxVector DoGetDataTxVector(WifiRemoteStation *station, uint16_t allowedWidth) override
WifiTxVector DoGetRtsTxVector(WifiRemoteStation *station) override
MinstrelMcsGroups m_minstrelGroups
Global array for groups information.
void AddMpduTxTime(uint8_t groupId, WifiMode mode, Time t)
Save a TxTime to the vector of groups.
void SetNextSample(MinstrelHtWifiRemoteStation *station)
Set the next sample from Sample Table.
uint8_t m_numRates
Number of rates per group Minstrel should consider.
uint8_t m_nSampleCol
Number of sample columns.
void RateInit(MinstrelHtWifiRemoteStation *station)
Initialize Minstrel Table.
void SetBestStationThRates(MinstrelHtWifiRemoteStation *station, uint16_t index)
Set index rate as maxTpRate or maxTp2Rate if is better than current values.
~MinstrelHtWifiManager() override
void PrintTable(MinstrelHtWifiRemoteStation *station)
Printing Minstrel Table.
void StatsDump(MinstrelHtWifiRemoteStation *station, uint8_t groupId, std::ofstream &of)
Print group statistics.
void DoReportAmpduTxStatus(WifiRemoteStation *station, uint16_t nSuccessfulMpdus, uint16_t nFailedMpdus, double rxSnr, double dataSnr, uint16_t dataChannelWidth, uint8_t dataNss) override
Typically called per A-MPDU, either when a Block ACK was successfully received or when a BlockAckTime...
double CalculateThroughput(MinstrelHtWifiRemoteStation *station, uint8_t groupId, uint8_t rateId, double ewmaProb)
Return the average throughput of the MCS defined by groupId and rateId.
void AddFirstMpduTxTime(uint8_t groupId, WifiMode mode, Time t)
Save a TxTime to the vector of groups.
double CalculateEwmsd(double oldEwmsd, double currentProb, double ewmaProb, double weight)
Perform EWMSD (Exponentially Weighted Moving Standard Deviation) calculation.
void DoReportDataFailed(WifiRemoteStation *station) override
This method is a pure virtual method that must be implemented by the sub-class.
void SetBestProbabilityRate(MinstrelHtWifiRemoteStation *station, uint16_t index)
Set index rate as maxProbRate if it is better than current value.
WifiModeList GetHeDeviceMcsList() const
Returns a list of only the HE MCS supported by the device.
Time m_updateStats
How frequent do we calculate the stats.
TracedValue< uint64_t > m_currentRate
Trace rate changes.
uint16_t GetLowestIndex(MinstrelHtWifiRemoteStation *station)
Returns the lowest global index of the rates supported by the station.
void DoInitialize() override
Initialize() implementation.
WifiModeList GetVhtDeviceMcsList() const
Returns a list of only the VHT MCS supported by the device.
Time CalculateMpduTxDuration(Ptr< WifiPhy > phy, uint8_t streams, uint16_t gi, uint16_t chWidth, WifiMode mode, MpduType mpduType)
Estimates the TxTime of a frame with a given mode and group (stream, guard interval and channel width...
void CheckInit(MinstrelHtWifiRemoteStation *station)
Check for initializations.
WifiModeList GetHtDeviceMcsList() const
Returns a list of only the HT MCS supported by the device.
void UpdateRetry(MinstrelHtWifiRemoteStation *station)
Update the number of retries and reset accordingly.
Time GetFirstMpduTxTime(uint8_t groupId, WifiMode mode) const
Obtain the TxTime saved in the group information.
Time GetMpduTxTime(uint8_t groupId, WifiMode mode) const
Obtain the TxTime saved in the group information.
uint16_t UpdateRateAfterAllowedWidth(uint16_t txRate, uint16_t allowedWidth)
Given the index of the current TX rate, check whether the channel width is not greater than the given...
uint8_t m_numGroups
Number of groups Minstrel should consider.
void CalculateRetransmits(MinstrelHtWifiRemoteStation *station, uint16_t index)
Calculate the number of retransmissions to set for the index rate.
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...
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.
uint8_t m_ewmaLevel
Exponential weighted moving average level (or coefficient).
uint16_t FindRate(MinstrelHtWifiRemoteStation *station)
Find a rate to use from Minstrel Table.
uint8_t m_lookAroundRate
The % to try other rates than our current rate.
void UpdateRate(MinstrelHtWifiRemoteStation *station)
Update rate.
uint8_t GetRateId(uint16_t index)
Return the rateId inside a group, from the global index.
Time m_legacyUpdateStats
How frequent do we calculate the stats for legacy MinstrelWifiManager.
uint8_t GetGroupId(uint16_t index)
Return the groupId from the global index.
uint8_t GetVhtGroupId(uint8_t txstreams, uint16_t gi, uint16_t chWidth)
Returns the groupId of a VHT MCS with the given number of streams, GI and channel width used.
uint8_t GetHtGroupId(uint8_t txstreams, uint16_t gi, uint16_t chWidth)
Returns the groupId of an HT MCS with the given number of streams, GI and channel width used.
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.
Ptr< UniformRandomVariable > m_uniformRandomVariable
Provides uniform random variables.
uint16_t GetNextSample(MinstrelHtWifiRemoteStation *station)
Getting the next sample from Sample Table.
void UpdateStats(MinstrelHtWifiRemoteStation *station)
Update the Minstrel Table.
uint16_t GetIndex(uint8_t groupId, uint8_t rateId)
Returns the global index corresponding to the groupId and rateId.
WifiRemoteStation * DoCreateStation() const override
Ptr< MinstrelWifiManager > m_legacyManager
Pointer to an instance of MinstrelWifiManager.
uint8_t GetHeGroupId(uint8_t txstreams, uint16_t gi, uint16_t chWidth)
Returns the groupId of an HE MCS with the given number of streams, GI and channel width used.
bool IsValidMcs(Ptr< WifiPhy > phy, uint8_t streams, uint16_t chWidth, WifiMode mode)
Check the validity of a combination of number of streams, chWidth and mode.
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...
void DoReportFinalDataFailed(WifiRemoteStation *station) override
This method is a pure virtual method that must be implemented by the sub-class.
void UpdatePacketCounters(MinstrelHtWifiRemoteStation *station, uint16_t nSuccessfulMpdus, uint16_t nFailedMpdus)
Update the number of sample count variables.
void DoReportFinalRtsFailed(WifiRemoteStation *station) override
This method is a pure virtual method that must be implemented by the sub-class.
bool m_useLatestAmendmentOnly
Flag if only the latest supported amendment by both peers should be used.
void DoReportRtsFailed(WifiRemoteStation *station) override
This method is a pure virtual method that must be implemented by the sub-class.
Smart pointer class similar to boost::intrusive_ptr.
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
static Time Now()
Return the current simulation virtual time.
Simulation virtual time values and global simulation resolution.
double GetSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
int64_t GetMicroSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
AttributeValue implementation for Time.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Hold an unsigned integer type.
represent a single transmission mode
WifiModulationClass GetModulationClass() const
uint64_t GetNonHtReferenceRate() const
uint64_t GetDataRate(uint16_t channelWidth, uint16_t guardInterval, uint8_t nss) const
uint8_t GetMcsValue() const
Time GetBlockAckTxTime() const
Return the estimated BlockAck TX time for this PHY.
static Time GetPayloadDuration(uint32_t size, const WifiTxVector &txVector, WifiPhyBand band, MpduType mpdutype=NORMAL_MPDU, uint16_t staId=SU_STA_ID)
Time GetSlot() const
Return the slot duration for this PHY.
Time GetSifs() const
Return the Short Interframe Space (SIFS) for this PHY.
uint16_t GetTxBandwidth(WifiMode mode, uint16_t maxAllowedBandWidth=std::numeric_limits< uint16_t >::max()) const
Get the bandwidth for a transmission occurring on the current operating channel and using the given W...
static Time CalculatePhyPreambleAndHeaderDuration(const WifiTxVector &txVector)
hold a list of per-remote-station state.
uint8_t GetNumberOfSupportedStreams(Mac48Address address) const
Return the number of spatial streams supported by the station.
uint8_t GetNess(const WifiRemoteStation *station) const
uint8_t GetNBasicModes() const
Return the number of basic modes we support.
uint16_t GetChannelWidth(const WifiRemoteStation *station) const
Return the channel width supported by the station.
uint8_t GetDefaultTxPowerLevel() const
Ptr< WifiPhy > GetPhy() const
Return the WifiPhy.
uint16_t GetGuardInterval() const
Return the supported HE guard interval duration (in nanoseconds).
bool GetAggregation(const WifiRemoteStation *station) const
Return whether the given station supports A-MPDU.
bool GetHtSupported() const
Return whether the device has HT capability support enabled.
uint8_t GetNumberOfAntennas() const
uint8_t GetNMcsSupported(Mac48Address address) const
Return the number of MCS supported by the station.
WifiMode GetBasicMode(uint8_t i) const
Return a basic mode from the set of basic modes.
bool GetShortGuardIntervalSupported() const
Return whether the device has SGI support enabled.
virtual void SetupPhy(const Ptr< WifiPhy > phy)
Set up PHY associated with this device since it is the object that knows the full set of transmit rat...
WifiMode GetMcsSupported(const WifiRemoteStation *station, uint8_t i) const
Return the WifiMode supported by the specified station at the specified index.
bool GetVhtSupported() const
Return whether the device has VHT capability support enabled.
bool GetShortPreambleEnabled() const
Return whether the device uses short PHY preambles.
bool GetHeSupported() const
Return whether the device has HE capability support enabled.
virtual void SetupMac(const Ptr< WifiMac > mac)
Set up MAC associated with this device since it is the object that knows the full set of timing param...
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
void SetStbc(bool stbc)
Sets if STBC is being used.
void SetNess(uint8_t ness)
Sets the Ness number.
bool IsValid() const
The standard disallows certain combinations of WifiMode, number of spatial streams,...
void SetChannelWidth(uint16_t channelWidth)
Sets the selected channelWidth (in MHz)
void SetGuardInterval(uint16_t guardInterval)
Sets the guard interval duration (in nanoseconds)
WifiMode GetMode(uint16_t staId=SU_STA_ID) const
If this TX vector is associated with an SU PPDU, return the selected payload transmission mode.
void SetMode(WifiMode mode)
Sets the selected payload transmission mode.
void SetNss(uint8_t nss)
Sets the number of Nss.
void SetPreambleType(WifiPreamble preamble)
Sets the preamble type.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Ptr< const AttributeChecker > MakeBooleanChecker()
Ptr< const AttributeChecker > MakeTimeChecker()
Helper to make an unbounded Time checker.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
MpduType
The type of an MPDU.
@ WIFI_MOD_CLASS_HT
HT (Clause 19)
@ WIFI_MOD_CLASS_VHT
VHT (Clause 22)
@ WIFI_MOD_CLASS_HE
HE (Clause 27)
@ FIRST_MPDU_IN_AGGREGATE
The MPDU is the first aggregate in an A-MPDU with multiple MPDUs, but is not the last aggregate.
@ MIDDLE_MPDU_IN_AGGREGATE
The MPDU is part of an A-MPDU with multiple MPDUs, but is neither the first nor the last aggregate.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static const uint8_t MAX_HT_GROUP_RATES
Number of rates (or MCS) per HT group.
static const uint8_t MAX_VHT_STREAM_GROUPS
Maximal number of groups per stream in VHT (4 possible channel widths and 2 possible GI configuration...
std::vector< RateInfo > MinstrelRate
Data structure for a Minstrel Rate table A vector of a struct RateInfo.
std::vector< McsGroup > MinstrelMcsGroups
Data structure for a table of group definitions.
@ WIFI_MINSTREL_GROUP_VHT
static const uint8_t MAX_VHT_GROUP_RATES
Number of rates (or MCS) per VHT group.
static const uint8_t MAX_VHT_SUPPORTED_STREAMS
Maximal number of streams supported by the VHT PHY layer.
static const uint8_t MAX_HT_SUPPORTED_STREAMS
Constants for maximum values.
static const uint8_t MAX_HE_GROUP_RATES
Number of rates (or MCS) per HE group.
static const uint8_t MAX_HT_WIDTH
Maximal channel width in MHz.
static const uint8_t MAX_HT_STREAM_GROUPS
Maximal number of groups per stream in HT (2 possible channel widths and 2 possible GI configurations...
static const uint8_t MAX_HE_STREAM_GROUPS
Maximal number of groups per stream in HE (4 possible channel widths and 3 possible GI configurations...
WifiPreamble GetPreambleForTransmission(WifiModulationClass modulation, bool useShortPreamble)
Return the preamble to be used for the transmission.
std::vector< MinstrelHtRateInfo > MinstrelHtRate
Data structure for a Minstrel Rate table.
std::vector< WifiMode > WifiModeList
In various parts of the code, folk are interested in maintaining a list of transmission modes.
std::vector< std::vector< uint8_t > > SampleRate
Data structure for a Sample Rate table A vector of a vector uint8_t.
static const uint8_t MAX_HE_WIDTH
Maximal channel width in MHz.
static const uint8_t MAX_VHT_WIDTH
Maximal channel width in MHz.
std::vector< GroupInfo > McsGroupData
Data structure for a table of groups.
static const uint8_t MAX_HE_SUPPORTED_STREAMS
Maximal number of streams supported by the HE PHY layer.
A struct to contain information of a group.
MinstrelHtRate m_ratesTable
Information about rates of this group.
uint16_t m_maxTpRate2
The second max throughput rate of this group in bps.
uint16_t m_maxProbRate
The highest success probability rate of this group in bps.
uint16_t m_maxTpRate
The max throughput rate of this group in bps.
Data structure to contain the information that defines a group.
uint16_t chWidth
channel width (MHz)
uint16_t gi
guard interval duration (nanoseconds)
McsGroupType type
identifies the group,
bool isSupported
flag whether group is supported
uint8_t streams
number of spatial streams
A struct to contain all statistics information related to a data rate.
Time perfectTxTime
Perfect transmission time calculation, or frame calculation.
double ewmaProb
Exponential weighted moving average of probability.
uint32_t numSamplesSkipped
Number of times this rate statistics were not updated because no attempts have been made.
MinstrelHtWifiRemoteStation structure.
McsGroupData m_groupsTable
Table of groups with stats.
uint32_t m_sampleCount
Max number of samples per update interval.
uint8_t m_sampleGroup
The group that the sample rate belongs to.
uint32_t m_ampduPacketCount
Number of A-MPDUs transmitted.
uint32_t m_numSamplesSlow
Number of times a slow rate was sampled.
uint32_t m_sampleTries
Number of sample tries after waiting sampleWait.
std::ofstream m_statsFile
File where statistics table is written.
uint32_t m_sampleWait
How many transmission attempts to wait until a new sample.
bool m_isHt
If the station is HT capable.
uint32_t m_avgAmpduLen
Average number of MPDUs in an A-MPDU.
uint32_t m_ampduLen
Number of MPDUs in an A-MPDU.
hold per-remote-station state for Minstrel Wifi manager.
uint16_t m_maxTpRate2
second highest throughput rate in bps
Time m_nextStatsUpdate
10 times every second
bool m_initialized
for initializing tables
uint16_t m_sampleRate
current sample rate in bps
uint8_t m_index
vector index
uint16_t m_txrate
current transmit rate in bps
int m_totalPacketsCount
total number of packets as of now
bool m_isSampling
a flag to indicate we are currently sampling
MinstrelRate m_minstrelTable
minstrel table
uint32_t m_shortRetry
short retries such as control packets
uint16_t m_maxTpRate
the current throughput rate in bps
bool m_sampleDeferred
a flag to indicate sample rate is on the second stage
uint8_t m_nModes
number of modes supported
SampleRate m_sampleTable
sample table
int m_samplePacketsCount
how many packets we have sample so far
uint8_t m_col
To keep track of the current position in the our random sample table going row by row from 1st column...
uint32_t m_longRetry
long retries such as data packets
uint16_t m_maxProbRate
rate with highest probability of success in bps
hold per-remote-station state.
WifiRemoteStationState * m_state
Remote station state.
Mac48Address m_address
Mac48Address of the remote station.
void CalculateThroughput()
Calculate the throughput.