wifi: Configure interfaces of all spectrum PHYs when the channel of one instance has changed

This commit is contained in:
Sébastien Deronne
2023-09-13 12:43:47 +02:00
parent 063e7adce5
commit b1b21c4883
3 changed files with 37 additions and 1 deletions

View File

@@ -147,6 +147,8 @@ SpectrumWifiPhyHelper::Create(Ptr<Node> node, Ptr<WifiNetDevice> device) const
phy->SetPreambleDetectionModel(preambleDetection);
}
InstallPhyInterfaces(i, phy);
phy->SetChannelSwitchedCallback(
MakeCallback(&SpectrumWifiPhyHelper::SpectrumChannelSwitched, this).Bind(phy));
phy->SetDevice(device);
phy->SetMobility(node->GetObject<MobilityModel>());
ret.emplace_back(phy);
@@ -175,4 +177,32 @@ SpectrumWifiPhyHelper::InstallPhyInterfaces(uint8_t linkId, Ptr<SpectrumWifiPhy>
}
}
void
SpectrumWifiPhyHelper::SpectrumChannelSwitched(Ptr<SpectrumWifiPhy> phy) const
{
NS_LOG_FUNCTION(this << phy);
for (const auto& otherPhy : phy->GetDevice()->GetPhys())
{
auto spectrumPhy = DynamicCast<SpectrumWifiPhy>(otherPhy);
NS_ASSERT(spectrumPhy);
if (spectrumPhy == phy)
{
// this is the PHY that has switched
continue;
}
if (spectrumPhy->GetCurrentFrequencyRange() == phy->GetCurrentFrequencyRange())
{
// this is the active interface
continue;
}
if (const auto& interfaces = spectrumPhy->GetSpectrumPhyInterfaces();
interfaces.count(phy->GetCurrentFrequencyRange()) == 0)
{
// no interface attached to that channel
continue;
}
spectrumPhy->ConfigureInterface(phy->GetFrequency(), phy->GetChannelWidth());
}
}
} // namespace ns3

View File

@@ -119,6 +119,12 @@ class SpectrumWifiPhyHelper : public WifiPhyHelper
*/
void InstallPhyInterfaces(uint8_t linkId, Ptr<SpectrumWifiPhy> phy) const;
/**
* Function that is notified when a spectrum channel switched
* \param phy spectrum PHY instance that has switched its channel
*/
void SpectrumChannelSwitched(Ptr<SpectrumWifiPhy> phy) const;
/**
* \param channel The channel to inspect to possibly add a WifiBandwidthFilter
*