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"
38 main(
int argc,
char* argv[])
40 uint32_t frameSizeBytes = 1500;
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", frameSizeBytes);
64 cmd.Parse(argc, argv);
75 uint32_t frameSizeBits = frameSizeBytes * 8;
77 for (
const auto& mode : modes)
79 std::cout << mode << std::endl;
87 for (
double snrDb = -5.0; snrDb <= 55.0; snrDb += 0.1)
89 double snr = std::pow(10.0, snrDb / 10.0);
91 double ps = yans->GetChunkSuccessRate(wifiMode, txVector, snr, frameSizeBits);
92 if (ps < 0.0 || ps > 1.0)
97 yansdataset.Add(snrDb, ps);
99 ps = nist->GetChunkSuccessRate(wifiMode, txVector, snr, frameSizeBits);
100 if (ps < 0.0 || ps > 1.0)
105 nistdataset.Add(snrDb, ps);
107 ps = table->GetChunkSuccessRate(wifiMode, txVector, snr, frameSizeBits);
108 if (ps < 0.0 || ps > 1.0)
113 tabledataset.Add(snrDb, ps);
121 std::stringstream plotExtra;
122 plotExtra <<
"set xrange [-5:55]\n\
125 const std::vector<std::string>
colors{
142 NS_ASSERT_MSG(
colors.size() == modes.size(),
"Colors and modes vectors have different sizes");
144 for (std::size_t i = 0; i < modes.size(); i++)
146 plotExtra <<
"set style line " << (i + 1) <<
" linewidth 5 linecolor rgb \"" <<
colors[i]
149 plotExtra <<
"set style increment user";
151 yansplot.
SetTerminal(
"postscript eps color enh \"Times-BoldItalic\"");
152 yansplot.
SetLegend(
"SNR(dB)",
"Frame Success Rate");
157 nistplot.
SetTerminal(
"postscript eps color enh \"Times-BoldItalic\"");
158 nistplot.
SetLegend(
"SNR(dB)",
"Frame Success Rate");
163 tableplot.
SetTerminal(
"postscript eps color enh \"Times-BoldItalic\"");
164 tableplot.
SetLegend(
"SNR(dB)",
"Frame Success Rate");
165 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.