26 #include "ns3/gnuplot.h"
27 #include "ns3/command-line.h"
28 #include "ns3/yans-error-rate-model.h"
29 #include "ns3/nist-error-rate-model.h"
30 #include "ns3/table-based-error-rate-model.h"
31 #include "ns3/wifi-tx-vector.h"
35 int main (
int argc,
char *argv[])
37 uint32_t FrameSize = 1500;
38 std::ofstream
file (
"frame-success-rate-dsss.plt");
39 std::vector <std::string> modes;
41 modes.push_back (
"DsssRate1Mbps");
42 modes.push_back (
"DsssRate2Mbps");
43 modes.push_back (
"DsssRate5_5Mbps");
44 modes.push_back (
"DsssRate11Mbps");
47 cmd.AddValue (
"FrameSize",
"The frame size in bytes", FrameSize);
48 cmd.Parse (argc, argv);
57 for (uint32_t i = 0; i < modes.size (); i++)
59 std::cout << modes[i] << std::endl;
63 for (
double snr = -10.0; snr <= 20.0; snr += 0.1)
65 double psYans = yans->GetChunkSuccessRate (
WifiMode (modes[i]), txVector, std::pow (10.0, snr / 10.0), FrameSize * 8);
66 if (psYans < 0.0 || psYans > 1.0)
71 double psNist = nist->GetChunkSuccessRate (
WifiMode (modes[i]), txVector, std::pow (10.0, snr / 10.0), FrameSize * 8);
72 if (psNist < 0.0 || psNist > 1.0)
74 std::cout<<psNist<<std::endl;
82 double psTable = table->GetChunkSuccessRate (
WifiMode (modes[i]), txVector, std::pow (10.0, snr / 10.0), FrameSize * 8);
83 if (psTable < 0.0 || psTable > 1.0)
85 std::cout << psTable << std::endl;
89 if (psTable != psYans)
93 dataset.Add (snr, psYans);
99 plot.
SetTerminal (
"postscript eps color enh \"Times-BoldItalic\"");
100 plot.
SetLegend (
"SNR(dB)",
"Frame Success Rate");
101 plot.
SetExtra (
"set xrange [-10:20]\n\
102 set yrange [0:1.2]\n\
103 set style line 1 linewidth 5\n\
104 set style line 2 linewidth 5\n\
105 set style line 3 linewidth 5\n\
106 set style line 4 linewidth 5\n\
107 set style line 5 linewidth 5\n\
108 set style line 6 linewidth 5\n\
109 set style line 7 linewidth 5\n\
110 set style line 8 linewidth 5\n\
111 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.