25#include "ns3/command-line.h"
26#include "ns3/gnuplot.h"
27#include "ns3/nist-error-rate-model.h"
28#include "ns3/table-based-error-rate-model.h"
29#include "ns3/wifi-tx-vector.h"
30#include "ns3/yans-error-rate-model.h"
38main(
int argc,
char* argv[])
41 std::ofstream yansfile(
"yans-frame-success-rate-be.plt");
42 std::ofstream nistfile(
"nist-frame-success-rate-be.plt");
43 std::ofstream tablefile(
"table-frame-success-rate-be.plt");
45 const std::vector<std::string> modes{
63 cmd.AddValue(
"FrameSize",
"The frame size", FrameSize);
64 cmd.Parse(argc, argv);
75 for (
uint32_t i = 0; i < modes.size(); i++)
77 std::cout << modes[i] << std::endl;
83 for (
double snr = -5.0; snr <= 55.0; snr += 0.1)
85 double ps = yans->GetChunkSuccessRate(
WifiMode(modes[i]),
87 std::pow(10.0, snr / 10.0),
89 if (ps < 0.0 || ps > 1.0)
94 yansdataset.Add(snr, ps);
96 ps = nist->GetChunkSuccessRate(
WifiMode(modes[i]),
98 std::pow(10.0, snr / 10.0),
100 if (ps < 0.0 || ps > 1.0)
105 nistdataset.Add(snr, ps);
107 ps = table->GetChunkSuccessRate(
WifiMode(modes[i]),
109 std::pow(10.0, snr / 10.0),
111 if (ps < 0.0 || ps > 1.0)
116 tabledataset.Add(snr, ps);
124 std::stringstream plotExtra;
125 plotExtra <<
"set xrange [-5:55]\n\
128 const std::vector<std::string>
colors{
145 NS_ASSERT_MSG(
colors.size() == modes.size(),
"Colors and modes vectors have different sizes");
147 for (std::size_t i = 0; i < modes.size(); i++)
149 plotExtra <<
"set style line " << (i + 1) <<
" linewidth 5 linecolor rgb \"" <<
colors[i]
152 plotExtra <<
"set style increment user";
154 yansplot.
SetTerminal(
"postscript eps color enh \"Times-BoldItalic\"");
155 yansplot.
SetLegend(
"SNR(dB)",
"Frame Success Rate");
160 nistplot.
SetTerminal(
"postscript eps color enh \"Times-BoldItalic\"");
161 nistplot.
SetLegend(
"SNR(dB)",
"Frame Success Rate");
166 tableplot.
SetTerminal(
"postscript eps color enh \"Times-BoldItalic\"");
167 tableplot.
SetLegend(
"SNR(dB)",
"Frame Success Rate");
168 tableplot.
SetExtra(plotExtra.str());
Parse command-line arguments.
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 GenerateOutput(std::ostream &os)
Writes gnuplot commands and data values to a single output stream.
void SetExtra(const std::string &extra)
Smart pointer class similar to boost::intrusive_ptr.
represent a single transmission mode
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
void SetMode(WifiMode mode)
Sets the selected payload transmission mode.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Every class exported by the ns3 library is enclosed in the ns3 namespace.