23 #include "ns3/command-line.h"
24 #include "ns3/gnuplot.h"
25 #include "ns3/nist-error-rate-model.h"
26 #include "ns3/table-based-error-rate-model.h"
27 #include "ns3/wifi-tx-vector.h"
28 #include "ns3/yans-error-rate-model.h"
36 main(
int argc,
char* argv[])
38 uint32_t frameSizeBytes = 1500;
39 std::ofstream yansfile(
"yans-frame-success-rate-n.plt");
40 std::ofstream nistfile(
"nist-frame-success-rate-n.plt");
41 std::ofstream tablefile(
"table-frame-success-rate-n.plt");
43 const std::vector<std::string> modes{
55 cmd.AddValue(
"FrameSize",
"The frame size in bytes", frameSizeBytes);
56 cmd.Parse(argc, argv);
67 uint32_t frameSizeBits = frameSizeBytes * 8;
69 for (
const auto& mode : modes)
71 std::cout << mode << std::endl;
79 for (
double snrDb = -5.0; snrDb <= 30.0; snrDb += 0.1)
81 double snr = std::pow(10.0, snrDb / 10.0);
83 double ps = yans->GetChunkSuccessRate(wifiMode, txVector, snr, frameSizeBits);
84 if (ps < 0.0 || ps > 1.0)
89 yansdataset.Add(snrDb, ps);
91 ps = nist->GetChunkSuccessRate(wifiMode, txVector, snr, frameSizeBits);
92 if (ps < 0.0 || ps > 1.0)
97 nistdataset.Add(snrDb, ps);
99 ps = table->GetChunkSuccessRate(wifiMode, txVector, snr, frameSizeBits);
100 if (ps < 0.0 || ps > 1.0)
105 tabledataset.Add(snrDb, ps);
113 yansplot.
SetTerminal(
"postscript eps color enh \"Times-BoldItalic\"");
114 yansplot.
SetLegend(
"SNR(dB)",
"Frame Success Rate");
115 yansplot.
SetExtra(
"set xrange [-5:30]\n\
116 set yrange [0:1.2]\n\
117 set style line 1 linewidth 5\n\
118 set style line 2 linewidth 5\n\
119 set style line 3 linewidth 5\n\
120 set style line 4 linewidth 5\n\
121 set style line 5 linewidth 5\n\
122 set style line 6 linewidth 5\n\
123 set style line 7 linewidth 5\n\
124 set style line 8 linewidth 5\n\
125 set style increment user");
129 nistplot.
SetTerminal(
"postscript eps color enh \"Times-BoldItalic\"");
130 nistplot.
SetLegend(
"SNR(dB)",
"Frame Success Rate");
131 nistplot.
SetExtra(
"set xrange [-5:30]\n\
132 set yrange [0:1.2]\n\
133 set style line 1 linewidth 5\n\
134 set style line 2 linewidth 5\n\
135 set style line 3 linewidth 5\n\
136 set style line 4 linewidth 5\n\
137 set style line 5 linewidth 5\n\
138 set style line 6 linewidth 5\n\
139 set style line 7 linewidth 5\n\
140 set style line 8 linewidth 5\n\
141 set style increment user");
146 tableplot.
SetTerminal(
"postscript eps color enh \"Times-BoldItalic\"");
147 tableplot.
SetLegend(
"SNR(dB)",
"Frame Success Rate");
148 tableplot.
SetExtra(
"set xrange [-5:30]\n\
149 set yrange [0:1.2]\n\
150 set style line 1 linewidth 5\n\
151 set style line 2 linewidth 5\n\
152 set style line 3 linewidth 5\n\
153 set style line 4 linewidth 5\n\
154 set style line 5 linewidth 5\n\
155 set style line 6 linewidth 5\n\
156 set style line 7 linewidth 5\n\
157 set style line 8 linewidth 5\n\
158 set style increment user");
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.