15#include "ns3/command-line.h"
16#include "ns3/gnuplot.h"
17#include "ns3/nist-error-rate-model.h"
18#include "ns3/table-based-error-rate-model.h"
19#include "ns3/wifi-tx-vector.h"
20#include "ns3/yans-error-rate-model.h"
28main(
int argc,
char* argv[])
31 bool tableErrorModelEnabled =
true;
32 bool yansErrorModelEnabled =
true;
33 bool nistErrorModelEnabled =
true;
37 std::string format(
"Ht");
40 cmd.AddValue(
"size",
"The size in bits", size);
41 cmd.AddValue(
"frameFormat",
"The frame format to use: Ht, Vht or He", format);
42 cmd.AddValue(
"beginMcs",
"The first MCS to test", beginMcs);
43 cmd.AddValue(
"endMcs",
"The last MCS to test", endMcs);
44 cmd.AddValue(
"stepMcs",
"The step between two MCSs to test", stepMcs);
45 cmd.AddValue(
"includeTableErrorModel",
46 "Flag to include/exclude Table-based error model",
47 tableErrorModelEnabled);
48 cmd.AddValue(
"includeYansErrorModel",
49 "Flag to include/exclude Yans error model",
50 yansErrorModelEnabled);
51 cmd.AddValue(
"includeNistErrorModel",
52 "Flag to include/exclude Nist error model",
53 nistErrorModelEnabled);
54 cmd.Parse(argc, argv);
56 std::ofstream errormodelfile(
"wifi-error-rate-models.plt");
63 std::vector<std::string> modes;
65 std::stringstream mode;
66 mode << format <<
"Mcs" << +beginMcs;
67 modes.push_back(mode.str());
68 for (uint8_t mcs = (beginMcs + stepMcs); mcs < endMcs; mcs += stepMcs)
71 mode << format <<
"Mcs" << +mcs;
72 modes.push_back(mode.str());
75 mode << format <<
"Mcs" << +endMcs;
76 modes.push_back(mode.str());
78 for (
const auto& mode : modes)
80 std::cout << mode << std::endl;
88 for (
double snrDb = -5.0; snrDb <= (endMcs * 5); snrDb += 0.1)
90 double snr = std::pow(10.0, snrDb / 10.0);
92 double ps = yans->GetChunkSuccessRate(wifiMode, txVector, snr, size);
98 yansdataset.Add(snrDb, 1 - ps);
99 ps = nist->GetChunkSuccessRate(wifiMode, txVector, snr, size);
100 if (ps < 0 || ps > 1)
105 nistdataset.Add(snrDb, 1 - ps);
106 ps = table->GetChunkSuccessRate(wifiMode, txVector, snr, size);
107 if (ps < 0 || ps > 1)
112 tabledataset.Add(snrDb, 1 - ps);
115 if (tableErrorModelEnabled)
117 std::stringstream ss;
118 ss <<
"Table-" << mode;
119 tabledataset.SetTitle(ss.str());
122 if (yansErrorModelEnabled)
124 std::stringstream ss;
125 ss <<
"Yans-" << mode;
126 yansdataset.SetTitle(ss.str());
129 if (nistErrorModelEnabled)
131 std::stringstream ss;
132 ss <<
"Nist-" << mode;
133 nistdataset.SetTitle(ss.str());
138 plot.
SetTerminal(
"postscript eps color enh \"Times-BoldItalic\"");
139 plot.
SetLegend(
"SNR(dB)",
"Frame Error Rate");
141 std::stringstream plotExtra;
142 plotExtra <<
"set xrange [-5:" << endMcs * 5 <<
"]\n\
144set yrange [0.0001:1]\n";
146 uint8_t lineNumber = 1;
147 for (
uint32_t i = 0; i < modes.size(); i++)
149 if (tableErrorModelEnabled)
151 plotExtra <<
"set style line " << +lineNumber++
152 <<
" linewidth 5 linecolor rgb \"red\" \n";
154 if (yansErrorModelEnabled)
156 plotExtra <<
"set style line " << +lineNumber++
157 <<
" linewidth 5 linecolor rgb \"green\" \n";
159 if (nistErrorModelEnabled)
161 plotExtra <<
"set style line " << +lineNumber++
162 <<
" linewidth 5 linecolor rgb \"blue\" \n";
166 plotExtra <<
"set style increment user";
170 errormodelfile.close();
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.
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.