examples (fixes #1098): Fix wrong configuration of spectrumPhy in wifi-spectrum-per-example.cc
This commit is contained in:
committed by
Tom Henderson
parent
825994ba1c
commit
f980106520
@@ -181,7 +181,7 @@ main(int argc, char* argv[])
|
|||||||
NodeContainer wifiApNode;
|
NodeContainer wifiApNode;
|
||||||
wifiApNode.Create(1);
|
wifiApNode.Create(1);
|
||||||
|
|
||||||
YansWifiPhyHelper phy;
|
YansWifiPhyHelper yansPhy;
|
||||||
SpectrumWifiPhyHelper spectrumPhy;
|
SpectrumWifiPhyHelper spectrumPhy;
|
||||||
if (wifiType == "ns3::YansWifiPhy")
|
if (wifiType == "ns3::YansWifiPhy")
|
||||||
{
|
{
|
||||||
@@ -190,9 +190,9 @@ main(int argc, char* argv[])
|
|||||||
"Frequency",
|
"Frequency",
|
||||||
DoubleValue(5.180e9));
|
DoubleValue(5.180e9));
|
||||||
channel.SetPropagationDelay("ns3::ConstantSpeedPropagationDelayModel");
|
channel.SetPropagationDelay("ns3::ConstantSpeedPropagationDelayModel");
|
||||||
phy.SetChannel(channel.Create());
|
yansPhy.SetChannel(channel.Create());
|
||||||
phy.Set("TxPowerStart", DoubleValue(1)); // dBm (1.26 mW)
|
yansPhy.Set("TxPowerStart", DoubleValue(1)); // dBm (1.26 mW)
|
||||||
phy.Set("TxPowerEnd", DoubleValue(1));
|
yansPhy.Set("TxPowerEnd", DoubleValue(1));
|
||||||
}
|
}
|
||||||
else if (wifiType == "ns3::SpectrumWifiPhy")
|
else if (wifiType == "ns3::SpectrumWifiPhy")
|
||||||
{
|
{
|
||||||
@@ -397,17 +397,19 @@ main(int argc, char* argv[])
|
|||||||
if (wifiType == "ns3::YansWifiPhy")
|
if (wifiType == "ns3::YansWifiPhy")
|
||||||
{
|
{
|
||||||
mac.SetType("ns3::StaWifiMac", "Ssid", SsidValue(ssid));
|
mac.SetType("ns3::StaWifiMac", "Ssid", SsidValue(ssid));
|
||||||
phy.Set("ChannelSettings",
|
yansPhy.Set(
|
||||||
StringValue(std::string("{0, ") + (i <= 15 ? "20" : "40") + ", BAND_5GHZ, 0}"));
|
"ChannelSettings",
|
||||||
staDevice = wifi.Install(phy, mac, wifiStaNode);
|
StringValue(std::string("{0, ") + (i <= 15 ? "20" : "40") + ", BAND_5GHZ, 0}"));
|
||||||
|
staDevice = wifi.Install(yansPhy, mac, wifiStaNode);
|
||||||
mac.SetType("ns3::ApWifiMac", "Ssid", SsidValue(ssid));
|
mac.SetType("ns3::ApWifiMac", "Ssid", SsidValue(ssid));
|
||||||
apDevice = wifi.Install(phy, mac, wifiApNode);
|
apDevice = wifi.Install(yansPhy, mac, wifiApNode);
|
||||||
}
|
}
|
||||||
else if (wifiType == "ns3::SpectrumWifiPhy")
|
else if (wifiType == "ns3::SpectrumWifiPhy")
|
||||||
{
|
{
|
||||||
mac.SetType("ns3::StaWifiMac", "Ssid", SsidValue(ssid));
|
mac.SetType("ns3::StaWifiMac", "Ssid", SsidValue(ssid));
|
||||||
phy.Set("ChannelSettings",
|
spectrumPhy.Set(
|
||||||
StringValue(std::string("{0, ") + (i <= 15 ? "20" : "40") + ", BAND_5GHZ, 0}"));
|
"ChannelSettings",
|
||||||
|
StringValue(std::string("{0, ") + (i <= 15 ? "20" : "40") + ", BAND_5GHZ, 0}"));
|
||||||
staDevice = wifi.Install(spectrumPhy, mac, wifiStaNode);
|
staDevice = wifi.Install(spectrumPhy, mac, wifiStaNode);
|
||||||
mac.SetType("ns3::ApWifiMac", "Ssid", SsidValue(ssid));
|
mac.SetType("ns3::ApWifiMac", "Ssid", SsidValue(ssid));
|
||||||
apDevice = wifi.Install(spectrumPhy, mac, wifiApNode);
|
apDevice = wifi.Install(spectrumPhy, mac, wifiApNode);
|
||||||
@@ -491,11 +493,15 @@ main(int argc, char* argv[])
|
|||||||
|
|
||||||
if (enablePcap)
|
if (enablePcap)
|
||||||
{
|
{
|
||||||
|
auto& phy = wifiType == "ns3::YansWifiPhy" ? dynamic_cast<WifiPhyHelper&>(yansPhy)
|
||||||
|
: dynamic_cast<WifiPhyHelper&>(spectrumPhy);
|
||||||
|
|
||||||
phy.SetPcapDataLinkType(WifiPhyHelper::DLT_IEEE802_11_RADIO);
|
phy.SetPcapDataLinkType(WifiPhyHelper::DLT_IEEE802_11_RADIO);
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << "wifi-spectrum-per-example-" << i;
|
ss << "wifi-spectrum-per-example-" << i;
|
||||||
phy.EnablePcap(ss.str(), apDevice);
|
phy.EnablePcap(ss.str(), apDevice);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_signalDbmAvg = 0;
|
g_signalDbmAvg = 0;
|
||||||
g_noiseDbmAvg = 0;
|
g_noiseDbmAvg = 0;
|
||||||
g_samples = 0;
|
g_samples = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user