wifi: Check that the width of the operating channel is supported

This commit is contained in:
Stefano Avallone
2022-05-05 19:35:58 +02:00
parent cad3108316
commit 42f667afdb
3 changed files with 27 additions and 5 deletions

View File

@@ -726,8 +726,8 @@ WifiHelper::Install (const WifiPhyHelper &phyHelper,
}
Ptr<WifiRemoteStationManager> manager = m_stationManager.Create<WifiRemoteStationManager> ();
Ptr<WifiPhy> phy = phyHelper.Create (node, device);
phy->ConfigureStandard (m_standard);
device->SetPhy (phy);
phy->ConfigureStandard (m_standard);
Ptr<WifiMac> mac = macHelper.Create (device, m_standard);
device->SetMac (mac);
device->SetRemoteStationManager (manager);

View File

@@ -20,6 +20,8 @@
*/
#include <algorithm>
#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<WifiPhyBand> (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));

View File

@@ -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<WifiRemoteStationManager> ());
apNode->AddDevice (apDev);
staDev->SetMac (staMac);
staDev->SetPhy (m_staPhy);
staDev->SetRemoteStationManager (manager.Create<WifiRemoteStationManager> ());
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<WaypointMobilityModel> staWaypointMobility = DynamicCast<WaypointMobilityModel>(wifiStaNode.Get(0)->GetObject<MobilityModel>());
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)));