25#include "ns3/boolean.h"
26#include "ns3/command-line.h"
27#include "ns3/config-store.h"
28#include "ns3/config.h"
31#include "ns3/string.h"
32#include "ns3/uinteger.h"
33#include "ns3/wifi-net-device.h"
34#include "ns3/yans-wifi-helper.h"
35#include "ns3/yans-wifi-phy.h"
71main(
int argc,
char* argv[])
74 bool printAttributes =
false;
75 bool exceptionThrown =
false;
78 cmd.AddValue(
"testCase",
"Test case", testCase);
79 cmd.AddValue(
"printAttributes",
"If true, print out attributes", printAttributes);
80 cmd.Parse(argc, argv);
91 wifi.SetRemoteStationManager(
"ns3::IdealWifiManager");
95 ssid =
Ssid(
"wifi-phy-configuration");
97 macSta.
SetType(
"ns3::StaWifiMac",
103 macAp.
SetType(
"ns3::ApWifiMac",
114 StringValue(
"output-attributes-" + std::to_string(testCase) +
".txt"));
122 phySta = CreateObject<YansWifiPhy>();
124 NS_ASSERT(!phySta->GetOperatingChannel().IsSet());
133 staDevice =
wifi.Install(phy, macSta, wifiStaNode.
Get(0));
137 NS_ASSERT(phySta->GetChannelNumber() == 36);
138 NS_ASSERT(phySta->GetChannelWidth() == 20);
139 NS_ASSERT(phySta->GetFrequency() == 5180);
144 staDevice =
wifi.Install(phy, macSta, wifiStaNode.
Get(0));
148 NS_ASSERT(phySta->GetChannelNumber() == 1);
149 NS_ASSERT(phySta->GetChannelWidth() == 22);
150 NS_ASSERT(phySta->GetFrequency() == 2412);
155 staDevice =
wifi.Install(phy, macSta, wifiStaNode.
Get(0));
159 NS_ASSERT(phySta->GetChannelNumber() == 1);
160 NS_ASSERT(phySta->GetChannelWidth() == 20);
161 NS_ASSERT(phySta->GetFrequency() == 2412);
167 staDevice =
wifi.Install(phy, macSta, wifiStaNode.
Get(0));
171 NS_ASSERT(phySta->GetChannelNumber() == 36);
172 NS_ASSERT(phySta->GetChannelWidth() == 20);
173 NS_ASSERT(phySta->GetFrequency() == 5180);
178 staDevice =
wifi.Install(phy, macSta, wifiStaNode.
Get(0));
182 NS_ASSERT(phySta->GetChannelNumber() == 1);
183 NS_ASSERT(phySta->GetChannelWidth() == 20);
184 NS_ASSERT(phySta->GetFrequency() == 2412);
189 staDevice =
wifi.Install(phy, macSta, wifiStaNode.
Get(0));
193 NS_ASSERT(phySta->GetChannelNumber() == 42);
194 NS_ASSERT(phySta->GetChannelWidth() == 80);
195 NS_ASSERT(phySta->GetFrequency() == 5210);
201 phy.Set(
"ChannelSettings",
StringValue(
"{0, 0, BAND_2_4GHZ, 0}"));
202 staDevice =
wifi.Install(phy, macSta, wifiStaNode.
Get(0));
206 NS_ASSERT(phySta->GetChannelNumber() == 1);
207 NS_ASSERT(phySta->GetChannelWidth() == 20);
208 NS_ASSERT(phySta->GetFrequency() == 2412);
213 staDevice =
wifi.Install(phy, macSta, wifiStaNode.
Get(0));
217 NS_ASSERT(phySta->GetChannelNumber() == 42);
218 NS_ASSERT(phySta->GetChannelWidth() == 80);
219 NS_ASSERT(phySta->GetFrequency() == 5210);
225 staDevice =
wifi.Install(phy, macSta, wifiStaNode.
Get(0));
229 NS_ASSERT(phySta->GetChannelNumber() == 7);
230 NS_ASSERT(phySta->GetChannelWidth() == 80);
231 NS_ASSERT(phySta->GetFrequency() == 5985);
237 staDevice =
wifi.Install(phy, macSta, wifiStaNode.
Get(0));
241 NS_ASSERT(phySta->GetChannelNumber() == 172);
242 NS_ASSERT(phySta->GetChannelWidth() == 10);
243 NS_ASSERT(phySta->GetFrequency() == 5860);
249 staDevice =
wifi.Install(phy, macSta, wifiStaNode.
Get(0));
253 NS_ASSERT(phySta->GetChannelNumber() == 171);
254 NS_ASSERT(phySta->GetChannelWidth() == 5);
255 NS_ASSERT(phySta->GetFrequency() == 5860);
260 phy.Set(
"ChannelSettings",
StringValue(
"{44, 20, BAND_5GHZ, 0}"));
261 staDevice =
wifi.Install(phy, macSta, wifiStaNode.
Get(0));
265 NS_ASSERT(phySta->GetChannelNumber() == 44);
266 NS_ASSERT(phySta->GetChannelWidth() == 20);
267 NS_ASSERT(phySta->GetFrequency() == 5220);
273 staDevice =
wifi.Install(phy, macSta, wifiStaNode.
Get(0));
278 "/NodeList/0/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::YansWifiPhy/ChannelSettings",
281 "/NodeList/1/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::YansWifiPhy/ChannelSettings",
284 NS_ASSERT(phySta->GetChannelNumber() == 40);
285 NS_ASSERT(phySta->GetChannelWidth() == 20);
286 NS_ASSERT(phySta->GetFrequency() == 5200);
292 staDevice =
wifi.Install(phy, macSta, wifiStaNode.
Get(0));
297 "/NodeList/0/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::YansWifiPhy/ChannelSettings",
300 "/NodeList/1/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::YansWifiPhy/ChannelSettings",
302 NS_ASSERT(phySta->GetChannelNumber() == 46);
303 NS_ASSERT(phySta->GetChannelWidth() == 40);
304 NS_ASSERT(phySta->GetFrequency() == 5230);
310 staDevice =
wifi.Install(phy, macSta, wifiStaNode.
Get(0));
315 "/NodeList/0/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::YansWifiPhy/ChannelSettings",
318 "/NodeList/1/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::YansWifiPhy/ChannelSettings",
320 NS_ASSERT(phySta->GetChannelNumber() == 46);
321 NS_ASSERT(phySta->GetChannelWidth() == 40);
322 NS_ASSERT(phySta->GetFrequency() == 5230);
329 exceptionThrown =
false;
332 staDevice =
wifi.Install(phy, macSta, wifiStaNode.
Get(0));
334 catch (
const std::runtime_error&)
336 exceptionThrown =
true;
339 exceptionThrown =
false;
344 catch (
const std::runtime_error&)
346 exceptionThrown =
true;
356 staDevice =
wifi.Install(phy, macSta, wifiStaNode.
Get(0));
360 NS_ASSERT(phySta->GetChannelNumber() == 100);
361 NS_ASSERT(phySta->GetChannelWidth() == 20);
362 NS_ASSERT(phySta->GetFrequency() == 5500);
368 staDevice =
wifi.Install(phy, macSta, wifiStaNode.
Get(0));
371 exceptionThrown =
false;
376 catch (
const std::runtime_error&)
378 exceptionThrown =
true;
387 staDevice =
wifi.Install(phy, macSta, wifiStaNode.
Get(0));
390 exceptionThrown =
false;
393 phySta->SetAttribute(
"ChannelSettings",
StringValue(
"{45, 0, BAND_5GHZ, 0}"));
395 catch (
const std::runtime_error&)
397 exceptionThrown =
true;
401 phySta->SetAttribute(
"ChannelSettings",
StringValue(
"{36, 0, BAND_5GHZ, 0}"));
403 NS_ASSERT(phySta->GetChannelNumber() == 36);
404 NS_ASSERT(phySta->GetChannelWidth() == 20);
405 NS_ASSERT(phySta->GetFrequency() == 5180);
406 exceptionThrown =
false;
409 phySta->SetAttribute(
"ChannelSettings",
StringValue(
"{43, 0, BAND_5GHZ, 0}"));
411 catch (
const std::runtime_error&)
413 exceptionThrown =
true;
417 phySta->SetAttribute(
"ChannelSettings",
StringValue(
"{36, 0, BAND_5GHZ, 0}"));
418 NS_ASSERT(phySta->GetChannelNumber() == 36);
419 NS_ASSERT(phySta->GetChannelWidth() == 20);
420 NS_ASSERT(phySta->GetFrequency() == 5180);
427 staDevice =
wifi.Install(phy, macSta, wifiStaNode.
Get(0));
430 NS_ASSERT(phySta->GetChannelNumber() == 40);
431 NS_ASSERT(phySta->GetChannelWidth() == 20);
432 NS_ASSERT(phySta->GetFrequency() == 5200);
435 staDevice =
wifi.Install(phy, macSta, wifiStaNode.
Get(0));
438 phySta->SetAttribute(
"ChannelSettings",
StringValue(
"{40, 0, BAND_5GHZ, 0}"));
439 NS_ASSERT(phySta->GetChannelNumber() == 40);
440 NS_ASSERT(phySta->GetChannelWidth() == 20);
441 NS_ASSERT(phySta->GetFrequency() == 5200);
442 exceptionThrown =
false;
445 phySta->SetAttribute(
"ChannelSettings",
StringValue(
"{45, 0, BAND_5GHZ, 0}"));
447 catch (
const std::runtime_error&)
449 exceptionThrown =
true;
451 phySta->SetAttribute(
"ChannelSettings",
StringValue(
"{36, 0, BAND_5GHZ, 0}"));
453 NS_ASSERT(phySta->GetChannelNumber() == 36);
454 NS_ASSERT(phySta->GetChannelWidth() == 20);
455 NS_ASSERT(phySta->GetFrequency() == 5180);
457 phySta->SetAttribute(
"ChannelSettings",
StringValue(
"{36, 0, BAND_5GHZ, 0}"));
458 exceptionThrown =
false;
461 phySta->SetAttribute(
"ChannelSettings",
StringValue(
"{43, 0, BAND_5GHZ, 0}"));
463 catch (
const std::runtime_error&)
465 exceptionThrown =
true;
468 NS_ASSERT(phySta->GetChannelNumber() == 36);
469 NS_ASSERT(phySta->GetChannelWidth() == 20);
470 NS_ASSERT(phySta->GetFrequency() == 5180);
475 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.
std::tuple< uint8_t, uint16_t, WifiPhyBand, uint8_t > ChannelTuple
Tuple identifying 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.
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.