38#include "ns3/attribute-container.h"
39#include "ns3/boolean.h"
40#include "ns3/command-line.h"
41#include "ns3/config.h"
42#include "ns3/double.h"
44#include "ns3/gnuplot.h"
45#include "ns3/he-configuration.h"
46#include "ns3/ht-configuration.h"
48#include "ns3/mobility-helper.h"
49#include "ns3/packet-socket-client.h"
50#include "ns3/packet-socket-helper.h"
51#include "ns3/packet-socket-server.h"
52#include "ns3/propagation-delay-model.h"
53#include "ns3/propagation-loss-model.h"
54#include "ns3/rng-seed-manager.h"
57#include "ns3/uinteger.h"
58#include "ns3/wifi-mac.h"
59#include "ns3/wifi-net-device.h"
60#include "ns3/yans-wifi-helper.h"
181 <<
"; setting new power to " <<
rss - step.
stepSize);
216 std::string standard(
"802.11a");
226 cmd.AddValue(
"maxRetryCount",
227 "The maximum number of retransmission attempts for a Data packet",
229 cmd.AddValue(
"rtsThreshold",
"RTS threshold", rtsThreshold);
230 cmd.AddValue(
"maxAmpduSize",
"Max A-MPDU size", maxAmpduSize);
231 cmd.AddValue(
"stepSize",
"Power between steps (dBm)", stepSize);
232 cmd.AddValue(
"stepTime",
"Time on each step (seconds)", stepTime);
233 cmd.AddValue(
"broadcast",
"Send broadcast instead of unicast",
broadcast);
234 cmd.AddValue(
"serverChannelWidth",
235 "Set channel width of the server (valid only for 802.11n or ac)",
237 cmd.AddValue(
"clientChannelWidth",
238 "Set channel width of the client (valid only for 802.11n or ac)",
240 cmd.AddValue(
"serverNss",
"Set nss of the server (valid only for 802.11n or ac)",
serverNss);
241 cmd.AddValue(
"clientNss",
"Set nss of the client (valid only for 802.11n or ac)",
clientNss);
242 cmd.AddValue(
"serverShortGuardInterval",
243 "Set short guard interval of the server (802.11n/ac/ax) in nanoseconds",
245 cmd.AddValue(
"clientShortGuardInterval",
246 "Set short guard interval of the client (802.11n/ac/ax) in nanoseconds",
250 "Set standard (802.11a, 802.11b, 802.11g, 802.11p-10MHz, 802.11p-5MHz, 802.11n-5GHz, "
251 "802.11n-2.4GHz, 802.11ac, 802.11ax-6GHz, 802.11ax-5GHz, 802.11ax-2.4GHz)",
253 cmd.AddValue(
"wifiManager",
254 "Set wifi rate manager (Aarf, Aarfcd, Amrr, Arf, Cara, Ideal, Minstrel, "
255 "MinstrelHt, Onoe, Rraa, ThompsonSampling)",
257 cmd.AddValue(
"infrastructure",
"Use infrastructure instead of adhoc",
infrastructure);
261 std::cout << std::endl
262 <<
"This program demonstrates and plots the operation of different " << std::endl;
263 std::cout <<
"Wi-Fi rate controls on different station configurations," << std::endl;
264 std::cout <<
"by stepping down the received signal strength across a wide range" << std::endl;
265 std::cout <<
"and observing the adjustment of the rate." << std::endl;
266 std::cout <<
"Run 'wifi-manager-example --PrintHelp' to show program options." << std::endl
272 "In ad hoc mode, we assume sender and receiver are similarly configured");
275 if (standard ==
"802.11b")
282 "Invalid channel width for standard " << standard);
289 "Invalid channel width for standard " << standard);
292 else if (standard ==
"802.11a" || standard ==
"802.11g")
299 "Invalid channel width for standard " << standard);
306 "Invalid channel width for standard " << standard);
309 else if (standard ==
"802.11n-5GHz" || standard ==
"802.11n-2.4GHz")
318 "Invalid channel width for standard " << standard);
320 "Invalid nss " <<
serverNss <<
" for standard " << standard);
326 "Invalid channel width for standard " << standard);
328 "Invalid nss " <<
clientNss <<
" for standard " << standard);
330 else if (standard ==
"802.11ac")
338 "Invalid channel width for standard " << standard);
340 "Invalid nss " <<
serverNss <<
" for standard " << standard);
347 "Invalid channel width for standard " << standard);
349 "Invalid nss " <<
clientNss <<
" for standard " << standard);
351 else if (standard ==
"802.11ax-6GHz" || standard ==
"802.11ax-5GHz" ||
352 standard ==
"802.11ax-2.4GHz")
363 "Invalid channel width for standard " << standard);
365 "Invalid nss " <<
serverNss <<
" for standard " << standard);
372 "Invalid channel width for standard " << standard);
374 "Invalid nss " <<
clientNss <<
" for standard " << standard);
604 "Standard " << standard <<
" not found");
606 "Standard " << standard <<
" not found");
610 "SNR values in wrong order");
620 std::string
plotName =
"wifi-manager-example-";
621 std::string
dataName =
"wifi-manager-example-";
628 if (standard ==
"802.11n-5GHz" || standard ==
"802.11n-2.4GHz" || standard ==
"802.11ac" ||
629 standard ==
"802.11ax-6GHz" || standard ==
"802.11ax-5GHz" || standard ==
"802.11ax-2.4GHz")
633 std::ostringstream
oss;
712 wifiMac.SetType(
"ns3::AdhocWifiMac");
727 Config::Set(
"/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/BE_MaxAmpduSize",
731 "/NodeList/0/DeviceList/*/$ns3::WifiNetDevice/RemoteStationManager/$ns3::" +
wifiManager +
744 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
857 "Expected BA agreement established for standard "
881 std::string title(
"Results for ");
882 title.append(standard);
883 title.append(
" with ");
886 if (standard ==
"802.11n-5GHz" || standard ==
"802.11n-2.4GHz" || standard ==
"802.11ac" ||
887 standard ==
"802.11ax-6GHz" || standard ==
"802.11ax-5GHz" || standard ==
"802.11ax-2.4GHz")
892 title.append(
"server: width=");
896 title.append(
" GI=");
900 title.append(
" nss=");
907 title.append(
"client: width=");
911 title.append(
" GI=");
915 title.append(
" nss=");
919 gnuplot.
SetTerminal(
"postscript eps color enh \"Times-BoldItalic\"");
920 gnuplot.
SetLegend(
"SNR (dB)",
"Rate (Mb/s)");
a polymophic address class
A container for one type of attribute.
AttributeValue implementation for Boolean.
Parse command-line arguments.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Class to represent a 2D points plot.
a simple class to generate gnuplot-ready plotting commands from a set of datasets.
void AddDataset(const GnuplotDataset &dataset)
void SetLegend(const std::string &xLegend, const std::string &yLegend)
void SetTerminal(const std::string &terminal)
void AppendExtra(const std::string &extra)
void GenerateOutput(std::ostream &os)
Writes gnuplot commands and data values to a single output stream.
void SetExtra(const std::string &extra)
void SetTitle(const std::string &title)
Helper class used to assign positions and mobility models to nodes.
holds a vector of ns3::NetDevice pointers
an address for a packet socket
void SetSingleDevice(uint32_t device)
Set the address to match only a specified NetDevice.
Give ns3::PacketSocket powers to ns3::Node.
void Install(Ptr< Node > node) const
Aggregate an instance of a ns3::PacketSocketFactory onto the provided node.
Smart pointer class similar to boost::intrusive_ptr.
static void SetRun(uint64_t run)
Set the run number of simulation.
static void SetSeed(uint32_t seed)
Set the seed.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
static Time Now()
Return the current simulation virtual time.
static void Run()
Run the simulation.
static void Stop()
Tell the Simulator the calling event should be the last one executed.
The IEEE 802.11 SSID Information Element.
AttributeValue implementation for Ssid.
AttributeValue implementation for Time.
AttributeValue implementation for Tuple.
Hold an unsigned integer type.
helps to create WifiNetDevice objects
static int64_t AssignStreams(NetDeviceContainer c, int64_t stream)
Assign a fixed random variable stream number to the random variables used by the PHY and MAC aspects ...
create MAC layers for a ns3::WifiNetDevice.
Hold together all Wifi-related objects.
void DisablePreambleDetectionModel()
Disable the preamble detection model on all links.
std::vector< ChannelTuple > ChannelSegments
segments identifying an operating channel
Make it easy to create and manage PHY objects for the YANS model.
void SetDefault(std::string name, const AttributeValue &value)
void ConnectWithoutContext(std::string path, const CallbackBase &cb)
void Set(std::string path, const AttributeValue &value)
#define NS_ABORT_MSG_UNLESS(cond, msg)
Abnormal program termination if a condition is false, with a message.
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Time NanoSeconds(uint64_t value)
Construct a Time in the indicated unit.
Time Seconds(double value)
Construct a Time in the indicated unit.
WifiStandard
Identifies the IEEE 802.11 specifications that a Wifi device can be configured to use.
WifiPhyBand
Identifies the PHY band.
@ WIFI_PHY_BAND_6GHZ
The 6 GHz band.
@ WIFI_PHY_BAND_2_4GHZ
The 2.4 GHz band.
@ WIFI_PHY_BAND_5GHZ
The 5 GHz band.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
dBm_u WToDbm(Watt_u val)
Convert from Watts to dBm.
MHz_u GetDefaultChannelWidth(WifiStandard standard, WifiPhyBand band)
Get the default channel width for the given PHY standard and band.
StandardInfo(std::string name, WifiStandard standard, WifiPhyBand band, MHz_u width, dB_u snrLow, dB_u snrHigh, double xMin, double xMax, double yMax)
Constructor.
WifiStandard m_standard
standard
WifiPhyBand m_band
PHY band.
dB_u m_snrHigh
highest SNR
MHz_u m_width
channel width
double stepTime
step size in seconds
uint64_t g_intervalRate
Rate in an interval.
void ChangeSignalAndReportRate(Ptr< FixedRssLossModel > rssModel, Step step, dBm_u rss, dBm_u noise, Gnuplot2dDataset &rateDataset, Gnuplot2dDataset &actualDataset)
Change the signal model and report the rate.
void RateChange(uint64_t oldVal, uint64_t newVal)
Rate changed.
void PacketRx(Ptr< const Packet > pkt, const Address &addr)
Packet received.
double g_intervalBytes
Bytes received in an interval.
static const uint32_t packetSize
Packet size generated at the AP.