27 #include "ns3/command-line.h"
28 #include "ns3/config-store.h"
29 #include "ns3/config.h"
30 #include "ns3/boolean.h"
31 #include "ns3/uinteger.h"
32 #include "ns3/string.h"
34 #include "ns3/yans-wifi-phy.h"
35 #include "ns3/yans-wifi-helper.h"
36 #include "ns3/wifi-net-device.h"
60 int main (
int argc,
char *argv[])
62 uint32_t testCase = 0;
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",
90 macAp.
SetType (
"ns3::ApWifiMac",
105 phySta = CreateObject<YansWifiPhy> ();
116 staDevice =
wifi.Install (
phy, macSta, wifiStaNode.
Get (0));
127 staDevice =
wifi.Install (
phy, macSta, wifiStaNode.
Get (0));
138 staDevice =
wifi.Install (
phy, macSta, wifiStaNode.
Get (0));
149 phy.Set (
"ChannelSettings",
StringValue (
"{0, 0, BAND_5GHZ, 0}"));
150 staDevice =
wifi.Install (
phy, macSta, wifiStaNode.
Get (0));
161 staDevice =
wifi.Install (
phy, macSta, wifiStaNode.
Get (0));
172 staDevice =
wifi.Install (
phy, macSta, wifiStaNode.
Get (0));
184 phy.Set (
"ChannelSettings",
StringValue (
"{0, 0, BAND_2_4GHZ, 0}"));
185 staDevice =
wifi.Install (
phy, macSta, wifiStaNode.
Get (0));
196 staDevice =
wifi.Install (
phy, macSta, wifiStaNode.
Get (0));
207 phy.Set (
"ChannelSettings",
StringValue (
"{0, 0, BAND_6GHZ, 0}"));
208 staDevice =
wifi.Install (
phy, macSta, wifiStaNode.
Get (0));
219 phy.Set (
"ChannelSettings",
StringValue (
"{0, 10, BAND_5GHZ, 0}"));
220 staDevice =
wifi.Install (
phy, macSta, wifiStaNode.
Get (0));
231 phy.Set (
"ChannelSettings",
StringValue (
"{0, 5, BAND_5GHZ, 0}"));
232 staDevice =
wifi.Install (
phy, macSta, wifiStaNode.
Get (0));
243 phy.Set (
"ChannelSettings",
StringValue (
"{44, 20, BAND_5GHZ, 0}"));
244 staDevice =
wifi.Install (
phy, macSta, wifiStaNode.
Get (0));
255 phy.Set (
"ChannelSettings",
StringValue (
"{44, 0, BAND_5GHZ, 0}"));
256 staDevice =
wifi.Install (
phy, macSta, wifiStaNode.
Get (0));
260 Config::Set (
"/NodeList/0/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::YansWifiPhy/ChannelSettings",
StringValue (
"{40, 0, BAND_5GHZ, 0}"));
261 Config::Set (
"/NodeList/1/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::YansWifiPhy/ChannelSettings",
StringValue (
"{40, 0, BAND_5GHZ, 0}"));
270 phy.Set (
"ChannelSettings",
StringValue (
"{44, 0, BAND_5GHZ, 0}"));
271 staDevice =
wifi.Install (
phy, macSta, wifiStaNode.
Get (0));
275 Config::Set (
"/NodeList/0/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::YansWifiPhy/ChannelSettings",
StringValue (
"{46, 0, BAND_5GHZ, 0}"));
276 Config::Set (
"/NodeList/1/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::YansWifiPhy/ChannelSettings",
StringValue (
"{46, 0, BAND_5GHZ, 0}"));
285 staDevice =
wifi.Install (
phy, macSta, wifiStaNode.
Get (0));
289 Config::Set (
"/NodeList/0/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::YansWifiPhy/ChannelSettings",
StringValue (
"{46, 0, BAND_5GHZ, 0}"));
290 Config::Set (
"/NodeList/1/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::YansWifiPhy/ChannelSettings",
StringValue (
"{46, 0, BAND_5GHZ, 0}"));
300 exceptionThrown =
false;
303 staDevice =
wifi.Install (
phy, macSta, wifiStaNode.
Get (0));
305 catch (
const std::runtime_error&)
307 exceptionThrown =
true;
310 exceptionThrown =
false;
315 catch (
const std::runtime_error&)
317 exceptionThrown =
true;
327 staDevice =
wifi.Install (
phy, macSta, wifiStaNode.
Get (0));
339 staDevice =
wifi.Install (
phy, macSta, wifiStaNode.
Get (0));
342 exceptionThrown =
false;
347 catch (
const std::runtime_error&)
349 exceptionThrown =
true;
357 phy.Set (
"ChannelSettings",
StringValue (
"{44, 0, BAND_5GHZ, 0}"));
358 staDevice =
wifi.Install (
phy, macSta, wifiStaNode.
Get (0));
361 exceptionThrown =
false;
366 catch (
const std::runtime_error&)
368 exceptionThrown =
true;
377 exceptionThrown =
false;
382 catch (
const std::runtime_error&)
384 exceptionThrown =
true;
398 staDevice =
wifi.Install (
phy, macSta, wifiStaNode.
Get (0));
406 staDevice =
wifi.Install (
phy, macSta, wifiStaNode.
Get (0));
413 exceptionThrown =
false;
418 catch (
const std::runtime_error&)
420 exceptionThrown =
true;
429 exceptionThrown =
false;
434 catch (
const std::runtime_error&)
436 exceptionThrown =
true;
446 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(void)
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(void) const
Get a pointer to the requested aggregated Object.
static void Destroy(void)
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.
Ptr< WifiPhy > GetPhy(void) const
uint8_t GetChannelNumber(void) const
Return current channel number.
const WifiPhyOperatingChannel & GetOperatingChannel(void) const
Get a const reference to the operating channel.
void SetOperatingChannel(const ChannelTuple &channelTuple)
If the standard for this object has not been set yet, store the given channel settings.
std::tuple< uint8_t, uint16_t, int, uint8_t > ChannelTuple
Tuple identifying an operating channel.
uint16_t GetChannelWidth(void) const
uint16_t GetFrequency(void) const
bool IsSet(void) 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(void)
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)
void PrintAttributesIfEnabled(bool enabled)