11#include "ns3/ht-configuration.h"
13#include "ns3/wifi-net-device.h"
14#include "ns3/wifi-phy.h"
51 TypeId(
"ns3::IdealWifiManager")
55 .AddAttribute(
"BerThreshold",
56 "The maximum Bit Error Rate acceptable at any transmission mode",
60 .AddTraceSource(
"Rate",
61 "Traced value for rate changes (b/s)",
63 "ns3::TracedValueCallback::Uint64");
123 if (
GetPhy()->GetDevice()->GetHtConfiguration())
132 const auto guardInterval =
138 <<
" nss " << +nss <<
" GI " << guardInterval);
145 Time guardInterval{};
160 <<
" channel width " << j <<
" nss " << +k
161 <<
" GI " << guardInterval);
183 [&txVector](
const std::pair<double, WifiTxVector>& p) ->
bool {
184 return ((txVector.GetMode() == p.second.GetMode()) &&
185 (txVector.GetNss() == p.second.GetNss()) &&
186 (txVector.GetChannelWidth() == p.second.GetChannelWidth()));
194 [&txVector](
const std::pair<double, WifiTxVector>& p) ->
bool {
195 return ((txVector.GetMode() == p.second.GetMode()) &&
196 (txVector.GetNss() == p.second.GetNss()) &&
197 (txVector.GetChannelWidth() == p.second.GetChannelWidth()));
227 st->m_lastChannelWidthObserved = 0;
228 st->m_lastNssObserved = 1;
231 st->m_lastChannelWidth = 0;
262 station->m_lastChannelWidthObserved =
264 station->m_lastNssObserved = 1;
272 MHz_u dataChannelWidth,
280 NS_LOG_WARN(
"DataSnr reported to be zero; not saving this report.");
283 station->m_lastSnrObserved = dataSnr;
284 station->m_lastChannelWidthObserved = dataChannelWidth;
285 station->m_lastNssObserved = dataNss;
290 uint16_t nSuccessfulMpdus,
291 uint16_t nFailedMpdus,
294 MHz_u dataChannelWidth,
297 NS_LOG_FUNCTION(
this << st << nSuccessfulMpdus << nFailedMpdus << rxSnr << dataSnr
298 << dataChannelWidth << +dataNss);
302 NS_LOG_WARN(
"DataSnr reported to be zero; not saving this report.");
305 station->m_lastSnrObserved = dataSnr;
306 station->m_lastChannelWidthObserved = dataChannelWidth;
307 station->m_lastNssObserved = dataNss;
334 uint64_t bestRate = 0;
335 uint8_t selectedNss = 1;
336 Time guardInterval{};
337 const auto channelWidth = std::min(
GetChannelWidth(station), allowedWidth);
340 (station->m_lastSnrObserved == station->m_lastSnrCached) &&
341 (channelWidth == station->m_lastChannelWidth))
344 maxMode = station->m_lastMode;
345 selectedNss = station->m_lastNss;
347 << station->m_lastSnrObserved <<
" cached "
348 << station->m_lastSnrCached <<
" channel width "
349 << station->m_lastChannelWidth <<
" nss "
354 if (
GetPhy()->GetDevice()->GetHtConfiguration() &&
365 Time guardInterval{};
381 uint8_t nss = (mode.GetMcsValue() / 8) + 1;
386 NS_LOG_DEBUG(
"Skipping mode " << mode.GetUniqueName() <<
" nss " << +nss
394 NS_LOG_DEBUG(
"Testing mode " << mode.GetUniqueName() <<
" data rate "
395 << dataRate <<
" threshold " << threshold
396 <<
" last snr observed "
397 << station->m_lastSnrObserved <<
" cached "
398 << station->m_lastSnrCached);
400 if (dataRate > bestRate && threshold < snr)
402 NS_LOG_DEBUG(
"Candidate mode = " << mode.GetUniqueName() <<
" data rate "
403 << dataRate <<
" threshold " << threshold
404 <<
" channel width " << channelWidth
420 NS_LOG_DEBUG(
"Skipping mode " << mode.GetUniqueName() <<
" nss " << +nss
429 NS_LOG_DEBUG(
"Testing mode = " << mode.GetUniqueName() <<
" data rate "
430 << dataRate <<
" threshold " << threshold
431 <<
" last snr observed "
432 << station->m_lastSnrObserved <<
" cached "
433 << station->m_lastSnrCached);
435 if (dataRate > bestRate && threshold < snr)
438 << mode.GetUniqueName() <<
" data rate " << dataRate
439 <<
" threshold " << threshold <<
" channel width "
440 << channelWidth <<
" snr " << snr);
457 txVector.
SetNss(selectedNss);
464 NS_LOG_DEBUG(
"mode = " << mode.GetUniqueName() <<
" threshold " << threshold
465 <<
" last snr observed " << station->m_lastSnrObserved);
467 if (dataRate > bestRate && threshold < snr)
469 NS_LOG_DEBUG(
"Candidate mode = " << mode.GetUniqueName() <<
" data rate "
470 << dataRate <<
" threshold " << threshold
478 << station->m_lastSnrObserved);
479 station->m_lastSnrCached = station->m_lastSnrObserved;
480 station->m_lastMode = maxMode;
481 station->m_lastNss = selectedNss;
483 NS_LOG_DEBUG(
"Found maxMode: " << maxMode <<
" channelWidth: " << channelWidth
484 <<
" nss: " << +selectedNss);
485 station->m_lastChannelWidth = channelWidth;
509 uint64_t maxDataRate = maxMode.
GetDataRate(bestTxVector);
526 double maxThreshold = 0.0;
539 if (threshold > maxThreshold && threshold < station->m_lastSnrObserved)
541 maxThreshold = threshold;
574 << snr <<
" for channel width " << channelWidth
575 <<
" and nss " << +nss);
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Ideal rate control algorithm.
void DoReportFinalRtsFailed(WifiRemoteStation *station) override
This method is a pure virtual method that must be implemented by the sub-class.
void AddSnrThreshold(WifiTxVector txVector, double snr)
Adds a pair of WifiTxVector and the minimum SNR for that given vector to the list.
void BuildSnrThresholds()
Construct the vector of minimum SNRs needed to successfully transmit for all possible combinations (r...
void DoReportDataOk(WifiRemoteStation *station, double ackSnr, WifiMode ackMode, double dataSnr, MHz_u dataChannelWidth, uint8_t dataNss) override
This method is a pure virtual method that must be implemented by the sub-class.
WifiTxVector DoGetRtsTxVector(WifiRemoteStation *station) override
void DoInitialize() override
Initialize() implementation.
double m_ber
The maximum Bit Error Rate acceptable at any transmission mode.
WifiRemoteStation * DoCreateStation() const override
MHz_u GetChannelWidthForNonHtMode(WifiMode mode) const
Convenience function for selecting a channel width for non-HT mode.
~IdealWifiManager() override
void DoReportRtsFailed(WifiRemoteStation *station) override
This method is a pure virtual method that must be implemented by the sub-class.
static TypeId GetTypeId()
Get the type ID.
double GetLastObservedSnr(IdealWifiRemoteStation *station, MHz_u channelWidth, uint8_t nss) const
Convenience function to get the last observed SNR from a given station for a given channel width and ...
void DoReportAmpduTxStatus(WifiRemoteStation *station, uint16_t nSuccessfulMpdus, uint16_t nFailedMpdus, double rxSnr, double dataSnr, MHz_u dataChannelWidth, uint8_t dataNss) override
Typically called per A-MPDU, either when a Block ACK was successfully received or when a BlockAckTime...
bool IsModulationClassSupported(WifiModulationClass mc, IdealWifiRemoteStation *station)
Check whether a given modulation class is supported by both the node and the peer.
bool IsCandidateModulationClass(WifiModulationClass mc, IdealWifiRemoteStation *station)
Check whether a given modulation class is supported and that there are no higher modulation classes t...
WifiTxVector DoGetDataTxVector(WifiRemoteStation *station, MHz_u allowedWidth) override
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...
TracedValue< uint64_t > m_currentRate
Trace rate changes.
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.
Thresholds m_thresholds
List of WifiTxVector and the minimum SNR pair.
void DoReportRxOk(WifiRemoteStation *station, double rxSnr, WifiMode txMode) override
This method is a pure virtual method that must be implemented by the sub-class.
double GetSnrThreshold(WifiTxVector txVector)
Return the minimum SNR needed to successfully transmit data with this WifiTxVector at the specified B...
void DoReportDataFailed(WifiRemoteStation *station) override
This method is a pure virtual method that must be implemented by the sub-class.
void DoReportFinalDataFailed(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.
Simulation virtual time values and global simulation resolution.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
represent a single transmission mode
const std::string & GetUniqueName() const
WifiModulationClass GetModulationClass() const
uint64_t GetDataRate(MHz_u channelWidth, Time guardInterval, uint8_t nss) const
bool IsAllowed(MHz_u channelWidth, uint8_t nss) const
uint8_t GetMcsValue() const
MHz_u GetTxBandwidth(WifiMode mode, MHz_u maxAllowedBandWidth=std::numeric_limits< MHz_u >::max()) const
Get the bandwidth for a transmission occurring on the current operating channel and using the given W...
MHz_u GetChannelWidth() const
uint8_t GetMaxSupportedTxSpatialStreams() const
std::list< WifiMode > GetMcsList() const
The WifiPhy::GetMcsList() method is used (e.g., by a WifiRemoteStationManager) to determine the set o...
std::list< WifiMode > GetModeList() const
The WifiPhy::GetModeList() method is used (e.g., by a WifiRemoteStationManager) to determine the set ...
hold a list of per-remote-station state.
uint8_t GetNumberOfSupportedStreams(Mac48Address address) const
Return the number of spatial streams supported by the station.
WifiMode GetDefaultModeForSta(const WifiRemoteStation *st) const
Return the default MCS to use to transmit frames to the given station.
uint8_t GetNBasicModes() const
Return the number of basic modes we support.
Time GetGuardInterval() const
Return the supported HE guard interval duration.
uint8_t GetDefaultTxPowerLevel() const
uint8_t GetNSupported(const WifiRemoteStation *station) const
Return the number of modes supported by the given station.
Ptr< WifiPhy > GetPhy() const
Return the WifiPhy.
MHz_u GetChannelWidth(const WifiRemoteStation *station) const
Return the channel width supported by the station.
Ptr< const He6GhzBandCapabilities > GetStationHe6GhzCapabilities(const Mac48Address &from) const
Return the HE 6 GHz Band Capabilities sent by a remote station.
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 on the link this manager is associated wi...
bool GetEhtSupported() const
Return whether the device has EHT 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...
uint8_t GetMaxNumberOfTransmitStreams() const
WifiMode GetMcsSupported(const WifiRemoteStation *station, uint8_t i) const
Return the WifiMode supported by the specified station at the specified index.
void Reset()
Reset the station, invoked in a STA upon dis-association or in an AP upon reboot.
bool GetVhtSupported() const
Return whether the device has VHT capability support enabled on the link this manager is associated w...
bool GetShortPreambleEnabled() const
Return whether the device uses short PHY preambles.
WifiMode GetSupported(const WifiRemoteStation *station, uint8_t i) const
Return whether mode associated with the specified station at the specified index.
bool GetHeSupported() const
Return whether the device has HE capability support enabled.
WifiMode GetDefaultMode() const
Return the default transmission mode.
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
void SetGuardInterval(Time guardInterval)
Sets the guard interval duration (in nanoseconds)
bool IsValid(WifiPhyBand band=WIFI_PHY_BAND_UNSPECIFIED) const
The standard disallows certain combinations of WifiMode, number of spatial streams,...
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 SetChannelWidth(MHz_u channelWidth)
Sets the selected channelWidth.
uint8_t GetNss(uint16_t staId=SU_STA_ID) const
If this TX vector is associated with an SU PPDU, return the number of spatial streams.
MHz_u GetChannelWidth() const
Time GetGuardInterval() const
void SetMode(WifiMode mode)
Sets the selected payload transmission mode.
void SetNss(uint8_t nss)
Sets the number of Nss.
#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...
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination 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_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Time NanoSeconds(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.
WifiModulationClass
This enumeration defines the modulation classes per (Table 10-6 "Modulation classes"; IEEE 802....
@ WIFI_MOD_CLASS_HR_DSSS
HR/DSSS (Clause 16)
@ WIFI_MOD_CLASS_HT
HT (Clause 19)
@ WIFI_MOD_CLASS_EHT
EHT (Clause 36)
@ WIFI_MOD_CLASS_VHT
VHT (Clause 22)
@ WIFI_MOD_CLASS_HE
HE (Clause 27)
@ WIFI_MOD_CLASS_DSSS
DSSS (Clause 15)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static const double CACHE_INITIAL_VALUE
To avoid using the cache before a valid value has been cached.
Ptr< const AttributeChecker > MakeDoubleChecker()
double MHz_u
MHz weak type.
WifiPreamble GetPreambleForTransmission(WifiModulationClass modulation, bool useShortPreamble)
Return the preamble to be used for the transmission.
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
hold per-remote-station state for Ideal Wifi manager.
WifiMode m_lastMode
Mode most recently used to the remote station.
double m_lastSnrObserved
SNR of most recently reported packet sent to the remote station.
double m_lastSnrCached
SNR most recently used to select a rate.
MHz_u m_lastChannelWidth
Channel width most recently used to the remote station.
MHz_u m_lastChannelWidthObserved
Channel width of most recently reported packet sent to the remote station.
uint8_t m_lastNss
Number of spatial streams most recently used to the remote station.
uint16_t m_lastNssObserved
Number of spatial streams of most recently reported packet sent to the remote station.
hold per-remote-station state.
WifiRemoteStationState * m_state
Remote station state.
Mac48Address m_address
Mac48Address of the remote station.