wifi: WifiMac holds per-link DSSS and ERP supported flags

This commit is contained in:
Stefano Avallone
2022-03-06 17:39:01 +01:00
parent ce13d31474
commit f6946d8d56
5 changed files with 115 additions and 110 deletions

View File

@@ -225,7 +225,7 @@ void
ApWifiMac::UpdateShortSlotTimeEnabled (void)
{
NS_LOG_FUNCTION (this);
if (GetErpSupported () && GetShortSlotTimeSupported () && (m_numNonErpStations == 0))
if (GetErpSupported (SINGLE_LINK_OP_ID) && GetShortSlotTimeSupported () && (m_numNonErpStations == 0))
{
for (const auto& sta : m_staList)
{
@@ -247,7 +247,7 @@ void
ApWifiMac::UpdateShortPreambleEnabled (void)
{
NS_LOG_FUNCTION (this);
if (GetErpSupported () && GetWifiPhy ()->GetShortPhyPreambleSupported ())
if (GetErpSupported (SINGLE_LINK_OP_ID) && GetWifiPhy ()->GetShortPhyPreambleSupported ())
{
for (const auto& sta : m_staList)
{
@@ -427,7 +427,7 @@ ApWifiMac::GetDsssParameterSet (void) const
{
NS_LOG_FUNCTION (this);
DsssParameterSet dsssParameters;
if (GetDsssSupported ())
if (GetDsssSupported (SINGLE_LINK_OP_ID))
{
dsssParameters.SetDsssSupported (1);
dsssParameters.SetCurrentChannel (GetWifiPhy ()->GetChannelNumber ());
@@ -452,7 +452,7 @@ ApWifiMac::GetErpInformation (void) const
NS_LOG_FUNCTION (this);
ErpInformation information;
information.SetErpSupported (1);
if (GetErpSupported ())
if (GetErpSupported (SINGLE_LINK_OP_ID))
{
information.SetNonErpPresent (m_numNonErpStations > 0);
information.SetUseProtection (GetUseNonErpProtection ());
@@ -751,11 +751,11 @@ ApWifiMac::SendProbeResp (Mac48Address to)
probe.SetCapabilities (GetCapabilities ());
GetWifiRemoteStationManager ()->SetShortPreambleEnabled (m_shortPreambleEnabled);
GetWifiRemoteStationManager ()->SetShortSlotTimeEnabled (m_shortSlotTimeEnabled);
if (GetDsssSupported ())
if (GetDsssSupported (SINGLE_LINK_OP_ID))
{
probe.SetDsssParameterSet (GetDsssParameterSet ());
}
if (GetErpSupported ())
if (GetErpSupported (SINGLE_LINK_OP_ID))
{
probe.SetErpInformation (GetErpInformation ());
}
@@ -864,7 +864,7 @@ ApWifiMac::SendAssocResp (Mac48Address to, bool success, bool isReassoc)
assoc.SetSupportedRates (GetSupportedRates ());
assoc.SetStatusCode (code);
assoc.SetCapabilities (GetCapabilities ());
if (GetErpSupported ())
if (GetErpSupported (SINGLE_LINK_OP_ID))
{
assoc.SetErpInformation (GetErpInformation ());
}
@@ -935,11 +935,11 @@ ApWifiMac::SendOneBeacon (void)
beacon.SetCapabilities (GetCapabilities ());
GetWifiRemoteStationManager ()->SetShortPreambleEnabled (m_shortPreambleEnabled);
GetWifiRemoteStationManager ()->SetShortSlotTimeEnabled (m_shortSlotTimeEnabled);
if (GetDsssSupported ())
if (GetDsssSupported (SINGLE_LINK_OP_ID))
{
beacon.SetDsssParameterSet (GetDsssParameterSet ());
}
if (GetErpSupported ())
if (GetErpSupported (SINGLE_LINK_OP_ID))
{
beacon.SetErpInformation (GetErpInformation ());
}
@@ -977,7 +977,7 @@ ApWifiMac::SendOneBeacon (void)
//If a STA that does not support Short Slot Time associates,
//the AP shall use long slot time beginning at the first Beacon
//subsequent to the association of the long slot time STA.
if (GetErpSupported ())
if (GetErpSupported (SINGLE_LINK_OP_ID))
{
if (m_shortSlotTimeEnabled)
{
@@ -1210,7 +1210,7 @@ ApWifiMac::Receive (Ptr<WifiMacQueueItem> mpdu)
GetWifiRemoteStationManager ()->AddSupportedMode (from, mode);
}
}
if (GetErpSupported () && GetWifiRemoteStationManager ()->GetErpOfdmSupported (from) && capabilities.IsShortSlotTime ())
if (GetErpSupported (SINGLE_LINK_OP_ID) && GetWifiRemoteStationManager ()->GetErpOfdmSupported (from) && capabilities.IsShortSlotTime ())
{
GetWifiRemoteStationManager ()->AddSupportedErpSlotTime (from, true);
}
@@ -1366,7 +1366,7 @@ ApWifiMac::Receive (Ptr<WifiMacQueueItem> mpdu)
GetWifiRemoteStationManager ()->AddSupportedMode (from, mode);
}
}
if (GetErpSupported () && GetWifiRemoteStationManager ()->GetErpOfdmSupported (from) && capabilities.IsShortSlotTime ())
if (GetErpSupported (SINGLE_LINK_OP_ID) && GetWifiRemoteStationManager ()->GetErpOfdmSupported (from) && capabilities.IsShortSlotTime ())
{
GetWifiRemoteStationManager ()->AddSupportedErpSlotTime (from, true);
}

View File

@@ -789,7 +789,7 @@ StaWifiMac::UpdateApInfoFromBeacon (MgtBeaconHeader beacon, Mac48Address apAddr,
}
}
bool isShortPreambleEnabled = capabilities.IsShortPreamble ();
if (GetErpSupported ())
if (GetErpSupported (SINGLE_LINK_OP_ID))
{
const ErpInformation& erpInformation = beacon.GetErpInformation ();
isShortPreambleEnabled &= !erpInformation.GetBarkerPreambleMode ();
@@ -925,7 +925,7 @@ StaWifiMac::UpdateApInfoFromProbeResp (MgtProbeResponseHeader probeResp, Mac48Ad
}
bool isShortPreambleEnabled = capabilities.IsShortPreamble ();
if (GetErpSupported ())
if (GetErpSupported (SINGLE_LINK_OP_ID))
{
bool isErpAllowed = false;
for (const auto & mode : GetWifiPhy ()->GetModeList (WIFI_MOD_CLASS_ERP_OFDM))
@@ -971,7 +971,7 @@ StaWifiMac::UpdateApInfoFromAssocResp (MgtAssocResponseHeader assocResp, Mac48Ad
const CapabilityInformation& capabilities = assocResp.GetCapabilities ();
const SupportedRates& rates = assocResp.GetSupportedRates ();
bool isShortPreambleEnabled = capabilities.IsShortPreamble ();
if (GetErpSupported ())
if (GetErpSupported (SINGLE_LINK_OP_ID))
{
bool isErpAllowed = false;
for (const auto & mode : GetWifiPhy ()->GetModeList (WIFI_MOD_CLASS_ERP_OFDM))
@@ -1156,8 +1156,8 @@ CapabilityInformation
StaWifiMac::GetCapabilities (void) const
{
CapabilityInformation capabilities;
capabilities.SetShortPreamble (GetWifiPhy ()->GetShortPhyPreambleSupported () || GetErpSupported ());
capabilities.SetShortSlotTime (GetShortSlotTimeSupported () && GetErpSupported ());
capabilities.SetShortPreamble (GetWifiPhy ()->GetShortPhyPreambleSupported () || GetErpSupported (SINGLE_LINK_OP_ID));
capabilities.SetShortSlotTime (GetShortSlotTimeSupported () && GetErpSupported (SINGLE_LINK_OP_ID));
return capabilities;
}

View File

@@ -44,9 +44,7 @@ NS_LOG_COMPONENT_DEFINE ("WifiMac");
NS_OBJECT_ENSURE_REGISTERED (WifiMac);
WifiMac::WifiMac ()
: m_qosSupported (false),
m_erpSupported (false),
m_dsssSupported (false)
: m_qosSupported (false)
{
NS_LOG_FUNCTION (this);
@@ -577,7 +575,12 @@ WifiMac::SetupEdcaQueue (AcIndex ac)
void
WifiMac::ConfigureContentionWindow (uint32_t cwMin, uint32_t cwMax)
{
bool isDsssOnly = GetDsssSupported () && !GetErpSupported ();
std::list<bool> isDsssOnly;
for (const auto& link : m_links)
{
isDsssOnly.push_back (link->dsssSupported && !link->erpSupported);
}
if (m_txop != nullptr)
{
//The special value of AC_BE_NQOS which exists in the Access
@@ -593,55 +596,53 @@ WifiMac::ConfigureContentionWindow (uint32_t cwMin, uint32_t cwMax)
}
void
WifiMac::ConfigureDcf (Ptr<Txop> dcf, uint32_t cwmin, uint32_t cwmax, bool isDsss, AcIndex ac)
WifiMac::ConfigureDcf (Ptr<Txop> dcf, uint32_t cwmin, uint32_t cwmax,
std::list<bool> isDsss, AcIndex ac)
{
NS_LOG_FUNCTION (this << dcf << cwmin << cwmax << isDsss << +ac);
/* see IEEE 802.11 section 7.3.2.29 */
NS_LOG_FUNCTION (this << dcf << cwmin << cwmax << +ac);
uint32_t cwMinValue = 0;
uint32_t cwMaxValue = 0;
uint8_t aifsnValue = 0;
Time txopLimitDsss (0);
Time txopLimitNoDsss (0);
/* see IEEE 802.11-2020 Table 9-155 "Default EDCA Parameter Set element parameter values" */
switch (ac)
{
case AC_VO:
dcf->SetMinCw ((cwmin + 1) / 4 - 1, SINGLE_LINK_OP_ID);
dcf->SetMaxCw ((cwmin + 1) / 2 - 1, SINGLE_LINK_OP_ID);
dcf->SetAifsn (2, SINGLE_LINK_OP_ID);
if (isDsss)
{
dcf->SetTxopLimit (MicroSeconds (3264), SINGLE_LINK_OP_ID);
}
else
{
dcf->SetTxopLimit (MicroSeconds (1504), SINGLE_LINK_OP_ID);
}
cwMinValue = (cwmin + 1) / 4 - 1;
cwMaxValue = (cwmin + 1) / 2 - 1;
aifsnValue = 2;
txopLimitDsss = MicroSeconds (3264);
txopLimitNoDsss = MicroSeconds (1504); // TODO should be MicroSeconds (2080)
break;
case AC_VI:
dcf->SetMinCw ((cwmin + 1) / 2 - 1, SINGLE_LINK_OP_ID);
dcf->SetMaxCw (cwmin, SINGLE_LINK_OP_ID);
dcf->SetAifsn (2, SINGLE_LINK_OP_ID);
if (isDsss)
{
dcf->SetTxopLimit (MicroSeconds (6016), SINGLE_LINK_OP_ID);
}
else
{
dcf->SetTxopLimit (MicroSeconds (3008), SINGLE_LINK_OP_ID);
}
cwMinValue = (cwmin + 1) / 2 - 1;
cwMaxValue = cwmin;
aifsnValue = 2;
txopLimitDsss = MicroSeconds (6016);
txopLimitNoDsss = MicroSeconds (3008); // TODO should be MicroSeconds (4096)
break;
case AC_BE:
dcf->SetMinCw (cwmin, SINGLE_LINK_OP_ID);
dcf->SetMaxCw (cwmax, SINGLE_LINK_OP_ID);
dcf->SetAifsn (3, SINGLE_LINK_OP_ID);
dcf->SetTxopLimit (MicroSeconds (0), SINGLE_LINK_OP_ID);
cwMinValue = cwmin;
cwMaxValue = cwmax;
aifsnValue = 3;
txopLimitDsss = MicroSeconds (0); // TODO should be MicroSeconds (3264)
txopLimitNoDsss = MicroSeconds (0); // TODO should be MicroSeconds (2528)
break;
case AC_BK:
dcf->SetMinCw (cwmin, SINGLE_LINK_OP_ID);
dcf->SetMaxCw (cwmax, SINGLE_LINK_OP_ID);
dcf->SetAifsn (7, SINGLE_LINK_OP_ID);
dcf->SetTxopLimit (MicroSeconds (0), SINGLE_LINK_OP_ID);
cwMinValue = cwmin;
cwMaxValue = cwmax;
aifsnValue = 7;
txopLimitDsss = MicroSeconds (0); // TODO should be MicroSeconds (3264)
txopLimitNoDsss = MicroSeconds (0); // TODO should be MicroSeconds (2528)
break;
case AC_BE_NQOS:
dcf->SetMinCw (cwmin, SINGLE_LINK_OP_ID);
dcf->SetMaxCw (cwmax, SINGLE_LINK_OP_ID);
dcf->SetAifsn (2, SINGLE_LINK_OP_ID);
dcf->SetTxopLimit (MicroSeconds (0), SINGLE_LINK_OP_ID);
cwMinValue = cwmin;
cwMaxValue = cwmax;
aifsnValue = 2;
txopLimitDsss = txopLimitNoDsss = MicroSeconds (0);
break;
case AC_BEACON:
// done by ApWifiMac
@@ -650,6 +651,21 @@ WifiMac::ConfigureDcf (Ptr<Txop> dcf, uint32_t cwmin, uint32_t cwmax, bool isDss
NS_FATAL_ERROR ("I don't know what to do with this");
break;
}
std::vector<uint32_t> cwValues (m_links.size ());
std::vector<uint8_t> aifsnValues (m_links.size ());
std::vector<Time> txopLimitValues (m_links.size ());
std::fill (cwValues.begin (), cwValues.end (), cwMinValue);
dcf->SetMinCws (cwValues);
std::fill (cwValues.begin (), cwValues.end (), cwMaxValue);
dcf->SetMaxCws (cwValues);
std::fill (aifsnValues.begin (), aifsnValues.end (), aifsnValue);
dcf->SetAifsns (aifsnValues);
std::transform (isDsss.begin (), isDsss.end (), txopLimitValues.begin (),
[&txopLimitDsss, &txopLimitNoDsss] (bool dsss)
{ return (dsss ? txopLimitDsss : txopLimitNoDsss); });
dcf->SetTxopLimits (txopLimitValues);
}
void
@@ -700,31 +716,18 @@ WifiMac::ConfigureStandard (WifiStandard standard)
void
WifiMac::ConfigurePhyDependentParameters (void)
{
auto& link = GetLink (SINGLE_LINK_OP_ID);
NS_ASSERT (link.phy != nullptr);
WifiPhyBand band = link.phy->GetPhyBand ();
NS_LOG_FUNCTION (this << band);
NS_LOG_FUNCTION (this);
uint32_t cwmin = 0;
uint32_t cwmax = 0;
WifiStandard standard = GetLink (SINGLE_LINK_OP_ID).phy->GetStandard ();
WifiStandard standard = link.phy->GetStandard ();
uint32_t cwmin = (standard == WIFI_STANDARD_80211b ? 31 : 15);
uint32_t cwmax = 1023;
if (standard == WIFI_STANDARD_80211b)
for (uint8_t linkId = 0; linkId < m_links.size (); ++linkId)
{
SetDsssSupported (true);
cwmin = 31;
cwmax = 1023;
}
else
{
if (standard >= WIFI_STANDARD_80211g && band == WIFI_PHY_BAND_2_4GHZ)
{
SetErpSupported (true);
}
cwmin = 15;
cwmax = 1023;
SetDsssSupported (standard == WIFI_STANDARD_80211b, linkId);
SetErpSupported (standard >= WIFI_STANDARD_80211g
&& m_links[linkId]->phy->GetPhyBand () == WIFI_PHY_BAND_2_4GHZ, linkId);
}
ConfigureContentionWindow (cwmin, cwmax);
@@ -904,33 +907,33 @@ WifiMac::GetQosSupported () const
}
bool
WifiMac::GetErpSupported () const
WifiMac::GetErpSupported (uint8_t linkId) const
{
return m_erpSupported;
return GetLink (linkId).erpSupported;
}
void
WifiMac::SetErpSupported (bool enable)
WifiMac::SetErpSupported (bool enable, uint8_t linkId)
{
NS_LOG_FUNCTION (this);
NS_LOG_FUNCTION (this << enable << +linkId);
if (enable)
{
SetDsssSupported (true);
SetDsssSupported (true, linkId);
}
m_erpSupported = enable;
GetLink (linkId).erpSupported = enable;
}
void
WifiMac::SetDsssSupported (bool enable)
WifiMac::SetDsssSupported (bool enable, uint8_t linkId)
{
NS_LOG_FUNCTION (this);
m_dsssSupported = enable;
NS_LOG_FUNCTION (this << enable << +linkId);
GetLink (linkId).dsssSupported = enable;
}
bool
WifiMac::GetDsssSupported () const
WifiMac::GetDsssSupported (uint8_t linkId) const
{
return m_dsssSupported;
return GetLink (linkId).dsssSupported;
}
void

View File

@@ -29,6 +29,7 @@
#include "ssid.h"
#include <memory>
#include <vector>
#include <list>
namespace ns3 {
@@ -415,17 +416,19 @@ public:
*/
bool GetQosSupported () const;
/**
* Return whether the device supports ERP.
* Return whether the device supports ERP on the given link.
*
* \param linkId the ID of the given link
* \return true if ERP is supported, false otherwise
*/
bool GetErpSupported () const;
bool GetErpSupported (uint8_t linkId) const;
/**
* Return whether the device supports DSSS.
* Return whether the device supports DSSS on the given link.
*
* \param linkId the ID of the given link
* \return true if DSSS is supported, false otherwise
*/
bool GetDsssSupported () const;
bool GetDsssSupported (uint8_t linkId) const;
/**
* Return whether the device supports HT.
*
@@ -573,6 +576,10 @@ protected:
Ptr<WifiPhy> phy; //!< Wifi PHY object
Ptr<ChannelAccessManager> channelAccessManager; //!< channel access manager object
Ptr<FrameExchangeManager> feManager; //!< Frame Exchange Manager object
bool erpSupported {false}; /**< set to \c true iff this WifiMac is
to model 802.11g */
bool dsssSupported {false}; /**< set to \c true iff this WifiMac is
to model 802.11b */
};
/**
@@ -596,12 +603,13 @@ private:
* \param dcf the DCF to be configured
* \param cwmin the minimum contention window for the DCF
* \param cwmax the maximum contention window for the DCF
* \param isDsss flag to indicate whether PHY is DSSS or HR/DSSS
* \param isDsss vector of flags to indicate whether PHY is DSSS or HR/DSSS for every link
* \param ac the access category for the DCF
*
* Configure the DCF with appropriate values depending on the given access category.
*/
void ConfigureDcf (Ptr<Txop> dcf, uint32_t cwmin, uint32_t cwmax, bool isDsss, AcIndex ac);
void ConfigureDcf (Ptr<Txop> dcf, uint32_t cwmin, uint32_t cwmax,
std::list<bool> isDsss, AcIndex ac);
/**
* Configure PHY dependent parameters such as CWmin and CWmax.
@@ -633,17 +641,19 @@ private:
virtual std::unique_ptr<LinkEntity> CreateLinkEntity (void) const;
/**
* Enable or disable ERP support for the device.
* Enable or disable ERP support for the given link.
*
* \param enable whether ERP is supported
* \param linkId the ID of the given link
*/
void SetErpSupported (bool enable);
void SetErpSupported (bool enable, uint8_t linkId);
/**
* Enable or disable DSSS support for the device.
* Enable or disable DSSS support for the given link.
*
* \param enable whether DSSS is supported
* \param linkId the ID of the given link
*/
void SetDsssSupported (bool enable);
void SetDsssSupported (bool enable, uint8_t linkId);
/**
* Set the block ack threshold for AC_VO.
@@ -709,16 +719,6 @@ private:
* however.
*/
bool m_qosSupported;
/**
* This Boolean is set \c true iff this WifiMac is to model
* 802.11g. It is exposed through the attribute system.
*/
bool m_erpSupported;
/**
* This Boolean is set \c true iff this WifiMac is to model
* 802.11b. It is exposed through the attribute system.
*/
bool m_dsssSupported;
bool m_shortSlotTimeSupported; ///< flag whether short slot time is supported
bool m_ctsToSelfSupported; ///< flag indicating whether CTS-To-Self is supported

View File

@@ -2475,6 +2475,7 @@ TestUlOfdmaPhyTransmission::DoSetup (void)
m_apPhyStateListener = std::make_unique<OfdmaTestPhyListener> ();
m_phyAp->RegisterListener (m_apPhyStateListener.get ());
apDev->SetPhy (m_phyAp);
apMac->SetWifiPhys ({m_phyAp});
apNode->AggregateObject (apMobility);
apNode->AddDevice (apDev);
@@ -3426,6 +3427,7 @@ TestPhyPaddingExclusion::DoSetup (void)
apDev->SetPhy (m_phyAp);
apDev->SetStandard (WIFI_STANDARD_80211ax);
apDev->SetHeConfiguration (CreateObject<HeConfiguration> ());
apMac->SetWifiPhys ({m_phyAp});
apNode->AggregateObject (apMobility);
apNode->AddDevice (apDev);