9#include "ns3/command-line.h"
10#include "ns3/gnuplot.h"
11#include "ns3/mobility-helper.h"
12#include "ns3/spectrum-analyzer-helper.h"
13#include "ns3/spectrum-channel.h"
14#include "ns3/spectrum-helper.h"
15#include "ns3/spectrum-wifi-helper.h"
17#include "ns3/string.h"
18#include "ns3/wifi-utils.h"
51 cmd.AddValue(
"standard",
52 "OFDM-based Wi-Fi standard [11a, 11p_10MHZ, 11p_5MHZ, 11n_2_4GHZ, 11n_5GHZ, 11ac, "
53 "11ax_2_4GHZ, 11ax_5GHZ]",
55 cmd.AddValue(
"bw",
"Bandwidth (consistent with standard, in MHz)", bw);
56 cmd.AddValue(
"txPower",
"Transmit power (dBm)",
pow);
57 cmd.AddValue(
"verbose",
58 "Display log messages for WifiSpectrumValueHelper and SpectrumWifiPhy",
70 WifiStandard standard{WifiStandard::WIFI_STANDARD_UNSPECIFIED};
83 std::cout <<
"Bandwidth is not compatible with standard" << std::endl;
99 std::cout <<
"Bandwidth is not compatible with standard" << std::endl;
115 std::cout <<
"Bandwidth is not compatible with standard" << std::endl;
131 std::cout <<
"Bandwidth is not compatible with standard" << std::endl;
146 std::cout <<
"Bandwidth is not compatible with standard" << std::endl;
162 std::cout <<
"Bandwidth is not compatible with standard" << std::endl;
178 std::cout <<
"Bandwidth is not compatible with standard" << std::endl;
194 std::cout <<
"Bandwidth is not compatible with standard" << std::endl;
200 std::cout <<
"Unknown OFDM standard (please refer to the listed possible values)"
230 channelHelper.AddSpectrumPropagationLoss(
"ns3::ConstantSpectrumPropagationLossModel");
237 spectrumPhy.SetErrorRateModel(
"ns3::NistErrorRateModel");
246 wifi.SetStandard(standard);
247 wifi.SetRemoteStationManager(
"ns3::ConstantRateWifiManager",
255 mac.SetType(
"ns3::ApWifiMac",
258 "EnableBeaconJitter",
268 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
281 std::vector<double>
freqs;
283 const auto band = (bw +
margin);
284 freqs.reserve(4 * 10 * band);
286 for (
int i = 0;
i < (4 * 10 * band); ++
i)
314 std::ostringstream
ossPlt;
317 std::ostringstream
ossPng;
324 plot.AppendExtra(
"unset surface");
325 plot.AppendExtra(
"set key off");
327 plot.AppendExtra(
"set term png");
328 plot.AppendExtra(
"set output file . '.png'");
330 plot.AppendExtra(
"set pm3d at s");
331 plot.AppendExtra(
"set palette");
333 plot.AppendExtra(
"set view 50,50");
335 plot.AppendExtra(
"set xlabel \"time (ms)\"");
336 plot.AppendExtra(
"set ylabel \"freq (MHz)\" offset 15,0,0");
337 plot.AppendExtra(
"set zlabel \"PSD (dBW/Hz)\" offset 15,0,0");
339 plot.AppendExtra(
"set ytics");
340 plot.AppendExtra(
"set mytics 2");
341 plot.AppendExtra(
"set ztics");
342 plot.AppendExtra(
"set mztics 5");
343 plot.AppendExtra(
"set grid ytics mytics ztics mztics");
345 plot.AppendExtra(
"filename = file . '.tr'");
347 plot.AppendExtra(
"stats filename using 3");
348 plot.AppendExtra(
"refW = STATS_max");
350 plot.AppendExtra(
"splot filename using ($1*1000.0):($2/1e6):(10*log10($3/refW))");
357 std::cout <<
"Simulation done!" << std::endl;
358 std::cout <<
"See spectrum analyzer output file: " <<
ossFileName.str() <<
".tr" << std::endl;
359 std::cout <<
"To generate plot simply execute the following command: gnuplot "
a polymophic address class
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'.
a simple class to generate gnuplot-ready plotting commands from a set of datasets.
Helper class used to assign positions and mobility models to nodes.
holds a vector of ns3::NetDevice pointers
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 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 void Run()
Run the simulation.
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Class to allow the Spectrum Analysis.
void SetChannel(Ptr< SpectrumChannel > channel)
Set the SpectrumChannel that will be used by SpectrumPhy instances created by this helper.
static SpectrumChannelHelper Default()
Setup a default SpectrumChannel.
Make it easy to create and manage PHY objects for the spectrum model.
void SetChannel(const Ptr< SpectrumChannel > channel)
The IEEE 802.11 SSID Information Element.
AttributeValue implementation for Ssid.
Hold variables of type string.
Simulation virtual time values and global simulation resolution.
AttributeValue implementation for Time.
helps to create WifiNetDevice objects
create MAC layers for a ns3::WifiNetDevice.
static ConstIterator FindFirst(uint8_t number, MHz_u frequency, MHz_u width, WifiStandard standard, WifiPhyBand band, ConstIterator start=m_frequencyChannels.begin())
Find the first frequency segment matching the specified parameters.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Time MicroSeconds(uint64_t 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_UNSPECIFIED
Unspecified.
@ 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.
void LogComponentEnable(const std::string &name, LogLevel level)
Enable the logging output associated with that log component.
@ LOG_LEVEL_ALL
Print everything.
@ LOG_PREFIX_ALL
All prefixes.
Hz_u MHzToHz(MHz_u val)
Convert from MHz to Hz.
void LogComponentEnableAll(LogLevel level)
Enable the logging output for all registered log components.
void SendPacket(Ptr< NetDevice > sourceDevice, Address &destination)
This example (inspired from tv-trans-example) enables to generate the transmitted spectra of Wi-Fi st...