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"
71 main(
int argc,
char* argv[])
73 uint32_t testCase = 0;
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",
122 phySta = CreateObject<YansWifiPhy>();
133 staDevice =
wifi.Install(
phy, macSta, wifiStaNode.
Get(0));
144 staDevice =
wifi.Install(
phy, macSta, wifiStaNode.
Get(0));
155 staDevice =
wifi.Install(
phy, macSta, wifiStaNode.
Get(0));
167 staDevice =
wifi.Install(
phy, macSta, wifiStaNode.
Get(0));
178 staDevice =
wifi.Install(
phy, macSta, wifiStaNode.
Get(0));
189 staDevice =
wifi.Install(
phy, macSta, wifiStaNode.
Get(0));
201 phy.Set(
"ChannelSettings",
StringValue(
"{0, 0, BAND_2_4GHZ, 0}"));
202 staDevice =
wifi.Install(
phy, macSta, wifiStaNode.
Get(0));
213 staDevice =
wifi.Install(
phy, macSta, wifiStaNode.
Get(0));
225 staDevice =
wifi.Install(
phy, macSta, wifiStaNode.
Get(0));
237 staDevice =
wifi.Install(
phy, macSta, wifiStaNode.
Get(0));
249 staDevice =
wifi.Install(
phy, macSta, wifiStaNode.
Get(0));
260 phy.Set(
"ChannelSettings",
StringValue(
"{44, 20, BAND_5GHZ, 0}"));
261 staDevice =
wifi.Install(
phy, macSta, wifiStaNode.
Get(0));
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",
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",
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",
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));
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;
395 catch (
const std::runtime_error&)
397 exceptionThrown =
true;
406 exceptionThrown =
false;
411 catch (
const std::runtime_error&)
413 exceptionThrown =
true;
427 staDevice =
wifi.Install(
phy, macSta, wifiStaNode.
Get(0));
435 staDevice =
wifi.Install(
phy, macSta, wifiStaNode.
Get(0));
442 exceptionThrown =
false;
447 catch (
const std::runtime_error&)
449 exceptionThrown =
true;
458 exceptionThrown =
false;
463 catch (
const std::runtime_error&)
465 exceptionThrown =
true;
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.
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
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.
Ptr< WifiPhy > GetPhy() const
uint16_t GetChannelWidth() const
uint16_t GetFrequency() const
void SetOperatingChannel(const ChannelTuple &channelTuple)
If the standard for this object has not been set yet, store the given channel settings.
uint8_t GetChannelNumber() const
Return current channel number.
std::tuple< uint8_t, uint16_t, WifiPhyBand, uint8_t > ChannelTuple
Tuple identifying an operating channel.
const WifiPhyOperatingChannel & GetOperatingChannel() const
Get a const reference to the operating channel.
bool IsSet() const
Return true if a valid channel has been set, false otherwise.
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.
NLOHMANN_BASIC_JSON_TPL_DECLARATION std::string to_string(const NLOHMANN_BASIC_JSON_TPL &j)
user-defined to_string function for JSON values
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< YansWifiPhy > GetYansWifiPhyPtr(const NetDeviceContainer &nc)
Get the Yans Wifi Phy Ptr object for the 1st node in the NodeContainer.
void PrintAttributesIfEnabled(bool enabled)
Print the attributes to a file.