12#include "ns3/command-line.h"
13#include "ns3/gnuplot.h"
14#include "ns3/nist-error-rate-model.h"
15#include "ns3/table-based-error-rate-model.h"
16#include "ns3/wifi-tx-vector.h"
17#include "ns3/yans-error-rate-model.h"
25main(
int argc,
char* argv[])
28 std::ofstream
file(
"frame-success-rate-dsss.plt");
30 const std::vector<std::string> modes{
38 cmd.AddValue(
"FrameSize",
"The frame size in bytes", frameSizeBytes);
39 cmd.Parse(argc, argv);
48 uint32_t frameSizeBits = frameSizeBytes * 8;
50 for (
const auto& mode : modes)
52 std::cout << mode << std::endl;
58 for (
double snrDb = -10.0; snrDb <= 20.0; snrDb += 0.1)
60 double snr = std::pow(10.0, snrDb / 10.0);
62 double psYans = yans->GetChunkSuccessRate(wifiMode, txVector, snr, frameSizeBits);
63 if (psYans < 0.0 || psYans > 1.0)
68 double psNist = nist->GetChunkSuccessRate(wifiMode, txVector, snr, frameSizeBits);
69 if (psNist < 0.0 || psNist > 1.0)
71 std::cout << psNist << std::endl;
79 double psTable = table->GetChunkSuccessRate(wifiMode, txVector, snr, frameSizeBits);
80 if (psTable < 0.0 || psTable > 1.0)
82 std::cout << psTable << std::endl;
86 if (psTable != psYans)
90 dataset.Add(snrDb, psYans);
96 plot.
SetTerminal(
"postscript eps color enh \"Times-BoldItalic\"");
97 plot.
SetLegend(
"SNR(dB)",
"Frame Success Rate");
98 plot.
SetExtra(
"set xrange [-10:20]\n\
100set style line 1 linewidth 5\n\
101set style line 2 linewidth 5\n\
102set style line 3 linewidth 5\n\
103set style line 4 linewidth 5\n\
104set style line 5 linewidth 5\n\
105set style line 6 linewidth 5\n\
106set style line 7 linewidth 5\n\
107set style line 8 linewidth 5\n\
108set 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.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Every class exported by the ns3 library is enclosed in the ns3 namespace.