14#include "ns3/boolean.h" 
   15#include "ns3/command-line.h" 
   16#include "ns3/config-store.h" 
   17#include "ns3/config.h" 
   20#include "ns3/string.h" 
   21#include "ns3/uinteger.h" 
   22#include "ns3/wifi-net-device.h" 
   23#include "ns3/yans-wifi-helper.h" 
   24#include "ns3/yans-wifi-phy.h" 
   60main(
int argc, 
char* argv[])
 
   63    bool printAttributes = 
false;
 
   64    bool exceptionThrown = 
false;
 
   67    cmd.AddValue(
"testCase", 
"Test case", testCase);
 
   68    cmd.AddValue(
"printAttributes", 
"If true, print out attributes", printAttributes);
 
   69    cmd.Parse(argc, argv);
 
   80    wifi.SetRemoteStationManager(
"ns3::IdealWifiManager");
 
   84    ssid = 
Ssid(
"wifi-phy-configuration");
 
   86    macSta.
SetType(
"ns3::StaWifiMac",
 
  103                       StringValue(
"output-attributes-" + std::to_string(testCase) + 
".txt"));
 
  113        NS_ASSERT(!phySta->GetOperatingChannel().IsSet());
 
  122        staDevice = 
wifi.Install(phy, macSta, wifiStaNode.
Get(0));
 
  126        NS_ASSERT(phySta->GetChannelNumber() == 36);
 
  133        staDevice = 
wifi.Install(phy, macSta, wifiStaNode.
Get(0));
 
  137        NS_ASSERT(phySta->GetChannelNumber() == 1);
 
  144        staDevice = 
wifi.Install(phy, macSta, wifiStaNode.
Get(0));
 
  148        NS_ASSERT(phySta->GetChannelNumber() == 1);
 
  156        staDevice = 
wifi.Install(phy, macSta, wifiStaNode.
Get(0));
 
  160        NS_ASSERT(phySta->GetChannelNumber() == 36);
 
  167        staDevice = 
wifi.Install(phy, macSta, wifiStaNode.
Get(0));
 
  171        NS_ASSERT(phySta->GetChannelNumber() == 1);
 
  178        staDevice = 
wifi.Install(phy, macSta, wifiStaNode.
Get(0));
 
  182        NS_ASSERT(phySta->GetChannelNumber() == 42);
 
  190        phy.Set(
"ChannelSettings", 
StringValue(
"{0, 0, BAND_2_4GHZ, 0}"));
 
  191        staDevice = 
wifi.Install(phy, macSta, wifiStaNode.
Get(0));
 
  195        NS_ASSERT(phySta->GetChannelNumber() == 1);
 
  202        staDevice = 
wifi.Install(phy, macSta, wifiStaNode.
Get(0));
 
  206        NS_ASSERT(phySta->GetChannelNumber() == 42);
 
  214        staDevice = 
wifi.Install(phy, macSta, wifiStaNode.
Get(0));
 
  218        NS_ASSERT(phySta->GetChannelNumber() == 7);
 
  226        staDevice = 
wifi.Install(phy, macSta, wifiStaNode.
Get(0));
 
  230        NS_ASSERT(phySta->GetChannelNumber() == 172);
 
  238        staDevice = 
wifi.Install(phy, macSta, wifiStaNode.
Get(0));
 
  242        NS_ASSERT(phySta->GetChannelNumber() == 171);
 
  249        phy.Set(
"ChannelSettings", 
StringValue(
"{44, 20, BAND_5GHZ, 0}"));
 
  250        staDevice = 
wifi.Install(phy, macSta, wifiStaNode.
Get(0));
 
  254        NS_ASSERT(phySta->GetChannelNumber() == 44);
 
  262        staDevice = 
wifi.Install(phy, macSta, wifiStaNode.
Get(0));
 
  267            "/NodeList/0/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::YansWifiPhy/ChannelSettings",
 
  270            "/NodeList/1/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::YansWifiPhy/ChannelSettings",
 
  273        NS_ASSERT(phySta->GetChannelNumber() == 40);
 
  281        staDevice = 
wifi.Install(phy, macSta, wifiStaNode.
Get(0));
 
  286            "/NodeList/0/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::YansWifiPhy/ChannelSettings",
 
  289            "/NodeList/1/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::YansWifiPhy/ChannelSettings",
 
  291        NS_ASSERT(phySta->GetChannelNumber() == 46);
 
  299        staDevice = 
wifi.Install(phy, macSta, wifiStaNode.
Get(0));
 
  304            "/NodeList/0/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::YansWifiPhy/ChannelSettings",
 
  307            "/NodeList/1/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::YansWifiPhy/ChannelSettings",
 
  309        NS_ASSERT(phySta->GetChannelNumber() == 46);
 
  318        exceptionThrown = 
false;
 
  321            staDevice = 
