38 #include "ns3/packet.h" 39 #include "ns3/simulator.h" 41 #include "ns3/random-variable-stream.h" 46 #define Min(a,b) ((a < b) ? a : b) 47 #define Max(a,b) ((a > b) ? a : b) 78 static TypeId tid =
TypeId (
"ns3::MinstrelHtWifiManager")
80 .AddConstructor<MinstrelHtWifiManager> ()
81 .SetGroupName (
"Wifi")
82 .AddAttribute (
"UpdateStatistics",
83 "The interval between updating statistics table ",
87 .AddAttribute (
"LookAroundRate",
88 "The percentage to try other rates (for legacy Minstrel)",
91 MakeUintegerChecker<uint8_t>(0, 100))
92 .AddAttribute (
"EWMA",
96 MakeUintegerChecker<uint8_t>(0, 100))
97 .AddAttribute (
"SampleColumn",
98 "The number of columns used for sampling",
101 MakeUintegerChecker <uint8_t> ())
102 .AddAttribute (
"PacketLength",
103 "The packet length used for calculating mode TxTime (bytes)",
106 MakeUintegerChecker <uint32_t> ())
107 .AddAttribute (
"UseVhtOnly",
108 "Use only VHT MCSs (and not HT) when VHT is available",
112 .AddAttribute (
"PrintStats",
113 "Control the printing of the statistics table",
117 .AddTraceSource (
"Rate",
118 "Traced value for rate changes (b/s)",
120 "ns3::TracedValueCallback::Uint64")
153 int64_t numStreamsAssigned = 0;
155 numStreamsAssigned++;
157 return numStreamsAssigned;
183 NS_FATAL_ERROR (
"WifiRemoteStationManager selected does not support HE rates");
217 for (uint16_t chWidth = 20; chWidth <=
MAX_HT_WIDTH; chWidth *= 2)
243 WifiMode mode = htMcsList[deviceIndex];
247 NS_LOG_DEBUG (
"Initialized group " << +groupId <<
": (" << +streams <<
"," << +
sgi <<
"," << chWidth <<
")");
256 for (uint16_t chWidth = 20; chWidth <=
MAX_VHT_WIDTH; chWidth *= 2)
289 NS_LOG_DEBUG (
"Initialized group " << +groupId <<
": (" << +streams <<
"," << +
sgi <<
"," << chWidth <<
")");
303 txvector.
SetNss (streams);
315 txvector.
SetNss (streams);
339 m_minstrelGroups[groupId].ratesFirstMpduTxTimeTable.insert (std::make_pair (mode, t));
355 m_minstrelGroups[groupId].ratesTxTimeTable.insert (std::make_pair (mode, t));
457 NS_LOG_DEBUG (
"DoReportRxOk m_txrate=" << static_cast<MinstrelHtWifiRemoteStation*> (st)->m_txrate);
516 station->
m_groupsTable[groupId].m_ratesTable[rateId].numRateAttempt++;
523 double dataSnr, uint16_t dataChannelWidth, uint8_t dataNss)
525 NS_LOG_FUNCTION (
this << st << ackSnr << ackMode << dataSnr << dataChannelWidth << +dataNss);
557 station->
m_groupsTable[groupId].m_ratesTable[rateId].numRateSuccess++;
558 station->
m_groupsTable[groupId].m_ratesTable[rateId].numRateAttempt++;
631 double rxSnr,
double dataSnr, uint16_t dataChannelWidth, uint8_t dataNss)
633 NS_LOG_FUNCTION (
this << st << +nSuccessfulMpdus << +nFailedMpdus << rxSnr << dataSnr << dataChannelWidth << +dataNss);
645 +nSuccessfulMpdus <<
" FailedMpdus=" << +nFailedMpdus);
648 station->
m_ampduLen += nSuccessfulMpdus + nFailedMpdus;
654 station->
m_groupsTable[groupId].m_ratesTable[rateId].numRateSuccess += nSuccessfulMpdus;
655 station->
m_groupsTable[groupId].m_ratesTable[rateId].numRateAttempt += nSuccessfulMpdus + nFailedMpdus;
736 station->
m_groupsTable[maxTp2GroupId].m_ratesTable[maxTp2RateId].retryCount))
744 station->
m_groupsTable[maxTp2GroupId].m_ratesTable[maxTp2RateId].retryCount +
745 station->
m_groupsTable[maxProbGroupId].m_ratesTable[maxProbRateId].retryCount))
769 station->
m_groupsTable[maxProbGroupId].m_ratesTable[maxProbRateId].retryCount)
793 NS_LOG_FUNCTION (
this << station << +nSuccessfulMpdus << +nFailedMpdus);
842 uint8_t mcsIndex = station->
m_groupsTable[groupId].m_ratesTable[rateId].mcsIndex;
844 NS_LOG_DEBUG (
"DoGetDataMode rateId= " << +rateId <<
" groupId= " << +groupId <<
" mode= " <<
GetMcsSupported (station, mcsIndex));
852 "," << +group.
sgi <<
"," << group.
chWidth <<
")" <<
863 return WifiTxVector (mode,
GetDefaultTxPowerLevel (),
GetPreambleForTransmission (mode.
GetModulationClass (),
GetShortPreambleEnabled (),
UseGreenfieldForDestination (
GetAddress (station))), group.
sgi ? 400 : 800,
GetNumberOfAntennas (), group.
streams,
GetNess (station),
GetChannelWidthForTransmission (mode, group.
chWidth),
GetAggregation (station) && !station->
m_isSampling,
false);
902 uint8_t mcsIndex = station->
m_groupsTable[groupId].m_ratesTable[rateId].mcsIndex;
909 bool rateFound =
false;
911 for (uint8_t i = 0; i < nBasicRates; i++)
914 if (rate <= lastDataRate)
924 uint8_t nSupportRates =
phy->GetNModes ();
925 for (uint8_t i = 0; i < nSupportRates; i++)
927 uint64_t rate =
phy->GetMode (i).GetDataRate (20);
928 if (rate <= lastDataRate)
930 rtsRate =
phy->GetMode (i);
969 NS_LOG_DEBUG (
"No re-transmission allowed. Retries: " << station->
m_longRetry <<
" Max retries: " << maxRetries);
991 return station->
m_groupsTable[maxTpGroupId].m_ratesTable[maxTpRateId].retryCount +
992 station->
m_groupsTable[maxTp2GroupId].m_ratesTable[maxTp2RateId].retryCount +
993 station->
m_groupsTable[maxProbGroupId].m_ratesTable[maxProbRateId].retryCount;
997 return 1 + station->
m_groupsTable[maxTpGroupId].m_ratesTable[maxTp2RateId].retryCount +
998 station->
m_groupsTable[maxProbGroupId].m_ratesTable[maxProbRateId].retryCount;
1007 uint8_t index = station->
m_groupsTable[sampleGroup].m_index;
1010 uint16_t rateIndex =
GetIndex (sampleGroup, sampleIndex);
1068 uint8_t sampleGroupId =
GetGroupId (sampleIdx);
1069 uint8_t sampleRateId =
GetRateId (sampleIdx);
1072 if (station->
m_groupsTable[sampleGroupId].m_supported && station->
m_groupsTable[sampleGroupId].m_ratesTable[sampleRateId].supported)
1084 " SampleRate= " << sampleIdx <<
" SampleProb= " << sampleRateInfo.
ewmaProb);
1105 Time maxTp2Duration = station->
m_groupsTable[maxTp2GroupId].m_ratesTable[maxTp2RateId].perfectTxTime;
1106 Time maxProbDuration = station->
m_groupsTable[maxProbGroupId].m_ratesTable[maxProbRateId].perfectTxTime;
1108 NS_LOG_DEBUG (
"Use sample rate? SampleDuration= " << sampleDuration <<
" maxTp2Duration= " << maxTp2Duration <<
1109 " maxProbDuration= " << maxProbDuration <<
" sampleStreams= " << +sampleStreams <<
1110 " maxTpStreams= " << +maxTpStreams);
1111 if (sampleDuration < maxTp2Duration || (sampleStreams < maxTpStreams && sampleDuration < maxProbDuration))
1119 NS_LOG_DEBUG (
"FindRate " <<
"sampleRate=" << sampleIdx);
1134 NS_LOG_DEBUG (
"FindRate " <<
"sampleRate=" << sampleIdx);
1193 station->
m_groupsTable[j].m_ratesTable[i].retryUpdated =
false;
1196 "\t attempt=" << station->
m_groupsTable[j].m_ratesTable[i].numRateAttempt <<
1197 "\t success=" << station->
m_groupsTable[j].m_ratesTable[i].numRateSuccess);
1200 if (station->
m_groupsTable[j].m_ratesTable[i].numRateAttempt > 0)
1202 station->
m_groupsTable[j].m_ratesTable[i].numSamplesSkipped = 0;
1207 tempProb = (100 * station->
m_groupsTable[j].m_ratesTable[i].numRateSuccess) / station->
m_groupsTable[j].m_ratesTable[i].numRateAttempt;
1212 if (station->
m_groupsTable[j].m_ratesTable[i].successHist == 0)
1214 station->
m_groupsTable[j].m_ratesTable[i].ewmaProb = tempProb;
1219 tempProb, station->
m_groupsTable[j].m_ratesTable[i].ewmaProb,
1223 station->
m_groupsTable[j].m_ratesTable[i].ewmaProb = tempProb;
1233 station->
m_groupsTable[j].m_ratesTable[i].numSamplesSkipped++;
1239 station->
m_groupsTable[j].m_ratesTable[i].numRateSuccess = 0;
1240 station->
m_groupsTable[j].m_ratesTable[i].numRateAttempt = 0;
1242 if (station->
m_groupsTable[j].m_ratesTable[i].throughput != 0)
1286 Time txTime = station->
m_groupsTable[groupId].m_ratesTable[rateId].perfectTxTime;
1303 uint8_t tmpGroupId, tmpRateId;
1304 double tmpTh, tmpProb;
1305 uint8_t groupId, rateId;
1308 uint8_t maxGPGroupId, maxGPRateId;
1318 tmpProb = station->
m_groupsTable[tmpGroupId].m_ratesTable[tmpRateId].ewmaProb;
1319 tmpTh = station->
m_groupsTable[tmpGroupId].m_ratesTable[tmpRateId].throughput;
1323 currentTh = station->
m_groupsTable[groupId].m_ratesTable[rateId].throughput;
1324 if (currentTh > tmpTh)
1331 maxGPTh = station->
m_groupsTable[maxGPGroupId].m_ratesTable[maxGPRateId].throughput;
1333 if (currentTh > maxGPTh)
1362 uint8_t groupId, rateId;
1364 uint8_t maxTpGroupId, maxTpRateId;
1365 uint8_t maxTp2GroupId, maxTp2RateId;
1366 double maxTpTh, maxTpProb;
1367 double maxTp2Th, maxTp2Prob;
1371 prob = station->
m_groupsTable[groupId].m_ratesTable[rateId].ewmaProb;
1372 th = station->
m_groupsTable[groupId].m_ratesTable[rateId].throughput;
1376 maxTpProb = station->
m_groupsTable[maxTpGroupId].m_ratesTable[maxTpRateId].ewmaProb;
1377 maxTpTh = station->
m_groupsTable[maxTpGroupId].m_ratesTable[maxTpRateId].throughput;
1381 maxTp2Prob = station->
m_groupsTable[maxTp2GroupId].m_ratesTable[maxTp2RateId].ewmaProb;
1382 maxTp2Th = station->
m_groupsTable[maxTp2GroupId].m_ratesTable[maxTp2RateId].throughput;
1384 if (th > maxTpTh || (th == maxTpTh && prob > maxTpProb))
1389 else if (th > maxTp2Th || (th == maxTp2Th && prob > maxTp2Prob))
1400 maxTpTh = station->
m_groupsTable[maxTpGroupId].m_ratesTable[maxTpRateId].throughput;
1404 maxTp2Prob = group->
m_ratesTable[maxTp2RateId].ewmaProb;
1405 maxTp2Th = station->
m_groupsTable[maxTp2GroupId].m_ratesTable[maxTp2RateId].throughput;
1407 if (th > maxTpTh || (th == maxTpTh && prob > maxTpProb))
1412 else if (th > maxTp2Th || (th == maxTp2Th && prob > maxTp2Prob))
1429 for (uint8_t groupId = 0; groupId <
m_numGroups; groupId++)
1450 station->
m_groupsTable[groupId].m_ratesTable[i].supported =
false;
1454 for (uint8_t i = 0; i < station->
m_nModes; i++)
1474 station->
m_groupsTable[groupId].m_ratesTable[rateId].supported =
true;
1475 station->
m_groupsTable[groupId].m_ratesTable[rateId].mcsIndex = i;
1476 station->
m_groupsTable[groupId].m_ratesTable[rateId].numRateAttempt = 0;
1477 station->
m_groupsTable[groupId].m_ratesTable[rateId].numRateSuccess = 0;
1478 station->
m_groupsTable[groupId].m_ratesTable[rateId].prob = 0;
1479 station->
m_groupsTable[groupId].m_ratesTable[rateId].ewmaProb = 0;
1480 station->
m_groupsTable[groupId].m_ratesTable[rateId].prevNumRateAttempt = 0;
1481 station->
m_groupsTable[groupId].m_ratesTable[rateId].prevNumRateSuccess = 0;
1482 station->
m_groupsTable[groupId].m_ratesTable[rateId].numSamplesSkipped = 0;
1483 station->
m_groupsTable[groupId].m_ratesTable[rateId].successHist = 0;
1484 station->
m_groupsTable[groupId].m_ratesTable[rateId].attemptHist = 0;
1485 station->
m_groupsTable[groupId].m_ratesTable[rateId].throughput = 0;
1487 station->
m_groupsTable[groupId].m_ratesTable[rateId].retryCount = 0;
1488 station->
m_groupsTable[groupId].m_ratesTable[rateId].adjustedRetryCount = 0;
1506 if (!station->
m_groupsTable[groupId].m_ratesTable[rateId].retryUpdated)
1518 uint32_t cwMax = 1023;
1519 Time cwTime, txTime, dataTxTime;
1523 if (station->
m_groupsTable[groupId].m_ratesTable[rateId].ewmaProb < 1)
1525 station->
m_groupsTable[groupId].m_ratesTable[rateId].retryCount = 1;
1529 station->
m_groupsTable[groupId].m_ratesTable[rateId].retryCount = 2;
1530 station->
m_groupsTable[groupId].m_ratesTable[rateId].retryUpdated =
true;
1536 cwTime = (cw / 2) * slotTime;
1537 cw =
Min ((cw + 1) * 2, cwMax);
1538 cwTime += (cw / 2) * slotTime;
1539 cw =
Min ((cw + 1) * 2, cwMax);
1542 txTime = cwTime + 2 * (dataTxTime + ackTime);
1548 cwTime = (cw / 2) * slotTime;
1549 cw =
Min ((cw + 1) * 2, cwMax);
1552 txTime += cwTime + ackTime + dataTxTime;
1555 && (++station->
m_groupsTable[groupId].m_ratesTable[rateId].retryCount < 7));
1562 double diff, incr, tmp;
1565 diff = currentProb - ewmaProb;
1566 incr = (100 - weight) * diff / 100;
1567 tmp = oldEwmsd * oldEwmsd;
1568 tmp = weight * (tmp + diff * incr) / 100;
1586 for (uint8_t i = 0; i < numSampleRates; i++ )
1593 newIndex = (i + uv) % numSampleRates;
1610 std::ostringstream tmp;
1612 station->
m_statsFile.open (tmp.str ().c_str (), std::ios::out);
1615 station->
m_statsFile <<
" best ____________rate__________ ________statistics________ ________last_______ ______sum-of________\n" <<
1616 " mode guard # rate [name idx airtime max_tp] [avg(tp) avg(prob) sd(prob)] [prob.|retry|suc|att] [#success | #attempts]\n";
1644 for (uint8_t i = 0; i < numRates; i++)
1650 of <<
"HT" << group.
chWidth <<
" " << giMode <<
"GI " << (int)group.
streams <<
" ";
1654 of <<
"VHT" << group.
chWidth <<
" " << giMode <<
"GI " << (int)group.
streams <<
" ";
1661 uint16_t idx =
GetIndex (groupId, i);
1662 if (idx == maxTpRate)
1670 if (idx == maxTpRate2)
1678 if (idx == maxProbRate)
1689 of << std::setw (4) <<
" MCS" << (group.
streams - 1) * 8 + i;
1693 of << std::setw (7) <<
" MCS" << +i <<
"/" << (int) group.
streams;
1696 of <<
" " << std::setw (3) << +idx <<
" ";
1703 std::setw (7) << station->
m_groupsTable[groupId].m_ratesTable[i].throughput / 100 <<
" " <<
1704 std::setw (7) << station->
m_groupsTable[groupId].m_ratesTable[i].ewmaProb <<
" " <<
1705 std::setw (7) << station->
m_groupsTable[groupId].m_ratesTable[i].ewmsdProb <<
" " <<
1706 std::setw (7) << station->
m_groupsTable[groupId].m_ratesTable[i].prob <<
" " <<
1707 std::setw (2) << station->
m_groupsTable[groupId].m_ratesTable[i].retryCount <<
" " <<
1708 std::setw (3) << station->
m_groupsTable[groupId].m_ratesTable[i].prevNumRateSuccess <<
" " <<
1709 std::setw (3) << station->
m_groupsTable[groupId].m_ratesTable[i].prevNumRateAttempt <<
" " <<
1710 std::setw (9) << station->
m_groupsTable[groupId].m_ratesTable[i].successHist <<
" " <<
1711 std::setw (9) << station->
m_groupsTable[groupId].m_ratesTable[i].attemptHist <<
"\n";
1759 uint8_t groupId = 0;
1761 while (groupId < m_numGroups && !station->m_groupsTable[groupId].m_supported)
1765 while (rateId < m_numRates && !station->m_groupsTable[groupId].m_ratesTable[rateId].supported)
1779 while (rateId < m_numRates && !station->m_groupsTable[groupId].m_ratesTable[rateId].supported)
1792 for (uint8_t i = 0; i <
phy->GetNMcs (); i++)
1797 vhtMcsList.push_back (mode);
1808 for (uint8_t i = 0; i <
phy->GetNMcs (); i++)
1813 htMcsList.push_back (mode);
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.
uint16_t m_maxProbRate
The highest success probability rate of this group in bps.
uint8_t GetNMcsSupported(Mac48Address address) const
Return the number of MCS supported by the station.
uint16_t m_maxProbRate
rate with highest probability of success in bps
uint8_t m_nSampleCol
Number of sample columns.
Simulation virtual time values and global simulation resolution.
Time GetMpduTxTime(uint8_t groupId, WifiMode mode) const
Obtain the TxTime saved in the group information.
bool GetVhtSupported(void) const
Return whether the device has VHT capability support enabled.
A struct to contain information of a group.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
WifiModeList GetVhtDeviceMcsList(void) const
Returns a list of only the VHT MCS supported by the device.
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
uint8_t m_sampleGroup
The group that the sample rate belongs to.
AttributeValue implementation for Boolean.
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
static const uint8_t MAX_SUPPORTED_STREAMS
Constants for maximum values.
TracedValue< uint64_t > m_currentRate
Trace rate changes.
uint8_t m_index
vector index
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
void SetChannelWidth(uint16_t channelWidth)
Sets the selected channelWidth (in MHz)
void PrintTable(MinstrelHtWifiRemoteStation *station)
Printing Minstrel Table.
uint16_t GetLowestIndex(MinstrelHtWifiRemoteStation *station)
Returns the lowest global index of the rates supported by the station.
uint8_t GetNumberOfAntennas(void) const
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...
void UpdatePacketCounters(MinstrelHtWifiRemoteStation *station, uint8_t nSuccessfulMpdus, uint8_t nFailedMpdus)
Update the number of sample count variables.
void SetBestProbabilityRate(MinstrelHtWifiRemoteStation *station, uint16_t index)
Set index rate as maxProbRate if it is better than current value.
uint16_t m_maxTpRate
the current throughput rate in bps
uint16_t m_txrate
current transmit rate in bps
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
MinstrelHtWifiRemoteStation structure.
uint16_t m_maxTpRate2
second highest throughput rate in bps
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
WifiTxVector DoGetDataTxVector(WifiRemoteStation *station)
hold per-remote-station state for Minstrel Wifi manager.
void CalculateRetransmits(MinstrelHtWifiRemoteStation *station, uint16_t index)
Calculate the number of retransmissions to set for the index rate.
uint32_t m_ampduPacketCount
Number of A-MPDUs transmitted.
static const uint8_t MAX_VHT_STREAM_GROUPS
Maximal number of groups per stream in VHT (4 possible channel widths and 2 possible SGI configuratio...
bool GetHeSupported(void) const
Return whether the device has HE capability support enabled.
#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.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
WifiRemoteStation * DoCreateStation(void) const
uint16_t m_sampleRate
current sample rate in bps
void SetStbc(bool stbc)
Sets if STBC is being used.
void DoReportFinalRtsFailed(WifiRemoteStation *station)
This method is a pure virtual method that must be implemented by the sub-class.
Mac48Address m_address
Mac48Address of the remote station.
HtMinstrelRate m_ratesTable
Information about rates of this group.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
uint8_t sgi
short guard interval (0 or 1)
uint16_t FindRate(MinstrelHtWifiRemoteStation *station)
Find a rate to use from Minstrel Table.
void DoReportRxOk(WifiRemoteStation *station, double rxSnr, WifiMode txMode)
This method is a pure virtual method that must be implemented by the sub-class.
MinstrelRate m_minstrelTable
minstrel table
WifiPreamble GetPreambleForTransmission(WifiModulationClass modulation, bool useShortPreamble, bool useGreenfield)
Return the preamble to be used for the transmission.
uint32_t m_frameLength
Frame length used for calculate modes TxTime in bytes.
MinstrelMcsGroups m_minstrelGroups
Global array for groups information.
bool m_isHt
If the station is HT capable.
bool m_sampleDeferred
a flag to indicate sample rate is on the second stage
std::vector< std::vector< uint8_t > > SampleRate
Data structure for a Sample Rate table A vector of a vector uint8_t.
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
std::vector< RateInfo > MinstrelRate
Data structure for a Minstrel Rate table A vector of a struct RateInfo.
bool DoNeedRetransmission(WifiRemoteStation *st, Ptr< const Packet > packet, bool normally)
uint8_t m_nModes
number of modes supported
uint8_t GetRateId(uint16_t index)
For managing rates from different groups, a global index for all rates in all groups is used...
WifiRemoteStationState * m_state
Remote station state.
bool m_printStats
If statistics table should be printed.
MpduType
The type of an MPDU.
uint16_t GetIndex(uint8_t groupId, uint8_t rateId)
Returns the global index corresponding to the groupId and rateId.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
uint8_t m_lookAroundRate
The % to try other rates than our current rate.
uint8_t m_ewmaLevel
Exponential weighted moving average level (or coefficient).
void SetBestStationThRates(MinstrelHtWifiRemoteStation *station, uint16_t index)
Set index rate as maxTpRate or maxTp2Rate if is better than current values.
Time GetFirstMpduTxTime(uint8_t groupId, WifiMode mode) const
Obtain the TxTime saved in the group information.
uint8_t GetNumberOfSupportedStreams(Mac48Address address) const
Return the number of spatial streams supported by the station.
bool GetShortPreambleEnabled(void) const
Return whether the device uses short PHY preambles.
int64x64_t Min(const int64x64_t &a, const int64x64_t &b)
Minimum.
The MPDU is the first aggregate in an A-MPDU with multiple MPDUs, but is not the last aggregate...
void DoReportAmpduTxStatus(WifiRemoteStation *station, uint8_t nSuccessfulMpdus, uint8_t nFailedMpdus, double rxSnr, double dataSnr, uint16_t dataChannelWidth, uint8_t dataNss)
Typically called per A-MPDU, either when a Block ACK was successfully received or when a BlockAckTime...
uint16_t chWidth
channel width (MHz)
bool m_isSampling
a flag to indicate we are currently sampling
WifiTxVector DoGetRtsTxVector(WifiRemoteStation *station)
bool IsValid(void) const
The standard disallows certain combinations of WifiMode, number of spatial streams, and channel widths.
AttributeValue implementation for Time.
SampleRate m_sampleTable
sample table
uint8_t m_col
To keep track of the current position in the our random sample table going row by row from 1st column...
void DoReportDataOk(WifiRemoteStation *station, double ackSnr, WifiMode ackMode, double dataSnr, uint16_t dataChannelWidth, uint8_t dataNss)
This method is a pure virtual method that must be implemented by the sub-class.
void SetGuardInterval(uint16_t guardInterval)
Sets the guard interval duration (in nanoseconds)
Hold an unsigned integer type.
static const uint8_t MAX_VHT_GROUP_RATES
Number of rates (or MCS) per VHT group.
static const uint8_t MAX_HT_WIDTH
Maximal channel width in MHz.
virtual ~MinstrelHtWifiManager()
bool GetHtSupported(void) const
Return whether the device has HT capability support enabled.
The MPDU is part of an A-MPDU with multiple MPDUs, but is neither the first nor the last aggregate...
int64x64_t Max(const int64x64_t &a, const int64x64_t &b)
Maximum.
static const uint8_t MAX_HT_STREAM_GROUPS
Maximal number of groups per stream in HT (2 possible channel widths and 2 possible SGI configuration...
WifiMode GetMode(void) const
static Time GetPayloadDuration(uint32_t size, WifiTxVector txVector, WifiPhyBand band, MpduType mpdutype=NORMAL_MPDU)
uint32_t m_sampleWait
How many transmission attempts to wait until a new sample.
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...
Ptr< UniformRandomVariable > m_uniformRandomVariable
Provides uniform random variables.
hold a list of per-remote-station state.
WifiModulationClass GetModulationClass() const
bool m_useVhtOnly
If only VHT MCS should be used, instead of HT and VHT.
std::vector< struct GroupInfo > McsGroupData
Data structure for a table of groups.
uint32_t m_longRetry
long retries such as data packets
static TypeId GetTypeId(void)
Get the type ID.
static const uint8_t MAX_VHT_WIDTH
Maximal channel width in MHz.
uint32_t m_ampduLen
Number of MPDUs in an A-MPDU.
void SetNss(uint8_t nss)
Sets the number of Nss refer to IEEE 802.11n Table 20-28 for explanation and range.
bool m_initialized
for initializing tables
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
Time GetBlockAckTxTime(void) const
Return the estimated BlockAck TX time for this PHY.
int64_t GetMicroSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
uint16_t GetNextSample(MinstrelHtWifiRemoteStation *station)
Getting the next sample from Sample Table.
uint16_t m_maxTpRate2
The second max throughput rate of this group in bps.
double ewmaProb
Exponential weighted moving average of probability.
Time perfectTxTime
Perfect transmission time calculation, or frame calculation.
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.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint8_t m_numRates
Number of rates per group Minstrel should consider.
void InitSampleTable(MinstrelHtWifiRemoteStation *station)
Initialize Sample Table.
void SetPreambleType(WifiPreamble preamble)
Sets the preamble type.
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 DoReportRtsFailed(WifiRemoteStation *station)
This method is a pure virtual method that must be implemented by the sub-class.
void UpdateRetry(MinstrelHtWifiRemoteStation *station)
Update the number of retries and reset accordingly.
uint32_t m_sampleCount
Max number of samples per update interval.
void DoReportFinalDataFailed(WifiRemoteStation *station)
This method is a pure virtual method that must be implemented by the sub-class.
uint16_t GetChannelWidthForTransmission(WifiMode mode, uint16_t maxSupportedChannelWidth)
Return the channel width that corresponds to the selected mode (instead of letting the PHY's default ...
uint8_t m_numGroups
Number of groups Minstrel should consider.
bool UseGreenfieldForDestination(Mac48Address dest) const
Time m_updateStats
How frequent do we calculate the stats (1/10 seconds).
static const uint8_t MAX_HT_GROUP_RATES
Number of rates (or MCS) per HT group.
Mac48Address GetAddress(const WifiRemoteStation *station) const
Return the address of the station.
void DoReportDataFailed(WifiRemoteStation *station)
This method is a pure virtual method that must be implemented by the sub-class.
void UpdateStats(MinstrelHtWifiRemoteStation *station)
Update the Minstrel Table every 1/10 seconds.
McsGroupData m_groupsTable
Table of groups with stats.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
std::vector< WifiMode > WifiModeList
In various parts of the code, folk are interested in maintaining a list of transmission modes...
uint16_t m_maxTpRate
The max throughput rate of this group in bps.
bool GetShortGuardIntervalSupported(void) const
Return whether the device has SGI support enabled.
static Time Now(void)
Return the current simulation virtual time.
std::vector< HtRateInfo > HtMinstrelRate
Data structure for a Minstrel Rate table.
std::ofstream m_statsFile
File where statistics table is written.
void RateInit(MinstrelHtWifiRemoteStation *station)
Initialize Minstrel Table.
int m_totalPacketsCount
total number of packets as of now
bool GetAggregation(const WifiRemoteStation *station) const
Return whether the given station supports A-MPDU.
Implementation of Minstrel HT Rate Control AlgorithmMinstrel-HT is a rate adaptation mechanism for th...
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...
void SetMode(WifiMode mode)
Sets the selected payload transmission mode.
Data structure to contain the information that defines a group.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
void DoInitialize(void)
Initialize() implementation.
uint8_t GetNBasicModes(void) const
Return the number of basic modes we support.
void StatsDump(MinstrelHtWifiRemoteStation *station, uint8_t groupId, std::ofstream &of)
Print group statistics.
uint64_t GetNonHtReferenceRate(void) const
int m_samplePacketsCount
how many packets we have sample so far
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...
Ptr< WifiPhy > GetPhy(void) const
Return the WifiPhy.
uint8_t GetVhtGroupId(uint8_t txstreams, uint8_t sgi, uint16_t chWidth)
Returns the groupId of a VHT MCS with the given number of streams, if using SGI and the channel width...
double CalculateEwmsd(double oldEwmsd, double currentProb, double ewmaProb, double weight)
Perform EWMSD (Exponentially Weighted Moving Standard Deviation) calculation.
Time GetSifs(void) const
Return the Short Interframe Space (SIFS) for this PHY.
std::vector< McsGroup > MinstrelMcsGroups
Data structure for a table of group definitions.
void AddMpduTxTime(uint8_t groupId, WifiMode mode, Time t)
Save a TxTime to the vector of groups.
A struct to contain all statistics information related to a data rate.
void SetNextSample(MinstrelHtWifiRemoteStation *station)
Set the next sample from Sample Table.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
WifiModeList GetHtDeviceMcsList(void) const
Returns a list of only the HT MCS supported by the device.
uint32_t m_numSamplesSlow
Number of times a slow rate was sampled.
Ptr< const AttributeChecker > MakeBooleanChecker(void)
Ptr< MinstrelWifiManager > m_legacyManager
Pointer to an instance of MinstrelWifiManager.
uint32_t numSamplesSkipped
Number of times this rate statistics were not updated because no attempts have been made...
Time GetSlot(void) const
Return the slot duration for this PHY.
uint8_t GetDefaultTxPowerLevel(void) const
uint32_t m_sampleTries
Number of sample tries after waiting sampleWait.
uint8_t GetHtGroupId(uint8_t txstreams, uint8_t sgi, uint16_t chWidth)
Returns the groupId of a HT MCS with the given number of streams, if using SGI and the channel width ...
void SetNess(uint8_t ness)
Sets the Ness number refer to IEEE 802.11n Table 20-6 for explanation.
uint8_t GetGroupId(uint16_t index)
Return the groupId from the global index.
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Time CalculateMpduTxDuration(Ptr< WifiPhy > phy, uint8_t streams, uint8_t sgi, 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...
uint32_t m_avgAmpduLen
Average number of MPDUs in an A-MPDU.
uint32_t CountRetries(MinstrelHtWifiRemoteStation *station)
Count retries.
void UpdateRate(MinstrelHtWifiRemoteStation *station)
Update rate.
uint32_t m_shortRetry
short retries such as control packets
WifiMode GetBasicMode(uint8_t i) const
Return a basic mode from the set of basic modes.
uint8_t GetMcsValue(void) const
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
void AddFirstMpduTxTime(uint8_t groupId, WifiMode mode, Time t)
Save a TxTime to the vector of groups.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
void CheckInit(MinstrelHtWifiRemoteStation *station)
Check for initializations.
hold per-remote-station state.
uint64_t GetDataRate(uint16_t channelWidth, uint16_t guardInterval, uint8_t nss) const
WifiMode GetMcsSupported(const WifiRemoteStation *station, uint8_t i) const
Return the WifiMode supported by the specified station at the specified index.
uint16_t GetChannelWidth(const WifiRemoteStation *station) const
Return the channel width supported by the station.
uint8_t GetNess(const WifiRemoteStation *station) const
static Time CalculatePhyPreambleAndHeaderDuration(WifiTxVector txVector)
Time m_nextStatsUpdate
10 times every second