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
460 m_minstrelGroups[groupId].ratesFirstMpduTxTimeTable.insert(std::make_pair(mode, t));
643 .m_ratesTable[rateId]
654 uint16_t dataChannelWidth,
657 NS_LOG_FUNCTION(
this << st << ackSnr << ackMode << dataSnr << dataChannelWidth << +dataNss);
670 <<
" (before update).");
683 <<
" (after update).");
697 station->
m_groupsTable[groupId].m_ratesTable[rateId].numRateSuccess++;
698 station->
m_groupsTable[groupId].m_ratesTable[rateId].numRateAttempt++;
706 <<
" (after update).");
775 uint16_t nSuccessfulMpdus,
776 uint16_t nFailedMpdus,
779 uint16_t dataChannelWidth,
782 NS_LOG_FUNCTION(
this << st << nSuccessfulMpdus << nFailedMpdus << rxSnr << dataSnr
783 << dataChannelWidth << +dataNss);
795 <<
" SuccMpdus=" << nSuccessfulMpdus
796 <<
" FailedMpdus=" << nFailedMpdus);
799 station->
m_ampduLen += nSuccessfulMpdus + nFailedMpdus;
805 station->
m_groupsTable[groupId].m_ratesTable[rateId].numRateSuccess += nSuccessfulMpdus;
806 station->
m_groupsTable[groupId].m_ratesTable[rateId].numRateAttempt +=
807 nSuccessfulMpdus + nFailedMpdus;
881 station->
m_groupsTable[maxTpGroupId].m_ratesTable[maxTpRateId].retryCount)
889 (station->
m_groupsTable[maxTpGroupId].m_ratesTable[maxTpRateId].retryCount +
890 station->
m_groupsTable[maxTp2GroupId].m_ratesTable[maxTp2RateId].retryCount))
898 (station->
m_groupsTable[maxTpGroupId].m_ratesTable[maxTpRateId].retryCount +
899 station->
m_groupsTable[maxTp2GroupId].m_ratesTable[maxTp2RateId].retryCount +
900 station->
m_groupsTable[maxProbGroupId].m_ratesTable[maxProbRateId].retryCount))
907 NS_FATAL_ERROR(
"Max retries reached and m_longRetry not cleared properly. longRetry= "
918 1 + station->
m_groupsTable[maxTpGroupId].m_ratesTable[maxTp2RateId].retryCount)
926 1 + station->
m_groupsTable[maxTpGroupId].m_ratesTable[maxTp2RateId].retryCount +
927 station->
m_groupsTable[maxProbGroupId].m_ratesTable[maxProbRateId].retryCount)
934 NS_FATAL_ERROR(
"Max retries reached and m_longRetry not cleared properly. longRetry= "
951 uint16_t nSuccessfulMpdus,
952 uint16_t nFailedMpdus)
983 if (group.
chWidth <= allowedWidth)
985 NS_LOG_DEBUG(
"Channel width is not greater than allowed width, nothing to do");
994 uint16_t width = group.
chWidth / 2;
998 if (width > allowedWidth)
1028 NS_ABORT_MSG_IF(width < 20,
"No rate compatible with the allowed width found");
1062 uint8_t mcsIndex = station->
m_groupsTable[groupId].m_ratesTable[rateId].mcsIndex;
1064 NS_LOG_DEBUG(
"DoGetDataMode rateId= " << +rateId <<
" groupId= " << +groupId
1141 uint8_t mcsIndex = station->
m_groupsTable[groupId].m_ratesTable[rateId].mcsIndex;
1148 bool rateFound =
false;
1150 for (uint8_t i = 0; i < nBasicRates; i++)
1153 if (rate <= lastDataRate)
1163 for (
const auto& mode :
phy->GetModeList())
1165 uint64_t rate = mode.GetDataRate(20);
1166 if (rate <= lastDataRate)
1204 uint32_t maxRetries;
1218 <<
" Max retries: " << maxRetries);
1224 <<
" Max retries: " << maxRetries);
1241 return station->
m_groupsTable[maxTpGroupId].m_ratesTable[maxTpRateId].retryCount +
1242 station->
m_groupsTable[maxTp2GroupId].m_ratesTable[maxTp2RateId].retryCount +
1243 station->
m_groupsTable[maxProbGroupId].m_ratesTable[maxProbRateId].retryCount;
1247 return 1 + station->
m_groupsTable[maxTpGroupId].m_ratesTable[maxTp2RateId].retryCount +
1248 station->
m_groupsTable[maxProbGroupId].m_ratesTable[maxProbRateId].retryCount;
1257 uint8_t index = station->
m_groupsTable[sampleGroup].m_index;
1260 uint16_t rateIndex =
GetIndex(sampleGroup, sampleIndex);
1318 uint8_t sampleGroupId =
GetGroupId(sampleIdx);
1319 uint8_t sampleRateId =
GetRateId(sampleIdx);
1323 station->
m_groupsTable[sampleGroupId].m_ratesTable[sampleRateId].supported)
1333 station->
m_groupsTable[sampleGroupId].m_ratesTable[sampleRateId];
1337 <<
" SampleRate= " << sampleIdx
1338 <<
" SampleProb= " << sampleRateInfo.
ewmaProb);
1358 Time maxTp2Duration =
1359 station->
m_groupsTable[maxTp2GroupId].m_ratesTable[maxTp2RateId].perfectTxTime;
1361 .m_ratesTable[maxProbRateId]
1365 << sampleDuration <<
" maxTp2Duration= " << maxTp2Duration
1366 <<
" maxProbDuration= " << maxProbDuration <<
" sampleStreams= "
1367 << +sampleStreams <<
" maxTpStreams= " << +maxTpStreams);
1368 if (sampleDuration < maxTp2Duration ||
1369 (sampleStreams < maxTpStreams && sampleDuration < maxProbDuration))
1378 <<
"sampleRate=" << sampleIdx);
1394 <<
"sampleRate=" << sampleIdx);
1456 station->
m_groupsTable[j].m_ratesTable[i].retryUpdated =
false;
1465 << station->
m_groupsTable[j].m_ratesTable[i].numRateSuccess);
1468 if (station->
m_groupsTable[j].m_ratesTable[i].numRateAttempt > 0)
1470 station->
m_groupsTable[j].m_ratesTable[i].numSamplesSkipped = 0;
1476 (100 * station->
m_groupsTable[j].m_ratesTable[i].numRateSuccess) /
1482 if (station->
m_groupsTable[j].m_ratesTable[i].successHist == 0)
1484 station->
m_groupsTable[j].m_ratesTable[i].ewmaProb = tempProb;
1498 station->
m_groupsTable[j].m_ratesTable[i].ewmaProb = tempProb;
1511 station->
m_groupsTable[j].m_ratesTable[i].numSamplesSkipped++;
1515 station->
m_groupsTable[j].m_ratesTable[i].prevNumRateSuccess =
1517 station->
m_groupsTable[j].m_ratesTable[i].prevNumRateAttempt =
1519 station->
m_groupsTable[j].m_ratesTable[i].numRateSuccess = 0;
1520 station->
m_groupsTable[j].m_ratesTable[i].numRateAttempt = 0;
1522 if (station->
m_groupsTable[j].m_ratesTable[i].throughput != 0)
1569 Time txTime = station->
m_groupsTable[groupId].m_ratesTable[rateId].perfectTxTime;
1594 uint8_t maxGPGroupId;
1595 uint8_t maxGPRateId;
1605 tmpProb = station->
m_groupsTable[tmpGroupId].m_ratesTable[tmpRateId].ewmaProb;
1606 tmpTh = station->
m_groupsTable[tmpGroupId].m_ratesTable[tmpRateId].throughput;
1610 currentTh = station->
m_groupsTable[groupId].m_ratesTable[rateId].throughput;
1611 if (currentTh > tmpTh)
1618 maxGPTh = station->
m_groupsTable[maxGPGroupId].m_ratesTable[maxGPRateId].throughput;
1620 if (currentTh > maxGPTh)
1653 uint8_t maxTpGroupId;
1654 uint8_t maxTpRateId;
1655 uint8_t maxTp2GroupId;
1656 uint8_t maxTp2RateId;
1664 prob = station->
m_groupsTable[groupId].m_ratesTable[rateId].ewmaProb;
1665 th = station->
m_groupsTable[groupId].m_ratesTable[rateId].throughput;
1669 maxTpProb = station->
m_groupsTable[maxTpGroupId].m_ratesTable[maxTpRateId].ewmaProb;
1670 maxTpTh = station->
m_groupsTable[maxTpGroupId].m_ratesTable[maxTpRateId].throughput;
1674 maxTp2Prob = station->
m_groupsTable[maxTp2GroupId].m_ratesTable[maxTp2RateId].ewmaProb;
1675 maxTp2Th = station->
m_groupsTable[maxTp2GroupId].m_ratesTable[maxTp2RateId].throughput;
1677 if (th > maxTpTh || (th == maxTpTh && prob > maxTpProb))
1682 else if (th > maxTp2Th || (th == maxTp2Th && prob > maxTp2Prob))
1693 maxTpTh = station->
m_groupsTable[maxTpGroupId].m_ratesTable[maxTpRateId].throughput;
1697 maxTp2Prob = group->
m_ratesTable[maxTp2RateId].ewmaProb;
1698 maxTp2Th = station->
m_groupsTable[maxTp2GroupId].m_ratesTable[maxTp2RateId].throughput;
1700 if (th > maxTpTh || (th == maxTpTh && prob > maxTpProb))
1705 else if (th > maxTp2Th || (th == maxTp2Th && prob > maxTp2Prob))
1722 bool noSupportedGroupFound =
true;
1723 for (uint8_t groupId = 0; groupId <
m_numGroups; groupId++)
1785 noSupportedGroupFound =
false;
1794 station->
m_groupsTable[groupId].m_ratesTable[i].supported =
false;
1799 for (uint8_t i = 0; i < station->
m_nModes; i++)
1835 station->
m_groupsTable[groupId].m_ratesTable[rateId].supported =
true;
1836 station->
m_groupsTable[groupId].m_ratesTable[rateId].mcsIndex =
1838 station->
m_groupsTable[groupId].m_ratesTable[rateId].numRateAttempt = 0;
1839 station->
m_groupsTable[groupId].m_ratesTable[rateId].numRateSuccess = 0;
1840 station->
m_groupsTable[groupId].m_ratesTable[rateId].prob = 0;
1841 station->
m_groupsTable[groupId].m_ratesTable[rateId].ewmaProb = 0;
1842 station->
m_groupsTable[groupId].m_ratesTable[rateId].prevNumRateAttempt = 0;
1843 station->
m_groupsTable[groupId].m_ratesTable[rateId].prevNumRateSuccess = 0;
1844 station->
m_groupsTable[groupId].m_ratesTable[rateId].numSamplesSkipped = 0;
1845 station->
m_groupsTable[groupId].m_ratesTable[rateId].successHist = 0;
1846 station->
m_groupsTable[groupId].m_ratesTable[rateId].attemptHist = 0;
1847 station->
m_groupsTable[groupId].m_ratesTable[rateId].throughput = 0;
1848 station->
m_groupsTable[groupId].m_ratesTable[rateId].perfectTxTime =
1850 station->
m_groupsTable[groupId].m_ratesTable[rateId].retryCount = 0;
1851 station->
m_groupsTable[groupId].m_ratesTable[rateId].adjustedRetryCount = 0;
1859 if (noSupportedGroupFound)
1874 if (!station->
m_groupsTable[groupId].m_ratesTable[rateId].retryUpdated)
1888 uint32_t cwMax = 1023;
1895 if (station->
m_groupsTable[groupId].m_ratesTable[rateId].ewmaProb < 1)
1897 station->
m_groupsTable[groupId].m_ratesTable[rateId].retryCount = 1;
1901 station->
m_groupsTable[groupId].m_ratesTable[rateId].retryCount = 2;
1902 station->
m_groupsTable[groupId].m_ratesTable[rateId].retryUpdated =
true;
1908 station->
m_groupsTable[groupId].m_ratesTable[rateId].mcsIndex)) +
1912 station->
m_groupsTable[groupId].m_ratesTable[rateId].mcsIndex)) *
1916 cwTime = (cw / 2) * slotTime;
1917 cw =
Min((cw + 1) * 2, cwMax);
1918 cwTime += (cw / 2) * slotTime;
1919 cw =
Min((cw + 1) * 2, cwMax);
1922 txTime = cwTime + 2 * (dataTxTime + ackTime);
1928 cwTime = (cw / 2) * slotTime;
1929 cw =
Min((cw + 1) * 2, cwMax);
1932 txTime += cwTime + ackTime + dataTxTime;
1934 (++station->
m_groupsTable[groupId].m_ratesTable[rateId].retryCount < 7));
1949 diff = currentProb - ewmaProb;
1950 incr = (100 - weight) * diff / 100;
1951 tmp = oldEwmsd * oldEwmsd;
1952 tmp = weight * (tmp + diff * incr) / 100;
1970 for (uint8_t i = 0; i < numSampleRates; i++)
1977 newIndex = (i + uv) % numSampleRates;
1994 std::ostringstream tmp;
1996 station->
m_statsFile.open(tmp.str(), std::ios::out);
2000 <<
" best ____________rate__________ ________statistics________ "
2001 "________last_______ ______sum-of________\n"
2002 <<
" mode guard # rate [name idx airtime max_tp] [avg(tp) avg(prob) sd(prob)] "
2003 "[prob.|retry|suc|att] [#success | #attempts]\n";
2009 station->
m_statsFile <<
"\nTotal packet count:: ideal "
2026 for (uint8_t i = 0; i < numRates; i++)
2038 uint16_t idx =
GetIndex(groupId, i);
2039 if (idx == maxTpRate)
2047 if (idx == maxTpRate2)
2055 if (idx == maxProbRate)
2066 of << std::setw(4) <<
" MCS" << (group.
streams - 1) * 8 + i;
2070 of << std::setw(7) <<
" MCS" << +i <<
"/" <<
static_cast<int>(group.
streams);
2073 of <<
" " << std::setw(3) << +idx <<
" ";
2082 << std::setw(7) << station->
m_groupsTable[groupId].m_ratesTable[i].throughput / 100
2083 <<
" " << std::setw(7) << station->
m_groupsTable[groupId].m_ratesTable[i].ewmaProb
2084 <<
" " << std::setw(7) << station->
m_groupsTable[groupId].m_ratesTable[i].ewmsdProb
2085 <<
" " << std::setw(7) << station->
m_groupsTable[groupId].m_ratesTable[i].prob
2086 <<
" " << std::setw(2) << station->
m_groupsTable[groupId].m_ratesTable[i].retryCount
2087 <<
" " << std::setw(3)
2088 << station->
m_groupsTable[groupId].m_ratesTable[i].prevNumRateSuccess <<
" "
2089 << std::setw(3) << station->
m_groupsTable[groupId].m_ratesTable[i].prevNumRateAttempt
2090 <<
" " << std::setw(9)
2091 << station->
m_groupsTable[groupId].m_ratesTable[i].successHist <<
" "
2092 << std::setw(9) << station->
m_groupsTable[groupId].m_ratesTable[i].attemptHist
2127 uint8_t giIndex = (gi == 400) ? 1 : 0;
2128 uint8_t widthIndex = (chWidth == 40) ? 1 : 0;
2137 uint8_t giIndex = (gi == 400) ? 1 : 0;
2143 else if (chWidth == 80)
2147 else if (chWidth == 40)
2170 else if (gi == 1600)
2183 else if (chWidth == 80)
2187 else if (chWidth == 40)
2210 uint8_t groupId = 0;
2212 while (groupId < m_numGroups && !station->m_groupsTable[groupId].m_supported)
2216 while (rateId < m_numRates && !station->m_groupsTable[groupId].m_ratesTable[rateId].supported)
2221 station->
m_groupsTable[groupId].m_ratesTable[rateId].supported);
2231 while (rateId < m_numRates && !station->m_groupsTable[groupId].m_ratesTable[rateId].supported)
2236 station->
m_groupsTable[groupId].m_ratesTable[rateId].supported);
2246 heMcsList.push_back(mode);
2257 vhtMcsList.push_back(mode);
2268 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.
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)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeChecker > MakeBooleanChecker()
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
#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.
int64x64_t Max(const int64x64_t &a, const int64x64_t &b)
Maximum.
int64x64_t Min(const int64x64_t &a, const int64x64_t &b)
Minimum.
#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.
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
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.
std::vector< struct GroupInfo > McsGroupData
Data structure for a table of groups.
static const uint8_t MAX_VHT_WIDTH
Maximal channel width in MHz.
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.