26#include "ns3/command-line.h"
27#include "ns3/gnuplot.h"
28#include "ns3/nist-error-rate-model.h"
29#include "ns3/table-based-error-rate-model.h"
30#include "ns3/wifi-tx-vector.h"
31#include "ns3/yans-error-rate-model.h"
39main(
int argc,
char* argv[])
42 bool tableErrorModelEnabled =
true;
43 bool yansErrorModelEnabled =
true;
44 bool nistErrorModelEnabled =
true;
48 std::string format(
"Ht");
51 cmd.AddValue(
"size",
"The size in bits", size);
52 cmd.AddValue(
"frameFormat",
"The frame format to use: Ht, Vht or He", format);
53 cmd.AddValue(
"beginMcs",
"The first MCS to test", beginMcs);
54 cmd.AddValue(
"endMcs",
"The last MCS to test", endMcs);
55 cmd.AddValue(
"stepMcs",
"The step between two MCSs to test", stepMcs);
56 cmd.AddValue(
"includeTableErrorModel",
57 "Flag to include/exclude Table-based error model",
58 tableErrorModelEnabled);
59 cmd.AddValue(
"includeYansErrorModel",
60 "Flag to include/exclude Yans error model",
61 yansErrorModelEnabled);
62 cmd.AddValue(
"includeNistErrorModel",
63 "Flag to include/exclude Nist error model",
64 nistErrorModelEnabled);
65 cmd.Parse(argc, argv);
67 std::ofstream errormodelfile(
"wifi-error-rate-models.plt");
74 std::vector<std::string> modes;
76 std::stringstream mode;
77 mode << format <<
"Mcs" << +beginMcs;
78 modes.push_back(mode.str());
79 for (uint8_t mcs = (beginMcs + stepMcs); mcs < endMcs; mcs += stepMcs)
82 mode << format <<
"Mcs" << +mcs;
83 modes.push_back(mode.str());
86 mode << format <<
"Mcs" << +endMcs;
87 modes.push_back(mode.str());
89 for (
uint32_t i = 0; i < modes.size(); i++)
91 std::cout << modes[i] << std::endl;
97 for (
double snr = -5.0; snr <= (endMcs * 5); snr += 0.1)
99 double ps = yans->GetChunkSuccessRate(
WifiMode(modes[i]),
101 std::pow(10.0, snr / 10.0),
103 if (ps < 0 || ps > 1)
108 yansdataset.Add(snr, 1 - ps);
109 ps = nist->GetChunkSuccessRate(
WifiMode(modes[i]),
111 std::pow(10.0, snr / 10.0),
113 if (ps < 0 || ps > 1)
118 nistdataset.Add(snr, 1 - ps);
119 ps = table->GetChunkSuccessRate(
WifiMode(modes[i]),
121 std::pow(10.0, snr / 10.0),
123 if (ps < 0 || ps > 1)
128 tabledataset.Add(snr, 1 - ps);
131 if (tableErrorModelEnabled)
133 std::stringstream ss;
134 ss <<
"Table-" << modes[i];
135 tabledataset.SetTitle(ss.str());
138 if (yansErrorModelEnabled)
140 std::stringstream ss;
141 ss <<
"Yans-" << modes[i];
142 yansdataset.SetTitle(ss.str());
145 if (nistErrorModelEnabled)
147 std::stringstream ss;
148 ss <<
"Nist-" << modes[i];
149 nistdataset.SetTitle(ss.str());
154 plot.
SetTerminal(
"postscript eps color enh \"Times-BoldItalic\"");
155 plot.
SetLegend(
"SNR(dB)",
"Frame Error Rate");
157 std::stringstream plotExtra;
158 plotExtra <<
"set xrange [-5:" << endMcs * 5 <<
"]\n\
160set yrange [0.0001:1]\n";
162 uint8_t lineNumber = 1;
163 for (
uint32_t i = 0; i < modes.size(); i++)
165 if (tableErrorModelEnabled)
167 plotExtra <<
"set style line " << +lineNumber++
168 <<
" linewidth 5 linecolor rgb \"red\" \n";
170 if (yansErrorModelEnabled)
172 plotExtra <<
"set style line " << +lineNumber++
173 <<
" linewidth 5 linecolor rgb \"green\" \n";
175 if (nistErrorModelEnabled)
177 plotExtra <<
"set style line " << +lineNumber++
178 <<
" linewidth 5 linecolor rgb \"blue\" \n";
182 plotExtra <<
"set style increment user";
186 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.
Every class exported by the ns3 library is enclosed in the ns3 namespace.