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/wifi-ns3-constants.h"
24#include "ns3/yans-wifi-helper.h"
25#include "ns3/yans-wifi-phy.h"
61main(
int argc,
char* argv[])
64 bool printAttributes =
false;
65 bool exceptionThrown =
false;
68 cmd.AddValue(
"testCase",
"Test case", testCase);
69 cmd.AddValue(
"printAttributes",
"If true, print out attributes", printAttributes);
70 cmd.Parse(argc, argv);
81 wifi.SetRemoteStationManager(
"ns3::IdealWifiManager");
85 ssid =
Ssid(
"wifi-phy-configuration");
87 macSta.
SetType(
"ns3::StaWifiMac",
104 StringValue(
"output-attributes-" + std::to_string(testCase) +
".txt"));
114 NS_ASSERT(!phySta->GetOperatingChannel().IsSet());
123 staDevice =
wifi.Install(phy, macSta, wifiStaNode.
Get(0));
127 NS_ASSERT(phySta->GetChannelNumber() == 36);
134 staDevice =
wifi.Install(phy, macSta, wifiStaNode.
Get(0));
138 NS_ASSERT(phySta->GetChannelNumber() == 1);
145 staDevice =
wifi.Install(phy, macSta, wifiStaNode.
Get(0));
149 NS_ASSERT(phySta->GetChannelNumber() == 1);
157 staDevice =
wifi.Install(phy, macSta, wifiStaNode.
Get(0));
161 NS_ASSERT(phySta->GetChannelNumber() == 36);
168 staDevice =
wifi.Install(phy, macSta, wifiStaNode.
Get(0));
172 NS_ASSERT(phySta->GetChannelNumber() == 1);
179 staDevice =
wifi.Install(phy, macSta, wifiStaNode.
Get(0));
183 NS_ASSERT(phySta->GetChannelNumber() == 42);
191 phy.Set(
"ChannelSettings",
StringValue(
"{0, 0, BAND_2_4GHZ, 0}"));
192 staDevice =
wifi.Install(phy, macSta, wifiStaNode.
Get(0));
196 NS_ASSERT(phySta->GetChannelNumber() == 1);
203 staDevice =
wifi.Install(phy, macSta, wifiStaNode.
Get(0));
207 NS_ASSERT(phySta->GetChannelNumber() == 42);
215 staDevice =
wifi.Install(phy, macSta, wifiStaNode.
Get(0));
219 NS_ASSERT(phySta->GetChannelNumber() == 7);
227 staDevice =
wifi.Install(phy, macSta, wifiStaNode.
Get(0));
231 NS_ASSERT(phySta->GetChannelNumber() == 172);
239 staDevice =
wifi.Install(phy, macSta, wifiStaNode.
Get(0));
243 NS_ASSERT(phySta->GetChannelNumber() == 171);
250 phy.Set(
"ChannelSettings",
StringValue(
"{44, 20, BAND_5GHZ, 0}"));
251 staDevice =
wifi.Install(phy, macSta, wifiStaNode.
Get(0));
255 NS_ASSERT(phySta->GetChannelNumber() == 44);
263 staDevice =
wifi.Install(phy, macSta, wifiStaNode.
Get(0));
268 "/NodeList/0/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::YansWifiPhy/ChannelSettings",
271 "/NodeList/1/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::YansWifiPhy/ChannelSettings",
274 NS_ASSERT(phySta->GetChannelNumber() == 40);
282 staDevice =
wifi.Install(phy, macSta, wifiStaNode.
Get(0));
287 "/NodeList/0/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::YansWifiPhy/ChannelSettings",
290 "/NodeList/1/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::YansWifiPhy/ChannelSettings",
292 NS_ASSERT(phySta->GetChannelNumber() == 46);
300 staDevice =
wifi.Install(phy, macSta, wifiStaNode.
Get(0));
305 "/NodeList/0/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::YansWifiPhy/ChannelSettings",
308 "/NodeList/1/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::YansWifiPhy/ChannelSettings",
310 NS_ASSERT(phySta->GetChannelNumber() == 46);
319 exceptionThrown =
false;
322 staDevice =
wifi.Install(phy, macSta, wifiStaNode.
Get(0));
324 catch (
const std::runtime_error&)
326 exceptionThrown =
true;
329 exceptionThrown =
false;
334 catch (
const std::runtime_error&)
336 exceptionThrown =
true;
346 staDevice =
wifi.Install(phy, macSta, wifiStaNode.
Get(0));
350 NS_ASSERT(phySta->GetChannelNumber() == 100);
358 staDevice =
wifi.Install(phy, macSta, wifiStaNode.
Get(0));
361 exceptionThrown =
false;
366 catch (
const std::runtime_error&)
368 exceptionThrown =
true;
377 staDevice =
wifi.Install(phy, macSta, wifiStaNode.
Get(0));
380 exceptionThrown =
false;
383 phySta->SetAttribute(
"ChannelSettings",
StringValue(
"{45, 0, BAND_5GHZ, 0}"));
385 catch (
const std::runtime_error&)
387 exceptionThrown =
true;
391 phySta->SetAttribute(
"ChannelSettings",
StringValue(
"{36, 0, BAND_5GHZ, 0}"));
393 NS_ASSERT(phySta->GetChannelNumber() == 36);
396 exceptionThrown =
false;
399 phySta->SetAttribute(
"ChannelSettings",
StringValue(
"{43, 0, BAND_5GHZ, 0}"));
401 catch (
const std::runtime_error&)
403 exceptionThrown =
true;
407 phySta->SetAttribute(
"ChannelSettings",
StringValue(
"{36, 0, BAND_5GHZ, 0}"));
408 NS_ASSERT(phySta->GetChannelNumber() == 36);
417 staDevice =
wifi.Install(phy, macSta, wifiStaNode.
Get(0));
420 NS_ASSERT(phySta->GetChannelNumber() == 40);
425 staDevice =
wifi.Install(phy, macSta, wifiStaNode.
Get(0));
428 phySta->SetAttribute(
"ChannelSettings",
StringValue(
"{40, 0, BAND_5GHZ, 0}"));
429 NS_ASSERT(phySta->GetChannelNumber() == 40);
432 exceptionThrown =
false;
435 phySta->SetAttribute(
"ChannelSettings",
StringValue(
"{45, 0, BAND_5GHZ, 0}"));
437 catch (
const std::runtime_error&)
439 exceptionThrown =
true;
441 phySta->SetAttribute(
"ChannelSettings",
StringValue(
"{36, 0, BAND_5GHZ, 0}"));
443 NS_ASSERT(phySta->GetChannelNumber() == 36);
447 exceptionThrown =
false;
450 phySta->SetAttribute(
"ChannelSettings",
StringValue(
"{43, 0, BAND_5GHZ, 0}"));
452 catch (
const std::runtime_error&)
454 exceptionThrown =
true;
456 phySta->SetAttribute(
"ChannelSettings",
StringValue(
"{36, 0, BAND_5GHZ, 0}"));
458 NS_ASSERT(phySta->GetChannelNumber() == 36);
465 std::cerr <<
"Invalid testcase number " << testCase << std::endl;
Parse command-line arguments.
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.
Hold variables of type string.
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.
WifiChannelConfig::SegmentWithoutUnits ChannelTuple
kept for backward compatibility, can be deprecated when using strong types
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.
@ WIFI_PHY_BAND_5GHZ
The 5 GHz band.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
double MHz_u
MHz weak type.
Time DEFAULT_BEACON_INTERVAL()
Default Beacon interval.
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.