29 #include "ns3/gnuplot.h" 30 #include "ns3/command-line.h" 31 #include "ns3/yans-error-rate-model.h" 32 #include "ns3/nist-error-rate-model.h" 33 #include "ns3/table-based-error-rate-model.h" 34 #include "ns3/wifi-tx-vector.h" 38 int main (
int argc,
char *argv[])
40 uint32_t size = 1500 * 8;
41 bool tableErrorModelEnabled =
true;
42 bool yansErrorModelEnabled =
true;
43 bool nistErrorModelEnabled =
true;
47 std::string format (
"Ht");
50 cmd.AddValue (
"size",
"The size in bits", size);
51 cmd.AddValue (
"frameFormat",
"The frame format to use: Ht, Vht or He", format);
52 cmd.AddValue (
"beginMcs",
"The first MCS to test", beginMcs);
53 cmd.AddValue (
"endMcs",
"The last MCS to test", endMcs);
54 cmd.AddValue (
"stepMcs",
"The step between two MCSs to test", stepMcs);
55 cmd.AddValue (
"includeTableErrorModel",
"Flag to include/exclude Table-based error model", tableErrorModelEnabled);
56 cmd.AddValue (
"includeYansErrorModel",
"Flag to include/exclude Yans error model", yansErrorModelEnabled);
57 cmd.AddValue (
"includeNistErrorModel",
"Flag to include/exclude Nist error model", nistErrorModelEnabled);
58 cmd.Parse (argc, argv);
60 std::ofstream errormodelfile (
"wifi-error-rate-models.plt");
67 std::vector <std::string> modes;
69 std::stringstream mode;
70 mode << format <<
"Mcs" << +beginMcs;
71 modes.push_back (mode.str ());
72 for (uint8_t mcs = (beginMcs + stepMcs); mcs < endMcs; mcs += stepMcs)
75 mode << format <<
"Mcs" << +mcs;
76 modes.push_back (mode.str ());
79 mode << format <<
"Mcs" << +endMcs;
80 modes.push_back (mode.str ());
82 for (uint32_t i = 0; i < modes.size (); i++)
84 std::cout << modes[i] << std::endl;
88 txVector.SetMode (modes[i]);
90 for (
double snr = -5.0; snr <= (endMcs * 5); snr += 0.1)
98 yansdataset.Add (snr, 1 - ps);
99 ps = nist->GetChunkSuccessRate (
WifiMode (modes[i]), txVector, std::pow (10.0, snr / 10.0), size);
100 if (ps < 0 || ps > 1)
105 nistdataset.Add (snr, 1 - ps);
106 ps = table->GetChunkSuccessRate (
WifiMode (modes[i]), txVector, std::pow (10.0, snr / 10.0), size);
107 if (ps < 0 || ps > 1)
112 tabledataset.Add (snr, 1 - ps);
115 if (tableErrorModelEnabled)
117 std::stringstream ss;
118 ss <<
"Table-" << modes[i];
119 tabledataset.SetTitle (ss.str());
122 if (yansErrorModelEnabled)
124 std::stringstream ss;
125 ss <<
"Yans-" << modes[i];
126 yansdataset.SetTitle (ss.str ());
129 if (nistErrorModelEnabled)
131 std::stringstream ss;
132 ss <<
"Nist-" << modes[i];
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\ 144 set 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++ <<
" linewidth 5 linecolor rgb \"red\" \n";
153 if (yansErrorModelEnabled)
155 plotExtra <<
"set style line " << +lineNumber++ <<
" linewidth 5 linecolor rgb \"green\" \n";
157 if (nistErrorModelEnabled)
159 plotExtra <<
"set style line " << +lineNumber++ <<
" linewidth 5 linecolor rgb \"blue\" \n";
163 plotExtra <<
"set style increment user";
167 errormodelfile.close ();
Smart pointer class similar to boost::intrusive_ptr.
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
Class to represent a 2D points plot.
void AddDataset(const GnuplotDataset &dataset)
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
a simple class to generate gnuplot-ready plotting commands from a set of datasets.
void GenerateOutput(std::ostream &os)
Writes gnuplot commands and data values to a single output stream.
Parse command-line arguments.
void SetLegend(const std::string &xLegend, const std::string &yLegend)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void SetExtra(const std::string &extra)
double GetChunkSuccessRate(WifiMode mode, WifiTxVector txVector, double snr, uint64_t nbits) const
This method returns the probability that the given 'chunk' of the packet will be successfully receive...
void SetTerminal(const std::string &terminal)