wifi.Install(phy, macSta, wifiStaNode.
Get(0));
 
  323        catch (
const std::runtime_error&)
 
  325            exceptionThrown = 
true;
 
  328        exceptionThrown = 
false;
 
  333        catch (
const std::runtime_error&)
 
  335            exceptionThrown = 
true;
 
  345        staDevice = 
wifi.Install(phy, macSta, wifiStaNode.
Get(0));
 
  349        NS_ASSERT(phySta->GetChannelNumber() == 100);
 
  357        staDevice = 
wifi.Install(phy, macSta, wifiStaNode.
Get(0));
 
  360        exceptionThrown = 
false;
 
  365        catch (
const std::runtime_error&)
 
  367            exceptionThrown = 
true;
 
  376        staDevice = 
wifi.Install(phy, macSta, wifiStaNode.
Get(0));
 
  379        exceptionThrown = 
false;
 
  382            phySta->SetAttribute(
"ChannelSettings", 
StringValue(
"{45, 0, BAND_5GHZ, 0}"));
 
  384        catch (
const std::runtime_error&)
 
  386            exceptionThrown = 
true;
 
  390        phySta->SetAttribute(
"ChannelSettings", 
StringValue(
"{36, 0, BAND_5GHZ, 0}"));
 
  392        NS_ASSERT(phySta->GetChannelNumber() == 36);
 
  395        exceptionThrown = 
false;
 
  398            phySta->SetAttribute(
"ChannelSettings", 
StringValue(
"{43, 0, BAND_5GHZ, 0}"));
 
  400        catch (
const std::runtime_error&)
 
  402            exceptionThrown = 
true;
 
  406        phySta->SetAttribute(
"ChannelSettings", 
StringValue(
"{36, 0, BAND_5GHZ, 0}"));
 
  407        NS_ASSERT(phySta->GetChannelNumber() == 36);
 
  416        staDevice = 
wifi.Install(phy, macSta, wifiStaNode.
Get(0));
 
  419        NS_ASSERT(phySta->GetChannelNumber() == 40);
 
  424        staDevice = 
wifi.Install(phy, macSta, wifiStaNode.
Get(0));
 
  427        phySta->SetAttribute(
"ChannelSettings", 
StringValue(
"{40, 0, BAND_5GHZ, 0}"));
 
  428        NS_ASSERT(phySta->GetChannelNumber() == 40);
 
  431        exceptionThrown = 
false;
 
  434            phySta->SetAttribute(
"ChannelSettings", 
StringValue(
"{45, 0, BAND_5GHZ, 0}"));
 
  436        catch (
const std::runtime_error&)
 
  438            exceptionThrown = 
true;
 
  440        phySta->SetAttribute(
"ChannelSettings", 
StringValue(
"{36, 0, BAND_5GHZ, 0}"));
 
  442        NS_ASSERT(phySta->GetChannelNumber() == 36);
 
  446        exceptionThrown = 
false;
 
  449            phySta->SetAttribute(
"ChannelSettings", 
StringValue(
"{43, 0, BAND_5GHZ, 0}"));
 
  451        catch (
const std::runtime_error&)
 
  453            exceptionThrown = 
true;
 
  455        phySta->SetAttribute(
"ChannelSettings", 
StringValue(
"{36, 0, BAND_5GHZ, 0}"));
 
  457        NS_ASSERT(phySta->GetChannelNumber() == 36);
 
  464        std::cerr << 
"Invalid testcase number " << testCase << std::endl;
 
AttributeValue implementation for Boolean.
Parse command-line arguments.
Introspection did not find any typical Config paths.
void ConfigureAttributes()
Configure the attribute values.
holds a vector of ns3::NetDevice pointers
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
keep track of a set of node pointers.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
Smart pointer class similar to boost::intrusive_ptr.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
The IEEE 802.11 SSID Information Element.
AttributeValue implementation for Ssid.
Hold variables of type string.
AttributeValue implementation for Time.
helps to create WifiNetDevice objects
create MAC layers for a ns3::WifiNetDevice.
void SetType(std::string type, Args &&... args)
Hold together all Wifi-related objects.
std::tuple< uint8_t, MHz_u, WifiPhyBand, uint8_t > ChannelTuple
Tuple identifying a segment of an operating channel.
manage and create wifi channel objects for the YANS model.
static YansWifiChannelHelper Default()
Create a channel helper in a default working state.
Make it easy to create and manage PHY objects for the YANS model.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
void SetDefault(std::string name, const AttributeValue &value)
void Set(std::string path, const AttributeValue &value)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
@ WIFI_PHY_BAND_5GHZ
The 5 GHz band.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void PrintAttributesIfEnabled(bool enabled)
Print the attributes to a file.
Ptr< YansWifiPhy > GetYansWifiPhyPtr(const NetDeviceContainer &nc)
Get the Yans Wifi Phy Ptr object for the 1st node in the NodeContainer.