14#include "ns3/command-line.h"
15#include "ns3/gnuplot.h"
16#include "ns3/nist-error-rate-model.h"
17#include "ns3/table-based-error-rate-model.h"
18#include "ns3/wifi-tx-vector.h"
19#include "ns3/yans-error-rate-model.h"
27main(
int argc,
char* argv[])
30 std::ofstream yansfile(
"yans-frame-success-rate-be.plt");
31 std::ofstream nistfile(
"nist-frame-success-rate-be.plt");
32 std::ofstream tablefile(
"table-frame-success-rate-be.plt");
34 const std::vector<std::string> modes{
52 cmd.AddValue(
"FrameSize",
"The frame size", frameSizeBytes);
53 cmd.Parse(argc, argv);
64 uint32_t frameSizeBits = frameSizeBytes * 8;
66 for (
const auto& mode : modes)
68 std::cout << mode << std::endl;
76 for (
double snrDb = -5.0; snrDb <= 55.0; snrDb += 0.1)
78 double snr = std::pow(10.0, snrDb / 10.0);
80 double ps = yans->GetChunkSuccessRate(wifiMode, txVector, snr, frameSizeBits);
81 if (ps < 0.0 || ps > 1.0)
86 yansdataset.Add(snrDb, ps);
88 ps = nist->GetChunkSuccessRate(wifiMode, txVector, snr, frameSizeBits);
89 if (ps < 0.0 || ps > 1.0)
94 nistdataset.Add(snrDb, ps);
96 ps = table->GetChunkSuccessRate(wifiMode, txVector, snr, frameSizeBits);
97 if (ps < 0.0 || ps > 1.0)
102 tabledataset.Add(snrDb, ps);
110 std::stringstream plotExtra;
111 plotExtra <<
"set xrange [-5:55]\n\
114 const std::vector<std::string>
colors{
131 NS_ASSERT_MSG(
colors.size() == modes.size(),
"Colors and modes vectors have different sizes");
133 for (std::size_t i = 0; i < modes.size(); i++)
135 plotExtra <<
"set style line " << (i + 1) <<
" linewidth 5 linecolor rgb \"" <<
colors[i]
138 plotExtra <<
"set style increment user";
140 yansplot.
SetTerminal(
"postscript eps color enh \"Times-BoldItalic\"");
141 yansplot.
SetLegend(
"SNR(dB)",
"Frame Success Rate");
146 nistplot.
SetTerminal(
"postscript eps color enh \"Times-BoldItalic\"");
147 nistplot.
SetLegend(
"SNR(dB)",
"Frame Success Rate");
152 tableplot.
SetTerminal(
"postscript eps color enh \"Times-BoldItalic\"");
153 tableplot.
SetLegend(
"SNR(dB)",
"Frame Success Rate");
154 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...
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Every class exported by the ns3 library is enclosed in the ns3 namespace.