Hey everybody,
I am a little bit confused and would appreciate some help. I am currently using ns.3.27.
My goal is to change the Wifi channel (and the width!) of two wifiphy during runtime. The expected outcome is that with a 40 MHz channel (compared to 20 MHz channel) the phy-rate should increase.
Therefore I schedule a function like this in the middle of my simulation.
Simulator::Schedule(Seconds(simulationTime-5), &ChangeFrequencyLocal, devices, 38);
In particular, I use channel 38 here, to change to a channel/width pair using 40 MHz. (btw. setting frequency and width directly leads to the same results)
The function looks like this:
void ChangeFrequencyLocal (NetDeviceContainer deviceslink, uint8_t channel){
for (uint32_t i = 0; i < deviceslink.GetN (); i++)
{
Ptr<WifiNetDevice> wifidevice = DynamicCast<WifiNetDevice> (deviceslink.Get(i));
Ptr<WifiPhy> phy0 = wifidevice->GetPhy();
phy0->SetChannelNumber (channel);
//phy0->SetFrequency (5190); Makes no difference
//phy0->SetChannelWidth (40); Makes no difference
std::cout << "Changed channel on " << deviceslink.Get (i)->GetAddress () << " to: "
<< channel << std::endl;
}
The log output looks good:
+5.000000000s -1 WifiPhy:DoChannelSwitch(): switching channel 36 -> 38
+5.000000000s -1 WifiPhy:SetChannelNumber(): Setting frequency to 5190; width to 40
Changed channel on 06-06-00:00:00:00:00:02 to: &
+5.000000000s -1 WifiPhy:DoChannelSwitch(): switching channel 36 -> 38
+5.000000000s -1 WifiPhy:SetChannelNumber(): Setting frequency to 5190; width to 40
Changed channel on 06-06-00:00:00:00:00:01 to: &
So the WiFiPhy conducted a channel switch!?
But:
- The .pcap log files show that just the channel switched. The width stays the same at 20 MHz. Therefore, the phy-rate does not change. Perhaps just some .pcap issue?
- In a larger project, I am unable to obtain any throughput gain when I change the frequency to a 40 MHz channel during runtime. However, there is a significant throughput gain when I set the interface to 40 MHz before! the simulation starts (not my goal).
- The same results occur for YansWifiPhy and SpectrumWiFiPhy.
Summary: It looks like the DoChannelSwitch function does change the channel but not the width?
I attached a minimal example to show this issue.
I am happy about any comments on this before I dig deep into debugging this issue.
With kind regards,
Michael