From 3fec6c013dc8cfdb71e7d74d8fd4093316430bb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deronne?= Date: Mon, 27 Sep 2021 19:54:10 +0200 Subject: [PATCH] wifi: merge RegularWifiMac and WifiMac --- examples/wireless/wifi-spatial-reuse.cc | 1 + src/mesh/helper/mesh-helper.cc | 51 +- src/mesh/model/dot11s/airtime-metric.h | 3 + src/mesh/model/dot11s/hwmp-protocol-mac.cc | 1 + .../dot11s/peer-management-protocol-mac.cc | 1 + src/mesh/model/flame/flame-protocol-mac.cc | 1 + src/mesh/model/mesh-wifi-interface-mac.cc | 73 +- src/mesh/model/mesh-wifi-interface-mac.h | 4 +- src/test/ns3wifi/wifi-issue-211-test-suite.cc | 1 + .../traced-callback-typedef-test-suite.cc | 1 + src/wave/helper/wave-helper.cc | 15 +- src/wave/model/ocb-wifi-mac.cc | 64 +- src/wave/model/ocb-wifi-mac.h | 4 +- src/wave/test/ocb-test-suite.cc | 45 +- src/wifi/CMakeLists.txt | 2 - src/wifi/doc/source/wifi-design.rst | 6 +- src/wifi/examples/wifi-bianchi.cc | 4 +- src/wifi/helper/wifi-helper.cc | 68 +- src/wifi/helper/wifi-helper.h | 2 +- src/wifi/helper/wifi-mac-helper.cc | 9 +- src/wifi/model/adhoc-wifi-mac.cc | 43 +- src/wifi/model/adhoc-wifi-mac.h | 4 +- src/wifi/model/ap-wifi-mac.cc | 235 +-- src/wifi/model/ap-wifi-mac.h | 5 +- src/wifi/model/frame-exchange-manager.cc | 2 +- src/wifi/model/frame-exchange-manager.h | 6 +- .../model/he/he-frame-exchange-manager.cc | 2 +- src/wifi/model/he/he-frame-exchange-manager.h | 2 +- .../model/ht/ht-frame-exchange-manager.cc | 2 +- src/wifi/model/ht/ht-frame-exchange-manager.h | 4 +- src/wifi/model/mpdu-aggregator.cc | 5 +- src/wifi/model/mpdu-aggregator.h | 10 +- src/wifi/model/msdu-aggregator.cc | 4 +- src/wifi/model/msdu-aggregator.h | 6 +- src/wifi/model/regular-wifi-mac.cc | 1269 ----------------- src/wifi/model/regular-wifi-mac.h | 549 ------- src/wifi/model/sta-wifi-mac.cc | 147 +- src/wifi/model/sta-wifi-mac.h | 4 +- src/wifi/model/txop.cc | 4 +- src/wifi/model/txop.h | 6 +- src/wifi/model/wifi-ack-manager.cc | 4 +- src/wifi/model/wifi-ack-manager.h | 6 +- .../model/wifi-default-protection-manager.cc | 2 +- src/wifi/model/wifi-mac.cc | 1221 +++++++++++++++- src/wifi/model/wifi-mac.h | 491 ++++++- src/wifi/model/wifi-protection-manager.cc | 4 +- src/wifi/model/wifi-protection-manager.h | 6 +- src/wifi/test/block-ack-test-suite.cc | 9 +- src/wifi/test/wifi-channel-switching-test.cc | 1 + src/wifi/test/wifi-mac-ofdma-test.cc | 4 +- src/wifi/test/wifi-phy-ofdma-test.cc | 2 + src/wifi/test/wifi-phy-reception-test.cc | 1 + src/wifi/test/wifi-primary-channels-test.cc | 2 + src/wifi/test/wifi-test.cc | 64 +- src/wifi/test/wifi-txop-test.cc | 2 + src/wifi/wscript | 2 - 56 files changed, 2154 insertions(+), 2332 deletions(-) delete mode 100644 src/wifi/model/regular-wifi-mac.cc delete mode 100644 src/wifi/model/regular-wifi-mac.h diff --git a/examples/wireless/wifi-spatial-reuse.cc b/examples/wireless/wifi-spatial-reuse.cc index b631340b1..b46275fc4 100644 --- a/examples/wireless/wifi-spatial-reuse.cc +++ b/examples/wireless/wifi-spatial-reuse.cc @@ -63,6 +63,7 @@ #include "ns3/command-line.h" #include "ns3/config.h" #include "ns3/string.h" +#include "ns3/double.h" #include "ns3/spectrum-wifi-helper.h" #include "ns3/ssid.h" #include "ns3/mobility-helper.h" diff --git a/src/mesh/helper/mesh-helper.cc b/src/mesh/helper/mesh-helper.cc index 4b306d2b5..1119d87ee 100644 --- a/src/mesh/helper/mesh-helper.cc +++ b/src/mesh/helper/mesh-helper.cc @@ -191,16 +191,15 @@ MeshHelper::CreateInterface (const WifiPhyHelper &phyHelper, Ptr node, uin Ptr phy = phyHelper.Create (node, device); mac->SetAddress (Mac48Address::Allocate ()); mac->ConfigureStandard (m_standard); - Ptr wifiMac = DynamicCast (mac); - Ptr fem; - if (wifiMac != 0 && (fem = wifiMac->GetFrameExchangeManager ()) != 0) + Ptr fem = mac->GetFrameExchangeManager (); + if (fem != nullptr) { Ptr protectionManager = CreateObject (); - protectionManager->SetWifiMac (wifiMac); + protectionManager->SetWifiMac (mac); fem->SetProtectionManager (protectionManager); Ptr ackManager = CreateObject (); - ackManager->SetWifiMac (wifiMac); + ackManager->SetWifiMac (mac); fem->SetAckManager (ackManager); } phy->ConfigureStandard (m_standard); @@ -263,34 +262,28 @@ MeshHelper::AssignStreams (NetDeviceContainer c, int64_t stream) } // Handle any random numbers in the mesh mac and plugins mac = DynamicCast (wifi->GetMac ()); - if (mac) - { - currentStream += mac->AssignStreams (currentStream); - } - Ptr rmac = DynamicCast (mac); - if (rmac) - { - PointerValue ptr; - rmac->GetAttribute ("Txop", ptr); - Ptr txop = ptr.Get (); - currentStream += txop->AssignStreams (currentStream); + currentStream += mac->AssignStreams (currentStream); - rmac->GetAttribute ("VO_Txop", ptr); - Ptr vo_txop = ptr.Get (); - currentStream += vo_txop->AssignStreams (currentStream); + PointerValue ptr; + mac->GetAttribute ("Txop", ptr); + Ptr txop = ptr.Get (); + currentStream += txop->AssignStreams (currentStream); - rmac->GetAttribute ("VI_Txop", ptr); - Ptr vi_txop = ptr.Get (); - currentStream += vi_txop->AssignStreams (currentStream); + mac->GetAttribute ("VO_Txop", ptr); + Ptr vo_txop = ptr.Get (); + currentStream += vo_txop->AssignStreams (currentStream); - rmac->GetAttribute ("BE_Txop", ptr); - Ptr be_txop = ptr.Get (); - currentStream += be_txop->AssignStreams (currentStream); + mac->GetAttribute ("VI_Txop", ptr); + Ptr vi_txop = ptr.Get (); + currentStream += vi_txop->AssignStreams (currentStream); - rmac->GetAttribute ("BK_Txop", ptr); - Ptr bk_txop = ptr.Get (); - currentStream += bk_txop->AssignStreams (currentStream); - } + mac->GetAttribute ("BE_Txop", ptr); + Ptr be_txop = ptr.Get (); + currentStream += be_txop->AssignStreams (currentStream); + + mac->GetAttribute ("BK_Txop", ptr); + Ptr bk_txop = ptr.Get (); + currentStream += bk_txop->AssignStreams (currentStream); } } } diff --git a/src/mesh/model/dot11s/airtime-metric.h b/src/mesh/model/dot11s/airtime-metric.h index 6b21b54af..64fee2b82 100644 --- a/src/mesh/model/dot11s/airtime-metric.h +++ b/src/mesh/model/dot11s/airtime-metric.h @@ -20,7 +20,10 @@ #ifndef AIRTIME_METRIC_H #define AIRTIME_METRIC_H + #include "ns3/mesh-wifi-interface-mac.h" +#include "ns3/wifi-mac-header.h" + namespace ns3 { namespace dot11s { /** diff --git a/src/mesh/model/dot11s/hwmp-protocol-mac.cc b/src/mesh/model/dot11s/hwmp-protocol-mac.cc index 08dab72ef..5f462082c 100644 --- a/src/mesh/model/dot11s/hwmp-protocol-mac.cc +++ b/src/mesh/model/dot11s/hwmp-protocol-mac.cc @@ -23,6 +23,7 @@ #include "ns3/simulator.h" #include "ns3/nstime.h" #include "ns3/log.h" +#include "ns3/wifi-mac-header.h" #include "dot11s-mac-header.h" #include "hwmp-protocol-mac.h" #include "hwmp-tag.h" diff --git a/src/mesh/model/dot11s/peer-management-protocol-mac.cc b/src/mesh/model/dot11s/peer-management-protocol-mac.cc index 0a2ed5323..2fa6497db 100644 --- a/src/mesh/model/dot11s/peer-management-protocol-mac.cc +++ b/src/mesh/model/dot11s/peer-management-protocol-mac.cc @@ -24,6 +24,7 @@ #include "peer-management-protocol-mac.h" #include "peer-management-protocol.h" #include "peer-link-frame.h" +#include "ns3/wifi-mac-queue-item.h" #include "ns3/mesh-wifi-interface-mac.h" #include "ns3/simulator.h" #include "ns3/mesh-information-element-vector.h" diff --git a/src/mesh/model/flame/flame-protocol-mac.cc b/src/mesh/model/flame/flame-protocol-mac.cc index 77098e4b1..d5498fb9b 100644 --- a/src/mesh/model/flame/flame-protocol-mac.cc +++ b/src/mesh/model/flame/flame-protocol-mac.cc @@ -21,6 +21,7 @@ #include "flame-protocol-mac.h" #include "flame-protocol.h" #include "flame-header.h" +#include "ns3/wifi-mac-header.h" #include "ns3/log.h" namespace ns3 { diff --git a/src/mesh/model/mesh-wifi-interface-mac.cc b/src/mesh/model/mesh-wifi-interface-mac.cc index d23708125..f535e4750 100644 --- a/src/mesh/model/mesh-wifi-interface-mac.cc +++ b/src/mesh/model/mesh-wifi-interface-mac.cc @@ -34,6 +34,7 @@ #include "ns3/wifi-net-device.h" #include "ns3/channel-access-manager.h" #include "ns3/mac-tx-middle.h" +#include "ns3/qos-txop.h" namespace ns3 { @@ -45,7 +46,7 @@ TypeId MeshWifiInterfaceMac::GetTypeId () { static TypeId tid = TypeId ("ns3::MeshWifiInterfaceMac") - .SetParent () + .SetParent () .SetGroupName ("Mesh") .AddConstructor () .AddAttribute ( "BeaconInterval", @@ -115,7 +116,7 @@ void MeshWifiInterfaceMac::SetLinkUpCallback (Callback linkUp) { NS_LOG_FUNCTION (this); - RegularWifiMac::SetLinkUpCallback (linkUp); + WifiMac::SetLinkUpCallback (linkUp); // The approach taken here is that, from the point of view of a mesh // node, the link is always up, so we immediately invoke the @@ -129,7 +130,7 @@ MeshWifiInterfaceMac::DoDispose () m_plugins.clear (); m_beaconSendEvent.Cancel (); - RegularWifiMac::DoDispose (); + WifiMac::DoDispose (); } void MeshWifiInterfaceMac::DoInitialize () @@ -182,15 +183,15 @@ uint16_t MeshWifiInterfaceMac::GetFrequencyChannel () const { NS_LOG_FUNCTION (this); - NS_ASSERT (m_phy != 0); // need PHY to set/get channel - return m_phy->GetChannelNumber (); + NS_ASSERT (GetWifiPhy () != 0); // need PHY to set/get channel + return GetWifiPhy ()->GetChannelNumber (); } void MeshWifiInterfaceMac::SwitchFrequencyChannel (uint16_t new_id) { NS_LOG_FUNCTION (this); - NS_ASSERT (m_phy != 0); // need PHY to set/get channel + NS_ASSERT (GetWifiPhy () != 0); // need PHY to set/get channel /** * \todo * Correct channel switching is: @@ -202,7 +203,7 @@ MeshWifiInterfaceMac::SwitchFrequencyChannel (uint16_t new_id) * * Now we use dirty channel switch -- just change frequency */ - m_phy->SetOperatingChannel (WifiPhy::ChannelTuple {new_id, 0, m_phy->GetPhyBand (), 0}); + GetWifiPhy ()->SetOperatingChannel (WifiPhy::ChannelTuple {new_id, 0, GetWifiPhy ()->GetPhyBand (), 0}); // Don't know NAV on new channel m_channelAccessManager->NotifyNavResetNow (Seconds (0)); } @@ -238,15 +239,15 @@ MeshWifiInterfaceMac::ForwardDown (Ptr packet, Mac48Address from, Mac48A // Assert that address1 is set. Assert will fail e.g. if there is no installed routing plugin. NS_ASSERT (hdr.GetAddr1 () != Mac48Address ()); // Queue frame - if (m_stationManager->IsBrandNew (hdr.GetAddr1 ())) + if (GetWifiRemoteStationManager ()->IsBrandNew (hdr.GetAddr1 ())) { // in adhoc mode, we assume that every destination // supports all the rates we support. - for (const auto & mode : m_phy->GetModeList ()) + for (const auto & mode : GetWifiPhy ()->GetModeList ()) { - m_stationManager->AddSupportedMode (hdr.GetAddr1 (), mode); + GetWifiRemoteStationManager ()->AddSupportedMode (hdr.GetAddr1 (), mode); } - m_stationManager->RecordDisassociated (hdr.GetAddr1 ()); + GetWifiRemoteStationManager ()->RecordDisassociated (hdr.GetAddr1 ()); } // Classify: application may have set a tag, which is removed here AcIndex ac; @@ -264,8 +265,8 @@ MeshWifiInterfaceMac::ForwardDown (Ptr packet, Mac48Address from, Mac48A } m_stats.sentFrames++; m_stats.sentBytes += packet->GetSize (); - NS_ASSERT (m_edca.find (ac) != m_edca.end ()); - m_edca[ac]->Queue (packet, hdr); + NS_ASSERT (GetQosTxop (ac) != nullptr); + GetQosTxop (ac)->Queue (packet, hdr); } void MeshWifiInterfaceMac::SendManagementFrame (Ptr packet, const WifiMacHeader& hdr) @@ -282,7 +283,7 @@ MeshWifiInterfaceMac::SendManagementFrame (Ptr packet, const WifiMacHead } m_stats.sentFrames++; m_stats.sentBytes += packet->GetSize (); - if ((m_edca.find (AC_VO) == m_edca.end ()) || (m_edca.find (AC_BK) == m_edca.end ())) + if ((GetQosTxop (AC_VO) == nullptr) || (GetQosTxop (AC_BK) == nullptr)) { NS_FATAL_ERROR ("Voice or Background queue is not set up!"); } @@ -296,11 +297,11 @@ MeshWifiInterfaceMac::SendManagementFrame (Ptr packet, const WifiMacHead */ if (hdr.GetAddr1 () != Mac48Address::GetBroadcast ()) { - m_edca[AC_VO]->Queue (packet, header); + GetQosTxop (AC_VO)->Queue (packet, header); } else { - m_edca[AC_BK]->Queue (packet, header); + GetQosTxop (AC_BK)->Queue (packet, header); } } SupportedRates @@ -309,28 +310,28 @@ MeshWifiInterfaceMac::GetSupportedRates () const // set the set of supported rates and make sure that we indicate // the Basic Rate set in this set of supported rates. SupportedRates rates; - for (const auto & mode : m_phy->GetModeList ()) + for (const auto & mode : GetWifiPhy ()->GetModeList ()) { - uint16_t gi = ConvertGuardIntervalToNanoSeconds (mode, m_phy->GetDevice ()); - rates.AddSupportedRate (mode.GetDataRate (m_phy->GetChannelWidth (), gi, 1)); + uint16_t gi = ConvertGuardIntervalToNanoSeconds (mode, GetWifiPhy ()->GetDevice ()); + rates.AddSupportedRate (mode.GetDataRate (GetWifiPhy ()->GetChannelWidth (), gi, 1)); } // set the basic rates - for (uint32_t j = 0; j < m_stationManager->GetNBasicModes (); j++) + for (uint32_t j = 0; j < GetWifiRemoteStationManager ()->GetNBasicModes (); j++) { - WifiMode mode = m_stationManager->GetBasicMode (j); - uint16_t gi = ConvertGuardIntervalToNanoSeconds (mode, m_phy->GetDevice ()); - rates.SetBasicRate (mode.GetDataRate (m_phy->GetChannelWidth (), gi, 1)); + WifiMode mode = GetWifiRemoteStationManager ()->GetBasicMode (j); + uint16_t gi = ConvertGuardIntervalToNanoSeconds (mode, GetWifiPhy ()->GetDevice ()); + rates.SetBasicRate (mode.GetDataRate (GetWifiPhy ()->GetChannelWidth (), gi, 1)); } return rates; } bool MeshWifiInterfaceMac::CheckSupportedRates (SupportedRates rates) const { - for (uint32_t i = 0; i < m_stationManager->GetNBasicModes (); i++) + for (uint32_t i = 0; i < GetWifiRemoteStationManager ()->GetNBasicModes (); i++) { - WifiMode mode = m_stationManager->GetBasicMode (i); - uint16_t gi = ConvertGuardIntervalToNanoSeconds (mode, m_phy->GetDevice ()); - if (!rates.IsSupportedRate (mode.GetDataRate (m_phy->GetChannelWidth (), gi, 1))) + WifiMode mode = GetWifiRemoteStationManager ()->GetBasicMode (i); + uint16_t gi = ConvertGuardIntervalToNanoSeconds (mode, GetWifiPhy ()->GetDevice ()); + if (!rates.IsSupportedRate (mode.GetDataRate (GetWifiPhy ()->GetChannelWidth (), gi, 1))) { return false; } @@ -436,16 +437,16 @@ MeshWifiInterfaceMac::Receive (Ptr mpdu) { SupportedRates rates = beacon_hdr.GetSupportedRates (); - for (const auto & mode : m_phy->GetModeList ()) + for (const auto & mode : GetWifiPhy ()->GetModeList ()) { - uint16_t gi = ConvertGuardIntervalToNanoSeconds (mode, m_phy->GetDevice ()); - uint64_t rate = mode.GetDataRate (m_phy->GetChannelWidth (), gi, 1); + uint16_t gi = ConvertGuardIntervalToNanoSeconds (mode, GetWifiPhy ()->GetDevice ()); + uint64_t rate = mode.GetDataRate (GetWifiPhy ()->GetChannelWidth (), gi, 1); if (rates.IsSupportedRate (rate)) { - m_stationManager->AddSupportedMode (hdr->GetAddr2 (), mode); + GetWifiRemoteStationManager ()->AddSupportedMode (hdr->GetAddr2 (), mode); if (rates.IsBasicRate (rate)) { - m_stationManager->AddBasicMode (mode); + GetWifiRemoteStationManager ()->AddBasicMode (mode); } } } @@ -478,9 +479,9 @@ MeshWifiInterfaceMac::Receive (Ptr mpdu) ForwardUp (packet, hdr->GetAddr4 (), hdr->GetAddr3 ()); } - // We don't bother invoking RegularWifiMac::Receive() here, because + // We don't bother invoking WifiMac::Receive() here, because // we've explicitly handled all the frames we care about. This is in - // contrast to most classes which derive from RegularWifiMac. + // contrast to most classes which derive from WifiMac. } uint32_t MeshWifiInterfaceMac::GetLinkMetric (Mac48Address peerAddress) @@ -547,14 +548,14 @@ void MeshWifiInterfaceMac::ConfigureStandard (enum WifiStandard standard) { NS_ABORT_IF (!GetQosSupported ()); - RegularWifiMac::ConfigureStandard (standard); + WifiMac::ConfigureStandard (standard); m_standard = standard; } void MeshWifiInterfaceMac::ConfigureContentionWindow (uint32_t cwMin, uint32_t cwMax) { - RegularWifiMac::ConfigureContentionWindow (cwMin, cwMax); + WifiMac::ConfigureContentionWindow (cwMin, cwMax); // We use the single DCF provided by WifiMac for the purpose of // Beacon transmission. For this we need to reconfigure the channel // access parameters slightly, and do so here. diff --git a/src/mesh/model/mesh-wifi-interface-mac.h b/src/mesh/model/mesh-wifi-interface-mac.h index 01099fc10..3c4b2754a 100644 --- a/src/mesh/model/mesh-wifi-interface-mac.h +++ b/src/mesh/model/mesh-wifi-interface-mac.h @@ -29,7 +29,7 @@ #include "ns3/callback.h" #include "ns3/packet.h" #include "ns3/nstime.h" -#include "ns3/regular-wifi-mac.h" +#include "ns3/wifi-mac.h" #include "ns3/mesh-wifi-interface-mac-plugin.h" #include "ns3/event-id.h" @@ -47,7 +47,7 @@ class UniformRandomVariable; * - management and priority traffic. * */ -class MeshWifiInterfaceMac : public RegularWifiMac +class MeshWifiInterfaceMac : public WifiMac { public: /** diff --git a/src/test/ns3wifi/wifi-issue-211-test-suite.cc b/src/test/ns3wifi/wifi-issue-211-test-suite.cc index b35e41875..541aabb92 100644 --- a/src/test/ns3wifi/wifi-issue-211-test-suite.cc +++ b/src/test/ns3wifi/wifi-issue-211-test-suite.cc @@ -21,6 +21,7 @@ #include "ns3/test.h" #include "ns3/string.h" +#include "ns3/boolean.h" #include "ns3/qos-utils.h" #include "ns3/packet.h" #include "ns3/wifi-net-device.h" diff --git a/src/test/traced/traced-callback-typedef-test-suite.cc b/src/test/traced/traced-callback-typedef-test-suite.cc index 25620379e..21cabee47 100644 --- a/src/test/traced/traced-callback-typedef-test-suite.cc +++ b/src/test/traced/traced-callback-typedef-test-suite.cc @@ -40,6 +40,7 @@ #include "ns3/stats-module.h" // TimeSeriesAdapter #include "ns3/uan-module.h" // UanPhy #include "ns3/wifi-phy-state-helper.h" +#include "ns3/wifi-mac-header.h" using namespace ns3; diff --git a/src/wave/helper/wave-helper.cc b/src/wave/helper/wave-helper.cc index de6020de1..9dcb8ccc1 100644 --- a/src/wave/helper/wave-helper.cc +++ b/src/wave/helper/wave-helper.cc @@ -23,6 +23,7 @@ #include "ns3/names.h" #include "ns3/abort.h" #include "ns3/wave-net-device.h" +#include "ns3/qos-txop.h" #include "ns3/minstrel-wifi-manager.h" #include "ns3/radiotap-header.h" #include "wave-mac-helper.h" @@ -458,10 +459,8 @@ WaveHelper::AssignStreams (NetDeviceContainer c, int64_t stream) std::map > macs = wave->GetMacs (); for ( std::map >::iterator k = macs.begin (); k != macs.end (); ++k) { - Ptr rmac = DynamicCast (k->second); - // Handle any random numbers in the station managers. - Ptr manager = rmac->GetWifiRemoteStationManager (); + Ptr manager = k->second->GetWifiRemoteStationManager (); Ptr minstrel = DynamicCast (manager); if (minstrel) { @@ -469,23 +468,23 @@ WaveHelper::AssignStreams (NetDeviceContainer c, int64_t stream) } PointerValue ptr; - rmac->GetAttribute ("Txop", ptr); + k->second->GetAttribute ("Txop", ptr); Ptr txop = ptr.Get (); currentStream += txop->AssignStreams (currentStream); - rmac->GetAttribute ("VO_Txop", ptr); + k->second->GetAttribute ("VO_Txop", ptr); Ptr vo_txop = ptr.Get (); currentStream += vo_txop->AssignStreams (currentStream); - rmac->GetAttribute ("VI_Txop", ptr); + k->second->GetAttribute ("VI_Txop", ptr); Ptr vi_txop = ptr.Get (); currentStream += vi_txop->AssignStreams (currentStream); - rmac->GetAttribute ("BE_Txop", ptr); + k->second->GetAttribute ("BE_Txop", ptr); Ptr be_txop = ptr.Get (); currentStream += be_txop->AssignStreams (currentStream); - rmac->GetAttribute ("BK_Txop", ptr); + k->second->GetAttribute ("BK_Txop", ptr); Ptr bk_txop = ptr.Get (); currentStream += bk_txop->AssignStreams (currentStream); } diff --git a/src/wave/model/ocb-wifi-mac.cc b/src/wave/model/ocb-wifi-mac.cc index 037de889e..2283ef8c7 100644 --- a/src/wave/model/ocb-wifi-mac.cc +++ b/src/wave/model/ocb-wifi-mac.cc @@ -46,7 +46,7 @@ TypeId OcbWifiMac::GetTypeId (void) { static TypeId tid = TypeId ("ns3::OcbWifiMac") - .SetParent () + .SetParent () .SetGroupName ("Wave") .AddConstructor () ; @@ -59,7 +59,7 @@ OcbWifiMac::OcbWifiMac (void) // Let the lower layers know that we are acting as an OCB node SetTypeOfStation (OCB); // BSSID is still needed in the low part of MAC - RegularWifiMac::SetBssid (WILDCARD_BSSID); + WifiMac::SetBssid (WILDCARD_BSSID); } OcbWifiMac::~OcbWifiMac (void) @@ -86,11 +86,11 @@ OcbWifiMac::SendVsc (Ptr vsc, Mac48Address peer, OrganizationIdentifier { uint8_t tid = QosUtilsGetTidForPacket (vsc); tid = tid > 7 ? 0 : tid; - m_edca[QosUtilsMapTidToAc (tid)]->Queue (vsc, hdr); + GetQosTxop (tid)->Queue (vsc, hdr); } else { - m_txop->Queue (vsc, hdr); + GetTxop ()->Queue (vsc, hdr); } } @@ -119,7 +119,7 @@ OcbWifiMac::GetSsid (void) const { NS_LOG_WARN ("in OCB mode we should not call GetSsid"); // we really do not want to return ssid, however we have to provide - return RegularWifiMac::GetSsid (); + return WifiMac::GetSsid (); } @@ -140,7 +140,7 @@ void OcbWifiMac::SetLinkUpCallback (Callback linkUp) { NS_LOG_FUNCTION (this << &linkUp); - RegularWifiMac::SetLinkUpCallback (linkUp); + WifiMac::SetLinkUpCallback (linkUp); // The approach taken here is that, from the point of view of a STA // in OCB mode, the link is always up, so we immediately invoke the @@ -152,7 +152,7 @@ void OcbWifiMac::SetLinkDownCallback (Callback linkDown) { NS_LOG_FUNCTION (this << &linkDown); - RegularWifiMac::SetLinkDownCallback (linkDown); + WifiMac::SetLinkDownCallback (linkDown); NS_LOG_WARN ("in OCB mode the like will never down, so linkDown will never be called"); } @@ -166,21 +166,21 @@ void OcbWifiMac::Enqueue (Ptr packet, Mac48Address to) { NS_LOG_FUNCTION (this << packet << to); - if (m_stationManager->IsBrandNew (to)) + if (GetWifiRemoteStationManager ()->IsBrandNew (to)) { //In ad hoc mode, we assume that every destination supports all //the rates we support. if (GetHtSupported () || GetVhtSupported ()) { - m_stationManager->AddAllSupportedMcs (to); - m_stationManager->AddStationHtCapabilities (to, GetHtCapabilities()); + GetWifiRemoteStationManager ()->AddAllSupportedMcs (to); + GetWifiRemoteStationManager ()->AddStationHtCapabilities (to, GetHtCapabilities()); } if (GetVhtSupported ()) { - m_stationManager->AddStationVhtCapabilities (to, GetVhtCapabilities()); + GetWifiRemoteStationManager ()->AddStationVhtCapabilities (to, GetVhtCapabilities()); } - m_stationManager->AddAllSupportedModes (to); - m_stationManager->RecordDisassociated (to); + GetWifiRemoteStationManager ()->AddAllSupportedModes (to); + GetWifiRemoteStationManager ()->RecordDisassociated (to); } WifiMacHeader hdr; @@ -232,11 +232,11 @@ OcbWifiMac::Enqueue (Ptr packet, Mac48Address to) { // Sanity check that the TID is valid NS_ASSERT (tid < 8); - m_edca[QosUtilsMapTidToAc (tid)]->Queue (packet, hdr); + GetQosTxop (tid)->Queue (packet, hdr); } else { - m_txop->Queue (packet, hdr); + GetTxop ()->Queue (packet, hdr); } } @@ -258,21 +258,21 @@ OcbWifiMac::Receive (Ptr mpdu) Mac48Address from = hdr->GetAddr2 (); Mac48Address to = hdr->GetAddr1 (); - if (m_stationManager->IsBrandNew (from)) + if (GetWifiRemoteStationManager ()->IsBrandNew (from)) { //In ad hoc mode, we assume that every destination supports all //the rates we support. if (GetHtSupported () || GetVhtSupported ()) { - m_stationManager->AddAllSupportedMcs (from); - m_stationManager->AddStationHtCapabilities (from, GetHtCapabilities()); + GetWifiRemoteStationManager ()->AddAllSupportedMcs (from); + GetWifiRemoteStationManager ()->AddStationHtCapabilities (from, GetHtCapabilities()); } if (GetVhtSupported ()) { - m_stationManager->AddStationVhtCapabilities (from, GetVhtCapabilities()); + GetWifiRemoteStationManager ()->AddStationVhtCapabilities (from, GetVhtCapabilities()); } - m_stationManager->AddAllSupportedModes (from); - m_stationManager->RecordDisassociated (from); + GetWifiRemoteStationManager ()->AddAllSupportedModes (from); + GetWifiRemoteStationManager ()->RecordDisassociated (from); } if (hdr->IsData ()) @@ -303,7 +303,7 @@ OcbWifiMac::Receive (Ptr mpdu) if (hdr->IsMgt () && hdr->IsAction ()) { // yes, we only care about VendorSpecificAction frame in OCB mode - // other management frames will be handled by RegularWifiMac::Receive + // other management frames will be handled by WifiMac::Receive VendorSpecificActionHeader vsaHdr; packet->PeekHeader (vsaHdr); if (vsaHdr.GetCategory () == CATEGORY_OF_VSA) @@ -331,7 +331,7 @@ OcbWifiMac::Receive (Ptr mpdu) // Invoke the receive handler of our parent class to deal with any // other frames. Specifically, this will handle Block Ack-related // Management Action frames. - RegularWifiMac::Receive (Create (packet, *hdr)); + WifiMac::Receive (Create (packet, *hdr)); } void @@ -342,31 +342,31 @@ OcbWifiMac::ConfigureEdca (uint32_t cwmin, uint32_t cwmax, uint32_t aifsn, enum switch (ac) { case AC_VO: - dcf = RegularWifiMac::GetVOQueue (); + dcf = WifiMac::GetVOQueue (); dcf->SetMinCw ((cwmin + 1) / 4 - 1); dcf->SetMaxCw ((cwmin + 1) / 2 - 1); dcf->SetAifsn (aifsn); break; case AC_VI: - dcf = RegularWifiMac::GetVIQueue (); + dcf = WifiMac::GetVIQueue (); dcf->SetMinCw ((cwmin + 1) / 2 - 1); dcf->SetMaxCw (cwmin); dcf->SetAifsn (aifsn); break; case AC_BE: - dcf = RegularWifiMac::GetBEQueue (); + dcf = WifiMac::GetBEQueue (); dcf->SetMinCw (cwmin); dcf->SetMaxCw (cwmax); dcf->SetAifsn (aifsn); break; case AC_BK: - dcf = RegularWifiMac::GetBKQueue (); + dcf = WifiMac::GetBKQueue (); dcf->SetMinCw (cwmin); dcf->SetMaxCw (cwmax); dcf->SetAifsn (aifsn); break; case AC_BE_NQOS: - dcf = RegularWifiMac::GetTxop (); + dcf = WifiMac::GetTxop (); dcf->SetMinCw (cwmin); dcf->SetMaxCw (cwmax); dcf->SetAifsn (aifsn); @@ -415,9 +415,9 @@ OcbWifiMac::ConfigureStandard (enum WifiStandard standard) m_channelAccessManager->SetupFrameExchangeManager (m_feManager); if (GetQosSupported ()) { - for (const auto& pair : m_edca) + for (auto& ac : {AC_BE, AC_BK, AC_VI, AC_VO}) { - pair.second->SetQosFrameExchangeManager (DynamicCast (m_feManager)); + GetQosTxop (ac)->SetQosFrameExchangeManager (DynamicCast (m_feManager)); } } } @@ -450,7 +450,7 @@ void OcbWifiMac::CancleTx (enum AcIndex ac) { NS_LOG_FUNCTION (this << ac); - Ptr queue = m_edca.find (ac)->second; + Ptr queue = GetQosTxop (ac); NS_ASSERT (queue != 0); // reset and flush queue queue->GetWifiMacQueue ()->Flush (); @@ -477,7 +477,7 @@ void OcbWifiMac::DoDispose (void) { NS_LOG_FUNCTION (this); - RegularWifiMac::DoDispose (); + WifiMac::DoDispose (); } } // namespace ns3 diff --git a/src/wave/model/ocb-wifi-mac.h b/src/wave/model/ocb-wifi-mac.h index f84d660b1..ea3ff0fcd 100644 --- a/src/wave/model/ocb-wifi-mac.h +++ b/src/wave/model/ocb-wifi-mac.h @@ -23,7 +23,7 @@ #define OCB_WIFI_MAC_H #include "ns3/object-factory.h" -#include "ns3/regular-wifi-mac.h" +#include "ns3/wifi-mac.h" #include "ns3/wifi-mac-queue.h" #include "vendor-specific-action.h" #include "wave-net-device.h" @@ -46,7 +46,7 @@ class WaveNetDevice; * However in simulation nodes are supposed to have GPS synchronization ability, * so we will not implement this feature. */ -class OcbWifiMac : public RegularWifiMac +class OcbWifiMac : public WifiMac { public: /** diff --git a/src/wave/test/ocb-test-suite.cc b/src/wave/test/ocb-test-suite.cc index d1511697b..a2d7d2eef 100644 --- a/src/wave/test/ocb-test-suite.cc +++ b/src/wave/test/ocb-test-suite.cc @@ -29,6 +29,7 @@ #include "ns3/mobility-model.h" #include "ns3/yans-wifi-helper.h" #include "ns3/sta-wifi-mac.h" +#include "ns3/qos-txop.h" #include "ns3/position-allocator.h" #include "ns3/packet-socket-helper.h" #include "ns3/mobility-helper.h" @@ -46,34 +47,30 @@ static void AssignWifiRandomStreams (Ptr mac, int64_t stream) { int64_t currentStream = stream; - Ptr rmac = DynamicCast (mac); - if (rmac) + PointerValue ptr; + if (!mac->GetQosSupported ()) { - PointerValue ptr; - if (!rmac->GetQosSupported ()) - { - rmac->GetAttribute ("Txop", ptr); - Ptr txop = ptr.Get (); - currentStream += txop->AssignStreams (currentStream); - } - else - { - rmac->GetAttribute ("VO_Txop", ptr); - Ptr vo_txop = ptr.Get (); - currentStream += vo_txop->AssignStreams (currentStream); + mac->GetAttribute ("Txop", ptr); + Ptr txop = ptr.Get (); + currentStream += txop->AssignStreams (currentStream); + } + else + { + mac->GetAttribute ("VO_Txop", ptr); + Ptr vo_txop = ptr.Get (); + currentStream += vo_txop->AssignStreams (currentStream); - rmac->GetAttribute ("VI_Txop", ptr); - Ptr vi_txop = ptr.Get (); - currentStream += vi_txop->AssignStreams (currentStream); + mac->GetAttribute ("VI_Txop", ptr); + Ptr vi_txop = ptr.Get (); + currentStream += vi_txop->AssignStreams (currentStream); - rmac->GetAttribute ("BE_Txop", ptr); - Ptr be_txop = ptr.Get (); - currentStream += be_txop->AssignStreams (currentStream); + mac->GetAttribute ("BE_Txop", ptr); + Ptr be_txop = ptr.Get (); + currentStream += be_txop->AssignStreams (currentStream); - rmac->GetAttribute ("BK_Txop", ptr); - Ptr bk_txop = ptr.Get (); - currentStream += bk_txop->AssignStreams (currentStream); - } + mac->GetAttribute ("BK_Txop", ptr); + Ptr bk_txop = ptr.Get (); + currentStream += bk_txop->AssignStreams (currentStream); } } diff --git a/src/wifi/CMakeLists.txt b/src/wifi/CMakeLists.txt index e66fe03b0..978e87ac9 100644 --- a/src/wifi/CMakeLists.txt +++ b/src/wifi/CMakeLists.txt @@ -82,7 +82,6 @@ set(source_files model/rate-control/rrpaa-wifi-manager.cc model/rate-control/thompson-sampling-wifi-manager.cc model/recipient-block-ack-agreement.cc - model/regular-wifi-mac.cc model/simple-frame-capture-model.cc model/snr-tag.cc model/spectrum-wifi-phy.cc @@ -218,7 +217,6 @@ set(header_files model/rate-control/thompson-sampling-wifi-manager.h model/recipient-block-ack-agreement.h model/reference/error-rate-tables.h - model/regular-wifi-mac.h model/simple-frame-capture-model.h model/snr-tag.h model/spectrum-wifi-phy.h diff --git a/src/wifi/doc/source/wifi-design.rst b/src/wifi/doc/source/wifi-design.rst index 99976ac50..ee1db0582 100644 --- a/src/wifi/doc/source/wifi-design.rst +++ b/src/wifi/doc/source/wifi-design.rst @@ -75,7 +75,7 @@ MAC high models There are presently three **MAC high models** that provide for the three (non-mesh; the mesh equivalent, which is a sibling of these with common -parent ``ns3::RegularWifiMac``, is not discussed here) Wi-Fi topological +parent ``ns3::WifiMac``, is not discussed here) Wi-Fi topological elements - Access Point (AP) (``ns3::ApWifiMac``), non-AP Station (STA) (``ns3::StaWifiMac``), and STA in an Independent Basic Service Set (IBSS) - also commonly referred to as an ad hoc @@ -90,7 +90,7 @@ re-association whenever too many beacons are missed. Finally, beacons, and that accepts every attempt to associate. These three MAC high models share a common parent in -``ns3::RegularWifiMac``, which exposes, among other MAC +``ns3::WifiMac``, which exposes, among other MAC configuration, an attribute ``QosSupported`` that allows configuration of 802.11e/WMM-style QoS support. @@ -1209,7 +1209,7 @@ Depending on your goal, the common tasks are (in no particular order): ``frame-exchange-manager.*`` or its subclasses to accomplish this. Handling of control frames is performed in ``FrameExchangeManager::ReceiveMpdu``. * MAC high modification. For example, handling new management frames (think beacon/probe), - beacon/probe generation. Users usually make changes to ``regular-wifi-mac.*``,``sta-wifi-mac.*``, ``ap-wifi-mac.*``, or ``adhoc-wifi-mac.*`` to accomplish this. + beacon/probe generation. Users usually make changes to ``wifi-mac.*``,``sta-wifi-mac.*``, ``ap-wifi-mac.*``, or ``adhoc-wifi-mac.*`` to accomplish this. * Wi-Fi queue management. The files ``txop.*`` and ``qos-txop.*`` are of interest for this task. * Channel access management. Users should modify the files ``channel-access-manager.*``, which grant access to ``Txop`` and ``QosTxop``. diff --git a/src/wifi/examples/wifi-bianchi.cc b/src/wifi/examples/wifi-bianchi.cc index 194683c03..52e089910 100644 --- a/src/wifi/examples/wifi-bianchi.cc +++ b/src/wifi/examples/wifi-bianchi.cc @@ -1003,9 +1003,9 @@ Experiment::Run (const WifiHelper &helper, const YansWifiPhyHelper &wifiPhy, con } // Trace CW evolution - Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/$ns3::RegularWifiMac/Txop/CwTrace", MakeCallback (&CwTrace)); + Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/$ns3::WifiMac/Txop/CwTrace", MakeCallback (&CwTrace)); // Trace backoff evolution - Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/$ns3::RegularWifiMac/Txop/BackoffTrace", MakeCallback (&BackoffTrace)); + Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/$ns3::WifiMac/Txop/BackoffTrace", MakeCallback (&BackoffTrace)); // Trace PHY Tx start events Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/PhyTxBegin", MakeCallback (&PhyTxTrace)); // Trace PHY Tx end events diff --git a/src/wifi/helper/wifi-helper.cc b/src/wifi/helper/wifi-helper.cc index 21d6b8bff..1a0f42bca 100644 --- a/src/wifi/helper/wifi-helper.cc +++ b/src/wifi/helper/wifi-helper.cc @@ -32,6 +32,7 @@ #include "ns3/net-device-queue-interface.h" #include "ns3/wifi-mac-queue.h" #include "ns3/qos-utils.h" +#include "ns3/qos-txop.h" #include "ns3/ht-configuration.h" #include "ns3/vht-configuration.h" #include "ns3/he-configuration.h" @@ -835,22 +836,20 @@ WifiHelper::Install (const WifiPhyHelper &phyHelper, } devices.Add (device); NS_LOG_DEBUG ("node=" << node << ", mob=" << node->GetObject ()); - // Aggregate a NetDeviceQueueInterface object if a RegularWifiMac is installed - Ptr rmac = DynamicCast (mac); - if (rmac && m_enableFlowControl) + if (m_enableFlowControl) { Ptr ndqi; BooleanValue qosSupported; Ptr wmq; - rmac->GetAttributeFailSafe ("QosSupported", qosSupported); + mac->GetAttributeFailSafe ("QosSupported", qosSupported); if (qosSupported.Get ()) { ndqi = CreateObjectWithAttributes ("NTxQueues", UintegerValue (4)); for (auto& ac : {AC_BE, AC_BK, AC_VI, AC_VO}) { - Ptr qosTxop = rmac->GetQosTxop (ac); + Ptr qosTxop = mac->GetQosTxop (ac); wmq = qosTxop->GetWifiMacQueue (); ndqi->GetTxQueue (static_cast (ac))->ConnectQueueTraces (wmq); } @@ -860,7 +859,7 @@ WifiHelper::Install (const WifiPhyHelper &phyHelper, { ndqi = CreateObject (); - wmq = rmac->GetTxop ()->GetWifiMacQueue (); + wmq = mac->GetTxop ()->GetWifiMacQueue (); ndqi->GetTxQueue (0)->ConnectQueueTraces (wmq); } device->AggregateObject (ndqi); @@ -945,7 +944,6 @@ WifiHelper::EnableLogComponents (void) LogComponentEnable ("PhyEntity", LOG_LEVEL_ALL); LogComponentEnable ("QosFrameExchangeManager", LOG_LEVEL_ALL); LogComponentEnable ("QosTxop", LOG_LEVEL_ALL); - LogComponentEnable ("RegularWifiMac", LOG_LEVEL_ALL); LogComponentEnable ("RraaWifiManager", LOG_LEVEL_ALL); LogComponentEnable ("RrMultiUserScheduler", LOG_LEVEL_ALL); LogComponentEnable ("RrpaaWifiManager", LOG_LEVEL_ALL); @@ -1008,41 +1006,37 @@ WifiHelper::AssignStreams (NetDeviceContainer c, int64_t stream) //Handle any random numbers in the MAC objects. Ptr mac = wifi->GetMac (); - Ptr rmac = DynamicCast (mac); - if (rmac) + PointerValue ptr; + if (!mac->GetQosSupported ()) { - PointerValue ptr; - if (!rmac->GetQosSupported ()) - { - rmac->GetAttribute ("Txop", ptr); - Ptr txop = ptr.Get (); - currentStream += txop->AssignStreams (currentStream); - } - else - { - rmac->GetAttribute ("VO_Txop", ptr); - Ptr vo_txop = ptr.Get (); - currentStream += vo_txop->AssignStreams (currentStream); + mac->GetAttribute ("Txop", ptr); + Ptr txop = ptr.Get (); + currentStream += txop->AssignStreams (currentStream); + } + else + { + mac->GetAttribute ("VO_Txop", ptr); + Ptr vo_txop = ptr.Get (); + currentStream += vo_txop->AssignStreams (currentStream); - rmac->GetAttribute ("VI_Txop", ptr); - Ptr vi_txop = ptr.Get (); - currentStream += vi_txop->AssignStreams (currentStream); + mac->GetAttribute ("VI_Txop", ptr); + Ptr vi_txop = ptr.Get (); + currentStream += vi_txop->AssignStreams (currentStream); - rmac->GetAttribute ("BE_Txop", ptr); - Ptr be_txop = ptr.Get (); - currentStream += be_txop->AssignStreams (currentStream); + mac->GetAttribute ("BE_Txop", ptr); + Ptr be_txop = ptr.Get (); + currentStream += be_txop->AssignStreams (currentStream); - rmac->GetAttribute ("BK_Txop", ptr); - Ptr bk_txop = ptr.Get (); - currentStream += bk_txop->AssignStreams (currentStream); - } + mac->GetAttribute ("BK_Txop", ptr); + Ptr bk_txop = ptr.Get (); + currentStream += bk_txop->AssignStreams (currentStream); + } - //if an AP, handle any beacon jitter - Ptr apmac = DynamicCast (rmac); - if (apmac) - { - currentStream += apmac->AssignStreams (currentStream); - } + //if an AP, handle any beacon jitter + Ptr apmac = DynamicCast (mac); + if (apmac) + { + currentStream += apmac->AssignStreams (currentStream); } } } diff --git a/src/wifi/helper/wifi-helper.h b/src/wifi/helper/wifi-helper.h index 6baf8fa54..830a0f4f3 100644 --- a/src/wifi/helper/wifi-helper.h +++ b/src/wifi/helper/wifi-helper.h @@ -405,7 +405,7 @@ public: * \param f the select queue callback * * Set the select queue callback to set on the NetDevice queue interface aggregated - * to the WifiNetDevice, in case RegularWifiMac with QoS enabled is used + * to the WifiNetDevice, in case WifiMac with QoS enabled is used */ void SetSelectQueueCallback (SelectQueueCallback f); diff --git a/src/wifi/helper/wifi-mac-helper.cc b/src/wifi/helper/wifi-mac-helper.cc index 889beb187..b7546f525 100644 --- a/src/wifi/helper/wifi-mac-helper.cc +++ b/src/wifi/helper/wifi-mac-helper.cc @@ -58,17 +58,16 @@ WifiMacHelper::Create (Ptr device, WifiStandard standard) const mac->SetAddress (Mac48Address::Allocate ()); mac->ConfigureStandard (standard); - Ptr wifiMac = DynamicCast (mac); - Ptr fem; + Ptr fem = mac->GetFrameExchangeManager (); - if (wifiMac != 0 && (fem = wifiMac->GetFrameExchangeManager ()) != 0) + if (fem != nullptr) { Ptr protectionManager = m_protectionManager.Create (); - protectionManager->SetWifiMac (wifiMac); + protectionManager->SetWifiMac (mac); fem->SetProtectionManager (protectionManager); Ptr ackManager = m_ackManager.Create (); - ackManager->SetWifiMac (wifiMac); + ackManager->SetWifiMac (mac); fem->SetAckManager (ackManager); // create and install the Multi User Scheduler if this is an HE AP diff --git a/src/wifi/model/adhoc-wifi-mac.cc b/src/wifi/model/adhoc-wifi-mac.cc index 9c23310de..f00d8b9af 100644 --- a/src/wifi/model/adhoc-wifi-mac.cc +++ b/src/wifi/model/adhoc-wifi-mac.cc @@ -23,6 +23,7 @@ #include "ns3/log.h" #include "ns3/packet.h" #include "adhoc-wifi-mac.h" +#include "qos-txop.h" #include "ns3/ht-capabilities.h" #include "ns3/vht-capabilities.h" #include "ns3/he-capabilities.h" @@ -37,7 +38,7 @@ TypeId AdhocWifiMac::GetTypeId (void) { static TypeId tid = TypeId ("ns3::AdhocWifiMac") - .SetParent () + .SetParent () .SetGroupName ("Wifi") .AddConstructor () ; @@ -66,8 +67,8 @@ AdhocWifiMac::SetAddress (Mac48Address address) //transmitted by each STA set to that STA's address. // //This is why we're overriding this method. - RegularWifiMac::SetAddress (address); - RegularWifiMac::SetBssid (address); + WifiMac::SetAddress (address); + WifiMac::SetBssid (address); } bool @@ -80,24 +81,24 @@ void AdhocWifiMac::Enqueue (Ptr packet, Mac48Address to) { NS_LOG_FUNCTION (this << packet << to); - if (m_stationManager->IsBrandNew (to)) + if (GetWifiRemoteStationManager ()->IsBrandNew (to)) { //In ad hoc mode, we assume that every destination supports all the rates we support. if (GetHtSupported ()) { - m_stationManager->AddAllSupportedMcs (to); - m_stationManager->AddStationHtCapabilities (to, GetHtCapabilities ()); + GetWifiRemoteStationManager ()->AddAllSupportedMcs (to); + GetWifiRemoteStationManager ()->AddStationHtCapabilities (to, GetHtCapabilities ()); } if (GetVhtSupported ()) { - m_stationManager->AddStationVhtCapabilities (to, GetVhtCapabilities ()); + GetWifiRemoteStationManager ()->AddStationVhtCapabilities (to, GetVhtCapabilities ()); } if (GetHeSupported ()) { - m_stationManager->AddStationHeCapabilities (to, GetHeCapabilities ()); + GetWifiRemoteStationManager ()->AddStationHeCapabilities (to, GetHeCapabilities ()); } - m_stationManager->AddAllSupportedModes (to); - m_stationManager->RecordDisassociated (to); + GetWifiRemoteStationManager ()->AddAllSupportedModes (to); + GetWifiRemoteStationManager ()->RecordDisassociated (to); } WifiMacHeader hdr; @@ -152,11 +153,11 @@ AdhocWifiMac::Enqueue (Ptr packet, Mac48Address to) { //Sanity check that the TID is valid NS_ASSERT (tid < 8); - m_edca[QosUtilsMapTidToAc (tid)]->Queue (packet, hdr); + GetQosTxop (tid)->Queue (packet, hdr); } else { - m_txop->Queue (packet, hdr); + GetTxop ()->Queue (packet, hdr); } } @@ -164,7 +165,7 @@ void AdhocWifiMac::SetLinkUpCallback (Callback linkUp) { NS_LOG_FUNCTION (this << &linkUp); - RegularWifiMac::SetLinkUpCallback (linkUp); + WifiMac::SetLinkUpCallback (linkUp); //The approach taken here is that, from the point of view of a STA //in IBSS mode, the link is always up, so we immediately invoke the @@ -180,24 +181,24 @@ AdhocWifiMac::Receive (Ptr mpdu) NS_ASSERT (!hdr->IsCtl ()); Mac48Address from = hdr->GetAddr2 (); Mac48Address to = hdr->GetAddr1 (); - if (m_stationManager->IsBrandNew (from)) + if (GetWifiRemoteStationManager ()->IsBrandNew (from)) { //In ad hoc mode, we assume that every destination supports all the rates we support. if (GetHtSupported ()) { - m_stationManager->AddAllSupportedMcs (from); - m_stationManager->AddStationHtCapabilities (from, GetHtCapabilities ()); + GetWifiRemoteStationManager ()->AddAllSupportedMcs (from); + GetWifiRemoteStationManager ()->AddStationHtCapabilities (from, GetHtCapabilities ()); } if (GetVhtSupported ()) { - m_stationManager->AddStationVhtCapabilities (from, GetVhtCapabilities ()); + GetWifiRemoteStationManager ()->AddStationVhtCapabilities (from, GetVhtCapabilities ()); } if (GetHeSupported ()) { - m_stationManager->AddStationHeCapabilities (from, GetHeCapabilities ()); + GetWifiRemoteStationManager ()->AddStationHeCapabilities (from, GetHeCapabilities ()); } - m_stationManager->AddAllSupportedModes (from); - m_stationManager->RecordDisassociated (from); + GetWifiRemoteStationManager ()->AddAllSupportedModes (from); + GetWifiRemoteStationManager ()->RecordDisassociated (from); } if (hdr->IsData ()) { @@ -216,7 +217,7 @@ AdhocWifiMac::Receive (Ptr mpdu) //Invoke the receive handler of our parent class to deal with any //other frames. Specifically, this will handle Block Ack-related //Management Action frames. - RegularWifiMac::Receive (mpdu); + WifiMac::Receive (mpdu); } } //namespace ns3 diff --git a/src/wifi/model/adhoc-wifi-mac.h b/src/wifi/model/adhoc-wifi-mac.h index e2a60c7e7..73dc2fdee 100644 --- a/src/wifi/model/adhoc-wifi-mac.h +++ b/src/wifi/model/adhoc-wifi-mac.h @@ -23,7 +23,7 @@ #ifndef ADHOC_WIFI_MAC_H #define ADHOC_WIFI_MAC_H -#include "regular-wifi-mac.h" +#include "wifi-mac.h" namespace ns3 { @@ -32,7 +32,7 @@ namespace ns3 { * * \brief Wifi MAC high model for an ad-hoc Wifi MAC */ -class AdhocWifiMac : public RegularWifiMac +class AdhocWifiMac : public WifiMac { public: /** diff --git a/src/wifi/model/ap-wifi-mac.cc b/src/wifi/model/ap-wifi-mac.cc index 84541954e..4b5edd834 100644 --- a/src/wifi/model/ap-wifi-mac.cc +++ b/src/wifi/model/ap-wifi-mac.cc @@ -38,6 +38,7 @@ #include "wifi-mac-queue.h" #include "ns3/ht-configuration.h" #include "ns3/he-configuration.h" +#include "qos-txop.h" namespace ns3 { @@ -49,7 +50,7 @@ TypeId ApWifiMac::GetTypeId (void) { static TypeId tid = TypeId ("ns3::ApWifiMac") - .SetParent () + .SetParent () .SetGroupName ("Wifi") .AddConstructor () .AddAttribute ("BeaconInterval", @@ -130,7 +131,7 @@ ApWifiMac::DoDispose () m_beaconTxop = 0; m_enableBeaconGeneration = false; m_beaconEvent.Cancel (); - RegularWifiMac::DoDispose (); + WifiMac::DoDispose (); } void @@ -139,8 +140,8 @@ ApWifiMac::SetAddress (Mac48Address address) NS_LOG_FUNCTION (this << address); //As an AP, our MAC address is also the BSSID. Hence we are //overriding this function and setting both in our parent class. - RegularWifiMac::SetAddress (address); - RegularWifiMac::SetBssid (address); + WifiMac::SetAddress (address); + WifiMac::SetBssid (address); } Ptr @@ -150,7 +151,7 @@ ApWifiMac::GetTxopQueue (AcIndex ac) const { return m_beaconTxop->GetWifiMacQueue (); } - return RegularWifiMac::GetTxopQueue (ac); + return WifiMac::GetTxopQueue (ac); } void @@ -179,7 +180,7 @@ void ApWifiMac::SetLinkUpCallback (Callback linkUp) { NS_LOG_FUNCTION (this << &linkUp); - RegularWifiMac::SetLinkUpCallback (linkUp); + WifiMac::SetLinkUpCallback (linkUp); //The approach taken here is that, from the point of view of an AP, //the link is always up, so we immediately invoke the callback if @@ -218,7 +219,7 @@ ApWifiMac::UpdateShortSlotTimeEnabled (void) { for (const auto& sta : m_staList) { - if (!m_stationManager->GetShortSlotTimeSupported (sta.second)) + if (!GetWifiRemoteStationManager ()->GetShortSlotTimeSupported (sta.second)) { m_shortSlotTimeEnabled = false; return; @@ -236,12 +237,12 @@ void ApWifiMac::UpdateShortPreambleEnabled (void) { NS_LOG_FUNCTION (this); - if (GetErpSupported () && m_phy->GetShortPhyPreambleSupported ()) + if (GetErpSupported () && GetWifiPhy ()->GetShortPhyPreambleSupported ()) { for (const auto& sta : m_staList) { - if (!m_stationManager->GetErpOfdmSupported (sta.second) || - !m_stationManager->GetShortPreambleSupported (sta.second)) + if (!GetWifiRemoteStationManager ()->GetErpOfdmSupported (sta.second) || + !GetWifiRemoteStationManager ()->GetShortPreambleSupported (sta.second)) { m_shortPreambleEnabled = false; return; @@ -258,14 +259,14 @@ ApWifiMac::UpdateShortPreambleEnabled (void) uint16_t ApWifiMac::GetVhtOperationalChannelWidth (void) const { - uint16_t channelWidth = m_phy->GetChannelWidth (); + uint16_t channelWidth = GetWifiPhy ()->GetChannelWidth (); for (const auto& sta : m_staList) { - if (m_stationManager->GetVhtSupported (sta.second)) + if (GetWifiRemoteStationManager ()->GetVhtSupported (sta.second)) { - if (m_stationManager->GetChannelWidthSupported (sta.second) < channelWidth) + if (GetWifiRemoteStationManager ()->GetChannelWidthSupported (sta.second) < channelWidth) { - channelWidth = m_stationManager->GetChannelWidthSupported (sta.second); + channelWidth = GetWifiRemoteStationManager ()->GetChannelWidthSupported (sta.second); } } } @@ -340,18 +341,18 @@ ApWifiMac::ForwardDown (Ptr packet, Mac48Address from, { //Sanity check that the TID is valid NS_ASSERT (tid < 8); - m_edca[QosUtilsMapTidToAc (tid)]->Queue (packet, hdr); + GetQosTxop (tid)->Queue (packet, hdr); } else { - m_txop->Queue (packet, hdr); + GetTxop ()->Queue (packet, hdr); } } bool ApWifiMac::CanForwardPacketsTo (Mac48Address to) const { - return (to.IsGroup () || m_stationManager->IsAssociated (to)); + return (to.IsGroup () || GetWifiRemoteStationManager ()->IsAssociated (to)); } void @@ -392,9 +393,9 @@ ApWifiMac::GetSupportedRates (void) const SupportedRates rates; //Send the set of supported rates and make sure that we indicate //the Basic Rate set in this set of supported rates. - for (const auto & mode : m_phy->GetModeList ()) + for (const auto & mode : GetWifiPhy ()->GetModeList ()) { - uint64_t modeDataRate = mode.GetDataRate (m_phy->GetChannelWidth ()); + uint64_t modeDataRate = mode.GetDataRate (GetWifiPhy ()->GetChannelWidth ()); NS_LOG_DEBUG ("Adding supported rate of " << modeDataRate); rates.AddSupportedRate (modeDataRate); //Add rates that are part of the BSSBasicRateSet (manufacturer dependent!) @@ -403,14 +404,14 @@ ApWifiMac::GetSupportedRates (void) const if (mode.IsMandatory () && (mode.GetModulationClass () != WIFI_MOD_CLASS_HR_DSSS)) { NS_LOG_DEBUG ("Adding basic mode " << mode.GetUniqueName ()); - m_stationManager->AddBasicMode (mode); + GetWifiRemoteStationManager ()->AddBasicMode (mode); } } //set the basic rates - for (uint8_t j = 0; j < m_stationManager->GetNBasicModes (); j++) + for (uint8_t j = 0; j < GetWifiRemoteStationManager ()->GetNBasicModes (); j++) { - WifiMode mode = m_stationManager->GetBasicMode (j); - uint64_t modeDataRate = mode.GetDataRate (m_phy->GetChannelWidth ()); + WifiMode mode = GetWifiRemoteStationManager ()->GetBasicMode (j); + uint64_t modeDataRate = mode.GetDataRate (GetWifiPhy ()->GetChannelWidth ()); NS_LOG_DEBUG ("Setting basic rate " << mode.GetUniqueName ()); rates.SetBasicRate (modeDataRate); } @@ -420,7 +421,7 @@ ApWifiMac::GetSupportedRates (void) const //Also the standard mentioned that at least 1 element should be included in the SupportedRates the rest can be in the ExtendedSupportedRates if (GetHtSupported ()) { - for (const auto & selector : m_phy->GetBssMembershipSelectorList ()) + for (const auto & selector : GetWifiPhy ()->GetBssMembershipSelectorList ()) { rates.AddBssMembershipSelectorRate (selector); } @@ -436,7 +437,7 @@ ApWifiMac::GetDsssParameterSet (void) const if (GetDsssSupported ()) { dsssParameters.SetDsssSupported (1); - dsssParameters.SetCurrentChannel (m_phy->GetChannelNumber ()); + dsssParameters.SetCurrentChannel (GetWifiPhy ()->GetChannelNumber ()); } return dsssParameters; } @@ -485,7 +486,7 @@ ApWifiMac::GetEdcaParameterSet (void) const Ptr edca; Time txopLimit; - edca = m_edca.find (AC_BE)->second; + edca = GetQosTxop (AC_BE); txopLimit = edca->GetTxopLimit (); edcaParameters.SetBeAci (0); edcaParameters.SetBeCWmin (edca->GetMinCw ()); @@ -493,7 +494,7 @@ ApWifiMac::GetEdcaParameterSet (void) const edcaParameters.SetBeAifsn (edca->GetAifsn ()); edcaParameters.SetBeTxopLimit (static_cast (txopLimit.GetMicroSeconds () / 32)); - edca = m_edca.find (AC_BK)->second; + edca = GetQosTxop (AC_BK); txopLimit = edca->GetTxopLimit (); edcaParameters.SetBkAci (1); edcaParameters.SetBkCWmin (edca->GetMinCw ()); @@ -501,7 +502,7 @@ ApWifiMac::GetEdcaParameterSet (void) const edcaParameters.SetBkAifsn (edca->GetAifsn ()); edcaParameters.SetBkTxopLimit (static_cast (txopLimit.GetMicroSeconds () / 32)); - edca = m_edca.find (AC_VI)->second; + edca = GetQosTxop (AC_VI); txopLimit = edca->GetTxopLimit (); edcaParameters.SetViAci (2); edcaParameters.SetViCWmin (edca->GetMinCw ()); @@ -509,7 +510,7 @@ ApWifiMac::GetEdcaParameterSet (void) const edcaParameters.SetViAifsn (edca->GetAifsn ()); edcaParameters.SetViTxopLimit (static_cast (txopLimit.GetMicroSeconds () / 32)); - edca = m_edca.find (AC_VO)->second; + edca = GetQosTxop (AC_VO); txopLimit = edca->GetTxopLimit (); edcaParameters.SetVoAci (3); edcaParameters.SetVoCWmin (edca->GetMinCw ()); @@ -584,10 +585,10 @@ ApWifiMac::GetHtOperation (void) const if (GetHtSupported ()) { operation.SetHtSupported (1); - operation.SetPrimaryChannel (m_phy->GetChannelNumber ()); + operation.SetPrimaryChannel (GetWifiPhy ()->GetChannelNumber ()); operation.SetRifsMode (false); operation.SetNonGfHtStasPresent (true); - if (m_phy->GetChannelWidth () > 20) + if (GetWifiPhy ()->GetChannelWidth () > 20) { operation.SetSecondaryChannelOffset (1); operation.SetStaChannelWidth (1); @@ -601,33 +602,33 @@ ApWifiMac::GetHtOperation (void) const operation.SetHtProtection (MIXED_MODE_PROTECTION); } uint64_t maxSupportedRate = 0; //in bit/s - for (const auto & mcs : m_phy->GetMcsList (WIFI_MOD_CLASS_HT)) + for (const auto & mcs : GetWifiPhy ()->GetMcsList (WIFI_MOD_CLASS_HT)) { uint8_t nss = (mcs.GetMcsValue () / 8) + 1; NS_ASSERT (nss > 0 && nss < 5); - uint64_t dataRate = mcs.GetDataRate (m_phy->GetChannelWidth (), GetHtConfiguration ()->GetShortGuardIntervalSupported () ? 400 : 800, nss); + uint64_t dataRate = mcs.GetDataRate (GetWifiPhy ()->GetChannelWidth (), GetHtConfiguration ()->GetShortGuardIntervalSupported () ? 400 : 800, nss); if (dataRate > maxSupportedRate) { maxSupportedRate = dataRate; NS_LOG_DEBUG ("Updating maxSupportedRate to " << maxSupportedRate); } } - uint8_t maxSpatialStream = m_phy->GetMaxSupportedTxSpatialStreams (); - auto mcsList = m_phy->GetMcsList (WIFI_MOD_CLASS_HT); + uint8_t maxSpatialStream = GetWifiPhy ()->GetMaxSupportedTxSpatialStreams (); + auto mcsList = GetWifiPhy ()->GetMcsList (WIFI_MOD_CLASS_HT); uint8_t nMcs = mcsList.size (); for (const auto& sta : m_staList) { - if (m_stationManager->GetHtSupported (sta.second)) + if (GetWifiRemoteStationManager ()->GetHtSupported (sta.second)) { uint64_t maxSupportedRateByHtSta = 0; //in bit/s auto itMcs = mcsList.begin (); - for (uint8_t j = 0; j < (std::min (nMcs, m_stationManager->GetNMcsSupported (sta.second))); j++) + for (uint8_t j = 0; j < (std::min (nMcs, GetWifiRemoteStationManager ()->GetNMcsSupported (sta.second))); j++) { WifiMode mcs = *itMcs++; uint8_t nss = (mcs.GetMcsValue () / 8) + 1; NS_ASSERT (nss > 0 && nss < 5); - uint64_t dataRate = mcs.GetDataRate (m_stationManager->GetChannelWidthSupported (sta.second), - m_stationManager->GetShortGuardIntervalSupported (sta.second) ? 400 : 800, nss); + uint64_t dataRate = mcs.GetDataRate (GetWifiRemoteStationManager ()->GetChannelWidthSupported (sta.second), + GetWifiRemoteStationManager ()->GetShortGuardIntervalSupported (sta.second) ? 400 : 800, nss); if (dataRate > maxSupportedRateByHtSta) { maxSupportedRateByHtSta = dataRate; @@ -637,13 +638,13 @@ ApWifiMac::GetHtOperation (void) const { maxSupportedRate = maxSupportedRateByHtSta; } - if (m_stationManager->GetNMcsSupported (sta.second) < nMcs) + if (GetWifiRemoteStationManager ()->GetNMcsSupported (sta.second) < nMcs) { - nMcs = m_stationManager->GetNMcsSupported (sta.second); + nMcs = GetWifiRemoteStationManager ()->GetNMcsSupported (sta.second); } - if (m_stationManager->GetNumberOfSupportedStreams (sta.second) < maxSpatialStream) + if (GetWifiRemoteStationManager ()->GetNumberOfSupportedStreams (sta.second) < maxSpatialStream) { - maxSpatialStream = m_stationManager->GetNumberOfSupportedStreams (sta.second); + maxSpatialStream = GetWifiRemoteStationManager ()->GetNumberOfSupportedStreams (sta.second); } } } @@ -686,14 +687,14 @@ ApWifiMac::GetVhtOperation (void) const { operation.SetChannelWidth (0); } - uint8_t maxSpatialStream = m_phy->GetMaxSupportedRxSpatialStreams (); + uint8_t maxSpatialStream = GetWifiPhy ()->GetMaxSupportedRxSpatialStreams (); for (const auto& sta : m_staList) { - if (m_stationManager->GetVhtSupported (sta.second)) + if (GetWifiRemoteStationManager ()->GetVhtSupported (sta.second)) { - if (m_stationManager->GetNumberOfSupportedStreams (sta.second) < maxSpatialStream) + if (GetWifiRemoteStationManager ()->GetNumberOfSupportedStreams (sta.second) < maxSpatialStream) { - maxSpatialStream = m_stationManager->GetNumberOfSupportedStreams (sta.second); + maxSpatialStream = GetWifiRemoteStationManager ()->GetNumberOfSupportedStreams (sta.second); } } } @@ -714,14 +715,14 @@ ApWifiMac::GetHeOperation (void) const if (GetHeSupported ()) { operation.SetHeSupported (1); - uint8_t maxSpatialStream = m_phy->GetMaxSupportedRxSpatialStreams (); + uint8_t maxSpatialStream = GetWifiPhy ()->GetMaxSupportedRxSpatialStreams (); for (const auto& sta : m_staList) { - if (m_stationManager->GetHeSupported (sta.second)) + if (GetWifiRemoteStationManager ()->GetHeSupported (sta.second)) { - if (m_stationManager->GetNumberOfSupportedStreams (sta.second) < maxSpatialStream) + if (GetWifiRemoteStationManager ()->GetNumberOfSupportedStreams (sta.second) < maxSpatialStream) { - maxSpatialStream = m_stationManager->GetNumberOfSupportedStreams (sta.second); + maxSpatialStream = GetWifiRemoteStationManager ()->GetNumberOfSupportedStreams (sta.second); } } } @@ -751,8 +752,8 @@ ApWifiMac::SendProbeResp (Mac48Address to) probe.SetSupportedRates (GetSupportedRates ()); probe.SetBeaconIntervalUs (GetBeaconInterval ().GetMicroSeconds ()); probe.SetCapabilities (GetCapabilities ()); - m_stationManager->SetShortPreambleEnabled (m_shortPreambleEnabled); - m_stationManager->SetShortSlotTimeEnabled (m_shortSlotTimeEnabled); + GetWifiRemoteStationManager ()->SetShortPreambleEnabled (m_shortPreambleEnabled); + GetWifiRemoteStationManager ()->SetShortSlotTimeEnabled (m_shortSlotTimeEnabled); if (GetDsssSupported ()) { probe.SetDsssParameterSet (GetDsssParameterSet ()); @@ -786,7 +787,7 @@ ApWifiMac::SendProbeResp (Mac48Address to) if (!GetQosSupported ()) { - m_txop->Queue (packet, hdr); + GetTxop ()->Queue (packet, hdr); } // "A QoS STA that transmits a Management frame determines access category used // for medium access in transmission of the Management frame as follows @@ -795,7 +796,7 @@ ApWifiMac::SendProbeResp (Mac48Address to) // AC_BE should be selected. // — If category AC_BE was not selected by the previous step, category AC_VO // shall be selected." (Sec. 10.2.3.2 of 802.11-2020) - else if (!m_stationManager->GetQosSupported (to)) + else if (!GetWifiRemoteStationManager ()->GetQosSupported (to)) { GetBEQueue ()->Queue (packet, hdr); } @@ -841,12 +842,12 @@ ApWifiMac::SendAssocResp (Mac48Address to, bool success, bool isReassoc) aid = GetNextAssociationId (); m_staList.insert (std::make_pair (aid, to)); m_assocLogger (aid, to); - m_stationManager->SetAssociationId (to, aid); - if (m_stationManager->GetDsssSupported (to) && !m_stationManager->GetErpOfdmSupported (to)) + GetWifiRemoteStationManager ()->SetAssociationId (to, aid); + if (GetWifiRemoteStationManager ()->GetDsssSupported (to) && !GetWifiRemoteStationManager ()->GetErpOfdmSupported (to)) { m_numNonErpStations++; } - if (!m_stationManager->GetHtSupported (to)) + if (!GetWifiRemoteStationManager ()->GetHtSupported (to)) { m_numNonHtStations++; } @@ -891,7 +892,7 @@ ApWifiMac::SendAssocResp (Mac48Address to, bool success, bool isReassoc) if (!GetQosSupported ()) { - m_txop->Queue (packet, hdr); + GetTxop ()->Queue (packet, hdr); } // "A QoS STA that transmits a Management frame determines access category used // for medium access in transmission of the Management frame as follows @@ -900,7 +901,7 @@ ApWifiMac::SendAssocResp (Mac48Address to, bool success, bool isReassoc) // AC_BE should be selected. // — If category AC_BE was not selected by the previous step, category AC_VO // shall be selected." (Sec. 10.2.3.2 of 802.11-2020) - else if (!m_stationManager->GetQosSupported (to)) + else if (!GetWifiRemoteStationManager ()->GetQosSupported (to)) { GetBEQueue ()->Queue (packet, hdr); } @@ -927,8 +928,8 @@ ApWifiMac::SendOneBeacon (void) beacon.SetSupportedRates (GetSupportedRates ()); beacon.SetBeaconIntervalUs (GetBeaconInterval ().GetMicroSeconds ()); beacon.SetCapabilities (GetCapabilities ()); - m_stationManager->SetShortPreambleEnabled (m_shortPreambleEnabled); - m_stationManager->SetShortSlotTimeEnabled (m_shortSlotTimeEnabled); + GetWifiRemoteStationManager ()->SetShortPreambleEnabled (m_shortPreambleEnabled); + GetWifiRemoteStationManager ()->SetShortSlotTimeEnabled (m_shortSlotTimeEnabled); if (GetDsssSupported ()) { beacon.SetDsssParameterSet (GetDsssParameterSet ()); @@ -972,12 +973,12 @@ ApWifiMac::SendOneBeacon (void) if (m_shortSlotTimeEnabled) { //Enable short slot time - m_phy->SetSlot (MicroSeconds (9)); + GetWifiPhy ()->SetSlot (MicroSeconds (9)); } else { //Disable short slot time - m_phy->SetSlot (MicroSeconds (20)); + GetWifiPhy ()->SetSlot (MicroSeconds (20)); } } } @@ -988,10 +989,10 @@ ApWifiMac::TxOk (Ptr mpdu) NS_LOG_FUNCTION (this << *mpdu); const WifiMacHeader& hdr = mpdu->GetHeader (); if ((hdr.IsAssocResp () || hdr.IsReassocResp ()) - && m_stationManager->IsWaitAssocTxOk (hdr.GetAddr1 ())) + && GetWifiRemoteStationManager ()->IsWaitAssocTxOk (hdr.GetAddr1 ())) { NS_LOG_DEBUG ("associated with sta=" << hdr.GetAddr1 ()); - m_stationManager->RecordGotAssocTxOk (hdr.GetAddr1 ()); + GetWifiRemoteStationManager ()->RecordGotAssocTxOk (hdr.GetAddr1 ()); } } @@ -1002,10 +1003,10 @@ ApWifiMac::TxFailed (WifiMacDropReason timeoutReason, PtrGetHeader (); if ((hdr.IsAssocResp () || hdr.IsReassocResp ()) - && m_stationManager->IsWaitAssocTxOk (hdr.GetAddr1 ())) + && GetWifiRemoteStationManager ()->IsWaitAssocTxOk (hdr.GetAddr1 ())) { NS_LOG_DEBUG ("association failed with sta=" << hdr.GetAddr1 ()); - m_stationManager->RecordGotAssocTxFailed (hdr.GetAddr1 ()); + GetWifiRemoteStationManager ()->RecordGotAssocTxFailed (hdr.GetAddr1 ()); } } @@ -1022,7 +1023,7 @@ ApWifiMac::Receive (Ptr mpdu) if (!hdr->IsFromDs () && hdr->IsToDs () && bssid == GetAddress () - && m_stationManager->IsAssociated (from)) + && GetWifiRemoteStationManager ()->IsAssociated (from)) { Mac48Address to = hdr->GetAddr3 (); if (to == GetAddress ()) @@ -1047,7 +1048,7 @@ ApWifiMac::Receive (Ptr mpdu) } } else if (to.IsGroup () - || m_stationManager->IsAssociated (to)) + || GetWifiRemoteStationManager ()->IsAssociated (to)) { NS_LOG_DEBUG ("forwarding frame from=" << from << ", to=" << to); Ptr copy = packet->Copy (); @@ -1110,7 +1111,7 @@ ApWifiMac::Receive (Ptr mpdu) MgtAssocRequestHeader assocReq; packet->PeekHeader (assocReq); CapabilityInformation capabilities = assocReq.GetCapabilities (); - m_stationManager->AddSupportedPhyPreamble (from, capabilities.IsShortPreamble ()); + GetWifiRemoteStationManager ()->AddSupportedPhyPreamble (from, capabilities.IsShortPreamble ()); SupportedRates rates = assocReq.GetSupportedRates (); bool problem = false; if (rates.GetNRates () == 0) @@ -1123,9 +1124,9 @@ ApWifiMac::Receive (Ptr mpdu) HtCapabilities htcapabilities = assocReq.GetHtCapabilities (); if (htcapabilities.IsSupportedMcs (0)) { - for (uint8_t i = 0; i < m_stationManager->GetNBasicMcs (); i++) + for (uint8_t i = 0; i < GetWifiRemoteStationManager ()->GetNBasicMcs (); i++) { - WifiMode mcs = m_stationManager->GetBasicMcs (i); + WifiMode mcs = GetWifiRemoteStationManager ()->GetBasicMcs (i); if (!htcapabilities.IsSupportedMcs (mcs.GetMcsValue ())) { problem = true; @@ -1140,9 +1141,9 @@ ApWifiMac::Receive (Ptr mpdu) VhtCapabilities vhtcapabilities = assocReq.GetVhtCapabilities (); if (vhtcapabilities.GetVhtCapabilitiesInfo () != 0) { - for (uint8_t i = 0; i < m_stationManager->GetNBasicMcs (); i++) + for (uint8_t i = 0; i < GetWifiRemoteStationManager ()->GetNBasicMcs (); i++) { - WifiMode mcs = m_stationManager->GetBasicMcs (i); + WifiMode mcs = GetWifiRemoteStationManager ()->GetBasicMcs (i); if (!vhtcapabilities.IsSupportedTxMcs (mcs.GetMcsValue ())) { problem = true; @@ -1157,9 +1158,9 @@ ApWifiMac::Receive (Ptr mpdu) HeCapabilities hecapabilities = assocReq.GetHeCapabilities (); if (hecapabilities.GetSupportedMcsAndNss () != 0) { - for (uint8_t i = 0; i < m_stationManager->GetNBasicMcs (); i++) + for (uint8_t i = 0; i < GetWifiRemoteStationManager ()->GetNBasicMcs (); i++) { - WifiMode mcs = m_stationManager->GetBasicMcs (i); + WifiMode mcs = GetWifiRemoteStationManager ()->GetBasicMcs (i); if (!hecapabilities.IsSupportedTxMcs (mcs.GetMcsValue ())) { problem = true; @@ -1177,23 +1178,23 @@ ApWifiMac::Receive (Ptr mpdu) { NS_LOG_DEBUG ("The Basic Rate set modes are supported by the station"); //record all its supported modes in its associated WifiRemoteStation - for (const auto & mode : m_phy->GetModeList ()) + for (const auto & mode : GetWifiPhy ()->GetModeList ()) { - if (rates.IsSupportedRate (mode.GetDataRate (m_phy->GetChannelWidth ()))) + if (rates.IsSupportedRate (mode.GetDataRate (GetWifiPhy ()->GetChannelWidth ()))) { - m_stationManager->AddSupportedMode (from, mode); + GetWifiRemoteStationManager ()->AddSupportedMode (from, mode); } } - if (GetErpSupported () && m_stationManager->GetErpOfdmSupported (from) && capabilities.IsShortSlotTime ()) + if (GetErpSupported () && GetWifiRemoteStationManager ()->GetErpOfdmSupported (from) && capabilities.IsShortSlotTime ()) { - m_stationManager->AddSupportedErpSlotTime (from, true); + GetWifiRemoteStationManager ()->AddSupportedErpSlotTime (from, true); } if (GetHtSupported ()) { HtCapabilities htCapabilities = assocReq.GetHtCapabilities (); if (htCapabilities.IsSupportedMcs (0)) { - m_stationManager->AddStationHtCapabilities (from, htCapabilities); + GetWifiRemoteStationManager ()->AddStationHtCapabilities (from, htCapabilities); } } if (GetVhtSupported ()) @@ -1202,12 +1203,12 @@ ApWifiMac::Receive (Ptr mpdu) //we will always fill in RxHighestSupportedLgiDataRate field at TX, so this can be used to check whether it supports VHT if (vhtCapabilities.GetRxHighestSupportedLgiDataRate () > 0) { - m_stationManager->AddStationVhtCapabilities (from, vhtCapabilities); - for (const auto & mcs : m_phy->GetMcsList (WIFI_MOD_CLASS_VHT)) + GetWifiRemoteStationManager ()->AddStationVhtCapabilities (from, vhtCapabilities); + for (const auto & mcs : GetWifiPhy ()->GetMcsList (WIFI_MOD_CLASS_VHT)) { if (vhtCapabilities.IsSupportedTxMcs (mcs.GetMcsValue ())) { - m_stationManager->AddSupportedMcs (hdr->GetAddr2 (), mcs); + GetWifiRemoteStationManager ()->AddSupportedMcs (hdr->GetAddr2 (), mcs); //here should add a control to add basic MCS when it is implemented } } @@ -1223,18 +1224,18 @@ ApWifiMac::Receive (Ptr mpdu) HeCapabilities heCapabilities = assocReq.GetHeCapabilities (); if (heCapabilities.GetSupportedMcsAndNss () != 0) { - m_stationManager->AddStationHeCapabilities (from, heCapabilities); - for (const auto & mcs : m_phy->GetMcsList (WIFI_MOD_CLASS_HE)) + GetWifiRemoteStationManager ()->AddStationHeCapabilities (from, heCapabilities); + for (const auto & mcs : GetWifiPhy ()->GetMcsList (WIFI_MOD_CLASS_HE)) { if (heCapabilities.IsSupportedTxMcs (mcs.GetMcsValue ())) { - m_stationManager->AddSupportedMcs (hdr->GetAddr2 (), mcs); + GetWifiRemoteStationManager ()->AddSupportedMcs (hdr->GetAddr2 (), mcs); //here should add a control to add basic MCS when it is implemented } } } } - m_stationManager->RecordWaitAssocTxOk (from); + GetWifiRemoteStationManager ()->RecordWaitAssocTxOk (from); NS_LOG_DEBUG ("Send association response with success status"); SendAssocResp (hdr->GetAddr2 (), true, false); } @@ -1248,7 +1249,7 @@ ApWifiMac::Receive (Ptr mpdu) MgtReassocRequestHeader reassocReq; packet->PeekHeader (reassocReq); CapabilityInformation capabilities = reassocReq.GetCapabilities (); - m_stationManager->AddSupportedPhyPreamble (from, capabilities.IsShortPreamble ()); + GetWifiRemoteStationManager ()->AddSupportedPhyPreamble (from, capabilities.IsShortPreamble ()); SupportedRates rates = reassocReq.GetSupportedRates (); bool problem = false; if (rates.GetNRates () == 0) @@ -1261,9 +1262,9 @@ ApWifiMac::Receive (Ptr mpdu) HtCapabilities htcapabilities = reassocReq.GetHtCapabilities (); if (htcapabilities.IsSupportedMcs (0)) { - for (uint8_t i = 0; i < m_stationManager->GetNBasicMcs (); i++) + for (uint8_t i = 0; i < GetWifiRemoteStationManager ()->GetNBasicMcs (); i++) { - WifiMode mcs = m_stationManager->GetBasicMcs (i); + WifiMode mcs = GetWifiRemoteStationManager ()->GetBasicMcs (i); if (!htcapabilities.IsSupportedMcs (mcs.GetMcsValue ())) { problem = true; @@ -1278,9 +1279,9 @@ ApWifiMac::Receive (Ptr mpdu) VhtCapabilities vhtcapabilities = reassocReq.GetVhtCapabilities (); if (vhtcapabilities.GetVhtCapabilitiesInfo () != 0) { - for (uint8_t i = 0; i < m_stationManager->GetNBasicMcs (); i++) + for (uint8_t i = 0; i < GetWifiRemoteStationManager ()->GetNBasicMcs (); i++) { - WifiMode mcs = m_stationManager->GetBasicMcs (i); + WifiMode mcs = GetWifiRemoteStationManager ()->GetBasicMcs (i); if (!vhtcapabilities.IsSupportedTxMcs (mcs.GetMcsValue ())) { problem = true; @@ -1295,9 +1296,9 @@ ApWifiMac::Receive (Ptr mpdu) HeCapabilities hecapabilities = reassocReq.GetHeCapabilities (); if (hecapabilities.GetSupportedMcsAndNss () != 0) { - for (uint8_t i = 0; i < m_stationManager->GetNBasicMcs (); i++) + for (uint8_t i = 0; i < GetWifiRemoteStationManager ()->GetNBasicMcs (); i++) { - WifiMode mcs = m_stationManager->GetBasicMcs (i); + WifiMode mcs = GetWifiRemoteStationManager ()->GetBasicMcs (i); if (!hecapabilities.IsSupportedTxMcs (mcs.GetMcsValue ())) { problem = true; @@ -1315,23 +1316,23 @@ ApWifiMac::Receive (Ptr mpdu) { NS_LOG_DEBUG ("The Basic Rate set modes are supported by the station"); //update all its supported modes in its associated WifiRemoteStation - for (const auto & mode : m_phy->GetModeList ()) + for (const auto & mode : GetWifiPhy ()->GetModeList ()) { - if (rates.IsSupportedRate (mode.GetDataRate (m_phy->GetChannelWidth ()))) + if (rates.IsSupportedRate (mode.GetDataRate (GetWifiPhy ()->GetChannelWidth ()))) { - m_stationManager->AddSupportedMode (from, mode); + GetWifiRemoteStationManager ()->AddSupportedMode (from, mode); } } - if (GetErpSupported () && m_stationManager->GetErpOfdmSupported (from) && capabilities.IsShortSlotTime ()) + if (GetErpSupported () && GetWifiRemoteStationManager ()->GetErpOfdmSupported (from) && capabilities.IsShortSlotTime ()) { - m_stationManager->AddSupportedErpSlotTime (from, true); + GetWifiRemoteStationManager ()->AddSupportedErpSlotTime (from, true); } if (GetHtSupported ()) { HtCapabilities htCapabilities = reassocReq.GetHtCapabilities (); if (htCapabilities.IsSupportedMcs (0)) { - m_stationManager->AddStationHtCapabilities (from, htCapabilities); + GetWifiRemoteStationManager ()->AddStationHtCapabilities (from, htCapabilities); } } if (GetVhtSupported ()) @@ -1340,12 +1341,12 @@ ApWifiMac::Receive (Ptr mpdu) //we will always fill in RxHighestSupportedLgiDataRate field at TX, so this can be used to check whether it supports VHT if (vhtCapabilities.GetRxHighestSupportedLgiDataRate () > 0) { - m_stationManager->AddStationVhtCapabilities (from, vhtCapabilities); - for (const auto & mcs : m_phy->GetMcsList (WIFI_MOD_CLASS_VHT)) + GetWifiRemoteStationManager ()->AddStationVhtCapabilities (from, vhtCapabilities); + for (const auto & mcs : GetWifiPhy ()->GetMcsList (WIFI_MOD_CLASS_VHT)) { if (vhtCapabilities.IsSupportedTxMcs (mcs.GetMcsValue ())) { - m_stationManager->AddSupportedMcs (hdr->GetAddr2 (), mcs); + GetWifiRemoteStationManager ()->AddSupportedMcs (hdr->GetAddr2 (), mcs); //here should add a control to add basic MCS when it is implemented } } @@ -1361,18 +1362,18 @@ ApWifiMac::Receive (Ptr mpdu) HeCapabilities heCapabilities = reassocReq.GetHeCapabilities (); if (heCapabilities.GetSupportedMcsAndNss () != 0) { - m_stationManager->AddStationHeCapabilities (from, heCapabilities); - for (const auto & mcs : m_phy->GetMcsList (WIFI_MOD_CLASS_HE)) + GetWifiRemoteStationManager ()->AddStationHeCapabilities (from, heCapabilities); + for (const auto & mcs : GetWifiPhy ()->GetMcsList (WIFI_MOD_CLASS_HE)) { if (heCapabilities.IsSupportedTxMcs (mcs.GetMcsValue ())) { - m_stationManager->AddSupportedMcs (hdr->GetAddr2 (), mcs); + GetWifiRemoteStationManager ()->AddSupportedMcs (hdr->GetAddr2 (), mcs); //here should add a control to add basic MCS when it is implemented } } } } - m_stationManager->RecordWaitAssocTxOk (from); + GetWifiRemoteStationManager ()->RecordWaitAssocTxOk (from); NS_LOG_DEBUG ("Send reassociation response with success status"); SendAssocResp (hdr->GetAddr2 (), true, true); } @@ -1381,18 +1382,18 @@ ApWifiMac::Receive (Ptr mpdu) else if (hdr->IsDisassociation ()) { NS_LOG_DEBUG ("Disassociation received from " << from); - m_stationManager->RecordDisassociated (from); + GetWifiRemoteStationManager ()->RecordDisassociated (from); for (auto it = m_staList.begin (); it != m_staList.end (); ++it) { if (it->second == from) { m_staList.erase (it); m_deAssocLogger (it->first, it->second); - if (m_stationManager->GetDsssSupported (from) && !m_stationManager->GetErpOfdmSupported (from)) + if (GetWifiRemoteStationManager ()->GetDsssSupported (from) && !GetWifiRemoteStationManager ()->GetErpOfdmSupported (from)) { m_numNonErpStations--; } - if (!m_stationManager->GetHtSupported (from)) + if (!GetWifiRemoteStationManager ()->GetHtSupported (from)) { m_numNonHtStations--; } @@ -1409,7 +1410,7 @@ ApWifiMac::Receive (Ptr mpdu) //Invoke the receive handler of our parent class to deal with any //other frames. Specifically, this will handle Block Ack-related //Management Action frames. - RegularWifiMac::Receive (Create (packet, *hdr)); + WifiMac::Receive (Create (packet, *hdr)); } void @@ -1455,7 +1456,7 @@ ApWifiMac::DoInitialize (void) } NS_ABORT_IF (!TraceConnectWithoutContext ("AckedMpdu", MakeCallback (&ApWifiMac::TxOk, this))); NS_ABORT_IF (!TraceConnectWithoutContext ("DroppedMpdu", MakeCallback (&ApWifiMac::TxFailed, this))); - RegularWifiMac::DoInitialize (); + WifiMac::DoInitialize (); UpdateShortSlotTimeEnabled (); UpdateShortPreambleEnabled (); } @@ -1464,7 +1465,7 @@ bool ApWifiMac::GetUseNonErpProtection (void) const { bool useProtection = (m_numNonErpStations > 0) && m_enableNonErpProtection; - m_stationManager->SetUseNonErpProtection (useProtection); + GetWifiRemoteStationManager ()->SetUseNonErpProtection (useProtection); return useProtection; } @@ -1492,7 +1493,7 @@ ApWifiMac::GetStaList (void) const uint16_t ApWifiMac::GetAssociationId (Mac48Address addr) const { - return m_stationManager->GetAssociationId (addr); + return GetWifiRemoteStationManager ()->GetAssociationId (addr); } uint8_t diff --git a/src/wifi/model/ap-wifi-mac.h b/src/wifi/model/ap-wifi-mac.h index a2d3d1f5d..5a6f47f6d 100644 --- a/src/wifi/model/ap-wifi-mac.h +++ b/src/wifi/model/ap-wifi-mac.h @@ -23,7 +23,7 @@ #ifndef AP_WIFI_MAC_H #define AP_WIFI_MAC_H -#include "regular-wifi-mac.h" +#include "wifi-mac.h" #include namespace ns3 { @@ -38,6 +38,7 @@ class HtOperation; class VhtOperation; class HeOperation; class CfParameterSet; +class UniformRandomVariable; /** * \brief Wi-Fi AP state machine @@ -46,7 +47,7 @@ class CfParameterSet; * Handle association, dis-association and authentication, * of STAs within an infrastructure BSS. */ -class ApWifiMac : public RegularWifiMac +class ApWifiMac : public WifiMac { public: /** diff --git a/src/wifi/model/frame-exchange-manager.cc b/src/wifi/model/frame-exchange-manager.cc index 38c3c4380..9e1beab6f 100644 --- a/src/wifi/model/frame-exchange-manager.cc +++ b/src/wifi/model/frame-exchange-manager.cc @@ -127,7 +127,7 @@ FrameExchangeManager::GetAckManager (void) const } void -FrameExchangeManager::SetWifiMac (Ptr mac) +FrameExchangeManager::SetWifiMac (Ptr mac) { NS_LOG_FUNCTION (this << mac); m_mac = mac; diff --git a/src/wifi/model/frame-exchange-manager.h b/src/wifi/model/frame-exchange-manager.h index 40c710ead..1b112cfc0 100644 --- a/src/wifi/model/frame-exchange-manager.h +++ b/src/wifi/model/frame-exchange-manager.h @@ -25,7 +25,7 @@ #include "qos-txop.h" #include "wifi-tx-vector.h" #include "wifi-psdu.h" -#include "regular-wifi-mac.h" +#include "wifi-mac.h" #include "mac-rx-middle.h" #include "mac-tx-middle.h" #include "wifi-phy.h" @@ -96,7 +96,7 @@ public: * * \param mac the MAC layer to use */ - virtual void SetWifiMac (const Ptr mac); + virtual void SetWifiMac (const Ptr mac); /** * Set the MAC TX Middle to use. * @@ -378,7 +378,7 @@ protected: Ptr m_dcf; //!< the DCF/EDCAF that gained channel access WifiTxTimer m_txTimer; //!< the timer set upon frame transmission EventId m_navResetEvent; //!< the event to reset the NAV after an RTS - Ptr m_mac; //!< the MAC layer on this station + Ptr m_mac; //!< the MAC layer on this station Ptr m_txMiddle; //!< the MAC TX Middle on this station Ptr m_rxMiddle; //!< the MAC RX Middle on this station Ptr m_channelAccessManager; //!< the channel access manager diff --git a/src/wifi/model/he/he-frame-exchange-manager.cc b/src/wifi/model/he/he-frame-exchange-manager.cc index f7bd9be73..d057a5c6e 100644 --- a/src/wifi/model/he/he-frame-exchange-manager.cc +++ b/src/wifi/model/he/he-frame-exchange-manager.cc @@ -74,7 +74,7 @@ HeFrameExchangeManager::GetSupportedBaBufferSize (void) const } void -HeFrameExchangeManager::SetWifiMac (const Ptr mac) +HeFrameExchangeManager::SetWifiMac (const Ptr mac) { m_apMac = DynamicCast (mac); m_staMac = DynamicCast (mac); diff --git a/src/wifi/model/he/he-frame-exchange-manager.h b/src/wifi/model/he/he-frame-exchange-manager.h index 8c7b12276..a8ecbdeb1 100644 --- a/src/wifi/model/he/he-frame-exchange-manager.h +++ b/src/wifi/model/he/he-frame-exchange-manager.h @@ -61,7 +61,7 @@ public: uint16_t GetSupportedBaBufferSize (void) const override; bool StartFrameExchange (Ptr edca, Time availableTime, bool initialFrame) override; - void SetWifiMac (const Ptr mac) override; + void SetWifiMac (const Ptr mac) override; void CalculateAcknowledgmentTime (WifiAcknowledgment* acknowledgment) const override; void SetTxopHolder (Ptr psdu, const WifiTxVector& txVector) override; diff --git a/src/wifi/model/ht/ht-frame-exchange-manager.cc b/src/wifi/model/ht/ht-frame-exchange-manager.cc index c694ba811..59ae97ac9 100644 --- a/src/wifi/model/ht/ht-frame-exchange-manager.cc +++ b/src/wifi/model/ht/ht-frame-exchange-manager.cc @@ -75,7 +75,7 @@ HtFrameExchangeManager::DoDispose (void) } void -HtFrameExchangeManager::SetWifiMac (const Ptr mac) +HtFrameExchangeManager::SetWifiMac (const Ptr mac) { m_msduAggregator->SetWifiMac (mac); m_mpduAggregator->SetWifiMac (mac); diff --git a/src/wifi/model/ht/ht-frame-exchange-manager.h b/src/wifi/model/ht/ht-frame-exchange-manager.h index a8bc5e13e..bd0699ca7 100644 --- a/src/wifi/model/ht/ht-frame-exchange-manager.h +++ b/src/wifi/model/ht/ht-frame-exchange-manager.h @@ -60,7 +60,7 @@ public: virtual ~HtFrameExchangeManager (); bool StartFrameExchange (Ptr edca, Time availableTime, bool initialFrame) override; - void SetWifiMac (const Ptr mac) override; + void SetWifiMac (const Ptr mac) override; void CalculateAcknowledgmentTime (WifiAcknowledgment* acknowledgment) const override; /** @@ -145,7 +145,7 @@ public: * \param startingSeq Sequence number of the first MPDU of all * packets for which block ack was negotiated. * - * This function is typically invoked only by ns3::RegularWifiMac + * This function is typically invoked only by ns3::WifiMac * when the STA (which may be non-AP in ESS, or in an IBSS) has * received an ADDBA Request frame and is transmitting an ADDBA * Response frame. At this point the frame exchange manager must diff --git a/src/wifi/model/mpdu-aggregator.cc b/src/wifi/model/mpdu-aggregator.cc index ee311edcb..b0fafaff3 100644 --- a/src/wifi/model/mpdu-aggregator.cc +++ b/src/wifi/model/mpdu-aggregator.cc @@ -33,7 +33,8 @@ #include "ns3/ht-capabilities.h" #include "ns3/vht-capabilities.h" #include "ns3/he-capabilities.h" -#include "regular-wifi-mac.h" +#include "wifi-mac.h" +#include "qos-txop.h" #include "ctrl-headers.h" #include "wifi-mac-trailer.h" #include "wifi-tx-parameters.h" @@ -71,7 +72,7 @@ MpduAggregator::DoDispose () } void -MpduAggregator::SetWifiMac (const Ptr mac) +MpduAggregator::SetWifiMac (const Ptr mac) { NS_LOG_FUNCTION (this << mac); m_mac = mac; diff --git a/src/wifi/model/mpdu-aggregator.h b/src/wifi/model/mpdu-aggregator.h index a102e7722..1aaf0d88a 100644 --- a/src/wifi/model/mpdu-aggregator.h +++ b/src/wifi/model/mpdu-aggregator.h @@ -23,7 +23,7 @@ #include "ns3/object.h" #include "wifi-mode.h" -#include "qos-txop.h" +#include "wifi-mac-queue-item.h" #include "ns3/nstime.h" #include @@ -31,9 +31,9 @@ namespace ns3 { class AmpduSubframeHeader; class WifiTxVector; +class QosTxop; class Packet; -class WifiMacQueueItem; -class RegularWifiMac; +class WifiMac; class WifiTxParameters; /** @@ -129,7 +129,7 @@ public: * * \param mac the MAC layer to use */ - void SetWifiMac (const Ptr mac); + void SetWifiMac (const Ptr mac); /** * \param ampduSize the size of the A-MPDU that needs to be padded in bytes @@ -155,7 +155,7 @@ protected: void DoDispose () override; private: - Ptr m_mac; //!< the MAC of this station + Ptr m_mac; //!< the MAC of this station }; } //namespace ns3 diff --git a/src/wifi/model/msdu-aggregator.cc b/src/wifi/model/msdu-aggregator.cc index b77b5ca7c..cdd2bb1a9 100644 --- a/src/wifi/model/msdu-aggregator.cc +++ b/src/wifi/model/msdu-aggregator.cc @@ -25,7 +25,7 @@ #include "qos-txop.h" #include "wifi-remote-station-manager.h" #include "ns3/ht-capabilities.h" -#include "regular-wifi-mac.h" +#include "wifi-mac.h" #include "wifi-mac-queue.h" #include "wifi-mac-trailer.h" #include "ns3/ht-frame-exchange-manager.h" @@ -66,7 +66,7 @@ MsduAggregator::DoDispose () } void -MsduAggregator::SetWifiMac (const Ptr mac) +MsduAggregator::SetWifiMac (const Ptr mac) { NS_LOG_FUNCTION (this << mac); m_mac = mac; diff --git a/src/wifi/model/msdu-aggregator.h b/src/wifi/model/msdu-aggregator.h index 25e41a724..bdbeef695 100644 --- a/src/wifi/model/msdu-aggregator.h +++ b/src/wifi/model/msdu-aggregator.h @@ -33,7 +33,7 @@ namespace ns3 { class Packet; class QosTxop; class WifiTxVector; -class RegularWifiMac; +class WifiMac; class HtFrameExchangeManager; class WifiTxParameters; @@ -125,7 +125,7 @@ public: * * \param mac the MAC layer to use */ - void SetWifiMac (const Ptr mac); + void SetWifiMac (const Ptr mac); /** * Calculate how much padding must be added to the end of an A-MSDU of the @@ -142,7 +142,7 @@ protected: void DoDispose () override; private: - Ptr m_mac; //!< the MAC of this station + Ptr m_mac; //!< the MAC of this station Ptr m_htFem; //!< the HT Frame Exchange Manager of this station }; diff --git a/src/wifi/model/regular-wifi-mac.cc b/src/wifi/model/regular-wifi-mac.cc deleted file mode 100644 index 030f63dfb..000000000 --- a/src/wifi/model/regular-wifi-mac.cc +++ /dev/null @@ -1,1269 +0,0 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ -/* - * Copyright (c) 2008 INRIA - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation; - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Author: Mathieu Lacage - */ - -#include "ns3/log.h" -#include "ns3/pointer.h" -#include "ns3/packet.h" -#include "regular-wifi-mac.h" -#include "wifi-phy.h" -#include "mac-rx-middle.h" -#include "mac-tx-middle.h" -#include "msdu-aggregator.h" -#include "mpdu-aggregator.h" -#include "mgt-headers.h" -#include "amsdu-subframe-header.h" -#include "wifi-net-device.h" -#include "ns3/ht-configuration.h" -#include "ns3/vht-configuration.h" -#include "ns3/he-configuration.h" -#include -#include -#include "ns3/he-frame-exchange-manager.h" -#include "channel-access-manager.h" -#include "wifi-mac-queue.h" - -namespace ns3 { - -NS_LOG_COMPONENT_DEFINE ("RegularWifiMac"); - -NS_OBJECT_ENSURE_REGISTERED (RegularWifiMac); - -RegularWifiMac::RegularWifiMac () - : m_qosSupported (0), - m_erpSupported (0), - m_dsssSupported (0) -{ - NS_LOG_FUNCTION (this); - m_rxMiddle = Create (); - m_rxMiddle->SetForwardCallback (MakeCallback (&RegularWifiMac::Receive, this)); - - m_txMiddle = Create (); - - m_channelAccessManager = CreateObject (); -} - -RegularWifiMac::~RegularWifiMac () -{ - NS_LOG_FUNCTION (this); -} - -void -RegularWifiMac::DoInitialize () -{ - NS_LOG_FUNCTION (this); - if (m_txop != nullptr) - { - m_txop->Initialize (); - } - - for (EdcaQueues::const_iterator i = m_edca.begin (); i != m_edca.end (); ++i) - { - i->second->Initialize (); - } -} - -void -RegularWifiMac::DoDispose () -{ - NS_LOG_FUNCTION (this); - - m_rxMiddle = 0; - m_txMiddle = 0; - - m_phy = 0; - m_stationManager = 0; - if (m_feManager != 0) - { - m_feManager->Dispose (); - } - m_feManager = 0; - - if (m_txop != nullptr) - { - m_txop->Dispose (); - } - m_txop = 0; - - for (EdcaQueues::iterator i = m_edca.begin (); i != m_edca.end (); ++i) - { - i->second->Dispose (); - i->second = 0; - } - - m_channelAccessManager->Dispose (); - m_channelAccessManager = 0; - - WifiMac::DoDispose (); -} - -void -RegularWifiMac::SetupFrameExchangeManager (WifiStandard standard) -{ - NS_LOG_FUNCTION (this); - NS_ABORT_MSG_IF (standard == WIFI_STANDARD_UNSPECIFIED, "Wifi standard not set"); - - if (standard >= WIFI_STANDARD_80211ax) - { - m_feManager = CreateObject (); - } - else if (standard >= WIFI_STANDARD_80211ac) - { - m_feManager = CreateObject (); - } - else if (standard >= WIFI_STANDARD_80211n) - { - m_feManager = CreateObject (); - } - else if (m_qosSupported) - { - m_feManager = CreateObject (); - } - else - { - m_feManager = CreateObject (); - } - - m_feManager->SetWifiMac (this); - m_feManager->SetMacTxMiddle (m_txMiddle); - m_feManager->SetMacRxMiddle (m_rxMiddle); - m_feManager->SetAddress (GetAddress ()); - m_feManager->SetBssid (GetBssid ()); - m_feManager->GetWifiTxTimer ().SetMpduResponseTimeoutCallback (MakeCallback (&MpduResponseTimeoutTracedCallback::operator(), - &m_mpduResponseTimeoutCallback)); - m_feManager->GetWifiTxTimer ().SetPsduResponseTimeoutCallback (MakeCallback (&PsduResponseTimeoutTracedCallback::operator(), - &m_psduResponseTimeoutCallback)); - m_feManager->GetWifiTxTimer ().SetPsduMapResponseTimeoutCallback (MakeCallback (&PsduMapResponseTimeoutTracedCallback::operator(), - &m_psduMapResponseTimeoutCallback)); - m_feManager->SetDroppedMpduCallback (MakeCallback (&DroppedMpduTracedCallback::operator(), - &m_droppedMpduCallback)); - m_feManager->SetAckedMpduCallback (MakeCallback (&MpduTracedCallback::operator(), - &m_ackedMpduCallback)); - m_channelAccessManager->SetupFrameExchangeManager (m_feManager); - if (GetQosSupported ()) - { - for (const auto& pair : m_edca) - { - pair.second->SetQosFrameExchangeManager (DynamicCast (m_feManager)); - } - } -} - -Ptr -RegularWifiMac::GetFrameExchangeManager (void) const -{ - return m_feManager; -} - -void -RegularWifiMac::SetWifiRemoteStationManager (const Ptr stationManager) -{ - NS_LOG_FUNCTION (this << stationManager); - m_stationManager = stationManager; -} - -Ptr -RegularWifiMac::GetWifiRemoteStationManager () const -{ - return m_stationManager; -} - -ExtendedCapabilities -RegularWifiMac::GetExtendedCapabilities (void) const -{ - NS_LOG_FUNCTION (this); - ExtendedCapabilities capabilities; - capabilities.SetHtSupported (GetHtSupported ()); - capabilities.SetVhtSupported (GetVhtSupported ()); - //TODO: to be completed - return capabilities; -} - -HtCapabilities -RegularWifiMac::GetHtCapabilities (void) const -{ - NS_LOG_FUNCTION (this); - HtCapabilities capabilities; - if (GetHtSupported ()) - { - Ptr htConfiguration = GetHtConfiguration (); - bool sgiSupported = htConfiguration->GetShortGuardIntervalSupported (); - capabilities.SetHtSupported (1); - capabilities.SetLdpc (htConfiguration->GetLdpcSupported ()); - capabilities.SetSupportedChannelWidth (m_phy->GetChannelWidth () >= 40); - capabilities.SetShortGuardInterval20 (sgiSupported); - capabilities.SetShortGuardInterval40 (m_phy->GetChannelWidth () >= 40 && sgiSupported); - // Set Maximum A-MSDU Length subfield - uint16_t maxAmsduSize = std::max ({m_voMaxAmsduSize, m_viMaxAmsduSize, - m_beMaxAmsduSize, m_bkMaxAmsduSize}); - if (maxAmsduSize <= 3839) - { - capabilities.SetMaxAmsduLength (3839); - } - else - { - capabilities.SetMaxAmsduLength (7935); - } - uint32_t maxAmpduLength = std::max ({m_voMaxAmpduSize, m_viMaxAmpduSize, - m_beMaxAmpduSize, m_bkMaxAmpduSize}); - // round to the next power of two minus one - maxAmpduLength = (1ul << static_cast (std::ceil (std::log2 (maxAmpduLength + 1)))) - 1; - // The maximum A-MPDU length in HT capabilities elements ranges from 2^13-1 to 2^16-1 - capabilities.SetMaxAmpduLength (std::min (std::max (maxAmpduLength, 8191u), 65535u)); - - capabilities.SetLSigProtectionSupport (true); - uint64_t maxSupportedRate = 0; //in bit/s - for (const auto & mcs : m_phy->GetMcsList (WIFI_MOD_CLASS_HT)) - { - capabilities.SetRxMcsBitmask (mcs.GetMcsValue ()); - uint8_t nss = (mcs.GetMcsValue () / 8) + 1; - NS_ASSERT (nss > 0 && nss < 5); - uint64_t dataRate = mcs.GetDataRate (m_phy->GetChannelWidth (), sgiSupported ? 400 : 800, nss); - if (dataRate > maxSupportedRate) - { - maxSupportedRate = dataRate; - NS_LOG_DEBUG ("Updating maxSupportedRate to " << maxSupportedRate); - } - } - capabilities.SetRxHighestSupportedDataRate (static_cast (maxSupportedRate / 1e6)); //in Mbit/s - capabilities.SetTxMcsSetDefined (m_phy->GetNMcs () > 0); - capabilities.SetTxMaxNSpatialStreams (m_phy->GetMaxSupportedTxSpatialStreams ()); - //we do not support unequal modulations - capabilities.SetTxRxMcsSetUnequal (0); - capabilities.SetTxUnequalModulation (0); - } - return capabilities; -} - -VhtCapabilities -RegularWifiMac::GetVhtCapabilities (void) const -{ - NS_LOG_FUNCTION (this); - VhtCapabilities capabilities; - if (GetVhtSupported ()) - { - Ptr htConfiguration = GetHtConfiguration (); - Ptr vhtConfiguration = GetVhtConfiguration (); - bool sgiSupported = htConfiguration->GetShortGuardIntervalSupported (); - capabilities.SetVhtSupported (1); - if (m_phy->GetChannelWidth () == 160) - { - capabilities.SetSupportedChannelWidthSet (1); - } - else - { - capabilities.SetSupportedChannelWidthSet (0); - } - // Set Maximum MPDU Length subfield - uint16_t maxAmsduSize = std::max ({m_voMaxAmsduSize, m_viMaxAmsduSize, - m_beMaxAmsduSize, m_bkMaxAmsduSize}); - if (maxAmsduSize <= 3839) - { - capabilities.SetMaxMpduLength (3895); - } - else if (maxAmsduSize <= 7935) - { - capabilities.SetMaxMpduLength (7991); - } - else - { - capabilities.SetMaxMpduLength (11454); - } - uint32_t maxAmpduLength = std::max ({m_voMaxAmpduSize, m_viMaxAmpduSize, - m_beMaxAmpduSize, m_bkMaxAmpduSize}); - // round to the next power of two minus one - maxAmpduLength = (1ul << static_cast (std::ceil (std::log2 (maxAmpduLength + 1)))) - 1; - // The maximum A-MPDU length in VHT capabilities elements ranges from 2^13-1 to 2^20-1 - capabilities.SetMaxAmpduLength (std::min (std::max (maxAmpduLength, 8191u), 1048575u)); - - capabilities.SetRxLdpc (htConfiguration->GetLdpcSupported ()); - capabilities.SetShortGuardIntervalFor80Mhz ((m_phy->GetChannelWidth () == 80) && sgiSupported); - capabilities.SetShortGuardIntervalFor160Mhz ((m_phy->GetChannelWidth () == 160) && sgiSupported); - uint8_t maxMcs = 0; - for (const auto & mcs : m_phy->GetMcsList (WIFI_MOD_CLASS_VHT)) - { - if (mcs.GetMcsValue () > maxMcs) - { - maxMcs = mcs.GetMcsValue (); - } - } - // Support same MaxMCS for each spatial stream - for (uint8_t nss = 1; nss <= m_phy->GetMaxSupportedRxSpatialStreams (); nss++) - { - capabilities.SetRxMcsMap (maxMcs, nss); - } - for (uint8_t nss = 1; nss <= m_phy->GetMaxSupportedTxSpatialStreams (); nss++) - { - capabilities.SetTxMcsMap (maxMcs, nss); - } - uint64_t maxSupportedRateLGI = 0; //in bit/s - for (const auto & mcs : m_phy->GetMcsList (WIFI_MOD_CLASS_VHT)) - { - if (!mcs.IsAllowed (m_phy->GetChannelWidth (), 1)) - { - continue; - } - if (mcs.GetDataRate (m_phy->GetChannelWidth ()) > maxSupportedRateLGI) - { - maxSupportedRateLGI = mcs.GetDataRate (m_phy->GetChannelWidth ()); - NS_LOG_DEBUG ("Updating maxSupportedRateLGI to " << maxSupportedRateLGI); - } - } - capabilities.SetRxHighestSupportedLgiDataRate (static_cast (maxSupportedRateLGI / 1e6)); //in Mbit/s - capabilities.SetTxHighestSupportedLgiDataRate (static_cast (maxSupportedRateLGI / 1e6)); //in Mbit/s - //To be filled in once supported - capabilities.SetRxStbc (0); - capabilities.SetTxStbc (0); - } - return capabilities; -} - -HeCapabilities -RegularWifiMac::GetHeCapabilities (void) const -{ - NS_LOG_FUNCTION (this); - HeCapabilities capabilities; - if (GetHeSupported ()) - { - Ptr htConfiguration = GetHtConfiguration (); - Ptr heConfiguration = GetHeConfiguration (); - capabilities.SetHeSupported (1); - uint8_t channelWidthSet = 0; - if ((m_phy->GetChannelWidth () >= 40) && (m_phy->GetPhyBand () == WIFI_PHY_BAND_2_4GHZ)) - { - channelWidthSet |= 0x01; - } - if ((m_phy->GetChannelWidth () >= 80) && ((m_phy->GetPhyBand () == WIFI_PHY_BAND_5GHZ) || (m_phy->GetPhyBand () == WIFI_PHY_BAND_6GHZ))) - { - channelWidthSet |= 0x02; - } - if ((m_phy->GetChannelWidth () >= 160) && ((m_phy->GetPhyBand () == WIFI_PHY_BAND_5GHZ) || (m_phy->GetPhyBand () == WIFI_PHY_BAND_6GHZ))) - { - channelWidthSet |= 0x04; - } - capabilities.SetChannelWidthSet (channelWidthSet); - capabilities.SetLdpcCodingInPayload (htConfiguration->GetLdpcSupported ()); - if (heConfiguration->GetGuardInterval () == NanoSeconds (800)) - { - //todo: We assume for now that if we support 800ns GI then 1600ns GI is supported as well - //todo: Assuming reception support for both 1x HE LTF and 4x HE LTF 800 ns - capabilities.SetHeSuPpdu1xHeLtf800nsGi (true); - capabilities.SetHePpdu4xHeLtf800nsGi (true); - } - - uint32_t maxAmpduLength = std::max ({m_voMaxAmpduSize, m_viMaxAmpduSize, - m_beMaxAmpduSize, m_bkMaxAmpduSize}); - // round to the next power of two minus one - maxAmpduLength = (1ul << static_cast (std::ceil (std::log2 (maxAmpduLength + 1)))) - 1; - // The maximum A-MPDU length in HE capabilities elements ranges from 2^20-1 to 2^23-1 - capabilities.SetMaxAmpduLength (std::min (std::max (maxAmpduLength, 1048575u), 8388607u)); - - uint8_t maxMcs = 0; - for (const auto & mcs : m_phy->GetMcsList (WIFI_MOD_CLASS_HE)) - { - if (mcs.GetMcsValue () > maxMcs) - { - maxMcs = mcs.GetMcsValue (); - } - } - capabilities.SetHighestMcsSupported (maxMcs); - capabilities.SetHighestNssSupported (m_phy->GetMaxSupportedTxSpatialStreams ()); - } - return capabilities; -} - -void -RegularWifiMac::SetVoBlockAckThreshold (uint8_t threshold) -{ - NS_LOG_FUNCTION (this << +threshold); - if (m_qosSupported) - { - GetVOQueue ()->SetBlockAckThreshold (threshold); - } -} - -void -RegularWifiMac::SetViBlockAckThreshold (uint8_t threshold) -{ - NS_LOG_FUNCTION (this << +threshold); - if (m_qosSupported) - { - GetVIQueue ()->SetBlockAckThreshold (threshold); - } -} - -void -RegularWifiMac::SetBeBlockAckThreshold (uint8_t threshold) -{ - NS_LOG_FUNCTION (this << +threshold); - if (m_qosSupported) - { - GetBEQueue ()->SetBlockAckThreshold (threshold); - } -} - -void -RegularWifiMac::SetBkBlockAckThreshold (uint8_t threshold) -{ - NS_LOG_FUNCTION (this << +threshold); - if (m_qosSupported) - { - GetBKQueue ()->SetBlockAckThreshold (threshold); - } -} - -void -RegularWifiMac::SetVoBlockAckInactivityTimeout (uint16_t timeout) -{ - NS_LOG_FUNCTION (this << timeout); - if (m_qosSupported) - { - GetVOQueue ()->SetBlockAckInactivityTimeout (timeout); - } -} - -void -RegularWifiMac::SetViBlockAckInactivityTimeout (uint16_t timeout) -{ - NS_LOG_FUNCTION (this << timeout); - if (m_qosSupported) - { - GetVIQueue ()->SetBlockAckInactivityTimeout (timeout); - } -} - -void -RegularWifiMac::SetBeBlockAckInactivityTimeout (uint16_t timeout) -{ - NS_LOG_FUNCTION (this << timeout); - if (m_qosSupported) - { - GetBEQueue ()->SetBlockAckInactivityTimeout (timeout); - } -} - -void -RegularWifiMac::SetBkBlockAckInactivityTimeout (uint16_t timeout) -{ - NS_LOG_FUNCTION (this << timeout); - if (m_qosSupported) - { - GetBKQueue ()->SetBlockAckInactivityTimeout (timeout); - } -} - -void -RegularWifiMac::SetupEdcaQueue (AcIndex ac) -{ - NS_LOG_FUNCTION (this << ac); - - //Our caller shouldn't be attempting to setup a queue that is - //already configured. - NS_ASSERT (m_edca.find (ac) == m_edca.end ()); - - Ptr edca = CreateObject (ac); - edca->SetChannelAccessManager (m_channelAccessManager); - edca->SetWifiMac (this); - edca->SetTxMiddle (m_txMiddle); - edca->GetBaManager ()->SetTxOkCallback (MakeCallback (&MpduTracedCallback::operator(), - &m_ackedMpduCallback)); - edca->GetBaManager ()->SetTxFailedCallback (MakeCallback (&MpduTracedCallback::operator(), - &m_nackedMpduCallback)); - edca->SetDroppedMpduCallback (MakeCallback (&DroppedMpduTracedCallback::operator(), - &m_droppedMpduCallback)); - - m_edca.insert (std::make_pair (ac, edca)); -} - -void -RegularWifiMac::SetTypeOfStation (TypeOfStation type) -{ - NS_LOG_FUNCTION (this << type); - m_typeOfStation = type; -} - -TypeOfStation -RegularWifiMac::GetTypeOfStation (void) const -{ - return m_typeOfStation; -} - -Ptr -RegularWifiMac::GetTxop () const -{ - return m_txop; -} - -Ptr -RegularWifiMac::GetQosTxop (AcIndex ac) const -{ - return m_edca.find (ac)->second; -} - -Ptr -RegularWifiMac::GetQosTxop (uint8_t tid) const -{ - return GetQosTxop (QosUtilsMapTidToAc (tid)); -} - -Ptr -RegularWifiMac::GetVOQueue () const -{ - return (m_qosSupported ? m_edca.find (AC_VO)->second : nullptr); -} - -Ptr -RegularWifiMac::GetVIQueue () const -{ - return (m_qosSupported ? m_edca.find (AC_VI)->second : nullptr); -} - -Ptr -RegularWifiMac::GetBEQueue () const -{ - return (m_qosSupported ? m_edca.find (AC_BE)->second : nullptr); -} - -Ptr -RegularWifiMac::GetBKQueue () const -{ - return (m_qosSupported ? m_edca.find (AC_BK)->second : nullptr); -} - -Ptr -RegularWifiMac::GetTxopQueue (AcIndex ac) const -{ - if (ac == AC_BE_NQOS) - { - NS_ASSERT (m_txop != nullptr); - return m_txop->GetWifiMacQueue (); - } - NS_ASSERT (ac == AC_BE || ac == AC_BK || ac == AC_VI || ac == AC_VO); - return m_edca.find (ac)->second->GetWifiMacQueue (); -} - -void -RegularWifiMac::SetWifiPhy (const Ptr phy) -{ - NS_LOG_FUNCTION (this << phy); - m_phy = phy; - NS_ABORT_MSG_IF (!m_phy->GetOperatingChannel ().IsSet (), - "PHY operating channel must have been set"); - ConfigurePhyDependentParameters (); - m_channelAccessManager->SetupPhyListener (phy); - NS_ASSERT (m_feManager != 0); - m_feManager->SetWifiPhy (phy); -} - -Ptr -RegularWifiMac::GetWifiPhy (void) const -{ - NS_LOG_FUNCTION (this); - return m_phy; -} - -void -RegularWifiMac::ResetWifiPhy (void) -{ - NS_LOG_FUNCTION (this); - NS_ASSERT (m_feManager != 0); - m_feManager->ResetPhy (); - m_channelAccessManager->RemovePhyListener (m_phy); - m_phy = 0; -} - -void -RegularWifiMac::SetForwardUpCallback (ForwardUpCallback upCallback) -{ - NS_LOG_FUNCTION (this); - m_forwardUp = upCallback; -} - -void -RegularWifiMac::SetLinkUpCallback (Callback linkUp) -{ - NS_LOG_FUNCTION (this); - m_linkUp = linkUp; -} - -void -RegularWifiMac::SetLinkDownCallback (Callback linkDown) -{ - NS_LOG_FUNCTION (this); - m_linkDown = linkDown; -} - -void -RegularWifiMac::SetQosSupported (bool enable) -{ - NS_LOG_FUNCTION (this << enable); - NS_ABORT_IF (IsInitialized ()); - m_qosSupported = enable; - - if (!m_qosSupported) - { - // create a non-QoS TXOP - m_txop = CreateObject (); - m_txop->SetChannelAccessManager (m_channelAccessManager); - m_txop->SetWifiMac (this); - m_txop->SetTxMiddle (m_txMiddle); - m_txop->SetDroppedMpduCallback (MakeCallback (&DroppedMpduTracedCallback::operator(), - &m_droppedMpduCallback)); - } - else - { - //Construct the EDCAFs. The ordering is important - highest - //priority (Table 9-1 UP-to-AC mapping; IEEE 802.11-2012) must be created - //first. - SetupEdcaQueue (AC_VO); - SetupEdcaQueue (AC_VI); - SetupEdcaQueue (AC_BE); - SetupEdcaQueue (AC_BK); - } -} - -bool -RegularWifiMac::GetQosSupported () const -{ - return m_qosSupported; -} - -bool -RegularWifiMac::GetHtSupported () const -{ - if (GetHtConfiguration ()) - { - return true; - } - return false; -} - -bool -RegularWifiMac::GetVhtSupported () const -{ - if (GetVhtConfiguration ()) - { - return true; - } - return false; -} - -bool -RegularWifiMac::GetHeSupported () const -{ - if (GetHeConfiguration ()) - { - return true; - } - return false; -} - -bool -RegularWifiMac::GetErpSupported () const -{ - return m_erpSupported; -} - -void -RegularWifiMac::SetErpSupported (bool enable) -{ - NS_LOG_FUNCTION (this); - if (enable) - { - SetDsssSupported (true); - } - m_erpSupported = enable; -} - -void -RegularWifiMac::SetDsssSupported (bool enable) -{ - NS_LOG_FUNCTION (this); - m_dsssSupported = enable; -} - -bool -RegularWifiMac::GetDsssSupported () const -{ - return m_dsssSupported; -} - -void -RegularWifiMac::SetCtsToSelfSupported (bool enable) -{ - NS_LOG_FUNCTION (this); - m_ctsToSelfSupported = enable; -} - -void -RegularWifiMac::SetAddress (Mac48Address address) -{ - NS_LOG_FUNCTION (this << address); - m_address = address; -} - -Mac48Address -RegularWifiMac::GetAddress (void) const -{ - return m_address; -} - -void -RegularWifiMac::SetSsid (Ssid ssid) -{ - NS_LOG_FUNCTION (this << ssid); - m_ssid = ssid; -} - -Ssid -RegularWifiMac::GetSsid (void) const -{ - return m_ssid; -} - -void -RegularWifiMac::SetBssid (Mac48Address bssid) -{ - NS_LOG_FUNCTION (this << bssid); - m_bssid = bssid; - if (m_feManager) - { - m_feManager->SetBssid (bssid); - } -} - -Mac48Address -RegularWifiMac::GetBssid (void) const -{ - return m_bssid; -} - -void -RegularWifiMac::SetPromisc (void) -{ - NS_ASSERT (m_feManager != 0); - m_feManager->SetPromisc (); -} - -void -RegularWifiMac::SetShortSlotTimeSupported (bool enable) -{ - NS_LOG_FUNCTION (this << enable); - m_shortSlotTimeSupported = enable; -} - -bool -RegularWifiMac::GetShortSlotTimeSupported (void) const -{ - return m_shortSlotTimeSupported; -} - -void -RegularWifiMac::Enqueue (Ptr packet, - Mac48Address to, Mac48Address from) -{ - //We expect RegularWifiMac subclasses which do support forwarding (e.g., - //AP) to override this method. Therefore, we throw a fatal error if - //someone tries to invoke this method on a class which has not done - //this. - NS_FATAL_ERROR ("This MAC entity (" << this << ", " << GetAddress () - << ") does not support Enqueue() with from address"); -} - -bool -RegularWifiMac::SupportsSendFrom (void) const -{ - return false; -} - -void -RegularWifiMac::ForwardUp (Ptr packet, Mac48Address from, Mac48Address to) -{ - NS_LOG_FUNCTION (this << packet << from << to); - m_forwardUp (packet, from, to); -} - -void -RegularWifiMac::Receive (Ptr mpdu) -{ - NS_LOG_FUNCTION (this << *mpdu); - - const WifiMacHeader* hdr = &mpdu->GetHeader (); - Ptr packet = mpdu->GetPacket ()->Copy (); - Mac48Address to = hdr->GetAddr1 (); - Mac48Address from = hdr->GetAddr2 (); - - //We don't know how to deal with any frame that is not addressed to - //us (and odds are there is nothing sensible we could do anyway), - //so we ignore such frames. - // - //The derived class may also do some such filtering, but it doesn't - //hurt to have it here too as a backstop. - if (to != GetAddress ()) - { - return; - } - - if (hdr->IsMgt () && hdr->IsAction ()) - { - //There is currently only any reason for Management Action - //frames to be flying about if we are a QoS STA. - NS_ASSERT (m_qosSupported); - - WifiActionHeader actionHdr; - packet->RemoveHeader (actionHdr); - - switch (actionHdr.GetCategory ()) - { - case WifiActionHeader::BLOCK_ACK: - - switch (actionHdr.GetAction ().blockAck) - { - case WifiActionHeader::BLOCK_ACK_ADDBA_REQUEST: - { - MgtAddBaRequestHeader reqHdr; - packet->RemoveHeader (reqHdr); - - //We've received an ADDBA Request. Our policy here is - //to automatically accept it, so we get the ADDBA - //Response on it's way immediately. - NS_ASSERT (m_feManager != 0); - Ptr htFem = DynamicCast (m_feManager); - if (htFem != 0) - { - htFem->SendAddBaResponse (&reqHdr, from); - } - //This frame is now completely dealt with, so we're done. - return; - } - case WifiActionHeader::BLOCK_ACK_ADDBA_RESPONSE: - { - MgtAddBaResponseHeader respHdr; - packet->RemoveHeader (respHdr); - - //We've received an ADDBA Response. We assume that it - //indicates success after an ADDBA Request we have - //sent (we could, in principle, check this, but it - //seems a waste given the level of the current model) - //and act by locally establishing the agreement on - //the appropriate queue. - AcIndex ac = QosUtilsMapTidToAc (respHdr.GetTid ()); - m_edca[ac]->GotAddBaResponse (&respHdr, from); - //This frame is now completely dealt with, so we're done. - return; - } - case WifiActionHeader::BLOCK_ACK_DELBA: - { - MgtDelBaHeader delBaHdr; - packet->RemoveHeader (delBaHdr); - - if (delBaHdr.IsByOriginator ()) - { - //This DELBA frame was sent by the originator, so - //this means that an ingoing established - //agreement exists in HtFrameExchangeManager and we need to - //destroy it. - NS_ASSERT (m_feManager != 0); - Ptr htFem = DynamicCast (m_feManager); - if (htFem != 0) - { - htFem->DestroyBlockAckAgreement (from, delBaHdr.GetTid ()); - } - } - else - { - //We must have been the originator. We need to - //tell the correct queue that the agreement has - //been torn down - AcIndex ac = QosUtilsMapTidToAc (delBaHdr.GetTid ()); - m_edca[ac]->GotDelBaFrame (&delBaHdr, from); - } - //This frame is now completely dealt with, so we're done. - return; - } - default: - NS_FATAL_ERROR ("Unsupported Action field in Block Ack Action frame"); - return; - } - default: - NS_FATAL_ERROR ("Unsupported Action frame received"); - return; - } - } - NS_FATAL_ERROR ("Don't know how to handle frame (type=" << hdr->GetType ()); -} - -void -RegularWifiMac::DeaggregateAmsduAndForward (Ptr mpdu) -{ - NS_LOG_FUNCTION (this << *mpdu); - for (auto& msduPair : *PeekPointer (mpdu)) - { - ForwardUp (msduPair.first, msduPair.second.GetSourceAddr (), - msduPair.second.GetDestinationAddr ()); - } -} - -TypeId -RegularWifiMac::GetTypeId (void) -{ - static TypeId tid = TypeId ("ns3::RegularWifiMac") - .SetParent () - .SetGroupName ("Wifi") - .AddAttribute ("QosSupported", - "This Boolean attribute is set to enable 802.11e/WMM-style QoS support at this STA.", - TypeId::ATTR_GET | TypeId::ATTR_CONSTRUCT, // prevent setting after construction - BooleanValue (false), - MakeBooleanAccessor (&RegularWifiMac::SetQosSupported, - &RegularWifiMac::GetQosSupported), - MakeBooleanChecker ()) - .AddAttribute ("CtsToSelfSupported", - "Use CTS to Self when using a rate that is not in the basic rate set.", - BooleanValue (false), - MakeBooleanAccessor (&RegularWifiMac::SetCtsToSelfSupported), - MakeBooleanChecker ()) - .AddAttribute ("VO_MaxAmsduSize", - "Maximum length in bytes of an A-MSDU for AC_VO access class " - "(capped to 7935 for HT PPDUs and 11398 for VHT/HE PPDUs). " - "Value 0 means A-MSDU aggregation is disabled for that AC.", - UintegerValue (0), - MakeUintegerAccessor (&RegularWifiMac::m_voMaxAmsduSize), - MakeUintegerChecker (0, 11398)) - .AddAttribute ("VI_MaxAmsduSize", - "Maximum length in bytes of an A-MSDU for AC_VI access class " - "(capped to 7935 for HT PPDUs and 11398 for VHT/HE PPDUs). " - "Value 0 means A-MSDU aggregation is disabled for that AC.", - UintegerValue (0), - MakeUintegerAccessor (&RegularWifiMac::m_viMaxAmsduSize), - MakeUintegerChecker (0, 11398)) - .AddAttribute ("BE_MaxAmsduSize", - "Maximum length in bytes of an A-MSDU for AC_BE access class " - "(capped to 7935 for HT PPDUs and 11398 for VHT/HE PPDUs). " - "Value 0 means A-MSDU aggregation is disabled for that AC.", - UintegerValue (0), - MakeUintegerAccessor (&RegularWifiMac::m_beMaxAmsduSize), - MakeUintegerChecker (0, 11398)) - .AddAttribute ("BK_MaxAmsduSize", - "Maximum length in bytes of an A-MSDU for AC_BK access class " - "(capped to 7935 for HT PPDUs and 11398 for VHT/HE PPDUs). " - "Value 0 means A-MSDU aggregation is disabled for that AC.", - UintegerValue (0), - MakeUintegerAccessor (&RegularWifiMac::m_bkMaxAmsduSize), - MakeUintegerChecker (0, 11398)) - .AddAttribute ("VO_MaxAmpduSize", - "Maximum length in bytes of an A-MPDU for AC_VO access class " - "(capped to 65535 for HT PPDUs, 1048575 for VHT PPDUs, and 6500631 for HE PPDUs). " - "Value 0 means A-MPDU aggregation is disabled for that AC.", - UintegerValue (0), - MakeUintegerAccessor (&RegularWifiMac::m_voMaxAmpduSize), - MakeUintegerChecker (0, 6500631)) - .AddAttribute ("VI_MaxAmpduSize", - "Maximum length in bytes of an A-MPDU for AC_VI access class " - "(capped to 65535 for HT PPDUs, 1048575 for VHT PPDUs, and 6500631 for HE PPDUs). " - "Value 0 means A-MPDU aggregation is disabled for that AC.", - UintegerValue (65535), - MakeUintegerAccessor (&RegularWifiMac::m_viMaxAmpduSize), - MakeUintegerChecker (0, 6500631)) - .AddAttribute ("BE_MaxAmpduSize", - "Maximum length in bytes of an A-MPDU for AC_BE access class " - "(capped to 65535 for HT PPDUs, 1048575 for VHT PPDUs, and 6500631 for HE PPDUs). " - "Value 0 means A-MPDU aggregation is disabled for that AC.", - UintegerValue (65535), - MakeUintegerAccessor (&RegularWifiMac::m_beMaxAmpduSize), - MakeUintegerChecker (0, 6500631)) - .AddAttribute ("BK_MaxAmpduSize", - "Maximum length in bytes of an A-MPDU for AC_BK access class " - "(capped to 65535 for HT PPDUs, 1048575 for VHT PPDUs, and 6500631 for HE PPDUs). " - "Value 0 means A-MPDU aggregation is disabled for that AC.", - UintegerValue (0), - MakeUintegerAccessor (&RegularWifiMac::m_bkMaxAmpduSize), - MakeUintegerChecker (0, 6500631)) - .AddAttribute ("VO_BlockAckThreshold", - "If number of packets in VO queue reaches this value, " - "block ack mechanism is used. If this value is 0, block ack is never used." - "When A-MPDU is enabled, block ack mechanism is used regardless of this value.", - UintegerValue (0), - MakeUintegerAccessor (&RegularWifiMac::SetVoBlockAckThreshold), - MakeUintegerChecker (0, 64)) - .AddAttribute ("VI_BlockAckThreshold", - "If number of packets in VI queue reaches this value, " - "block ack mechanism is used. If this value is 0, block ack is never used." - "When A-MPDU is enabled, block ack mechanism is used regardless of this value.", - UintegerValue (0), - MakeUintegerAccessor (&RegularWifiMac::SetViBlockAckThreshold), - MakeUintegerChecker (0, 64)) - .AddAttribute ("BE_BlockAckThreshold", - "If number of packets in BE queue reaches this value, " - "block ack mechanism is used. If this value is 0, block ack is never used." - "When A-MPDU is enabled, block ack mechanism is used regardless of this value.", - UintegerValue (0), - MakeUintegerAccessor (&RegularWifiMac::SetBeBlockAckThreshold), - MakeUintegerChecker (0, 64)) - .AddAttribute ("BK_BlockAckThreshold", - "If number of packets in BK queue reaches this value, " - "block ack mechanism is used. If this value is 0, block ack is never used." - "When A-MPDU is enabled, block ack mechanism is used regardless of this value.", - UintegerValue (0), - MakeUintegerAccessor (&RegularWifiMac::SetBkBlockAckThreshold), - MakeUintegerChecker (0, 64)) - .AddAttribute ("VO_BlockAckInactivityTimeout", - "Represents max time (blocks of 1024 microseconds) allowed for block ack" - "inactivity for AC_VO. If this value isn't equal to 0 a timer start after that a" - "block ack setup is completed and will be reset every time that a block ack" - "frame is received. If this value is 0, block ack inactivity timeout won't be used.", - UintegerValue (0), - MakeUintegerAccessor (&RegularWifiMac::SetVoBlockAckInactivityTimeout), - MakeUintegerChecker ()) - .AddAttribute ("VI_BlockAckInactivityTimeout", - "Represents max time (blocks of 1024 microseconds) allowed for block ack" - "inactivity for AC_VI. If this value isn't equal to 0 a timer start after that a" - "block ack setup is completed and will be reset every time that a block ack" - "frame is received. If this value is 0, block ack inactivity timeout won't be used.", - UintegerValue (0), - MakeUintegerAccessor (&RegularWifiMac::SetViBlockAckInactivityTimeout), - MakeUintegerChecker ()) - .AddAttribute ("BE_BlockAckInactivityTimeout", - "Represents max time (blocks of 1024 microseconds) allowed for block ack" - "inactivity for AC_BE. If this value isn't equal to 0 a timer start after that a" - "block ack setup is completed and will be reset every time that a block ack" - "frame is received. If this value is 0, block ack inactivity timeout won't be used.", - UintegerValue (0), - MakeUintegerAccessor (&RegularWifiMac::SetBeBlockAckInactivityTimeout), - MakeUintegerChecker ()) - .AddAttribute ("BK_BlockAckInactivityTimeout", - "Represents max time (blocks of 1024 microseconds) allowed for block ack" - "inactivity for AC_BK. If this value isn't equal to 0 a timer start after that a" - "block ack setup is completed and will be reset every time that a block ack" - "frame is received. If this value is 0, block ack inactivity timeout won't be used.", - UintegerValue (0), - MakeUintegerAccessor (&RegularWifiMac::SetBkBlockAckInactivityTimeout), - MakeUintegerChecker ()) - .AddAttribute ("ShortSlotTimeSupported", - "Whether or not short slot time is supported (only used by ERP APs or STAs).", - BooleanValue (true), - MakeBooleanAccessor (&RegularWifiMac::SetShortSlotTimeSupported, - &RegularWifiMac::GetShortSlotTimeSupported), - MakeBooleanChecker ()) - .AddAttribute ("Txop", - "The Txop object.", - PointerValue (), - MakePointerAccessor (&RegularWifiMac::GetTxop), - MakePointerChecker ()) - .AddAttribute ("VO_Txop", - "Queue that manages packets belonging to AC_VO access class.", - PointerValue (), - MakePointerAccessor (&RegularWifiMac::GetVOQueue), - MakePointerChecker ()) - .AddAttribute ("VI_Txop", - "Queue that manages packets belonging to AC_VI access class.", - PointerValue (), - MakePointerAccessor (&RegularWifiMac::GetVIQueue), - MakePointerChecker ()) - .AddAttribute ("BE_Txop", - "Queue that manages packets belonging to AC_BE access class.", - PointerValue (), - MakePointerAccessor (&RegularWifiMac::GetBEQueue), - MakePointerChecker ()) - .AddAttribute ("BK_Txop", - "Queue that manages packets belonging to AC_BK access class.", - PointerValue (), - MakePointerAccessor (&RegularWifiMac::GetBKQueue), - MakePointerChecker ()) - .AddTraceSource ("TxOkHeader", - "The header of successfully transmitted packet.", - MakeTraceSourceAccessor (&RegularWifiMac::m_txOkCallback), - "ns3::WifiMacHeader::TracedCallback", - TypeId::OBSOLETE, - "Use the AckedMpdu trace instead.") - .AddTraceSource ("TxErrHeader", - "The header of unsuccessfully transmitted packet.", - MakeTraceSourceAccessor (&RegularWifiMac::m_txErrCallback), - "ns3::WifiMacHeader::TracedCallback", - TypeId::OBSOLETE, - "Depending on the failure type, use the NAckedMpdu trace, the " - "DroppedMpdu trace or one of the traces associated with TX timeouts.") - .AddTraceSource ("AckedMpdu", - "An MPDU that was successfully acknowledged, via either a " - "Normal Ack or a Block Ack.", - MakeTraceSourceAccessor (&RegularWifiMac::m_ackedMpduCallback), - "ns3::WifiMacQueueItem::TracedCallback") - .AddTraceSource ("NAckedMpdu", - "An MPDU that was negatively acknowledged via a Block Ack.", - MakeTraceSourceAccessor (&RegularWifiMac::m_nackedMpduCallback), - "ns3::WifiMacQueueItem::TracedCallback") - .AddTraceSource ("DroppedMpdu", - "An MPDU that was dropped for the given reason (see WifiMacDropReason).", - MakeTraceSourceAccessor (&RegularWifiMac::m_droppedMpduCallback), - "ns3::RegularWifiMac::DroppedMpduCallback") - .AddTraceSource ("MpduResponseTimeout", - "An MPDU whose response was not received before the timeout, along with " - "an identifier of the type of timeout (see WifiTxTimer::Reason) and the " - "TXVECTOR used to transmit the MPDU. This trace source is fired when a " - "CTS is missing after an RTS or a Normal Ack is missing after an MPDU " - "or after a DL MU PPDU acknowledged in SU format.", - MakeTraceSourceAccessor (&RegularWifiMac::m_mpduResponseTimeoutCallback), - "ns3::RegularWifiMac::MpduResponseTimeoutCallback") - .AddTraceSource ("PsduResponseTimeout", - "A PSDU whose response was not received before the timeout, along with " - "an identifier of the type of timeout (see WifiTxTimer::Reason) and the " - "TXVECTOR used to transmit the PSDU. This trace source is fired when a " - "BlockAck is missing after an A-MPDU, a BlockAckReq (possibly in the " - "context of the acknowledgment of a DL MU PPDU in SU format) or a TB PPDU " - "(in the latter case the missing BlockAck is a Multi-STA BlockAck).", - MakeTraceSourceAccessor (&RegularWifiMac::m_psduResponseTimeoutCallback), - "ns3::RegularWifiMac::PsduResponseTimeoutCallback") - .AddTraceSource ("PsduMapResponseTimeout", - "A PSDU map for which not all the responses were received before the timeout, " - "along with an identifier of the type of timeout (see WifiTxTimer::Reason), " - "the set of MAC addresses of the stations that did not respond and the total " - "number of stations that had to respond. This trace source is fired when not " - "all the addressed stations responded to an MU-BAR Trigger frame (either sent as " - "a SU frame or aggregated to PSDUs in the DL MU PPDU), a Basic Trigger Frame or " - "a BSRP Trigger Frame.", - MakeTraceSourceAccessor (&RegularWifiMac::m_psduMapResponseTimeoutCallback), - "ns3::RegularWifiMac::PsduMapResponseTimeoutCallback") - ; - return tid; -} - -void -RegularWifiMac::ConfigureStandard (WifiStandard standard) -{ - NS_LOG_FUNCTION (this << standard); - - NS_ABORT_IF (standard >= WIFI_STANDARD_80211n && !m_qosSupported); - - SetupFrameExchangeManager (standard); -} - -void -RegularWifiMac::NotifyChannelSwitching (void) -{ - NS_LOG_FUNCTION (this); - - // we may have changed PHY band, in which case it is necessary to re-configure - // the PHY dependent parameters. In any case, this makes no harm - ConfigurePhyDependentParameters (); - - // SetupPhy not only resets the remote station manager, but also sets the - // default TX mode and MCS, which is required when switching to a channel - // in a different band - m_stationManager->SetupPhy (m_phy); -} - -void -RegularWifiMac::ConfigurePhyDependentParameters (void) -{ - WifiPhyBand band = m_phy->GetPhyBand (); - NS_LOG_FUNCTION (this << band); - - uint32_t cwmin = 0; - uint32_t cwmax = 0; - - NS_ASSERT (m_phy != 0); - WifiStandard standard = m_phy->GetStandard (); - - if (standard == WIFI_STANDARD_80211b) - { - SetDsssSupported (true); - cwmin = 31; - cwmax = 1023; - return; - } - - if (standard >= WIFI_STANDARD_80211g && band == WIFI_PHY_BAND_2_4GHZ) - { - SetErpSupported (true); - } - - cwmin = 15; - cwmax = 1023; - - ConfigureContentionWindow (cwmin, cwmax); -} - -void -RegularWifiMac::ConfigureContentionWindow (uint32_t cwMin, uint32_t cwMax) -{ - bool isDsssOnly = m_dsssSupported && !m_erpSupported; - if (m_txop != nullptr) - { - //The special value of AC_BE_NQOS which exists in the Access - //Category enumeration allows us to configure plain old DCF. - ConfigureDcf (m_txop, cwMin, cwMax, isDsssOnly, AC_BE_NQOS); - } - - //Now we configure the EDCA functions - for (EdcaQueues::const_iterator i = m_edca.begin (); i != m_edca.end (); ++i) - { - ConfigureDcf (i->second, cwMin, cwMax, isDsssOnly, i->first); - } -} - -uint32_t -RegularWifiMac::GetMaxAmpduSize (AcIndex ac) const -{ - uint32_t maxSize = 0; - switch (ac) - { - case AC_BE: - maxSize = m_beMaxAmpduSize; - break; - case AC_BK: - maxSize = m_bkMaxAmpduSize; - break; - case AC_VI: - maxSize = m_viMaxAmpduSize; - break; - case AC_VO: - maxSize = m_voMaxAmpduSize; - break; - default: - NS_ABORT_MSG ("Unknown AC " << ac); - return 0; - } - return maxSize; -} - -uint16_t -RegularWifiMac::GetMaxAmsduSize (AcIndex ac) const -{ - uint16_t maxSize = 0; - switch (ac) - { - case AC_BE: - maxSize = m_beMaxAmsduSize; - break; - case AC_BK: - maxSize = m_bkMaxAmsduSize; - break; - case AC_VI: - maxSize = m_viMaxAmsduSize; - break; - case AC_VO: - maxSize = m_voMaxAmsduSize; - break; - default: - NS_ABORT_MSG ("Unknown AC " << ac); - return 0; - } - return maxSize; -} - -} //namespace ns3 diff --git a/src/wifi/model/regular-wifi-mac.h b/src/wifi/model/regular-wifi-mac.h deleted file mode 100644 index bdce637ca..000000000 --- a/src/wifi/model/regular-wifi-mac.h +++ /dev/null @@ -1,549 +0,0 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ -/* - * Copyright (c) 2008 INRIA - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation; - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Author: Mathieu Lacage - */ - -#ifndef REGULAR_WIFI_MAC_H -#define REGULAR_WIFI_MAC_H - -#include "wifi-mac.h" -#include "qos-txop.h" -#include "ssid.h" -#include -#include - -namespace ns3 { - -class MacRxMiddle; -class MacTxMiddle; -class ChannelAccessManager; -class ExtendedCapabilities; -class FrameExchangeManager; -class WifiPsdu; -class WifiMacQueue; -enum WifiTxTimerReason : uint8_t; - -typedef std::unordered_map /* PSDU */> WifiPsduMap; - -/** - * \brief base class for all MAC-level wifi objects. - * \ingroup wifi - * - * This class encapsulates all the low-level MAC functionality and all the - * high-level MAC functionality (association/disassociation state machines). - * - */ -class RegularWifiMac : public WifiMac -{ -public: - /** - * \brief Get the type ID. - * \return the object TypeId - */ - static TypeId GetTypeId (void); - - RegularWifiMac (); - virtual ~RegularWifiMac (); - - // Implementations of pure virtual methods. - void SetShortSlotTimeSupported (bool enable) override; - void SetSsid (Ssid ssid) override; - void SetAddress (Mac48Address address) override; - void SetPromisc (void) override; - bool GetShortSlotTimeSupported (void) const override; - Ssid GetSsid (void) const override; - Mac48Address GetAddress (void) const override; - Mac48Address GetBssid (void) const override; - void Enqueue (Ptr packet, Mac48Address to, Mac48Address from) override; - bool SupportsSendFrom (void) const override; - void SetWifiPhy (const Ptr phy) override; - Ptr GetWifiPhy (void) const override; - void ResetWifiPhy (void) override; - void SetWifiRemoteStationManager (const Ptr stationManager) override; - void ConfigureStandard (WifiStandard standard) override; - TypeOfStation GetTypeOfStation (void) const override; - void SetForwardUpCallback (ForwardUpCallback upCallback) override; - void SetLinkUpCallback (Callback linkUp) override; - void SetLinkDownCallback (Callback linkDown) override; - Ptr GetWifiRemoteStationManager (void) const override; - - // Should be implemented by child classes - void Enqueue (Ptr packet, Mac48Address to) override = 0; - - /** - * Get the Frame Exchange Manager - * - * \return the Frame Exchange Manager - */ - Ptr GetFrameExchangeManager (void) const; - - /** - * Enable or disable CTS-to-self feature. - * - * \param enable true if CTS-to-self is to be supported, - * false otherwise - */ - void SetCtsToSelfSupported (bool enable); - /** - * \param bssid the BSSID of the network that this device belongs to. - */ - void SetBssid (Mac48Address bssid); - - /** - * Accessor for the DCF object - * - * \return a smart pointer to Txop - */ - Ptr GetTxop (void) const; - /** - * Accessor for a specified EDCA object - * - * \param ac the Access Category - * \return a smart pointer to a QosTxop - */ - Ptr GetQosTxop (AcIndex ac) const; - /** - * Accessor for a specified EDCA object - * - * \param tid the Traffic ID - * \return a smart pointer to a QosTxop - */ - Ptr GetQosTxop (uint8_t tid) const; - /** - * Get the wifi MAC queue of the (Qos)Txop associated with the given AC. - * - * \param ac the given Access Category - * \return the wifi MAC queue of the (Qos)Txop associated with the given AC - */ - virtual Ptr GetTxopQueue (AcIndex ac) const; - - /** - * Return whether the device supports QoS. - * - * \return true if QoS is supported, false otherwise - */ - bool GetQosSupported () const; - /** - * Return whether the device supports ERP. - * - * \return true if ERP is supported, false otherwise - */ - bool GetErpSupported () const; - /** - * Return whether the device supports DSSS. - * - * \return true if DSSS is supported, false otherwise - */ - bool GetDsssSupported () const; - /** - * Return whether the device supports HT. - * - * \return true if HT is supported, false otherwise - */ - bool GetHtSupported () const; - /** - * Return whether the device supports VHT. - * - * \return true if VHT is supported, false otherwise - */ - bool GetVhtSupported () const; - /** - * Return whether the device supports HE. - * - * \return true if HE is supported, false otherwise - */ - bool GetHeSupported () const; - - /** - * Return the extended capabilities of the device. - * - * \return the extended capabilities that we support - */ - ExtendedCapabilities GetExtendedCapabilities (void) const; - /** - * Return the HT capabilities of the device. - * - * \return the HT capabilities that we support - */ - HtCapabilities GetHtCapabilities (void) const; - /** - * Return the VHT capabilities of the device. - * - * \return the VHT capabilities that we support - */ - VhtCapabilities GetVhtCapabilities (void) const; - /** - * Return the HE capabilities of the device. - * - * \return the HE capabilities that we support - */ - HeCapabilities GetHeCapabilities (void) const; - - /** - * Return the maximum A-MPDU size of the given Access Category. - * - * \param ac Access Category index - * \return the maximum A-MPDU size - */ - uint32_t GetMaxAmpduSize (AcIndex ac) const; - /** - * Return the maximum A-MSDU size of the given Access Category. - * - * \param ac Access Category index - * \return the maximum A-MSDU size - */ - uint16_t GetMaxAmsduSize (AcIndex ac) const; - - /** - * Notify that channel has been switched. - */ - virtual void NotifyChannelSwitching (void); - -protected: - void DoInitialize () override; - void DoDispose () override; - void SetTypeOfStation (TypeOfStation type) override; - - Ptr m_rxMiddle; //!< RX middle (defragmentation etc.) - Ptr m_txMiddle; //!< TX middle (aggregation etc.) - Ptr m_channelAccessManager; //!< channel access manager - Ptr m_phy; //!< Wifi PHY - Ptr m_feManager; //!< Frame Exchange Manager - - Ptr m_stationManager; //!< Remote station manager (rate control, RTS/CTS/fragmentation thresholds etc.) - - ForwardUpCallback m_forwardUp; //!< Callback to forward packet up the stack - Callback m_linkUp; //!< Callback when a link is up - Callback m_linkDown; //!< Callback when a link is down - - Ssid m_ssid; //!< Service Set ID (SSID) - - /** This holds a pointer to the TXOP instance for this WifiMac - used - for transmission of frames to non-QoS peers. */ - Ptr m_txop; - - /** This type defines a mapping between an Access Category index, - and a pointer to the corresponding channel access function */ - typedef std::map > EdcaQueues; - - /** This is a map from Access Category index to the corresponding - channel access function */ - EdcaQueues m_edca; - - /** - * Accessor for the AC_VO channel access function - * - * \return a smart pointer to QosTxop - */ - Ptr GetVOQueue (void) const; - /** - * Accessor for the AC_VI channel access function - * - * \return a smart pointer to QosTxop - */ - Ptr GetVIQueue (void) const; - /** - * Accessor for the AC_BE channel access function - * - * \return a smart pointer to QosTxop - */ - Ptr GetBEQueue (void) const; - /** - * Accessor for the AC_BK channel access function - * - * \return a smart pointer to QosTxop - */ - Ptr GetBKQueue (void) const; - - /** - * \param cwMin the minimum contention window size - * \param cwMax the maximum contention window size - * - * This method is called to set the minimum and the maximum - * contention window size. - */ - virtual void ConfigureContentionWindow (uint32_t cwMin, uint32_t cwMax); - - /** - * This method acts as the MacRxMiddle receive callback and is - * invoked to notify us that a frame has been received. The - * implementation is intended to capture logic that is going to be - * common to all (or most) derived classes. Specifically, handling - * of Block Ack management frames is dealt with here. - * - * This method will need, however, to be overridden by derived - * classes so that they can perform their data handling before - * invoking the base version. - * - * \param mpdu the MPDU that has been received. - */ - virtual void Receive (Ptr mpdu); - - /** - * Forward the packet up to the device. - * - * \param packet the packet that we are forwarding up to the device - * \param from the address of the source - * \param to the address of the destination - */ - void ForwardUp (Ptr packet, Mac48Address from, Mac48Address to); - - /** - * This method can be called to de-aggregate an A-MSDU and forward - * the constituent packets up the stack. - * - * \param mpdu the MPDU containing the A-MSDU. - */ - virtual void DeaggregateAmsduAndForward (Ptr mpdu); - - /** - * Enable or disable QoS support for the device. Construct a Txop object - * or QosTxop objects accordingly. This method can only be called before - * initialization. - * - * \param enable whether QoS is supported - */ - virtual void SetQosSupported (bool enable); - - /** - * Create a Frame Exchange Manager depending on the supported version - * of the standard. - * - * \param standard the supported version of the standard - */ - void SetupFrameExchangeManager (WifiStandard standard); - - /** - * Enable or disable ERP support for the device. - * - * \param enable whether ERP is supported - */ - void SetErpSupported (bool enable); - - /** - * Enable or disable DSSS support for the device. - * - * \param enable whether DSSS is supported - */ - void SetDsssSupported (bool enable); - -private: - /// type conversion operator - RegularWifiMac (const RegularWifiMac &); - /** - * assignment operator - * - * \param mac the RegularWifiMac to assign - * \returns the assigned value - */ - RegularWifiMac & operator= (const RegularWifiMac & mac); - - /** - * This method is a private utility invoked to configure the channel - * access function for the specified Access Category. - * - * \param ac the Access Category of the queue to initialise. - */ - void SetupEdcaQueue (AcIndex ac); - - /** - * Set the block ack threshold for AC_VO. - * - * \param threshold the block ack threshold for AC_VO. - */ - void SetVoBlockAckThreshold (uint8_t threshold); - /** - * Set the block ack threshold for AC_VI. - * - * \param threshold the block ack threshold for AC_VI. - */ - void SetViBlockAckThreshold (uint8_t threshold); - /** - * Set the block ack threshold for AC_BE. - * - * \param threshold the block ack threshold for AC_BE. - */ - void SetBeBlockAckThreshold (uint8_t threshold); - /** - * Set the block ack threshold for AC_BK. - * - * \param threshold the block ack threshold for AC_BK. - */ - void SetBkBlockAckThreshold (uint8_t threshold); - - /** - * Set VO block ack inactivity timeout. - * - * \param timeout the VO block ack inactivity timeout. - */ - void SetVoBlockAckInactivityTimeout (uint16_t timeout); - /** - * Set VI block ack inactivity timeout. - * - * \param timeout the VI block ack inactivity timeout. - */ - void SetViBlockAckInactivityTimeout (uint16_t timeout); - /** - * Set BE block ack inactivity timeout. - * - * \param timeout the BE block ack inactivity timeout. - */ - void SetBeBlockAckInactivityTimeout (uint16_t timeout); - /** - * Set BK block ack inactivity timeout. - * - * \param timeout the BK block ack inactivity timeout. - */ - void SetBkBlockAckInactivityTimeout (uint16_t timeout); - - /** - * Configure PHY dependent parameters such as CWmin and CWmax. - */ - void ConfigurePhyDependentParameters (void); - - TypeOfStation m_typeOfStation; //!< the type of station - - /** - * This Boolean is set \c true iff this WifiMac is to model - * 802.11e/WMM style Quality of Service. It is exposed through the - * attribute system. - * - * At the moment, this flag is the sole selection between QoS and - * non-QoS operation for the STA (whether IBSS, AP, or - * non-AP). Ultimately, we will want a QoS-enabled STA to be able to - * fall back to non-QoS operation with a non-QoS peer. This'll - * require further intelligence - i.e., per-association QoS - * state. Having a big switch seems like a good intermediate stage, - * 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; - - Mac48Address m_address; ///< MAC address of this station - Mac48Address m_bssid; ///< the BSSID - - uint16_t m_voMaxAmsduSize; ///< maximum A-MSDU size for AC_VO (in bytes) - uint16_t m_viMaxAmsduSize; ///< maximum A-MSDU size for AC_VI (in bytes) - uint16_t m_beMaxAmsduSize; ///< maximum A-MSDU size for AC_BE (in bytes) - uint16_t m_bkMaxAmsduSize; ///< maximum A-MSDU size for AC_BK (in bytes) - - uint32_t m_voMaxAmpduSize; ///< maximum A-MPDU size for AC_VO (in bytes) - uint32_t m_viMaxAmpduSize; ///< maximum A-MPDU size for AC_VI (in bytes) - uint32_t m_beMaxAmpduSize; ///< maximum A-MPDU size for AC_BE (in bytes) - uint32_t m_bkMaxAmpduSize; ///< maximum A-MPDU size for AC_BK (in bytes) - - TracedCallback m_txOkCallback; ///< transmit OK callback - TracedCallback m_txErrCallback; ///< transmit error callback - - /// TracedCallback for acked/nacked MPDUs typedef - typedef TracedCallback> MpduTracedCallback; - - MpduTracedCallback m_ackedMpduCallback; ///< ack'ed MPDU callback - MpduTracedCallback m_nackedMpduCallback; ///< nack'ed MPDU callback - - /** - * TracedCallback signature for MPDU drop events. - * - * \param reason the reason why the MPDU was dropped (\see WifiMacDropReason) - * \param mpdu the dropped MPDU - */ - typedef void (* DroppedMpduCallback)(WifiMacDropReason reason, Ptr mpdu); - - /// TracedCallback for MPDU drop events typedef - typedef TracedCallback> DroppedMpduTracedCallback; - - /** - * This trace indicates that an MPDU was dropped for the given reason. - */ - DroppedMpduTracedCallback m_droppedMpduCallback; - - /** - * TracedCallback signature for MPDU response timeout events. - * - * \param reason the reason why the timer was started - * \param mpdu the MPDU whose response was not received before the timeout - * \param txVector the TXVECTOR used to transmit the MPDU - */ - typedef void (* MpduResponseTimeoutCallback)(uint8_t reason, Ptr mpdu, - const WifiTxVector& txVector); - - /// TracedCallback for MPDU response timeout events typedef - typedef TracedCallback, const WifiTxVector&> MpduResponseTimeoutTracedCallback; - - /** - * MPDU response timeout traced callback. - * This trace source is fed by a WifiTxTimer object. - */ - MpduResponseTimeoutTracedCallback m_mpduResponseTimeoutCallback; - - /** - * TracedCallback signature for PSDU response timeout events. - * - * \param reason the reason why the timer was started - * \param psdu the PSDU whose response was not received before the timeout - * \param txVector the TXVECTOR used to transmit the PSDU - */ - typedef void (* PsduResponseTimeoutCallback)(uint8_t reason, Ptr psdu, - const WifiTxVector& txVector); - - /// TracedCallback for PSDU response timeout events typedef - typedef TracedCallback, const WifiTxVector&> PsduResponseTimeoutTracedCallback; - - /** - * PSDU response timeout traced callback. - * This trace source is fed by a WifiTxTimer object. - */ - PsduResponseTimeoutTracedCallback m_psduResponseTimeoutCallback; - - /** - * TracedCallback signature for PSDU map response timeout events. - * - * \param reason the reason why the timer was started - * \param psduMap the PSDU map for which not all responses were received before the timeout - * \param missingStations the MAC addresses of the stations that did not respond - * \param nTotalStations the total number of stations that had to respond - */ - typedef void (* PsduMapResponseTimeoutCallback)(uint8_t reason, WifiPsduMap* psduMap, - const std::set* missingStations, - std::size_t nTotalStations); - - /// TracedCallback for PSDU map response timeout events typedef - typedef TracedCallback*, std::size_t> PsduMapResponseTimeoutTracedCallback; - - /** - * PSDU map response timeout traced callback. - * This trace source is fed by a WifiTxTimer object. - */ - PsduMapResponseTimeoutTracedCallback m_psduMapResponseTimeoutCallback; - - bool m_shortSlotTimeSupported; ///< flag whether short slot time is supported - bool m_ctsToSelfSupported; ///< flag indicating whether CTS-To-Self is supported -}; - -} //namespace ns3 - -#endif /* REGULAR_WIFI_MAC_H */ diff --git a/src/wifi/model/sta-wifi-mac.cc b/src/wifi/model/sta-wifi-mac.cc index a38038674..c010e248d 100644 --- a/src/wifi/model/sta-wifi-mac.cc +++ b/src/wifi/model/sta-wifi-mac.cc @@ -23,6 +23,7 @@ #include "ns3/log.h" #include "ns3/packet.h" #include "ns3/simulator.h" +#include "qos-txop.h" #include "sta-wifi-mac.h" #include "wifi-phy.h" #include "mgt-headers.h" @@ -41,7 +42,7 @@ TypeId StaWifiMac::GetTypeId (void) { static TypeId tid = TypeId ("ns3::StaWifiMac") - .SetParent () + .SetParent () .SetGroupName ("Wifi") .AddConstructor () .AddAttribute ("ProbeRequestTimeout", "The duration to actively probe the channel.", @@ -141,8 +142,8 @@ void StaWifiMac::SetWifiPhy (const Ptr phy) { NS_LOG_FUNCTION (this << phy); - RegularWifiMac::SetWifiPhy (phy); - m_phy->SetCapabilitiesChangedCallback (MakeCallback (&StaWifiMac::PhyCapabilitiesChanged, this)); + WifiMac::SetWifiPhy (phy); + GetWifiPhy ()->SetCapabilitiesChangedCallback (MakeCallback (&StaWifiMac::PhyCapabilitiesChanged, this)); } void @@ -177,7 +178,7 @@ StaWifiMac::SendProbeRequest (void) if (!GetQosSupported ()) { - m_txop->Queue (packet, hdr); + GetTxop ()->Queue (packet, hdr); } // "A QoS STA that transmits a Management frame determines access category used // for medium access in transmission of the Management frame as follows @@ -252,7 +253,7 @@ StaWifiMac::SendAssociationRequest (bool isReassoc) if (!GetQosSupported ()) { - m_txop->Queue (packet, hdr); + GetTxop ()->Queue (packet, hdr); } // "A QoS STA that transmits a Management frame determines access category used // for medium access in transmission of the Management frame as follows @@ -261,7 +262,7 @@ StaWifiMac::SendAssociationRequest (bool isReassoc) // AC_BE should be selected. // — If category AC_BE was not selected by the previous step, category AC_VO // shall be selected." (Sec. 10.2.3.2 of 802.11-2020) - else if (!m_stationManager->GetQosSupported (GetBssid ())) + else if (!GetWifiRemoteStationManager ()->GetQosSupported (GetBssid ())) { GetBEQueue ()->Queue (packet, hdr); } @@ -413,9 +414,9 @@ StaWifiMac::MissedBeacons (void) // a frame, wait until the RX is completed (otherwise, crashes may occur if // we are receiving a MU frame because its reception requires the STA-ID) Time delay = Seconds (0); - if (m_phy->IsStateRx ()) + if (GetWifiPhy ()->IsStateRx ()) { - delay = m_phy->GetDelayUntilIdle (); + delay = GetWifiPhy ()->GetDelayUntilIdle (); } Simulator::Schedule (delay, &StaWifiMac::Disassociated, this); } @@ -522,11 +523,11 @@ StaWifiMac::Enqueue (Ptr packet, Mac48Address to) { //Sanity check that the TID is valid NS_ASSERT (tid < 8); - m_edca[QosUtilsMapTidToAc (tid)]->Queue (packet, hdr); + GetQosTxop (tid)->Queue (packet, hdr); } else { - m_txop->Queue (packet, hdr); + GetTxop ()->Queue (packet, hdr); } } @@ -613,7 +614,7 @@ StaWifiMac::Receive (Ptr mpdu) } SupportedRates rates = beacon.GetSupportedRates (); bool bssMembershipSelectorMatch = false; - auto selectorList = m_phy->GetBssMembershipSelectorList (); + auto selectorList = GetWifiPhy ()->GetBssMembershipSelectorList (); for (const auto & selector : selectorList) { if (rates.IsBssMembershipSelectorRate (selector)) @@ -728,7 +729,7 @@ StaWifiMac::Receive (Ptr mpdu) //Invoke the receive handler of our parent class to deal with any //other frames. Specifically, this will handle Block Ack-related //Management Action frames. - RegularWifiMac::Receive (Create (packet, *hdr)); + WifiMac::Receive (Create (packet, *hdr)); } void @@ -764,11 +765,11 @@ StaWifiMac::UpdateApInfoFromBeacon (MgtBeaconHeader beacon, Mac48Address apAddr, SetBssid (bssid); CapabilityInformation capabilities = beacon.GetCapabilities (); SupportedRates rates = beacon.GetSupportedRates (); - for (const auto & mode : m_phy->GetModeList ()) + for (const auto & mode : GetWifiPhy ()->GetModeList ()) { - if (rates.IsSupportedRate (mode.GetDataRate (m_phy->GetChannelWidth ()))) + if (rates.IsSupportedRate (mode.GetDataRate (GetWifiPhy ()->GetChannelWidth ()))) { - m_stationManager->AddSupportedMode (apAddr, mode); + GetWifiRemoteStationManager ()->AddSupportedMode (apAddr, mode); } } bool isShortPreambleEnabled = capabilities.IsShortPreamble (); @@ -778,21 +779,21 @@ StaWifiMac::UpdateApInfoFromBeacon (MgtBeaconHeader beacon, Mac48Address apAddr, isShortPreambleEnabled &= !erpInformation.GetBarkerPreambleMode (); if (erpInformation.GetUseProtection () != 0) { - m_stationManager->SetUseNonErpProtection (true); + GetWifiRemoteStationManager ()->SetUseNonErpProtection (true); } else { - m_stationManager->SetUseNonErpProtection (false); + GetWifiRemoteStationManager ()->SetUseNonErpProtection (false); } if (capabilities.IsShortSlotTime () == true) { //enable short slot time - m_phy->SetSlot (MicroSeconds (9)); + GetWifiPhy ()->SetSlot (MicroSeconds (9)); } else { //disable short slot time - m_phy->SetSlot (MicroSeconds (20)); + GetWifiPhy ()->SetSlot (MicroSeconds (20)); } } if (GetQosSupported ()) @@ -808,18 +809,18 @@ StaWifiMac::UpdateApInfoFromBeacon (MgtBeaconHeader beacon, Mac48Address apAddr, SetEdcaParameters (AC_VI, edcaParameters.GetViCWmin (), edcaParameters.GetViCWmax (), edcaParameters.GetViAifsn (), 32 * MicroSeconds (edcaParameters.GetViTxopLimit ())); SetEdcaParameters (AC_VO, edcaParameters.GetVoCWmin (), edcaParameters.GetVoCWmax (), edcaParameters.GetVoAifsn (), 32 * MicroSeconds (edcaParameters.GetVoTxopLimit ())); } - m_stationManager->SetQosSupport (apAddr, qosSupported); + GetWifiRemoteStationManager ()->SetQosSupport (apAddr, qosSupported); } if (GetHtSupported ()) { HtCapabilities htCapabilities = beacon.GetHtCapabilities (); if (!htCapabilities.IsSupportedMcs (0)) { - m_stationManager->RemoveAllSupportedMcs (apAddr); + GetWifiRemoteStationManager ()->RemoveAllSupportedMcs (apAddr); } else { - m_stationManager->AddStationHtCapabilities (apAddr, htCapabilities); + GetWifiRemoteStationManager ()->AddStationHtCapabilities (apAddr, htCapabilities); } } if (GetVhtSupported ()) @@ -828,13 +829,13 @@ StaWifiMac::UpdateApInfoFromBeacon (MgtBeaconHeader beacon, Mac48Address apAddr, //we will always fill in RxHighestSupportedLgiDataRate field at TX, so this can be used to check whether it supports VHT if (vhtCapabilities.GetRxHighestSupportedLgiDataRate () > 0) { - m_stationManager->AddStationVhtCapabilities (apAddr, vhtCapabilities); + GetWifiRemoteStationManager ()->AddStationVhtCapabilities (apAddr, vhtCapabilities); VhtOperation vhtOperation = beacon.GetVhtOperation (); - for (const auto & mcs : m_phy->GetMcsList (WIFI_MOD_CLASS_VHT)) + for (const auto & mcs : GetWifiPhy ()->GetMcsList (WIFI_MOD_CLASS_VHT)) { if (vhtCapabilities.IsSupportedRxMcs (mcs.GetMcsValue ())) { - m_stationManager->AddSupportedMcs (apAddr, mcs); + GetWifiRemoteStationManager ()->AddSupportedMcs (apAddr, mcs); } } } @@ -849,13 +850,13 @@ StaWifiMac::UpdateApInfoFromBeacon (MgtBeaconHeader beacon, Mac48Address apAddr, HeCapabilities heCapabilities = beacon.GetHeCapabilities (); if (heCapabilities.GetSupportedMcsAndNss () != 0) { - m_stationManager->AddStationHeCapabilities (apAddr, heCapabilities); + GetWifiRemoteStationManager ()->AddStationHeCapabilities (apAddr, heCapabilities); HeOperation heOperation = beacon.GetHeOperation (); - for (const auto & mcs : m_phy->GetMcsList (WIFI_MOD_CLASS_HE)) + for (const auto & mcs : GetWifiPhy ()->GetMcsList (WIFI_MOD_CLASS_HE)) { if (heCapabilities.IsSupportedRxMcs (mcs.GetMcsValue ())) { - m_stationManager->AddSupportedMcs (apAddr, mcs); + GetWifiRemoteStationManager ()->AddSupportedMcs (apAddr, mcs); } } } @@ -873,8 +874,8 @@ StaWifiMac::UpdateApInfoFromBeacon (MgtBeaconHeader beacon, Mac48Address apAddr, muEdcaParameters.GetMuAifsn (AC_VO), muEdcaParameters.GetMuEdcaTimer (AC_VO)); } } - m_stationManager->SetShortPreambleEnabled (isShortPreambleEnabled); - m_stationManager->SetShortSlotTimeEnabled (capabilities.IsShortSlotTime ()); + GetWifiRemoteStationManager ()->SetShortPreambleEnabled (isShortPreambleEnabled); + GetWifiRemoteStationManager ()->SetShortSlotTimeEnabled (capabilities.IsShortSlotTime ()); } void @@ -883,7 +884,7 @@ StaWifiMac::UpdateApInfoFromProbeResp (MgtProbeResponseHeader probeResp, Mac48Ad NS_LOG_FUNCTION (this << probeResp << apAddr << bssid); CapabilityInformation capabilities = probeResp.GetCapabilities (); SupportedRates rates = probeResp.GetSupportedRates (); - for (const auto & selector : m_phy->GetBssMembershipSelectorList ()) + for (const auto & selector : GetWifiPhy ()->GetBssMembershipSelectorList ()) { if (!rates.IsBssMembershipSelectorRate (selector)) { @@ -891,14 +892,14 @@ StaWifiMac::UpdateApInfoFromProbeResp (MgtProbeResponseHeader probeResp, Mac48Ad return; } } - for (const auto & mode : m_phy->GetModeList ()) + for (const auto & mode : GetWifiPhy ()->GetModeList ()) { - if (rates.IsSupportedRate (mode.GetDataRate (m_phy->GetChannelWidth ()))) + if (rates.IsSupportedRate (mode.GetDataRate (GetWifiPhy ()->GetChannelWidth ()))) { - m_stationManager->AddSupportedMode (apAddr, mode); - if (rates.IsBasicRate (mode.GetDataRate (m_phy->GetChannelWidth ()))) + GetWifiRemoteStationManager ()->AddSupportedMode (apAddr, mode); + if (rates.IsBasicRate (mode.GetDataRate (GetWifiPhy ()->GetChannelWidth ()))) { - m_stationManager->AddBasicMode (mode); + GetWifiRemoteStationManager ()->AddBasicMode (mode); } } } @@ -907,9 +908,9 @@ StaWifiMac::UpdateApInfoFromProbeResp (MgtProbeResponseHeader probeResp, Mac48Ad if (GetErpSupported ()) { bool isErpAllowed = false; - for (const auto & mode : m_phy->GetModeList (WIFI_MOD_CLASS_ERP_OFDM)) + for (const auto & mode : GetWifiPhy ()->GetModeList (WIFI_MOD_CLASS_ERP_OFDM)) { - if (rates.IsSupportedRate (mode.GetDataRate (m_phy->GetChannelWidth ()))) + if (rates.IsSupportedRate (mode.GetDataRate (GetWifiPhy ()->GetChannelWidth ()))) { isErpAllowed = true; break; @@ -918,28 +919,28 @@ StaWifiMac::UpdateApInfoFromProbeResp (MgtProbeResponseHeader probeResp, Mac48Ad if (!isErpAllowed) { //disable short slot time and set cwMin to 31 - m_phy->SetSlot (MicroSeconds (20)); + GetWifiPhy ()->SetSlot (MicroSeconds (20)); ConfigureContentionWindow (31, 1023); } else { ErpInformation erpInformation = probeResp.GetErpInformation (); isShortPreambleEnabled &= !erpInformation.GetBarkerPreambleMode (); - if (m_stationManager->GetShortSlotTimeEnabled ()) + if (GetWifiRemoteStationManager ()->GetShortSlotTimeEnabled ()) { //enable short slot time - m_phy->SetSlot (MicroSeconds (9)); + GetWifiPhy ()->SetSlot (MicroSeconds (9)); } else { //disable short slot time - m_phy->SetSlot (MicroSeconds (20)); + GetWifiPhy ()->SetSlot (MicroSeconds (20)); } ConfigureContentionWindow (15, 1023); } } - m_stationManager->SetShortPreambleEnabled (isShortPreambleEnabled); - m_stationManager->SetShortSlotTimeEnabled (capabilities.IsShortSlotTime ()); + GetWifiRemoteStationManager ()->SetShortPreambleEnabled (isShortPreambleEnabled); + GetWifiRemoteStationManager ()->SetShortSlotTimeEnabled (capabilities.IsShortSlotTime ()); SetBssid (bssid); } @@ -953,9 +954,9 @@ StaWifiMac::UpdateApInfoFromAssocResp (MgtAssocResponseHeader assocResp, Mac48Ad if (GetErpSupported ()) { bool isErpAllowed = false; - for (const auto & mode : m_phy->GetModeList (WIFI_MOD_CLASS_ERP_OFDM)) + for (const auto & mode : GetWifiPhy ()->GetModeList (WIFI_MOD_CLASS_ERP_OFDM)) { - if (rates.IsSupportedRate (mode.GetDataRate (m_phy->GetChannelWidth ()))) + if (rates.IsSupportedRate (mode.GetDataRate (GetWifiPhy ()->GetChannelWidth ()))) { isErpAllowed = true; break; @@ -964,28 +965,28 @@ StaWifiMac::UpdateApInfoFromAssocResp (MgtAssocResponseHeader assocResp, Mac48Ad if (!isErpAllowed) { //disable short slot time and set cwMin to 31 - m_phy->SetSlot (MicroSeconds (20)); + GetWifiPhy ()->SetSlot (MicroSeconds (20)); ConfigureContentionWindow (31, 1023); } else { ErpInformation erpInformation = assocResp.GetErpInformation (); isShortPreambleEnabled &= !erpInformation.GetBarkerPreambleMode (); - if (m_stationManager->GetShortSlotTimeEnabled ()) + if (GetWifiRemoteStationManager ()->GetShortSlotTimeEnabled ()) { //enable short slot time - m_phy->SetSlot (MicroSeconds (9)); + GetWifiPhy ()->SetSlot (MicroSeconds (9)); } else { //disable short slot time - m_phy->SetSlot (MicroSeconds (20)); + GetWifiPhy ()->SetSlot (MicroSeconds (20)); } ConfigureContentionWindow (15, 1023); } } - m_stationManager->SetShortPreambleEnabled (isShortPreambleEnabled); - m_stationManager->SetShortSlotTimeEnabled (capabilities.IsShortSlotTime ()); + GetWifiRemoteStationManager ()->SetShortPreambleEnabled (isShortPreambleEnabled); + GetWifiRemoteStationManager ()->SetShortSlotTimeEnabled (capabilities.IsShortSlotTime ()); if (GetQosSupported ()) { bool qosSupported = false; @@ -999,18 +1000,18 @@ StaWifiMac::UpdateApInfoFromAssocResp (MgtAssocResponseHeader assocResp, Mac48Ad SetEdcaParameters (AC_VI, edcaParameters.GetViCWmin (), edcaParameters.GetViCWmax (), edcaParameters.GetViAifsn (), 32 * MicroSeconds (edcaParameters.GetViTxopLimit ())); SetEdcaParameters (AC_VO, edcaParameters.GetVoCWmin (), edcaParameters.GetVoCWmax (), edcaParameters.GetVoAifsn (), 32 * MicroSeconds (edcaParameters.GetVoTxopLimit ())); } - m_stationManager->SetQosSupport (apAddr, qosSupported); + GetWifiRemoteStationManager ()->SetQosSupport (apAddr, qosSupported); } if (GetHtSupported ()) { HtCapabilities htCapabilities = assocResp.GetHtCapabilities (); if (!htCapabilities.IsSupportedMcs (0)) { - m_stationManager->RemoveAllSupportedMcs (apAddr); + GetWifiRemoteStationManager ()->RemoveAllSupportedMcs (apAddr); } else { - m_stationManager->AddStationHtCapabilities (apAddr, htCapabilities); + GetWifiRemoteStationManager ()->AddStationHtCapabilities (apAddr, htCapabilities); } } if (GetVhtSupported ()) @@ -1019,7 +1020,7 @@ StaWifiMac::UpdateApInfoFromAssocResp (MgtAssocResponseHeader assocResp, Mac48Ad //we will always fill in RxHighestSupportedLgiDataRate field at TX, so this can be used to check whether it supports VHT if (vhtCapabilities.GetRxHighestSupportedLgiDataRate () > 0) { - m_stationManager->AddStationVhtCapabilities (apAddr, vhtCapabilities); + GetWifiRemoteStationManager ()->AddStationVhtCapabilities (apAddr, vhtCapabilities); VhtOperation vhtOperation = assocResp.GetVhtOperation (); } } @@ -1028,7 +1029,7 @@ StaWifiMac::UpdateApInfoFromAssocResp (MgtAssocResponseHeader assocResp, Mac48Ad HeCapabilities hecapabilities = assocResp.GetHeCapabilities (); if (hecapabilities.GetSupportedMcsAndNss () != 0) { - m_stationManager->AddStationHeCapabilities (apAddr, hecapabilities); + GetWifiRemoteStationManager ()->AddStationHeCapabilities (apAddr, hecapabilities); HeOperation heOperation = assocResp.GetHeOperation (); GetHeConfiguration ()->SetAttribute ("BssColor", UintegerValue (heOperation.GetBssColor ())); } @@ -1046,25 +1047,25 @@ StaWifiMac::UpdateApInfoFromAssocResp (MgtAssocResponseHeader assocResp, Mac48Ad muEdcaParameters.GetMuAifsn (AC_VO), muEdcaParameters.GetMuEdcaTimer (AC_VO)); } } - for (const auto & mode : m_phy->GetModeList ()) + for (const auto & mode : GetWifiPhy ()->GetModeList ()) { - if (rates.IsSupportedRate (mode.GetDataRate (m_phy->GetChannelWidth ()))) + if (rates.IsSupportedRate (mode.GetDataRate (GetWifiPhy ()->GetChannelWidth ()))) { - m_stationManager->AddSupportedMode (apAddr, mode); - if (rates.IsBasicRate (mode.GetDataRate (m_phy->GetChannelWidth ()))) + GetWifiRemoteStationManager ()->AddSupportedMode (apAddr, mode); + if (rates.IsBasicRate (mode.GetDataRate (GetWifiPhy ()->GetChannelWidth ()))) { - m_stationManager->AddBasicMode (mode); + GetWifiRemoteStationManager ()->AddBasicMode (mode); } } } if (GetHtSupported ()) { HtCapabilities htCapabilities = assocResp.GetHtCapabilities (); - for (const auto & mcs : m_phy->GetMcsList (WIFI_MOD_CLASS_HT)) + for (const auto & mcs : GetWifiPhy ()->GetMcsList (WIFI_MOD_CLASS_HT)) { if (htCapabilities.IsSupportedMcs (mcs.GetMcsValue ())) { - m_stationManager->AddSupportedMcs (apAddr, mcs); + GetWifiRemoteStationManager ()->AddSupportedMcs (apAddr, mcs); //here should add a control to add basic MCS when it is implemented } } @@ -1072,11 +1073,11 @@ StaWifiMac::UpdateApInfoFromAssocResp (MgtAssocResponseHeader assocResp, Mac48Ad if (GetVhtSupported ()) { VhtCapabilities vhtcapabilities = assocResp.GetVhtCapabilities (); - for (const auto & mcs : m_phy->GetMcsList (WIFI_MOD_CLASS_VHT)) + for (const auto & mcs : GetWifiPhy ()->GetMcsList (WIFI_MOD_CLASS_VHT)) { if (vhtcapabilities.IsSupportedRxMcs (mcs.GetMcsValue ())) { - m_stationManager->AddSupportedMcs (apAddr, mcs); + GetWifiRemoteStationManager ()->AddSupportedMcs (apAddr, mcs); //here should add a control to add basic MCS when it is implemented } } @@ -1089,11 +1090,11 @@ StaWifiMac::UpdateApInfoFromAssocResp (MgtAssocResponseHeader assocResp, Mac48Ad if (GetHeSupported ()) { HeCapabilities heCapabilities = assocResp.GetHeCapabilities (); - for (const auto & mcs : m_phy->GetMcsList (WIFI_MOD_CLASS_HE)) + for (const auto & mcs : GetWifiPhy ()->GetMcsList (WIFI_MOD_CLASS_HE)) { if (heCapabilities.IsSupportedRxMcs (mcs.GetMcsValue ())) { - m_stationManager->AddSupportedMcs (apAddr, mcs); + GetWifiRemoteStationManager ()->AddSupportedMcs (apAddr, mcs); //here should add a control to add basic MCS when it is implemented } } @@ -1104,15 +1105,15 @@ SupportedRates StaWifiMac::GetSupportedRates (void) const { SupportedRates rates; - for (const auto & mode : m_phy->GetModeList ()) + for (const auto & mode : GetWifiPhy ()->GetModeList ()) { - uint64_t modeDataRate = mode.GetDataRate (m_phy->GetChannelWidth ()); + uint64_t modeDataRate = mode.GetDataRate (GetWifiPhy ()->GetChannelWidth ()); NS_LOG_DEBUG ("Adding supported rate of " << modeDataRate); rates.AddSupportedRate (modeDataRate); } if (GetHtSupported ()) { - for (const auto & selector : m_phy->GetBssMembershipSelectorList ()) + for (const auto & selector : GetWifiPhy ()->GetBssMembershipSelectorList ()) { rates.AddBssMembershipSelectorRate (selector); } @@ -1124,7 +1125,7 @@ CapabilityInformation StaWifiMac::GetCapabilities (void) const { CapabilityInformation capabilities; - capabilities.SetShortPreamble (m_phy->GetShortPhyPreambleSupported () || GetErpSupported ()); + capabilities.SetShortPreamble (GetWifiPhy ()->GetShortPhyPreambleSupported () || GetErpSupported ()); capabilities.SetShortSlotTime (GetShortSlotTimeSupported () && GetErpSupported ()); return capabilities; } @@ -1182,7 +1183,7 @@ StaWifiMac::NotifyChannelSwitching (void) { NS_LOG_FUNCTION (this); - RegularWifiMac::NotifyChannelSwitching (); + WifiMac::NotifyChannelSwitching (); if (IsInitialized ()) { diff --git a/src/wifi/model/sta-wifi-mac.h b/src/wifi/model/sta-wifi-mac.h index 238847fc6..bb4fdf965 100644 --- a/src/wifi/model/sta-wifi-mac.h +++ b/src/wifi/model/sta-wifi-mac.h @@ -23,7 +23,7 @@ #ifndef STA_WIFI_MAC_H #define STA_WIFI_MAC_H -#include "regular-wifi-mac.h" +#include "wifi-mac.h" #include "mgt-headers.h" class TwoLevelAggregationTest; @@ -103,7 +103,7 @@ struct ApInfo * 7. The transition from Associated to Unassociated occurs if the number * of missed beacons exceeds the threshold. */ -class StaWifiMac : public RegularWifiMac +class StaWifiMac : public WifiMac { public: /// Allow test cases to access private members diff --git a/src/wifi/model/txop.cc b/src/wifi/model/txop.cc index 7a8a8a205..a34e07e81 100644 --- a/src/wifi/model/txop.cc +++ b/src/wifi/model/txop.cc @@ -25,7 +25,7 @@ #include "ns3/socket.h" #include "txop.h" #include "channel-access-manager.h" -#include "regular-wifi-mac.h" +#include "wifi-mac.h" #include "wifi-mac-queue.h" #include "mac-tx-middle.h" #include "wifi-mac-trailer.h" @@ -133,7 +133,7 @@ void Txop::SetTxMiddle (const Ptr txMiddle) } void -Txop::SetWifiMac (const Ptr mac) +Txop::SetWifiMac (const Ptr mac) { NS_LOG_FUNCTION (this << mac); m_mac = mac; diff --git a/src/wifi/model/txop.h b/src/wifi/model/txop.h index 4a037267a..e6a987227 100644 --- a/src/wifi/model/txop.h +++ b/src/wifi/model/txop.h @@ -34,7 +34,7 @@ class WifiMacQueue; class WifiMacQueueItem; class UniformRandomVariable; class CtrlBAckResponseHeader; -class RegularWifiMac; +class WifiMac; enum WifiMacDropReason : uint8_t; // opaque enum declaration /** @@ -114,7 +114,7 @@ public: * * \param mac associated wifi MAC */ - virtual void SetWifiMac (const Ptr mac); + virtual void SetWifiMac (const Ptr mac); /** * Set MacTxMiddle this Txop is associated to. * @@ -322,7 +322,7 @@ protected: DroppedMpdu m_droppedMpduCallback; //!< the dropped MPDU callback Ptr m_queue; //!< the wifi MAC queue Ptr m_txMiddle; //!< the MacTxMiddle - Ptr m_mac; //!< the wifi MAC + Ptr m_mac; //!< the wifi MAC Ptr m_rng; //!< the random stream uint32_t m_cwMin; //!< the minimum contention window diff --git a/src/wifi/model/wifi-ack-manager.cc b/src/wifi/model/wifi-ack-manager.cc index cba37313d..5485bd494 100644 --- a/src/wifi/model/wifi-ack-manager.cc +++ b/src/wifi/model/wifi-ack-manager.cc @@ -21,7 +21,7 @@ #include "ns3/log.h" #include "wifi-ack-manager.h" #include "wifi-psdu.h" -#include "regular-wifi-mac.h" +#include "wifi-mac.h" namespace ns3 { @@ -54,7 +54,7 @@ WifiAckManager::DoDispose (void) } void -WifiAckManager::SetWifiMac (Ptr mac) +WifiAckManager::SetWifiMac (Ptr mac) { NS_LOG_FUNCTION (this << mac); m_mac = mac; diff --git a/src/wifi/model/wifi-ack-manager.h b/src/wifi/model/wifi-ack-manager.h index 35c7f90a3..1e97b1bbb 100644 --- a/src/wifi/model/wifi-ack-manager.h +++ b/src/wifi/model/wifi-ack-manager.h @@ -31,7 +31,7 @@ namespace ns3 { class WifiTxParameters; class WifiMacQueueItem; class WifiPsdu; -class RegularWifiMac; +class WifiMac; /** * \ingroup wifi @@ -54,7 +54,7 @@ public: * * \param mac a pointer to the MAC */ - void SetWifiMac (Ptr mac); + void SetWifiMac (Ptr mac); /** * Set the QoS Ack policy for the given MPDU, which must be a QoS data frame. @@ -101,7 +101,7 @@ public: protected: void DoDispose (void) override; - Ptr m_mac; //!< MAC which is using this Acknowledgment Manager + Ptr m_mac; //!< MAC which is using this Acknowledgment Manager }; diff --git a/src/wifi/model/wifi-default-protection-manager.cc b/src/wifi/model/wifi-default-protection-manager.cc index 3fcdc2192..cf5caafd8 100644 --- a/src/wifi/model/wifi-default-protection-manager.cc +++ b/src/wifi/model/wifi-default-protection-manager.cc @@ -22,7 +22,7 @@ #include "wifi-default-protection-manager.h" #include "wifi-tx-parameters.h" #include "wifi-mac-queue-item.h" -#include "regular-wifi-mac.h" +#include "wifi-mac.h" namespace ns3 { diff --git a/src/wifi/model/wifi-mac.cc b/src/wifi/model/wifi-mac.cc index 72c28a5fd..fdc70cdff 100644 --- a/src/wifi/model/wifi-mac.cc +++ b/src/wifi/model/wifi-mac.cc @@ -19,14 +19,22 @@ */ #include "ns3/log.h" +#include "ns3/pointer.h" #include "ns3/packet.h" #include "wifi-mac.h" -#include "txop.h" +#include "qos-txop.h" #include "ssid.h" +#include "mgt-headers.h" #include "wifi-net-device.h" +#include "wifi-mac-queue.h" +#include "mac-rx-middle.h" +#include "mac-tx-middle.h" +#include "channel-access-manager.h" #include "ns3/ht-configuration.h" #include "ns3/vht-configuration.h" #include "ns3/he-configuration.h" +#include "ns3/he-frame-exchange-manager.h" +#include "extended-capabilities.h" namespace ns3 { @@ -34,6 +42,26 @@ NS_LOG_COMPONENT_DEFINE ("WifiMac"); NS_OBJECT_ENSURE_REGISTERED (WifiMac); +WifiMac::WifiMac () + : m_qosSupported (false), + m_erpSupported (false), + m_dsssSupported (false) +{ + NS_LOG_FUNCTION (this); + + m_rxMiddle = Create (); + m_rxMiddle->SetForwardCallback (MakeCallback (&WifiMac::Receive, this)); + + m_txMiddle = Create (); + + m_channelAccessManager = CreateObject (); +} + +WifiMac::~WifiMac () +{ + NS_LOG_FUNCTION (this); +} + TypeId WifiMac::GetTypeId (void) { @@ -45,6 +73,165 @@ WifiMac::GetTypeId (void) MakeSsidAccessor (&WifiMac::GetSsid, &WifiMac::SetSsid), MakeSsidChecker ()) + .AddAttribute ("QosSupported", + "This Boolean attribute is set to enable 802.11e/WMM-style QoS support at this STA.", + TypeId::ATTR_GET | TypeId::ATTR_CONSTRUCT, // prevent setting after construction + BooleanValue (false), + MakeBooleanAccessor (&WifiMac::SetQosSupported, + &WifiMac::GetQosSupported), + MakeBooleanChecker ()) + .AddAttribute ("CtsToSelfSupported", + "Use CTS to Self when using a rate that is not in the basic rate set.", + BooleanValue (false), + MakeBooleanAccessor (&WifiMac::SetCtsToSelfSupported), + MakeBooleanChecker ()) + .AddAttribute ("ShortSlotTimeSupported", + "Whether or not short slot time is supported (only used by ERP APs or STAs).", + BooleanValue (true), + MakeBooleanAccessor (&WifiMac::SetShortSlotTimeSupported, + &WifiMac::GetShortSlotTimeSupported), + MakeBooleanChecker ()) + .AddAttribute ("Txop", + "The Txop object.", + PointerValue (), + MakePointerAccessor (&WifiMac::GetTxop), + MakePointerChecker ()) + .AddAttribute ("VO_Txop", + "Queue that manages packets belonging to AC_VO access class.", + PointerValue (), + MakePointerAccessor (&WifiMac::GetVOQueue), + MakePointerChecker ()) + .AddAttribute ("VI_Txop", + "Queue that manages packets belonging to AC_VI access class.", + PointerValue (), + MakePointerAccessor (&WifiMac::GetVIQueue), + MakePointerChecker ()) + .AddAttribute ("BE_Txop", + "Queue that manages packets belonging to AC_BE access class.", + PointerValue (), + MakePointerAccessor (&WifiMac::GetBEQueue), + MakePointerChecker ()) + .AddAttribute ("BK_Txop", + "Queue that manages packets belonging to AC_BK access class.", + PointerValue (), + MakePointerAccessor (&WifiMac::GetBKQueue), + MakePointerChecker ()) + .AddAttribute ("VO_MaxAmsduSize", + "Maximum length in bytes of an A-MSDU for AC_VO access class " + "(capped to 7935 for HT PPDUs and 11398 for VHT/HE PPDUs). " + "Value 0 means A-MSDU aggregation is disabled for that AC.", + UintegerValue (0), + MakeUintegerAccessor (&WifiMac::m_voMaxAmsduSize), + MakeUintegerChecker (0, 11398)) + .AddAttribute ("VI_MaxAmsduSize", + "Maximum length in bytes of an A-MSDU for AC_VI access class " + "(capped to 7935 for HT PPDUs and 11398 for VHT/HE PPDUs). " + "Value 0 means A-MSDU aggregation is disabled for that AC.", + UintegerValue (0), + MakeUintegerAccessor (&WifiMac::m_viMaxAmsduSize), + MakeUintegerChecker (0, 11398)) + .AddAttribute ("BE_MaxAmsduSize", + "Maximum length in bytes of an A-MSDU for AC_BE access class " + "(capped to 7935 for HT PPDUs and 11398 for VHT/HE PPDUs). " + "Value 0 means A-MSDU aggregation is disabled for that AC.", + UintegerValue (0), + MakeUintegerAccessor (&WifiMac::m_beMaxAmsduSize), + MakeUintegerChecker (0, 11398)) + .AddAttribute ("BK_MaxAmsduSize", + "Maximum length in bytes of an A-MSDU for AC_BK access class " + "(capped to 7935 for HT PPDUs and 11398 for VHT/HE PPDUs). " + "Value 0 means A-MSDU aggregation is disabled for that AC.", + UintegerValue (0), + MakeUintegerAccessor (&WifiMac::m_bkMaxAmsduSize), + MakeUintegerChecker (0, 11398)) + .AddAttribute ("VO_MaxAmpduSize", + "Maximum length in bytes of an A-MPDU for AC_VO access class " + "(capped to 65535 for HT PPDUs, 1048575 for VHT PPDUs, and 6500631 for HE PPDUs). " + "Value 0 means A-MPDU aggregation is disabled for that AC.", + UintegerValue (0), + MakeUintegerAccessor (&WifiMac::m_voMaxAmpduSize), + MakeUintegerChecker (0, 6500631)) + .AddAttribute ("VI_MaxAmpduSize", + "Maximum length in bytes of an A-MPDU for AC_VI access class " + "(capped to 65535 for HT PPDUs, 1048575 for VHT PPDUs, and 6500631 for HE PPDUs). " + "Value 0 means A-MPDU aggregation is disabled for that AC.", + UintegerValue (65535), + MakeUintegerAccessor (&WifiMac::m_viMaxAmpduSize), + MakeUintegerChecker (0, 6500631)) + .AddAttribute ("BE_MaxAmpduSize", + "Maximum length in bytes of an A-MPDU for AC_BE access class " + "(capped to 65535 for HT PPDUs, 1048575 for VHT PPDUs, and 6500631 for HE PPDUs). " + "Value 0 means A-MPDU aggregation is disabled for that AC.", + UintegerValue (65535), + MakeUintegerAccessor (&WifiMac::m_beMaxAmpduSize), + MakeUintegerChecker (0, 6500631)) + .AddAttribute ("BK_MaxAmpduSize", + "Maximum length in bytes of an A-MPDU for AC_BK access class " + "(capped to 65535 for HT PPDUs, 1048575 for VHT PPDUs, and 6500631 for HE PPDUs). " + "Value 0 means A-MPDU aggregation is disabled for that AC.", + UintegerValue (0), + MakeUintegerAccessor (&WifiMac::m_bkMaxAmpduSize), + MakeUintegerChecker (0, 6500631)) + .AddAttribute ("VO_BlockAckThreshold", + "If number of packets in VO queue reaches this value, " + "block ack mechanism is used. If this value is 0, block ack is never used." + "When A-MPDU is enabled, block ack mechanism is used regardless of this value.", + UintegerValue (0), + MakeUintegerAccessor (&WifiMac::SetVoBlockAckThreshold), + MakeUintegerChecker (0, 64)) + .AddAttribute ("VI_BlockAckThreshold", + "If number of packets in VI queue reaches this value, " + "block ack mechanism is used. If this value is 0, block ack is never used." + "When A-MPDU is enabled, block ack mechanism is used regardless of this value.", + UintegerValue (0), + MakeUintegerAccessor (&WifiMac::SetViBlockAckThreshold), + MakeUintegerChecker (0, 64)) + .AddAttribute ("BE_BlockAckThreshold", + "If number of packets in BE queue reaches this value, " + "block ack mechanism is used. If this value is 0, block ack is never used." + "When A-MPDU is enabled, block ack mechanism is used regardless of this value.", + UintegerValue (0), + MakeUintegerAccessor (&WifiMac::SetBeBlockAckThreshold), + MakeUintegerChecker (0, 64)) + .AddAttribute ("BK_BlockAckThreshold", + "If number of packets in BK queue reaches this value, " + "block ack mechanism is used. If this value is 0, block ack is never used." + "When A-MPDU is enabled, block ack mechanism is used regardless of this value.", + UintegerValue (0), + MakeUintegerAccessor (&WifiMac::SetBkBlockAckThreshold), + MakeUintegerChecker (0, 64)) + .AddAttribute ("VO_BlockAckInactivityTimeout", + "Represents max time (blocks of 1024 microseconds) allowed for block ack" + "inactivity for AC_VO. If this value isn't equal to 0 a timer start after that a" + "block ack setup is completed and will be reset every time that a block ack" + "frame is received. If this value is 0, block ack inactivity timeout won't be used.", + UintegerValue (0), + MakeUintegerAccessor (&WifiMac::SetVoBlockAckInactivityTimeout), + MakeUintegerChecker ()) + .AddAttribute ("VI_BlockAckInactivityTimeout", + "Represents max time (blocks of 1024 microseconds) allowed for block ack" + "inactivity for AC_VI. If this value isn't equal to 0 a timer start after that a" + "block ack setup is completed and will be reset every time that a block ack" + "frame is received. If this value is 0, block ack inactivity timeout won't be used.", + UintegerValue (0), + MakeUintegerAccessor (&WifiMac::SetViBlockAckInactivityTimeout), + MakeUintegerChecker ()) + .AddAttribute ("BE_BlockAckInactivityTimeout", + "Represents max time (blocks of 1024 microseconds) allowed for block ack" + "inactivity for AC_BE. If this value isn't equal to 0 a timer start after that a" + "block ack setup is completed and will be reset every time that a block ack" + "frame is received. If this value is 0, block ack inactivity timeout won't be used.", + UintegerValue (0), + MakeUintegerAccessor (&WifiMac::SetBeBlockAckInactivityTimeout), + MakeUintegerChecker ()) + .AddAttribute ("BK_BlockAckInactivityTimeout", + "Represents max time (blocks of 1024 microseconds) allowed for block ack" + "inactivity for AC_BK. If this value isn't equal to 0 a timer start after that a" + "block ack setup is completed and will be reset every time that a block ack" + "frame is received. If this value is 0, block ack inactivity timeout won't be used.", + UintegerValue (0), + MakeUintegerAccessor (&WifiMac::SetBkBlockAckInactivityTimeout), + MakeUintegerChecker ()) .AddTraceSource ("MacTx", "A packet has been received from higher layers and is being processed in preparation for " "queueing for transmission.", @@ -71,16 +258,128 @@ WifiMac::GetTypeId (void) "A packet has been dropped in the MAC layer after it has been passed up from the physical layer.", MakeTraceSourceAccessor (&WifiMac::m_macRxDropTrace), "ns3::Packet::TracedCallback") + .AddTraceSource ("TxOkHeader", + "The header of successfully transmitted packet.", + MakeTraceSourceAccessor (&WifiMac::m_txOkCallback), + "ns3::WifiMacHeader::TracedCallback", + TypeId::OBSOLETE, + "Use the AckedMpdu trace instead.") + .AddTraceSource ("TxErrHeader", + "The header of unsuccessfully transmitted packet.", + MakeTraceSourceAccessor (&WifiMac::m_txErrCallback), + "ns3::WifiMacHeader::TracedCallback", + TypeId::OBSOLETE, + "Depending on the failure type, use the NAckedMpdu trace, the " + "DroppedMpdu trace or one of the traces associated with TX timeouts.") + .AddTraceSource ("AckedMpdu", + "An MPDU that was successfully acknowledged, via either a " + "Normal Ack or a Block Ack.", + MakeTraceSourceAccessor (&WifiMac::m_ackedMpduCallback), + "ns3::WifiMacQueueItem::TracedCallback") + .AddTraceSource ("NAckedMpdu", + "An MPDU that was negatively acknowledged via a Block Ack.", + MakeTraceSourceAccessor (&WifiMac::m_nackedMpduCallback), + "ns3::WifiMacQueueItem::TracedCallback") + .AddTraceSource ("DroppedMpdu", + "An MPDU that was dropped for the given reason (see WifiMacDropReason).", + MakeTraceSourceAccessor (&WifiMac::m_droppedMpduCallback), + "ns3::WifiMac::DroppedMpduCallback") + .AddTraceSource ("MpduResponseTimeout", + "An MPDU whose response was not received before the timeout, along with " + "an identifier of the type of timeout (see WifiTxTimer::Reason) and the " + "TXVECTOR used to transmit the MPDU. This trace source is fired when a " + "CTS is missing after an RTS or a Normal Ack is missing after an MPDU " + "or after a DL MU PPDU acknowledged in SU format.", + MakeTraceSourceAccessor (&WifiMac::m_mpduResponseTimeoutCallback), + "ns3::WifiMac::MpduResponseTimeoutCallback") + .AddTraceSource ("PsduResponseTimeout", + "A PSDU whose response was not received before the timeout, along with " + "an identifier of the type of timeout (see WifiTxTimer::Reason) and the " + "TXVECTOR used to transmit the PSDU. This trace source is fired when a " + "BlockAck is missing after an A-MPDU, a BlockAckReq (possibly in the " + "context of the acknowledgment of a DL MU PPDU in SU format) or a TB PPDU " + "(in the latter case the missing BlockAck is a Multi-STA BlockAck).", + MakeTraceSourceAccessor (&WifiMac::m_psduResponseTimeoutCallback), + "ns3::WifiMac::PsduResponseTimeoutCallback") + .AddTraceSource ("PsduMapResponseTimeout", + "A PSDU map for which not all the responses were received before the timeout, " + "along with an identifier of the type of timeout (see WifiTxTimer::Reason), " + "the set of MAC addresses of the stations that did not respond and the total " + "number of stations that had to respond. This trace source is fired when not " + "all the addressed stations responded to an MU-BAR Trigger frame (either sent as " + "a SU frame or aggregated to PSDUs in the DL MU PPDU), a Basic Trigger Frame or " + "a BSRP Trigger Frame.", + MakeTraceSourceAccessor (&WifiMac::m_psduMapResponseTimeoutCallback), + "ns3::WifiMac::PsduMapResponseTimeoutCallback") ; return tid; } + +void +WifiMac::DoInitialize () +{ + NS_LOG_FUNCTION (this); + + if (m_txop != nullptr) + { + m_txop->Initialize (); + } + + for (auto it = m_edca.begin (); it != m_edca.end (); ++it) + { + it->second->Initialize (); + } +} + void WifiMac::DoDispose () { + NS_LOG_FUNCTION (this); + + m_rxMiddle = 0; + m_txMiddle = 0; + + m_channelAccessManager->Dispose (); + m_channelAccessManager = 0; + + if (m_txop != nullptr) + { + m_txop->Dispose (); + } + m_txop = 0; + + for (auto it = m_edca.begin (); it != m_edca.end (); ++it) + { + it->second->Dispose (); + it->second = 0; + } + + if (m_feManager != 0) + { + m_feManager->Dispose (); + } + m_feManager = 0; + + m_stationManager = 0; + m_phy = 0; + m_device = 0; } +void +WifiMac::SetTypeOfStation (TypeOfStation type) +{ + NS_LOG_FUNCTION (this << type); + m_typeOfStation = type; +} + +TypeOfStation +WifiMac::GetTypeOfStation (void) const +{ + return m_typeOfStation; +} + void WifiMac::SetDevice (const Ptr device) { @@ -93,6 +392,130 @@ WifiMac::GetDevice (void) const return m_device; } +void +WifiMac::SetAddress (Mac48Address address) +{ + NS_LOG_FUNCTION (this << address); + m_address = address; +} + +Mac48Address +WifiMac::GetAddress (void) const +{ + return m_address; +} + +void +WifiMac::SetSsid (Ssid ssid) +{ + NS_LOG_FUNCTION (this << ssid); + m_ssid = ssid; +} + +Ssid +WifiMac::GetSsid (void) const +{ + return m_ssid; +} + +void +WifiMac::SetBssid (Mac48Address bssid) +{ + NS_LOG_FUNCTION (this << bssid); + m_bssid = bssid; + if (m_feManager) + { + m_feManager->SetBssid (bssid); + } +} + +Mac48Address +WifiMac::GetBssid (void) const +{ + return m_bssid; +} + +void +WifiMac::SetPromisc (void) +{ + NS_ASSERT (m_feManager != 0); + m_feManager->SetPromisc (); +} + +Ptr +WifiMac::GetTxop () const +{ + return m_txop; +} + +Ptr +WifiMac::GetQosTxop (AcIndex ac) const +{ + const auto it = m_edca.find (ac); + if (it == m_edca.cend ()) + { + return nullptr; + } + return it->second; +} + +Ptr +WifiMac::GetQosTxop (uint8_t tid) const +{ + return GetQosTxop (QosUtilsMapTidToAc (tid)); +} + +Ptr +WifiMac::GetVOQueue () const +{ + return (m_qosSupported ? GetQosTxop (AC_VO) : nullptr); +} + +Ptr +WifiMac::GetVIQueue () const +{ + return (m_qosSupported ? GetQosTxop (AC_VI) : nullptr); +} + +Ptr +WifiMac::GetBEQueue () const +{ + return (m_qosSupported ? GetQosTxop (AC_BE) : nullptr); +} + +Ptr +WifiMac::GetBKQueue () const +{ + return (m_qosSupported ? GetQosTxop (AC_BK) : nullptr); +} + +Ptr +WifiMac::GetTxopQueue (AcIndex ac) const +{ + if (ac == AC_BE_NQOS) + { + NS_ASSERT (m_txop != nullptr); + return m_txop->GetWifiMacQueue (); + } + NS_ASSERT (ac == AC_BE || ac == AC_BK || ac == AC_VI || ac == AC_VO); + return m_edca.find (ac)->second->GetWifiMacQueue (); +} + +void +WifiMac::NotifyChannelSwitching (void) +{ + NS_LOG_FUNCTION (this); + + // we may have changed PHY band, in which case it is necessary to re-configure + // the PHY dependent parameters. In any case, this makes no harm + ConfigurePhyDependentParameters (); + + // SetupPhy not only resets the remote station manager, but also sets the + // default TX mode and MCS, which is required when switching to a channel + // in a different band + m_stationManager->SetupPhy (m_phy); +} + void WifiMac::NotifyTx (Ptr packet) { @@ -123,6 +546,47 @@ WifiMac::NotifyRxDrop (Ptr packet) m_macRxDropTrace (packet); } +void +WifiMac::SetupEdcaQueue (AcIndex ac) +{ + NS_LOG_FUNCTION (this << ac); + + //Our caller shouldn't be attempting to setup a queue that is + //already configured. + NS_ASSERT (m_edca.find (ac) == m_edca.end ()); + + Ptr edca = CreateObject (ac); + edca->SetChannelAccessManager (m_channelAccessManager); + edca->SetWifiMac (this); + edca->SetTxMiddle (m_txMiddle); + edca->GetBaManager ()->SetTxOkCallback (MakeCallback (&MpduTracedCallback::operator(), + &m_ackedMpduCallback)); + edca->GetBaManager ()->SetTxFailedCallback (MakeCallback (&MpduTracedCallback::operator(), + &m_nackedMpduCallback)); + edca->SetDroppedMpduCallback (MakeCallback (&DroppedMpduTracedCallback::operator(), + &m_droppedMpduCallback)); + + m_edca.insert (std::make_pair (ac, edca)); +} + +void +WifiMac::ConfigureContentionWindow (uint32_t cwMin, uint32_t cwMax) +{ + bool isDsssOnly = GetDsssSupported () && !GetErpSupported (); + if (m_txop != nullptr) + { + //The special value of AC_BE_NQOS which exists in the Access + //Category enumeration allows us to configure plain old DCF. + ConfigureDcf (m_txop, cwMin, cwMax, isDsssOnly, AC_BE_NQOS); + } + + //Now we configure the EDCA functions + for (auto it = m_edca.begin (); it!= m_edca.end (); ++it) + { + ConfigureDcf (it->second, cwMin, cwMax, isDsssOnly, it->first); + } +} + void WifiMac::ConfigureDcf (Ptr dcf, uint32_t cwmin, uint32_t cwmax, bool isDsss, AcIndex ac) { @@ -183,6 +647,397 @@ WifiMac::ConfigureDcf (Ptr dcf, uint32_t cwmin, uint32_t cwmax, bool isDss } } +void +WifiMac::ConfigureStandard (WifiStandard standard) +{ + NS_LOG_FUNCTION (this << standard); + + NS_ABORT_IF (standard >= WIFI_STANDARD_80211n && !m_qosSupported); + + SetupFrameExchangeManager (standard); +} + +void +WifiMac::ConfigurePhyDependentParameters (void) +{ + WifiPhyBand band = m_phy->GetPhyBand (); + NS_LOG_FUNCTION (this << band); + + uint32_t cwmin = 0; + uint32_t cwmax = 0; + + NS_ASSERT (m_phy != 0); + WifiStandard standard = m_phy->GetStandard (); + + if (standard == WIFI_STANDARD_80211b) + { + SetDsssSupported (true); + cwmin = 31; + cwmax = 1023; + return; + } + + if (standard >= WIFI_STANDARD_80211g && band == WIFI_PHY_BAND_2_4GHZ) + { + SetErpSupported (true); + } + + cwmin = 15; + cwmax = 1023; + + ConfigureContentionWindow (cwmin, cwmax); +} + +void +WifiMac::SetupFrameExchangeManager (WifiStandard standard) +{ + NS_LOG_FUNCTION (this << standard); + NS_ABORT_MSG_IF (standard == WIFI_STANDARD_UNSPECIFIED, "Wifi standard not set"); + + if (standard >= WIFI_STANDARD_80211ax) + { + m_feManager = CreateObject (); + } + else if (standard >= WIFI_STANDARD_80211ac) + { + m_feManager = CreateObject (); + } + else if (standard >= WIFI_STANDARD_80211n) + { + m_feManager = CreateObject (); + } + else if (m_qosSupported) + { + m_feManager = CreateObject (); + } + else + { + m_feManager = CreateObject (); + } + + m_feManager->SetWifiMac (this); + m_feManager->SetMacTxMiddle (m_txMiddle); + m_feManager->SetMacRxMiddle (m_rxMiddle); + m_feManager->SetAddress (GetAddress ()); + m_feManager->SetBssid (GetBssid ()); + m_feManager->GetWifiTxTimer ().SetMpduResponseTimeoutCallback (MakeCallback (&MpduResponseTimeoutTracedCallback::operator(), + &m_mpduResponseTimeoutCallback)); + m_feManager->GetWifiTxTimer ().SetPsduResponseTimeoutCallback (MakeCallback (&PsduResponseTimeoutTracedCallback::operator(), + &m_psduResponseTimeoutCallback)); + m_feManager->GetWifiTxTimer ().SetPsduMapResponseTimeoutCallback (MakeCallback (&PsduMapResponseTimeoutTracedCallback::operator(), + &m_psduMapResponseTimeoutCallback)); + m_feManager->SetDroppedMpduCallback (MakeCallback (&DroppedMpduTracedCallback::operator(), + &m_droppedMpduCallback)); + m_feManager->SetAckedMpduCallback (MakeCallback (&MpduTracedCallback::operator(), + &m_ackedMpduCallback)); + m_channelAccessManager->SetupFrameExchangeManager (m_feManager); + if (GetQosSupported ()) + { + for (const auto& pair : m_edca) + { + pair.second->SetQosFrameExchangeManager (DynamicCast (m_feManager)); + } + } +} + +Ptr +WifiMac::GetFrameExchangeManager (void) const +{ + return m_feManager; +} + +void +WifiMac::SetWifiRemoteStationManager (const Ptr stationManager) +{ + NS_LOG_FUNCTION (this << stationManager); + m_stationManager = stationManager; +} + +Ptr +WifiMac::GetWifiRemoteStationManager () const +{ + return m_stationManager; +} + +void +WifiMac::SetWifiPhy (const Ptr phy) +{ + NS_LOG_FUNCTION (this << phy); + m_phy = phy; + NS_ABORT_MSG_IF (!m_phy->GetOperatingChannel ().IsSet (), + "PHY operating channel must have been set"); + ConfigurePhyDependentParameters (); + m_channelAccessManager->SetupPhyListener (phy); + NS_ASSERT (m_feManager != 0); + m_feManager->SetWifiPhy (phy); +} + +Ptr +WifiMac::GetWifiPhy (void) const +{ + NS_LOG_FUNCTION (this); + return m_phy; +} + +void +WifiMac::ResetWifiPhy (void) +{ + NS_LOG_FUNCTION (this); + NS_ASSERT (m_feManager != 0); + m_feManager->ResetPhy (); + m_channelAccessManager->RemovePhyListener (m_phy); + m_phy = 0; +} + +void +WifiMac::SetQosSupported (bool enable) +{ + NS_LOG_FUNCTION (this << enable); + NS_ABORT_IF (IsInitialized ()); + m_qosSupported = enable; + + if (!m_qosSupported) + { + // create a non-QoS TXOP + m_txop = CreateObject (); + m_txop->SetChannelAccessManager (m_channelAccessManager); + m_txop->SetWifiMac (this); + m_txop->SetTxMiddle (m_txMiddle); + m_txop->SetDroppedMpduCallback (MakeCallback (&DroppedMpduTracedCallback::operator(), + &m_droppedMpduCallback)); + } + else + { + //Construct the EDCAFs. The ordering is important - highest + //priority (Table 9-1 UP-to-AC mapping; IEEE 802.11-2012) must be created + //first. + SetupEdcaQueue (AC_VO); + SetupEdcaQueue (AC_VI); + SetupEdcaQueue (AC_BE); + SetupEdcaQueue (AC_BK); + } +} + +bool +WifiMac::GetQosSupported () const +{ + return m_qosSupported; +} + +bool +WifiMac::GetErpSupported () const +{ + return m_erpSupported; +} + +void +WifiMac::SetErpSupported (bool enable) +{ + NS_LOG_FUNCTION (this); + if (enable) + { + SetDsssSupported (true); + } + m_erpSupported = enable; +} + +void +WifiMac::SetDsssSupported (bool enable) +{ + NS_LOG_FUNCTION (this); + m_dsssSupported = enable; +} + +bool +WifiMac::GetDsssSupported () const +{ + return m_dsssSupported; +} + +void +WifiMac::SetCtsToSelfSupported (bool enable) +{ + NS_LOG_FUNCTION (this); + m_ctsToSelfSupported = enable; +} + +void +WifiMac::SetShortSlotTimeSupported (bool enable) +{ + NS_LOG_FUNCTION (this << enable); + m_shortSlotTimeSupported = enable; +} + +bool +WifiMac::GetShortSlotTimeSupported (void) const +{ + return m_shortSlotTimeSupported; +} + +bool +WifiMac::SupportsSendFrom (void) const +{ + return false; +} + +void +WifiMac::SetForwardUpCallback (ForwardUpCallback upCallback) +{ + NS_LOG_FUNCTION (this); + m_forwardUp = upCallback; +} + +void +WifiMac::SetLinkUpCallback (Callback linkUp) +{ + NS_LOG_FUNCTION (this); + m_linkUp = linkUp; +} + +void +WifiMac::SetLinkDownCallback (Callback linkDown) +{ + NS_LOG_FUNCTION (this); + m_linkDown = linkDown; +} + +void +WifiMac::Enqueue (Ptr packet, Mac48Address to, Mac48Address from) +{ + //We expect WifiMac subclasses which do support forwarding (e.g., + //AP) to override this method. Therefore, we throw a fatal error if + //someone tries to invoke this method on a class which has not done + //this. + NS_FATAL_ERROR ("This MAC entity (" << this << ", " << GetAddress () + << ") does not support Enqueue() with from address"); +} + +void +WifiMac::ForwardUp (Ptr packet, Mac48Address from, Mac48Address to) +{ + NS_LOG_FUNCTION (this << packet << from << to); + m_forwardUp (packet, from, to); +} + +void +WifiMac::Receive (Ptr mpdu) +{ + NS_LOG_FUNCTION (this << *mpdu); + + const WifiMacHeader* hdr = &mpdu->GetHeader (); + Ptr packet = mpdu->GetPacket ()->Copy (); + Mac48Address to = hdr->GetAddr1 (); + Mac48Address from = hdr->GetAddr2 (); + + //We don't know how to deal with any frame that is not addressed to + //us (and odds are there is nothing sensible we could do anyway), + //so we ignore such frames. + // + //The derived class may also do some such filtering, but it doesn't + //hurt to have it here too as a backstop. + if (to != GetAddress ()) + { + return; + } + + if (hdr->IsMgt () && hdr->IsAction ()) + { + //There is currently only any reason for Management Action + //frames to be flying about if we are a QoS STA. + NS_ASSERT (GetQosSupported ()); + + WifiActionHeader actionHdr; + packet->RemoveHeader (actionHdr); + + switch (actionHdr.GetCategory ()) + { + case WifiActionHeader::BLOCK_ACK: + + switch (actionHdr.GetAction ().blockAck) + { + case WifiActionHeader::BLOCK_ACK_ADDBA_REQUEST: + { + MgtAddBaRequestHeader reqHdr; + packet->RemoveHeader (reqHdr); + + //We've received an ADDBA Request. Our policy here is + //to automatically accept it, so we get the ADDBA + //Response on it's way immediately. + NS_ASSERT (m_feManager != 0); + Ptr htFem = DynamicCast (m_feManager); + if (htFem != 0) + { + htFem->SendAddBaResponse (&reqHdr, from); + } + //This frame is now completely dealt with, so we're done. + return; + } + case WifiActionHeader::BLOCK_ACK_ADDBA_RESPONSE: + { + MgtAddBaResponseHeader respHdr; + packet->RemoveHeader (respHdr); + + //We've received an ADDBA Response. We assume that it + //indicates success after an ADDBA Request we have + //sent (we could, in principle, check this, but it + //seems a waste given the level of the current model) + //and act by locally establishing the agreement on + //the appropriate queue. + GetQosTxop (respHdr.GetTid ())->GotAddBaResponse (&respHdr, from); + //This frame is now completely dealt with, so we're done. + return; + } + case WifiActionHeader::BLOCK_ACK_DELBA: + { + MgtDelBaHeader delBaHdr; + packet->RemoveHeader (delBaHdr); + + if (delBaHdr.IsByOriginator ()) + { + //This DELBA frame was sent by the originator, so + //this means that an ingoing established + //agreement exists in HtFrameExchangeManager and we need to + //destroy it. + NS_ASSERT (m_feManager != 0); + Ptr htFem = DynamicCast (m_feManager); + if (htFem != 0) + { + htFem->DestroyBlockAckAgreement (from, delBaHdr.GetTid ()); + } + } + else + { + //We must have been the originator. We need to + //tell the correct queue that the agreement has + //been torn down + GetQosTxop (delBaHdr.GetTid ())->GotDelBaFrame (&delBaHdr, from); + } + //This frame is now completely dealt with, so we're done. + return; + } + default: + NS_FATAL_ERROR ("Unsupported Action field in Block Ack Action frame"); + return; + } + default: + NS_FATAL_ERROR ("Unsupported Action frame received"); + return; + } + } + NS_FATAL_ERROR ("Don't know how to handle frame (type=" << hdr->GetType ()); +} + +void +WifiMac::DeaggregateAmsduAndForward (Ptr mpdu) +{ + NS_LOG_FUNCTION (this << *mpdu); + for (auto& msduPair : *PeekPointer (mpdu)) + { + ForwardUp (msduPair.first, msduPair.second.GetSourceAddr (), + msduPair.second.GetDestinationAddr ()); + } +} + Ptr WifiMac::GetHtConfiguration (void) const { @@ -201,5 +1056,369 @@ WifiMac::GetHeConfiguration (void) const return GetDevice ()->GetHeConfiguration (); } +bool +WifiMac::GetHtSupported () const +{ + if (GetHtConfiguration ()) + { + return true; + } + return false; +} + +bool +WifiMac::GetVhtSupported () const +{ + if (GetVhtConfiguration ()) + { + return true; + } + return false; +} + +bool +WifiMac::GetHeSupported () const +{ + if (GetHeConfiguration ()) + { + return true; + } + return false; +} + +void +WifiMac::SetVoBlockAckThreshold (uint8_t threshold) +{ + NS_LOG_FUNCTION (this << +threshold); + if (m_qosSupported) + { + GetVOQueue ()->SetBlockAckThreshold (threshold); + } +} + +void +WifiMac::SetViBlockAckThreshold (uint8_t threshold) +{ + NS_LOG_FUNCTION (this << +threshold); + if (m_qosSupported) + { + GetVIQueue ()->SetBlockAckThreshold (threshold); + } +} + +void +WifiMac::SetBeBlockAckThreshold (uint8_t threshold) +{ + NS_LOG_FUNCTION (this << +threshold); + if (m_qosSupported) + { + GetBEQueue ()->SetBlockAckThreshold (threshold); + } +} + +void +WifiMac::SetBkBlockAckThreshold (uint8_t threshold) +{ + NS_LOG_FUNCTION (this << +threshold); + if (m_qosSupported) + { + GetBKQueue ()->SetBlockAckThreshold (threshold); + } +} + +void +WifiMac::SetVoBlockAckInactivityTimeout (uint16_t timeout) +{ + NS_LOG_FUNCTION (this << timeout); + if (m_qosSupported) + { + GetVOQueue ()->SetBlockAckInactivityTimeout (timeout); + } +} + +void +WifiMac::SetViBlockAckInactivityTimeout (uint16_t timeout) +{ + NS_LOG_FUNCTION (this << timeout); + if (m_qosSupported) + { + GetVIQueue ()->SetBlockAckInactivityTimeout (timeout); + } +} + +void +WifiMac::SetBeBlockAckInactivityTimeout (uint16_t timeout) +{ + NS_LOG_FUNCTION (this << timeout); + if (m_qosSupported) + { + GetBEQueue ()->SetBlockAckInactivityTimeout (timeout); + } +} + +void +WifiMac::SetBkBlockAckInactivityTimeout (uint16_t timeout) +{ + NS_LOG_FUNCTION (this << timeout); + if (m_qosSupported) + { + GetBKQueue ()->SetBlockAckInactivityTimeout (timeout); + } +} + +ExtendedCapabilities +WifiMac::GetExtendedCapabilities (void) const +{ + NS_LOG_FUNCTION (this); + ExtendedCapabilities capabilities; + capabilities.SetHtSupported (GetHtSupported ()); + capabilities.SetVhtSupported (GetVhtSupported ()); + //TODO: to be completed + return capabilities; +} + +HtCapabilities +WifiMac::GetHtCapabilities (void) const +{ + NS_LOG_FUNCTION (this); + HtCapabilities capabilities; + if (GetHtSupported ()) + { + Ptr htConfiguration = GetHtConfiguration (); + bool sgiSupported = htConfiguration->GetShortGuardIntervalSupported (); + capabilities.SetHtSupported (1); + capabilities.SetLdpc (htConfiguration->GetLdpcSupported ()); + capabilities.SetSupportedChannelWidth (GetWifiPhy ()->GetChannelWidth () >= 40); + capabilities.SetShortGuardInterval20 (sgiSupported); + capabilities.SetShortGuardInterval40 (GetWifiPhy ()->GetChannelWidth () >= 40 && sgiSupported); + // Set Maximum A-MSDU Length subfield + uint16_t maxAmsduSize = std::max ({m_voMaxAmsduSize, m_viMaxAmsduSize, + m_beMaxAmsduSize, m_bkMaxAmsduSize}); + if (maxAmsduSize <= 3839) + { + capabilities.SetMaxAmsduLength (3839); + } + else + { + capabilities.SetMaxAmsduLength (7935); + } + uint32_t maxAmpduLength = std::max ({m_voMaxAmpduSize, m_viMaxAmpduSize, + m_beMaxAmpduSize, m_bkMaxAmpduSize}); + // round to the next power of two minus one + maxAmpduLength = (1ul << static_cast (std::ceil (std::log2 (maxAmpduLength + 1)))) - 1; + // The maximum A-MPDU length in HT capabilities elements ranges from 2^13-1 to 2^16-1 + capabilities.SetMaxAmpduLength (std::min (std::max (maxAmpduLength, 8191u), 65535u)); + + capabilities.SetLSigProtectionSupport (true); + uint64_t maxSupportedRate = 0; //in bit/s + for (const auto & mcs : GetWifiPhy ()->GetMcsList (WIFI_MOD_CLASS_HT)) + { + capabilities.SetRxMcsBitmask (mcs.GetMcsValue ()); + uint8_t nss = (mcs.GetMcsValue () / 8) + 1; + NS_ASSERT (nss > 0 && nss < 5); + uint64_t dataRate = mcs.GetDataRate (GetWifiPhy ()->GetChannelWidth (), sgiSupported ? 400 : 800, nss); + if (dataRate > maxSupportedRate) + { + maxSupportedRate = dataRate; + NS_LOG_DEBUG ("Updating maxSupportedRate to " << maxSupportedRate); + } + } + capabilities.SetRxHighestSupportedDataRate (static_cast (maxSupportedRate / 1e6)); //in Mbit/s + capabilities.SetTxMcsSetDefined (GetWifiPhy ()->GetNMcs () > 0); + capabilities.SetTxMaxNSpatialStreams (GetWifiPhy ()->GetMaxSupportedTxSpatialStreams ()); + //we do not support unequal modulations + capabilities.SetTxRxMcsSetUnequal (0); + capabilities.SetTxUnequalModulation (0); + } + return capabilities; +} + +VhtCapabilities +WifiMac::GetVhtCapabilities (void) const +{ + NS_LOG_FUNCTION (this); + VhtCapabilities capabilities; + if (GetVhtSupported ()) + { + Ptr htConfiguration = GetHtConfiguration (); + Ptr vhtConfiguration = GetVhtConfiguration (); + bool sgiSupported = htConfiguration->GetShortGuardIntervalSupported (); + capabilities.SetVhtSupported (1); + if (GetWifiPhy ()->GetChannelWidth () == 160) + { + capabilities.SetSupportedChannelWidthSet (1); + } + else + { + capabilities.SetSupportedChannelWidthSet (0); + } + // Set Maximum MPDU Length subfield + uint16_t maxAmsduSize = std::max ({m_voMaxAmsduSize, m_viMaxAmsduSize, + m_beMaxAmsduSize, m_bkMaxAmsduSize}); + if (maxAmsduSize <= 3839) + { + capabilities.SetMaxMpduLength (3895); + } + else if (maxAmsduSize <= 7935) + { + capabilities.SetMaxMpduLength (7991); + } + else + { + capabilities.SetMaxMpduLength (11454); + } + uint32_t maxAmpduLength = std::max ({m_voMaxAmpduSize, m_viMaxAmpduSize, + m_beMaxAmpduSize, m_bkMaxAmpduSize}); + // round to the next power of two minus one + maxAmpduLength = (1ul << static_cast (std::ceil (std::log2 (maxAmpduLength + 1)))) - 1; + // The maximum A-MPDU length in VHT capabilities elements ranges from 2^13-1 to 2^20-1 + capabilities.SetMaxAmpduLength (std::min (std::max (maxAmpduLength, 8191u), 1048575u)); + + capabilities.SetRxLdpc (htConfiguration->GetLdpcSupported ()); + capabilities.SetShortGuardIntervalFor80Mhz ((GetWifiPhy ()->GetChannelWidth () == 80) && sgiSupported); + capabilities.SetShortGuardIntervalFor160Mhz ((GetWifiPhy ()->GetChannelWidth () == 160) && sgiSupported); + uint8_t maxMcs = 0; + for (const auto & mcs : GetWifiPhy ()->GetMcsList (WIFI_MOD_CLASS_VHT)) + { + if (mcs.GetMcsValue () > maxMcs) + { + maxMcs = mcs.GetMcsValue (); + } + } + // Support same MaxMCS for each spatial stream + for (uint8_t nss = 1; nss <= GetWifiPhy ()->GetMaxSupportedRxSpatialStreams (); nss++) + { + capabilities.SetRxMcsMap (maxMcs, nss); + } + for (uint8_t nss = 1; nss <= GetWifiPhy ()->GetMaxSupportedTxSpatialStreams (); nss++) + { + capabilities.SetTxMcsMap (maxMcs, nss); + } + uint64_t maxSupportedRateLGI = 0; //in bit/s + for (const auto & mcs : GetWifiPhy ()->GetMcsList (WIFI_MOD_CLASS_VHT)) + { + if (!mcs.IsAllowed (GetWifiPhy ()->GetChannelWidth (), 1)) + { + continue; + } + if (mcs.GetDataRate (GetWifiPhy ()->GetChannelWidth ()) > maxSupportedRateLGI) + { + maxSupportedRateLGI = mcs.GetDataRate (GetWifiPhy ()->GetChannelWidth ()); + NS_LOG_DEBUG ("Updating maxSupportedRateLGI to " << maxSupportedRateLGI); + } + } + capabilities.SetRxHighestSupportedLgiDataRate (static_cast (maxSupportedRateLGI / 1e6)); //in Mbit/s + capabilities.SetTxHighestSupportedLgiDataRate (static_cast (maxSupportedRateLGI / 1e6)); //in Mbit/s + //To be filled in once supported + capabilities.SetRxStbc (0); + capabilities.SetTxStbc (0); + } + return capabilities; +} + +HeCapabilities +WifiMac::GetHeCapabilities (void) const +{ + NS_LOG_FUNCTION (this); + HeCapabilities capabilities; + if (GetHeSupported ()) + { + Ptr htConfiguration = GetHtConfiguration (); + Ptr heConfiguration = GetHeConfiguration (); + capabilities.SetHeSupported (1); + uint8_t channelWidthSet = 0; + if ((m_phy->GetChannelWidth () >= 40) && (m_phy->GetPhyBand () == WIFI_PHY_BAND_2_4GHZ)) + { + channelWidthSet |= 0x01; + } + if ((m_phy->GetChannelWidth () >= 80) && ((m_phy->GetPhyBand () == WIFI_PHY_BAND_5GHZ) || (m_phy->GetPhyBand () == WIFI_PHY_BAND_6GHZ))) + { + channelWidthSet |= 0x02; + } + if ((m_phy->GetChannelWidth () >= 160) && ((m_phy->GetPhyBand () == WIFI_PHY_BAND_5GHZ) || (m_phy->GetPhyBand () == WIFI_PHY_BAND_6GHZ))) + { + channelWidthSet |= 0x04; + } + capabilities.SetChannelWidthSet (channelWidthSet); + capabilities.SetLdpcCodingInPayload (htConfiguration->GetLdpcSupported ()); + if (heConfiguration->GetGuardInterval () == NanoSeconds (800)) + { + //todo: We assume for now that if we support 800ns GI then 1600ns GI is supported as well + //todo: Assuming reception support for both 1x HE LTF and 4x HE LTF 800 ns + capabilities.SetHeSuPpdu1xHeLtf800nsGi (true); + capabilities.SetHePpdu4xHeLtf800nsGi (true); + } + + uint32_t maxAmpduLength = std::max ({m_voMaxAmpduSize, m_viMaxAmpduSize, + m_beMaxAmpduSize, m_bkMaxAmpduSize}); + // round to the next power of two minus one + maxAmpduLength = (1ul << static_cast (std::ceil (std::log2 (maxAmpduLength + 1)))) - 1; + // The maximum A-MPDU length in HE capabilities elements ranges from 2^20-1 to 2^23-1 + capabilities.SetMaxAmpduLength (std::min (std::max (maxAmpduLength, 1048575u), 8388607u)); + + uint8_t maxMcs = 0; + for (const auto & mcs : m_phy->GetMcsList (WIFI_MOD_CLASS_HE)) + { + if (mcs.GetMcsValue () > maxMcs) + { + maxMcs = mcs.GetMcsValue (); + } + } + capabilities.SetHighestMcsSupported (maxMcs); + capabilities.SetHighestNssSupported (m_phy->GetMaxSupportedTxSpatialStreams ()); + } + return capabilities; +} + +uint32_t +WifiMac::GetMaxAmpduSize (AcIndex ac) const +{ + uint32_t maxSize = 0; + switch (ac) + { + case AC_BE: + maxSize = m_beMaxAmpduSize; + break; + case AC_BK: + maxSize = m_bkMaxAmpduSize; + break; + case AC_VI: + maxSize = m_viMaxAmpduSize; + break; + case AC_VO: + maxSize = m_voMaxAmpduSize; + break; + default: + NS_ABORT_MSG ("Unknown AC " << ac); + return 0; + } + return maxSize; +} + +uint16_t +WifiMac::GetMaxAmsduSize (AcIndex ac) const +{ + uint16_t maxSize = 0; + switch (ac) + { + case AC_BE: + maxSize = m_beMaxAmsduSize; + break; + case AC_BK: + maxSize = m_bkMaxAmsduSize; + break; + case AC_VI: + maxSize = m_viMaxAmsduSize; + break; + case AC_VO: + maxSize = m_voMaxAmsduSize; + break; + default: + NS_ABORT_MSG ("Unknown AC " << ac); + return 0; + } + return maxSize; +} + } //namespace ns3 diff --git a/src/wifi/model/wifi-mac.h b/src/wifi/model/wifi-mac.h index d8b25876e..70c2fba99 100644 --- a/src/wifi/model/wifi-mac.h +++ b/src/wifi/model/wifi-mac.h @@ -21,18 +21,29 @@ #ifndef WIFI_MAC_H #define WIFI_MAC_H +#include +#include #include "wifi-standards.h" #include "wifi-remote-station-manager.h" #include "qos-utils.h" +#include "ssid.h" namespace ns3 { -class Ssid; class Txop; class WifiNetDevice; +class QosTxop; +class WifiPsdu; +class MacRxMiddle; +class MacTxMiddle; +class WifiMacQueue; +class WifiMacQueueItem; class HtConfiguration; class VhtConfiguration; class HeConfiguration; +class FrameExchangeManager; +class ChannelAccessManager; +class ExtendedCapabilities; /** * Enumeration for type of station @@ -59,6 +70,8 @@ enum WifiMacDropReason : uint8_t WIFI_MAC_DROP_QOS_OLD_PACKET }; +typedef std::unordered_map /* PSDU */> WifiPsduMap; + /** * \brief base class for all MAC-level wifi objects. * \ingroup wifi @@ -71,14 +84,15 @@ enum WifiMacDropReason : uint8_t class WifiMac : public Object { public: - virtual void DoDispose (); - /** * \brief Get the type ID. * \return the object TypeId */ static TypeId GetTypeId (void); + WifiMac (); + virtual ~WifiMac (); + /** * Sets the device this PHY is associated with. * @@ -92,6 +106,41 @@ public: */ Ptr GetDevice (void) const; + /** + * Get the Frame Exchange Manager + * + * \return the Frame Exchange Manager + */ + Ptr GetFrameExchangeManager (void) const; + + /** + * Accessor for the Txop object + * + * \return a smart pointer to Txop + */ + Ptr GetTxop (void) const; + /** + * Accessor for a specified EDCA object + * + * \param ac the Access Category + * \return a smart pointer to a QosTxop + */ + Ptr GetQosTxop (AcIndex ac) const; + /** + * Accessor for a specified EDCA object + * + * \param tid the Traffic ID + * \return a smart pointer to a QosTxop + */ + Ptr GetQosTxop (uint8_t tid) const; + /** + * Get the wifi MAC queue of the (Qos)Txop associated with the given AC. + * + * \param ac the given Access Category + * \return the wifi MAC queue of the (Qos)Txop associated with the given AC + */ + virtual Ptr GetTxopQueue (AcIndex ac) const; + /** * This method is invoked by a subclass to specify what type of * station it is implementing. This is something that the channel @@ -99,25 +148,18 @@ public: * * \param type the type of station. */ - virtual void SetTypeOfStation (TypeOfStation type) = 0; + void SetTypeOfStation (TypeOfStation type); /** * Return the type of station. * * \return the type of station. */ - virtual TypeOfStation GetTypeOfStation (void) const = 0; + TypeOfStation GetTypeOfStation (void) const; /** * \param ssid the current SSID of this MAC layer. */ - virtual void SetSsid (Ssid ssid) = 0; - /** - * Enable or disable short slot time feature. - * - * \param enable true if short slot time is to be supported, - * false otherwise - */ - virtual void SetShortSlotTimeSupported (bool enable) = 0; + void SetSsid (Ssid ssid); /** * \brief Sets the interface in promiscuous mode. * @@ -125,28 +167,35 @@ public: * filtering on the incoming frame path may affect the overall * behavior. */ - virtual void SetPromisc (void) = 0; + void SetPromisc (void); + /** + * Enable or disable CTS-to-self feature. + * + * \param enable true if CTS-to-self is to be supported, + * false otherwise + */ + void SetCtsToSelfSupported (bool enable); /** * \return the MAC address associated to this MAC layer. */ - virtual Mac48Address GetAddress (void) const = 0; + Mac48Address GetAddress (void) const; /** * \return the SSID which this MAC layer is going to try to stay in. */ - virtual Ssid GetSsid (void) const = 0; + Ssid GetSsid (void) const; /** * \param address the current address of this MAC layer. */ - virtual void SetAddress (Mac48Address address) = 0; + virtual void SetAddress (Mac48Address address); /** * \return the BSSID of the network this device belongs to. */ - virtual Mac48Address GetBssid (void) const = 0; + Mac48Address GetBssid (void) const; /** - * \return whether the device supports short slot time capability. + * \param bssid the BSSID of the network that this device belongs to. */ - virtual bool GetShortSlotTimeSupported (void) const = 0; + void SetBssid (Mac48Address bssid); /** * Return true if packets can be forwarded to the given destination, @@ -167,7 +216,7 @@ public: * this device to operate in a bridged mode, forwarding received * frames without altering the source address. */ - virtual void Enqueue (Ptr packet, Mac48Address to, Mac48Address from) = 0; + virtual void Enqueue (Ptr packet, Mac48Address to, Mac48Address from); /** * \param packet the packet to send. * \param to the address to which the packet should be sent. @@ -184,27 +233,29 @@ public: * This function returns true if sending from arbitrary address is supported, * false otherwise. */ - virtual bool SupportsSendFrom (void) const = 0; + virtual bool SupportsSendFrom (void) const; + /** * \param phy the physical layer attached to this MAC. */ - virtual void SetWifiPhy (Ptr phy) = 0; + virtual void SetWifiPhy (Ptr phy); /** * \return the physical layer attached to this MAC */ - virtual Ptr GetWifiPhy (void) const = 0; + Ptr GetWifiPhy (void) const; /** * Remove currently attached WifiPhy device from this MAC. */ - virtual void ResetWifiPhy (void) = 0; + void ResetWifiPhy (void); + /** * \param stationManager the station manager attached to this MAC. */ - virtual void SetWifiRemoteStationManager (Ptr stationManager) = 0; + void SetWifiRemoteStationManager (Ptr stationManager); /** * \return the station manager attached to this MAC. */ - virtual Ptr GetWifiRemoteStationManager (void) const = 0; + Ptr GetWifiRemoteStationManager (void) const; /** * This type defines the callback of a higher layer that a @@ -220,19 +271,24 @@ public: * \param upCallback the callback to invoke when a packet must be * forwarded up the stack. */ - virtual void SetForwardUpCallback (ForwardUpCallback upCallback) = 0; + void SetForwardUpCallback (ForwardUpCallback upCallback); /** * \param linkUp the callback to invoke when the link becomes up. */ - virtual void SetLinkUpCallback (Callback linkUp) = 0; + virtual void SetLinkUpCallback (Callback linkUp); /** * \param linkDown the callback to invoke when the link becomes down. */ - virtual void SetLinkDownCallback (Callback linkDown) = 0; + void SetLinkDownCallback (Callback linkDown); /* Next functions are not pure virtual so non QoS WifiMacs are not * forced to implement them. */ + /** + * Notify that channel has been switched. + */ + virtual void NotifyChannelSwitching (void); + /** * \param packet the packet being enqueued * @@ -275,7 +331,7 @@ public: * Subclasses should implement this method to configure their DCF queues * according to the requested standard. */ - virtual void ConfigureStandard (WifiStandard standard) = 0; + virtual void ConfigureStandard (WifiStandard standard); /** * \return pointer to HtConfiguration if it exists @@ -290,8 +346,195 @@ public: */ Ptr GetHeConfiguration (void) const; + /** + * Return the extended capabilities of the device. + * + * \return the extended capabilities that we support + */ + ExtendedCapabilities GetExtendedCapabilities (void) const; + /** + * Return the HT capabilities of the device. + * + * \return the HT capabilities that we support + */ + HtCapabilities GetHtCapabilities (void) const; + /** + * Return the VHT capabilities of the device. + * + * \return the VHT capabilities that we support + */ + VhtCapabilities GetVhtCapabilities (void) const; + /** + * Return the HE capabilities of the device. + * + * \return the HE capabilities that we support + */ + HeCapabilities GetHeCapabilities (void) const; + + /** + * Return whether the device supports QoS. + * + * \return true if QoS is supported, false otherwise + */ + bool GetQosSupported () const; + /** + * Return whether the device supports ERP. + * + * \return true if ERP is supported, false otherwise + */ + bool GetErpSupported () const; + /** + * Return whether the device supports DSSS. + * + * \return true if DSSS is supported, false otherwise + */ + bool GetDsssSupported () const; + /** + * Return whether the device supports HT. + * + * \return true if HT is supported, false otherwise + */ + bool GetHtSupported () const; + /** + * Return whether the device supports VHT. + * + * \return true if VHT is supported, false otherwise + */ + bool GetVhtSupported () const; + /** + * Return whether the device supports HE. + * + * \return true if HE is supported, false otherwise + */ + bool GetHeSupported () const; + + /** + * Return the maximum A-MPDU size of the given Access Category. + * + * \param ac Access Category index + * \return the maximum A-MPDU size + */ + uint32_t GetMaxAmpduSize (AcIndex ac) const; + /** + * Return the maximum A-MSDU size of the given Access Category. + * + * \param ac Access Category index + * \return the maximum A-MSDU size + */ + uint16_t GetMaxAmsduSize (AcIndex ac) const; + protected: + void DoInitialize () override; + void DoDispose () override; + + /** + * \param cwMin the minimum contention window size + * \param cwMax the maximum contention window size + * + * This method is called to set the minimum and the maximum + * contention window size. + */ + virtual void ConfigureContentionWindow (uint32_t cwMin, uint32_t cwMax); + + /** + * Enable or disable QoS support for the device. Construct a Txop object + * or QosTxop objects accordingly. This method can only be called before + * initialization. + * + * \param enable whether QoS is supported + */ + void SetQosSupported (bool enable); + + /** + * Enable or disable short slot time feature. + * + * \param enable true if short slot time is to be supported, + * false otherwise + */ + void SetShortSlotTimeSupported (bool enable); + /** + * \return whether the device supports short slot time capability. + */ + bool GetShortSlotTimeSupported (void) const; + + /** + * Accessor for the AC_VO channel access function + * + * \return a smart pointer to QosTxop + */ + Ptr GetVOQueue (void) const; + /** + * Accessor for the AC_VI channel access function + * + * \return a smart pointer to QosTxop + */ + Ptr GetVIQueue (void) const; + /** + * Accessor for the AC_BE channel access function + * + * \return a smart pointer to QosTxop + */ + Ptr GetBEQueue (void) const; + /** + * Accessor for the AC_BK channel access function + * + * \return a smart pointer to QosTxop + */ + Ptr GetBKQueue (void) const; + + /** + * This method acts as the MacRxMiddle receive callback and is + * invoked to notify us that a frame has been received. The + * implementation is intended to capture logic that is going to be + * common to all (or most) derived classes. Specifically, handling + * of Block Ack management frames is dealt with here. + * + * This method will need, however, to be overridden by derived + * classes so that they can perform their data handling before + * invoking the base version. + * + * \param mpdu the MPDU that has been received. + */ + virtual void Receive (Ptr mpdu); + /** + * Forward the packet up to the device. + * + * \param packet the packet that we are forwarding up to the device + * \param from the address of the source + * \param to the address of the destination + */ + void ForwardUp (Ptr packet, Mac48Address from, Mac48Address to); + + /** + * This method can be called to de-aggregate an A-MSDU and forward + * the constituent packets up the stack. + * + * \param mpdu the MPDU containing the A-MSDU. + */ + virtual void DeaggregateAmsduAndForward (Ptr mpdu); + + Ptr m_rxMiddle; //!< RX middle (defragmentation etc.) + Ptr m_txMiddle; //!< TX middle (aggregation etc.) + Ptr m_channelAccessManager; //!< channel access manager + Ptr m_feManager; //!< Frame Exchange Manager + Ptr m_txop; //!< TXOP used for transmission of frames to non-QoS peers. + + Callback m_linkUp; //!< Callback when a link is up + Callback m_linkDown; //!< Callback when a link is down + + +private: + /// type conversion operator + WifiMac (const WifiMac&); + /** + * assignment operator + * + * \param mac the WifiMac to assign + * \returns the assigned value + */ + WifiMac & operator= (const WifiMac& mac); + /** * \param dcf the DCF to be configured * \param cwmin the minimum contention window for the DCF @@ -303,9 +546,147 @@ protected: */ void ConfigureDcf (Ptr dcf, uint32_t cwmin, uint32_t cwmax, bool isDsss, AcIndex ac); + /** + * Configure PHY dependent parameters such as CWmin and CWmax. + */ + void ConfigurePhyDependentParameters (void); -private: - Ptr m_device; ///< Pointer to the device + /** + * This method is a private utility invoked to configure the channel + * access function for the specified Access Category. + * + * \param ac the Access Category of the queue to initialise. + */ + void SetupEdcaQueue (AcIndex ac); + + /** + * Create a Frame Exchange Manager depending on the supported version + * of the standard. + * + * \param standard the supported version of the standard + */ + void SetupFrameExchangeManager (WifiStandard standard); + + /** + * Enable or disable ERP support for the device. + * + * \param enable whether ERP is supported + */ + void SetErpSupported (bool enable); + /** + * Enable or disable DSSS support for the device. + * + * \param enable whether DSSS is supported + */ + void SetDsssSupported (bool enable); + + /** + * Set the block ack threshold for AC_VO. + * + * \param threshold the block ack threshold for AC_VO. + */ + void SetVoBlockAckThreshold (uint8_t threshold); + /** + * Set the block ack threshold for AC_VI. + * + * \param threshold the block ack threshold for AC_VI. + */ + void SetViBlockAckThreshold (uint8_t threshold); + /** + * Set the block ack threshold for AC_BE. + * + * \param threshold the block ack threshold for AC_BE. + */ + void SetBeBlockAckThreshold (uint8_t threshold); + /** + * Set the block ack threshold for AC_BK. + * + * \param threshold the block ack threshold for AC_BK. + */ + void SetBkBlockAckThreshold (uint8_t threshold); + + /** + * Set VO block ack inactivity timeout. + * + * \param timeout the VO block ack inactivity timeout. + */ + void SetVoBlockAckInactivityTimeout (uint16_t timeout); + /** + * Set VI block ack inactivity timeout. + * + * \param timeout the VI block ack inactivity timeout. + */ + void SetViBlockAckInactivityTimeout (uint16_t timeout); + /** + * Set BE block ack inactivity timeout. + * + * \param timeout the BE block ack inactivity timeout. + */ + void SetBeBlockAckInactivityTimeout (uint16_t timeout); + /** + * Set BK block ack inactivity timeout. + * + * \param timeout the BK block ack inactivity timeout. + */ + void SetBkBlockAckInactivityTimeout (uint16_t timeout); + + /** + * This Boolean is set \c true iff this WifiMac is to model + * 802.11e/WMM style Quality of Service. It is exposed through the + * attribute system. + * + * At the moment, this flag is the sole selection between QoS and + * non-QoS operation for the STA (whether IBSS, AP, or + * non-AP). Ultimately, we will want a QoS-enabled STA to be able to + * fall back to non-QoS operation with a non-QoS peer. This'll + * require further intelligence - i.e., per-association QoS + * state. Having a big switch seems like a good intermediate stage, + * 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 + + TypeOfStation m_typeOfStation; //!< the type of station + + Ptr m_device; //!< Pointer to the device + Ptr m_phy; //!< Wifi PHY + Ptr m_stationManager; //!< Remote station manager (rate control, RTS/CTS/fragmentation thresholds etc.) + + Mac48Address m_address; //!< MAC address of this station + Ssid m_ssid; //!< Service Set ID (SSID) + Mac48Address m_bssid; //!< the BSSID + + /** This type defines a mapping between an Access Category index, + and a pointer to the corresponding channel access function */ + typedef std::map > EdcaQueues; + + /** This is a map from Access Category index to the corresponding + channel access function */ + EdcaQueues m_edca; + + uint16_t m_voMaxAmsduSize; ///< maximum A-MSDU size for AC_VO (in bytes) + uint16_t m_viMaxAmsduSize; ///< maximum A-MSDU size for AC_VI (in bytes) + uint16_t m_beMaxAmsduSize; ///< maximum A-MSDU size for AC_BE (in bytes) + uint16_t m_bkMaxAmsduSize; ///< maximum A-MSDU size for AC_BK (in bytes) + + uint32_t m_voMaxAmpduSize; ///< maximum A-MPDU size for AC_VO (in bytes) + uint32_t m_viMaxAmpduSize; ///< maximum A-MPDU size for AC_VI (in bytes) + uint32_t m_beMaxAmpduSize; ///< maximum A-MPDU size for AC_BE (in bytes) + uint32_t m_bkMaxAmpduSize; ///< maximum A-MPDU size for AC_BK (in bytes) + + ForwardUpCallback m_forwardUp; //!< Callback to forward packet up the stack /** * The trace source fired when packets come into the "top" of the device @@ -344,6 +725,50 @@ private: * \see class CallBackTraceSource */ TracedCallback > m_macRxDropTrace; + + TracedCallback m_txOkCallback; ///< transmit OK callback + TracedCallback m_txErrCallback; ///< transmit error callback + + /// TracedCallback for MPDU drop events typedef + typedef TracedCallback> DroppedMpduTracedCallback; + + /** + * This trace indicates that an MPDU was dropped for the given reason. + */ + DroppedMpduTracedCallback m_droppedMpduCallback; + + /// TracedCallback for acked/nacked MPDUs typedef + typedef TracedCallback> MpduTracedCallback; + + MpduTracedCallback m_ackedMpduCallback; ///< ack'ed MPDU callback + MpduTracedCallback m_nackedMpduCallback; ///< nack'ed MPDU callback + + /// TracedCallback for MPDU response timeout events typedef + typedef TracedCallback, const WifiTxVector&> MpduResponseTimeoutTracedCallback; + + /** + * MPDU response timeout traced callback. + * This trace source is fed by a WifiTxTimer object. + */ + MpduResponseTimeoutTracedCallback m_mpduResponseTimeoutCallback; + + /// TracedCallback for PSDU response timeout events typedef + typedef TracedCallback, const WifiTxVector&> PsduResponseTimeoutTracedCallback; + + /** + * PSDU response timeout traced callback. + * This trace source is fed by a WifiTxTimer object. + */ + PsduResponseTimeoutTracedCallback m_psduResponseTimeoutCallback; + + /// TracedCallback for PSDU map response timeout events typedef + typedef TracedCallback*, std::size_t> PsduMapResponseTimeoutTracedCallback; + + /** + * PSDU map response timeout traced callback. + * This trace source is fed by a WifiTxTimer object. + */ + PsduMapResponseTimeoutTracedCallback m_psduMapResponseTimeoutCallback; }; } //namespace ns3 diff --git a/src/wifi/model/wifi-protection-manager.cc b/src/wifi/model/wifi-protection-manager.cc index d1a5aa819..f21563413 100644 --- a/src/wifi/model/wifi-protection-manager.cc +++ b/src/wifi/model/wifi-protection-manager.cc @@ -20,7 +20,7 @@ #include "ns3/log.h" #include "wifi-protection-manager.h" -#include "regular-wifi-mac.h" +#include "wifi-mac.h" namespace ns3 { @@ -53,7 +53,7 @@ WifiProtectionManager::DoDispose (void) } void -WifiProtectionManager::SetWifiMac (Ptr mac) +WifiProtectionManager::SetWifiMac (Ptr mac) { NS_LOG_FUNCTION (this << mac); m_mac = mac; diff --git a/src/wifi/model/wifi-protection-manager.h b/src/wifi/model/wifi-protection-manager.h index b10ae3ddd..7d00e9cb0 100644 --- a/src/wifi/model/wifi-protection-manager.h +++ b/src/wifi/model/wifi-protection-manager.h @@ -30,7 +30,7 @@ namespace ns3 { class WifiTxParameters; class WifiMacQueueItem; -class RegularWifiMac; +class WifiMac; /** * \ingroup wifi @@ -53,7 +53,7 @@ public: * * \param mac a pointer to the MAC */ - void SetWifiMac (Ptr mac); + void SetWifiMac (Ptr mac); /** * Determine the protection method to use if the given MPDU is added to the current @@ -84,7 +84,7 @@ public: protected: virtual void DoDispose (void); - Ptr m_mac; //!< MAC which is using this Protection Manager + Ptr m_mac; //!< MAC which is using this Protection Manager }; diff --git a/src/wifi/test/block-ack-test-suite.cc b/src/wifi/test/block-ack-test-suite.cc index 9d6ac5d5e..a75cdc685 100644 --- a/src/wifi/test/block-ack-test-suite.cc +++ b/src/wifi/test/block-ack-test-suite.cc @@ -19,6 +19,8 @@ */ #include "ns3/test.h" +#include "ns3/double.h" +#include "ns3/boolean.h" #include "ns3/string.h" #include "ns3/qos-utils.h" #include "ns3/ctrl-headers.h" @@ -35,6 +37,9 @@ #include "ns3/pointer.h" #include "ns3/recipient-block-ack-agreement.h" #include "ns3/mac-rx-middle.h" +#include "ns3/qos-txop.h" +#include "ns3/originator-block-ack-agreement.h" +#include "ns3/wifi-mac-queue-item.h" #include using namespace ns3; @@ -1546,9 +1551,7 @@ BlockAckAggregationDisabledTest::DoRun (void) ptr.Get ()->TraceConnectWithoutContext ("TxopTrace", MakeCallback (&TxopDurationTracer::Trace, &txopTracer)); // set the TXOP limit on BE AC - Ptr ap_mac = DynamicCast (ap_device->GetMac ()); - NS_ASSERT (ap_mac); - ap_mac->GetAttribute ("BE_Txop", ptr); + ap_device->GetMac ()->GetAttribute ("BE_Txop", ptr); ptr.Get ()->SetTxopLimit (MicroSeconds (4800)); } diff --git a/src/wifi/test/wifi-channel-switching-test.cc b/src/wifi/test/wifi-channel-switching-test.cc index 73e744dfd..f3c2cd7b4 100644 --- a/src/wifi/test/wifi-channel-switching-test.cc +++ b/src/wifi/test/wifi-channel-switching-test.cc @@ -20,6 +20,7 @@ #include "ns3/test.h" #include "ns3/string.h" +#include "ns3/boolean.h" #include "ns3/qos-utils.h" #include "ns3/wifi-psdu.h" #include "ns3/wifi-net-device.h" diff --git a/src/wifi/test/wifi-mac-ofdma-test.cc b/src/wifi/test/wifi-mac-ofdma-test.cc index 2b29de85d..7b87afcb4 100644 --- a/src/wifi/test/wifi-mac-ofdma-test.cc +++ b/src/wifi/test/wifi-mac-ofdma-test.cc @@ -476,7 +476,7 @@ OfdmaAckSequenceTest::Transmit (std::string context, WifiConstPsduMap psduMap, W if (txVector.GetPreambleType () == WIFI_PREAMBLE_HE_MU) { auto dev = DynamicCast (m_apDevice); - Ptr queue = DynamicCast (dev->GetMac ())->GetQosTxop (AC_BE)->GetWifiMacQueue (); + Ptr queue = dev->GetMac ()->GetQosTxop (AC_BE)->GetWifiMacQueue (); m_flushed = 0; for (auto it = queue->begin (); it != queue->end (); ) { @@ -499,7 +499,7 @@ OfdmaAckSequenceTest::Transmit (std::string context, WifiConstPsduMap psduMap, W if (dev->GetAddress () == sender) { - Ptr qosTxop = DynamicCast (dev->GetMac ())->GetQosTxop (AC_BE); + Ptr qosTxop = dev->GetMac ()->GetQosTxop (AC_BE); if (m_muEdcaParameterSet.muTimer > 0 && m_muEdcaParameterSet.muAifsn > 0) { diff --git a/src/wifi/test/wifi-phy-ofdma-test.cc b/src/wifi/test/wifi-phy-ofdma-test.cc index 16f3ce728..98b5a7cc9 100644 --- a/src/wifi/test/wifi-phy-ofdma-test.cc +++ b/src/wifi/test/wifi-phy-ofdma-test.cc @@ -23,6 +23,8 @@ #include "ns3/node.h" #include "ns3/pointer.h" #include "ns3/string.h" +#include "ns3/double.h" +#include "ns3/boolean.h" #include "ns3/simulator.h" #include "ns3/rng-seed-manager.h" #include "ns3/constant-position-mobility-model.h" diff --git a/src/wifi/test/wifi-phy-reception-test.cc b/src/wifi/test/wifi-phy-reception-test.cc index e8938fcfe..cefa147f2 100644 --- a/src/wifi/test/wifi-phy-reception-test.cc +++ b/src/wifi/test/wifi-phy-reception-test.cc @@ -29,6 +29,7 @@ #include "ns3/packet-socket-server.h" #include "ns3/test.h" #include "ns3/double.h" +#include "ns3/boolean.h" #include "ns3/pointer.h" #include "ns3/rng-seed-manager.h" #include "ns3/spectrum-wifi-helper.h" diff --git a/src/wifi/test/wifi-primary-channels-test.cc b/src/wifi/test/wifi-primary-channels-test.cc index 08bd4606c..986a2e25d 100644 --- a/src/wifi/test/wifi-primary-channels-test.cc +++ b/src/wifi/test/wifi-primary-channels-test.cc @@ -18,6 +18,8 @@ * Author: Stefano Avallone */ +#include "ns3/boolean.h" +#include "ns3/enum.h" #include "ns3/test.h" #include "ns3/wifi-net-device.h" #include "ns3/mobility-helper.h" diff --git a/src/wifi/test/wifi-test.cc b/src/wifi/test/wifi-test.cc index 17e8d01b8..9f9d21629 100644 --- a/src/wifi/test/wifi-test.cc +++ b/src/wifi/test/wifi-test.cc @@ -61,34 +61,30 @@ static void AssignWifiRandomStreams (Ptr mac, int64_t stream) { int64_t currentStream = stream; - Ptr rmac = DynamicCast (mac); - if (rmac) + PointerValue ptr; + if (!mac->GetQosSupported ()) { - PointerValue ptr; - if (!rmac->GetQosSupported ()) - { - rmac->GetAttribute ("Txop", ptr); - Ptr txop = ptr.Get (); - currentStream += txop->AssignStreams (currentStream); - } - else - { - rmac->GetAttribute ("VO_Txop", ptr); - Ptr vo_txop = ptr.Get (); - currentStream += vo_txop->AssignStreams (currentStream); + mac->GetAttribute ("Txop", ptr); + Ptr txop = ptr.Get (); + currentStream += txop->AssignStreams (currentStream); + } + else + { + mac->GetAttribute ("VO_Txop", ptr); + Ptr vo_txop = ptr.Get (); + currentStream += vo_txop->AssignStreams (currentStream); - rmac->GetAttribute ("VI_Txop", ptr); - Ptr vi_txop = ptr.Get (); - currentStream += vi_txop->AssignStreams (currentStream); + mac->GetAttribute ("VI_Txop", ptr); + Ptr vi_txop = ptr.Get (); + currentStream += vi_txop->AssignStreams (currentStream); - rmac->GetAttribute ("BE_Txop", ptr); - Ptr be_txop = ptr.Get (); - currentStream += be_txop->AssignStreams (currentStream); + mac->GetAttribute ("BE_Txop", ptr); + Ptr be_txop = ptr.Get (); + currentStream += be_txop->AssignStreams (currentStream); - rmac->GetAttribute ("BK_Txop", ptr); - Ptr bk_txop = ptr.Get (); - bk_txop->AssignStreams (currentStream); - } + mac->GetAttribute ("BK_Txop", ptr); + Ptr bk_txop = ptr.Get (); + bk_txop->AssignStreams (currentStream); } } @@ -144,7 +140,7 @@ WifiTest::CreateOne (Vector pos, Ptr channel) Ptr node = CreateObject (); Ptr dev = CreateObject (); - Ptr mac = m_mac.Create (); + Ptr mac = m_mac.Create (); mac->SetDevice (dev); mac->SetAddress (Mac48Address::Allocate ()); mac->ConfigureStandard (WIFI_STANDARD_80211a); @@ -320,7 +316,7 @@ InterferenceHelperSequenceTest::CreateOne (Vector pos, Ptr chan Ptr node = CreateObject (); Ptr dev = CreateObject (); - Ptr mac = m_mac.Create (); + Ptr mac = m_mac.Create (); mac->SetDevice (dev); mac->SetAddress (Mac48Address::Allocate ()); mac->ConfigureStandard (WIFI_STANDARD_80211a); @@ -522,7 +518,7 @@ DcfImmediateAccessBroadcastTestCase::DoRun (void) Ptr txNode = CreateObject (); Ptr txDev = CreateObject (); - Ptr txMac = m_mac.Create (); + Ptr txMac = m_mac.Create (); txMac->SetDevice (txDev); txMac->ConfigureStandard (WIFI_STANDARD_80211a); Ptr fem = txMac->GetFrameExchangeManager (); @@ -846,10 +842,8 @@ QosFragmentationTestCase::DoRun (void) Ptr sta_device = DynamicCast (staDevices.Get (0)); // set the TXOP limit on BE AC - Ptr sta_mac = DynamicCast (sta_device->GetMac ()); - NS_ASSERT (sta_mac); PointerValue ptr; - sta_mac->GetAttribute ("BE_Txop", ptr); + sta_device->GetMac ()->GetAttribute ("BE_Txop", ptr); ptr.Get ()->SetTxopLimit (MicroSeconds (3008)); PacketSocketAddress socket; @@ -1738,7 +1732,7 @@ Bug2831TestCase::DoRun (void) mac.SetTypeId ("ns3::ApWifiMac"); mac.Set ("EnableBeaconJitter", BooleanValue (false)); mac.Set ("QosSupported", BooleanValue (true)); - Ptr apMac = mac.Create (); + Ptr apMac = mac.Create (); apMac->SetDevice (apDev); apMac->SetAddress (Mac48Address::Allocate ()); apMac->ConfigureStandard (WIFI_STANDARD_80211ax); @@ -1756,7 +1750,7 @@ Bug2831TestCase::DoRun (void) Ptr staHtConfiguration = CreateObject (); staDev->SetHtConfiguration (staHtConfiguration); mac.SetTypeId ("ns3::StaWifiMac"); - Ptr staMac = mac.Create (); + Ptr staMac = mac.Create (); staMac->SetDevice (staDev); staMac->SetAddress (Mac48Address::Allocate ()); staMac->ConfigureStandard (WIFI_STANDARD_80211ax); @@ -2217,7 +2211,7 @@ Bug2470TestCase::RunSubtest (PointerValue apErrorModel, PointerValue staErrorMod Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/MonitorSnifferRx", MakeCallback (&Bug2470TestCase::RxCallback, this)); Config::Connect ("/NodeList/*/DeviceList/*/Phy/State/RxError", MakeCallback (&Bug2470TestCase::RxErrorCallback, this)); - Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/$ns3::RegularWifiMac/BE_Txop/BlockAckManager/AgreementState", MakeCallback (&Bug2470TestCase::AddbaStateChangedCallback, this)); + Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/$ns3::WifiMac/BE_Txop/BlockAckManager/AgreementState", MakeCallback (&Bug2470TestCase::AddbaStateChangedCallback, this)); Simulator::Schedule (Seconds (0.5), &Bug2470TestCase::SendPacketBurst, this, 1, apDevice.Get (0), staDevice.Get (0)->GetAddress ()); Simulator::Schedule (Seconds (0.5) + MicroSeconds (5), &Bug2470TestCase::SendPacketBurst, this, 4, apDevice.Get (0), staDevice.Get (0)->GetAddress ()); @@ -2448,10 +2442,8 @@ Issue40TestCase::RunOne (bool useAmpdu) { // Disable use of BAR that are sent with the lowest modulation so that we can also reproduce the problem with A-MPDU, i.e. the lack of feedback about SNR change Ptr ap_device = DynamicCast (apDevice.Get (0)); - Ptr ap_mac = DynamicCast (ap_device->GetMac ()); - NS_ASSERT (ap_mac); PointerValue ptr; - ap_mac->GetAttribute ("BE_Txop", ptr); + ap_device->GetMac ()->GetAttribute ("BE_Txop", ptr); ptr.Get ()->SetAttribute ("UseExplicitBarAfterMissedBlockAck", BooleanValue (false)); } diff --git a/src/wifi/test/wifi-txop-test.cc b/src/wifi/test/wifi-txop-test.cc index 6f5826745..deab0d1b5 100644 --- a/src/wifi/test/wifi-txop-test.cc +++ b/src/wifi/test/wifi-txop-test.cc @@ -20,6 +20,7 @@ #include "ns3/test.h" #include "ns3/string.h" +#include "ns3/boolean.h" #include "ns3/qos-utils.h" #include "ns3/packet.h" #include "ns3/wifi-net-device.h" @@ -36,6 +37,7 @@ #include "ns3/wifi-psdu.h" #include "ns3/wifi-ppdu.h" #include "ns3/ap-wifi-mac.h" +#include "ns3/qos-txop.h" using namespace ns3; diff --git a/src/wifi/wscript b/src/wifi/wscript index be876b389..bb182da11 100644 --- a/src/wifi/wscript +++ b/src/wifi/wscript @@ -50,7 +50,6 @@ def build(bld): 'model/mgt-headers.cc', 'model/channel-access-manager.cc', 'model/wifi-mac.cc', - 'model/regular-wifi-mac.cc', 'model/wifi-remote-station-info.cc', 'model/wifi-remote-station-manager.cc', 'model/ap-wifi-mac.cc', @@ -203,7 +202,6 @@ def build(bld): 'model/rate-control/minstrel-ht-wifi-manager.h', 'model/rate-control/thompson-sampling-wifi-manager.h', 'model/wifi-mac.h', - 'model/regular-wifi-mac.h', 'model/supported-rates.h', 'model/error-rate-model.h', 'model/yans-error-rate-model.h',