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
file(
"frame-success-rate-dsss.plt");
41 const std::vector<std::string> modes{
49 cmd.AddValue(
"FrameSize",
"The frame size in bytes", frameSizeBytes);
50 cmd.Parse(argc, argv);
59 uint32_t frameSizeBits = frameSizeBytes * 8;
61 for (
const auto& mode : modes)
63 std::cout << mode << std::endl;
69 for (
double snrDb = -10.0; snrDb <= 20.0; snrDb += 0.1)
71 double snr = std::pow(10.0, snrDb / 10.0);
73 double psYans = yans->GetChunkSuccessRate(wifiMode, txVector, snr, frameSizeBits);
74 if (psYans < 0.0 || psYans > 1.0)
79 double psNist = nist->GetChunkSuccessRate(wifiMode, txVector, snr, frameSizeBits);
80 if (psNist < 0.0 || psNist > 1.0)
82 std::cout << psNist << std::endl;
90 double psTable = table->GetChunkSuccessRate(wifiMode, txVector, snr, frameSizeBits);
91 if (psTable < 0.0 || psTable > 1.0)
93 std::cout << psTable << std::endl;
97 if (psTable != psYans)
101 dataset.Add(snrDb, psYans);
107 plot.
SetTerminal(
"postscript eps color enh \"Times-BoldItalic\"");
108 plot.
SetLegend(
"SNR(dB)",
"Frame Success Rate");
109 plot.
SetExtra(
"set xrange [-10:20]\n\
110 set yrange [0:1.2]\n\
111 set style line 1 linewidth 5\n\
112 set style line 2 linewidth 5\n\
113 set style line 3 linewidth 5\n\
114 set style line 4 linewidth 5\n\
115 set style line 5 linewidth 5\n\
116 set style line 6 linewidth 5\n\
117 set style line 7 linewidth 5\n\
118 set style line 8 linewidth 5\n\
119 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.