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);
127 NS_ASSERT(phySta->GetChannelWidth() == 20);
128 NS_ASSERT(phySta->GetFrequency() == 5180);
133 staDevice =
wifi.Install(phy, macSta, wifiStaNode.
Get(0));
137 NS_ASSERT(phySta->GetChannelNumber() == 1);
138 NS_ASSERT(phySta->GetChannelWidth() == 22);
139 NS_ASSERT(phySta->GetFrequency() == 2412);
144 staDevice =
wifi.Install(phy, macSta, wifiStaNode.
Get(0));
148 NS_ASSERT(phySta->GetChannelNumber() == 1);
149 NS_ASSERT(phySta->GetChannelWidth() == 20);
150 NS_ASSERT(phySta->GetFrequency() == 2412);
156 staDevice =
wifi.Install(phy, macSta, wifiStaNode.
Get(0));
160 NS_ASSERT(phySta->GetChannelNumber() == 36);
161 NS_ASSERT(phySta->GetChannelWidth() == 20);
162 NS_ASSERT(phySta->GetFrequency() == 5180);
167 staDevice =
wifi.Install(phy, macSta, wifiStaNode.
Get(0));
171 NS_ASSERT(phySta->GetChannelNumber() == 1);
172 NS_ASSERT(phySta->GetChannelWidth() == 20);
173 NS_ASSERT(phySta->GetFrequency() == 2412);
178 staDevice =
wifi.Install(phy, macSta, wifiStaNode.
Get(0));
182 NS_ASSERT(phySta->GetChannelNumber() == 42);
183 NS_ASSERT(phySta->GetChannelWidth() == 80);
184 NS_ASSERT(phySta->GetFrequency() == 5210);
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);
196 NS_ASSERT(phySta->GetChannelWidth() == 20);
197 NS_ASSERT(phySta->GetFrequency() == 2412);
202 staDevice =
wifi.Install(phy, macSta, wifiStaNode.
Get(0));
206 NS_ASSERT(phySta->GetChannelNumber() == 42);
207 NS_ASSERT(phySta->GetChannelWidth() == 80);
208 NS_ASSERT(phySta->GetFrequency() == 5210);
214 staDevice =
wifi.Install(phy, macSta, wifiStaNode.
Get(0));
218 NS_ASSERT(phySta->GetChannelNumber() == 7);
219 NS_ASSERT(phySta->GetChannelWidth() == 80);
220 NS_ASSERT(phySta->GetFrequency() == 5985);
226 staDevice =
wifi.Install(phy, macSta, wifiStaNode.
Get(0));
230 NS_ASSERT(phySta->GetChannelNumber() == 172);
231 NS_ASSERT(phySta->GetChannelWidth() == 10);
232 NS_ASSERT(phySta->GetFrequency() == 5860);
238 staDevice =
wifi.Install(phy, macSta, wifiStaNode.
Get(0));
242 NS_ASSERT(phySta->GetChannelNumber() == 171);
243 NS_ASSERT(phySta->GetChannelWidth() == 5);
244 NS_ASSERT(phySta->GetFrequency() == 5860);
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);
255 NS_ASSERT(phySta->GetChannelWidth() == 20);
256 NS_ASSERT(phySta->GetFrequency() == 5220);
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);
274 NS_ASSERT(phySta->GetChannelWidth() == 20);
275 NS_ASSERT(phySta->GetFrequency() == 5200);
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);
292 NS_ASSERT(phySta->GetChannelWidth() == 40);
293 NS_ASSERT(phySta->GetFrequency() == 5230);
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);
310 NS_ASSERT(phySta->GetChannelWidth() == 40);
311 NS_ASSERT(phySta->GetFrequency() == 5230);
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);
350 NS_ASSERT(phySta->GetChannelWidth() == 20);
351 NS_ASSERT(phySta->GetFrequency() == 5500);
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);
393 NS_ASSERT(phySta->GetChannelWidth() == 20);
394 NS_ASSERT(phySta->GetFrequency() == 5180);
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);
408 NS_ASSERT(phySta->GetChannelWidth() == 20);
409 NS_ASSERT(phySta->GetFrequency() == 5180);
416 staDevice =
wifi.Install(phy, macSta, wifiStaNode.
Get(0));
419 NS_ASSERT(phySta->GetChannelNumber() == 40);
420 NS_ASSERT(phySta->GetChannelWidth() == 20);
421 NS_ASSERT(phySta->GetFrequency() == 5200);
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);
429 NS_ASSERT(phySta->GetChannelWidth() == 20);
430 NS_ASSERT(phySta->GetFrequency() == 5200);
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);
443 NS_ASSERT(phySta->GetChannelWidth() == 20);
444 NS_ASSERT(phySta->GetFrequency() == 5180);
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);
458 NS_ASSERT(phySta->GetChannelWidth() == 20);
459 NS_ASSERT(phySta->GetFrequency() == 5180);
464 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, 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.