diff --git a/src/wifi/helper/wifi-helper.cc b/src/wifi/helper/wifi-helper.cc index a4388c421..f8b3b18e9 100644 --- a/src/wifi/helper/wifi-helper.cc +++ b/src/wifi/helper/wifi-helper.cc @@ -726,8 +726,8 @@ WifiHelper::Install (const WifiPhyHelper &phyHelper, } Ptr manager = m_stationManager.Create (); Ptr phy = phyHelper.Create (node, device); - phy->ConfigureStandard (m_standard); device->SetPhy (phy); + phy->ConfigureStandard (m_standard); Ptr mac = macHelper.Create (device, m_standard); device->SetMac (mac); device->SetRemoteStationManager (manager); diff --git a/src/wifi/model/wifi-phy.cc b/src/wifi/model/wifi-phy.cc index 4f486ab40..b42695f8a 100644 --- a/src/wifi/model/wifi-phy.cc +++ b/src/wifi/model/wifi-phy.cc @@ -20,6 +20,8 @@ */ #include +#include "ns3/ht-configuration.h" +#include "ns3/vht-configuration.h" #include "ns3/simulator.h" #include "ns3/log.h" #include "ns3/pointer.h" @@ -1055,8 +1057,28 @@ WifiPhy::DoChannelSwitch (void) m_band = static_cast (std::get<2> (m_channelSettings)); + // check that the channel width is supported + uint16_t chWidth = std::get<1> (m_channelSettings); + + if (m_device != nullptr) + { + if (auto htConfig = m_device->GetHtConfiguration (); + htConfig != nullptr && !htConfig->Get40MHzOperationSupported () && chWidth > 20) + { + NS_ABORT_MSG ("Attempting to set a " << chWidth << " MHz channel on" + "a station only supporting 20 MHz operation"); + } + + if (auto vhtConfig = m_device->GetVhtConfiguration (); + vhtConfig != nullptr && !vhtConfig->Get160MHzOperationSupported () && chWidth > 80) + { + NS_ABORT_MSG ("Attempting to set a " << chWidth << " MHz channel on" + "a station supporting up to 80 MHz operation"); + } + } + NS_LOG_DEBUG ("switching channel"); - m_operatingChannel.Set (std::get<0> (m_channelSettings), 0, std::get<1> (m_channelSettings), + m_operatingChannel.Set (std::get<0> (m_channelSettings), 0, chWidth, m_standard, m_band); m_operatingChannel.SetPrimary20Index (std::get<3> (m_channelSettings)); diff --git a/src/wifi/test/wifi-test.cc b/src/wifi/test/wifi-test.cc index b6e6806e7..2687cf8de 100644 --- a/src/wifi/test/wifi-test.cc +++ b/src/wifi/test/wifi-test.cc @@ -1780,6 +1780,7 @@ Bug2831TestCase::DoRun (void) m_apPhy->SetChannel (channel); m_apPhy->SetMobility (apMobility); m_apPhy->SetDevice (apDev); + apDev->SetPhy (m_apPhy); m_apPhy->ConfigureStandard (WIFI_STANDARD_80211ax); m_apPhy->SetOperatingChannel (WifiPhy::ChannelTuple {36, 20, (int)(WIFI_PHY_BAND_5GHZ), 0}); @@ -1795,18 +1796,17 @@ Bug2831TestCase::DoRun (void) m_staPhy->SetChannel (channel); m_staPhy->SetMobility (staMobility); m_staPhy->SetDevice (apDev); + staDev->SetPhy (m_staPhy); m_staPhy->ConfigureStandard (WIFI_STANDARD_80211ax); m_staPhy->SetOperatingChannel (WifiPhy::ChannelTuple {36, 20, (int)(WIFI_PHY_BAND_5GHZ), 0}); apDev->SetMac (apMac); - apDev->SetPhy (m_apPhy); ObjectFactory manager; manager.SetTypeId ("ns3::ConstantRateWifiManager"); apDev->SetRemoteStationManager (manager.Create ()); apNode->AddDevice (apDev); staDev->SetMac (staMac); - staDev->SetPhy (m_staPhy); staDev->SetRemoteStationManager (manager.Create ()); staNode->AddDevice (staDev); @@ -2444,7 +2444,7 @@ Issue40TestCase::RunOne (bool useAmpdu) Config::Connect ("/NodeList/*/DeviceList/*/RemoteStationManager/MacTxFinalDataFailed", MakeCallback (&Issue40TestCase::TxFinalDataFailedCallback, this)); Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/$ns3::WifiMac/MacRx", MakeCallback (&Issue40TestCase::RxSuccessCallback, this)); - + Ptr staWaypointMobility = DynamicCast(wifiStaNode.Get(0)->GetObject()); staWaypointMobility->AddWaypoint (Waypoint (Seconds(1.0), Vector (10.0, 0.0, 0.0))); staWaypointMobility->AddWaypoint (Waypoint (Seconds(1.5), Vector (50.0, 0.0, 0.0)));