wifi: Configure interfaces of all spectrum PHYs when the channel of one instance has changed
This commit is contained in:
@@ -60,7 +60,7 @@ cpp_examples = [
|
||||
("wifi-eht-network --simulationTime=0.1 --frequency=5 --useRts=1 --minExpectedThroughput=6 --maxExpectedThroughput=547", "True", "True"),
|
||||
("wifi-eht-network --simulationTime=0.1 --frequency=2.4 --useRts=0 --useExtendedBlockAck=1 --frequency2=5 --minExpectedThroughput=12 --maxExpectedThroughput=500", "True", "True"),
|
||||
("wifi-eht-network --simulationTime=0.1 --frequency=2.4 --useRts=1 --minExpectedThroughput=6 --maxExpectedThroughput=212", "True", "True"),
|
||||
("wifi-eht-network --simulationTime=0.22 --udp=0 --downlink=1 --useRts=0 --nStations=4 --dlAckType=ACK-SU-FORMAT --enableUlOfdma=1 --enableBsrp=0 --mcs=4 --frequency2=6 --minExpectedThroughput=35 --maxExpectedThroughput=280", "True", "True"),
|
||||
("wifi-eht-network --simulationTime=0.23 --udp=0 --downlink=1 --useRts=0 --nStations=4 --dlAckType=ACK-SU-FORMAT --enableUlOfdma=1 --enableBsrp=0 --mcs=4 --frequency2=6 --minExpectedThroughput=35 --maxExpectedThroughput=280", "True", "True"),
|
||||
("wifi-eht-network --simulationTime=0.25 --frequency=2.4 --udp=0 --downlink=1 --useRts=0 --nStations=5 --dlAckType=MU-BAR --enableUlOfdma=1 --enableBsrp=1 --mcs=5 --frequency2=5 --useExtendedBlockAck=1 --minExpectedThroughput=40 --maxExpectedThroughput=100", "True", "True"),
|
||||
("wifi-eht-network --simulationTime=0.3 --udp=0 --downlink=1 --useRts=1 --nStations=5 --dlAckType=AGGR-MU-BAR --enableUlOfdma=1 --enableBsrp=0 --mcs=6 --muSchedAccessReqInterval=50ms --frequency2=2.4 --minExpectedThroughput=50 --maxExpectedThroughput=140", "True", "True"),
|
||||
("wifi-eht-network --simulationTime=0.2 --udp=1 --downlink=0 --useRts=0 --nStations=5 --dlAckType=AGGR-MU-BAR --enableUlOfdma=1 --enableBsrp=1 --mcs=5 --muSchedAccessReqInterval=50ms --frequency2=6 --minExpectedThroughput=70 --maxExpectedThroughput=715", "True", "True"),
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user