26#include "ns3/command-line.h" 
   27#include "ns3/gnuplot.h" 
   28#include "ns3/nist-error-rate-model.h" 
   29#include "ns3/table-based-error-rate-model.h" 
   30#include "ns3/wifi-tx-vector.h" 
   31#include "ns3/yans-error-rate-model.h" 
   39main(
int argc, 
char* argv[])
 
   42    bool tableErrorModelEnabled = 
true;
 
   43    bool yansErrorModelEnabled = 
true;
 
   44    bool nistErrorModelEnabled = 
true;
 
   48    std::string format(
"Ht");
 
   51    cmd.AddValue(
"size", 
"The size in bits", size);
 
   52    cmd.AddValue(
"frameFormat", 
"The frame format to use: Ht, Vht or He", format);
 
   53    cmd.AddValue(
"beginMcs", 
"The first MCS to test", beginMcs);
 
   54    cmd.AddValue(
"endMcs", 
"The last MCS to test", endMcs);
 
   55    cmd.AddValue(
"stepMcs", 
"The step between two MCSs to test", stepMcs);
 
   56    cmd.AddValue(
"includeTableErrorModel",
 
   57                 "Flag to include/exclude Table-based error model",
 
   58                 tableErrorModelEnabled);
 
   59    cmd.AddValue(
"includeYansErrorModel",
 
   60                 "Flag to include/exclude Yans error model",
 
   61                 yansErrorModelEnabled);
 
   62    cmd.AddValue(
"includeNistErrorModel",
 
   63                 "Flag to include/exclude Nist error model",
 
   64                 nistErrorModelEnabled);
 
   65    cmd.Parse(argc, argv);
 
   67    std::ofstream errormodelfile(
"wifi-error-rate-models.plt");
 
   74    std::vector<std::string> modes;
 
   76    std::stringstream mode;
 
   77    mode << format << 
"Mcs" << +beginMcs;
 
   78    modes.push_back(mode.str());
 
   79    for (uint8_t mcs = (beginMcs + stepMcs); mcs < endMcs; mcs += stepMcs)
 
   82        mode << format << 
"Mcs" << +mcs;
 
   83        modes.push_back(mode.str());
 
   86    mode << format << 
"Mcs" << +endMcs;
 
   87    modes.push_back(mode.str());
 
   89    for (
const auto& mode : modes)
 
   91        std::cout << mode << std::endl;
 
   99        for (
double snrDb = -5.0; snrDb <= (endMcs * 5); snrDb += 0.1)
 
  101            double snr = std::pow(10.0, snrDb / 10.0);
 
  103            double ps = yans->GetChunkSuccessRate(wifiMode, txVector, snr, size);
 
  104            if (ps < 0 || ps > 1)
 
  109            yansdataset.Add(snrDb, 1 - ps);
 
  110            ps = nist->GetChunkSuccessRate(wifiMode, txVector, snr, size);
 
  111            if (ps < 0 || ps > 1)
 
  116            nistdataset.Add(snrDb, 1 - ps);
 
  117            ps = table->GetChunkSuccessRate(wifiMode, txVector, snr, size);
 
  118            if (ps < 0 || ps > 1)
 
  123            tabledataset.Add(snrDb, 1 - ps);
 
  126        if (tableErrorModelEnabled)
 
  128            std::stringstream ss;
 
  129            ss << 
"Table-" << mode;
 
  130            tabledataset.SetTitle(ss.str());
 
  133        if (yansErrorModelEnabled)
 
  135            std::stringstream ss;
 
  136            ss << 
"Yans-" << mode;
 
  137            yansdataset.SetTitle(ss.str());
 
  140        if (nistErrorModelEnabled)
 
  142            std::stringstream ss;
 
  143            ss << 
"Nist-" << mode;
 
  144            nistdataset.SetTitle(ss.str());
 
  149    plot.
SetTerminal(
"postscript eps color enh \"Times-BoldItalic\"");
 
  150    plot.
SetLegend(
"SNR(dB)", 
"Frame Error Rate");
 
  152    std::stringstream plotExtra;
 
  153    plotExtra << 
"set xrange [-5:" << endMcs * 5 << 
"]\n\ 
  155set yrange [0.0001:1]\n";
 
  157    uint8_t lineNumber = 1;
 
  158    for (
uint32_t i = 0; i < modes.size(); i++)
 
  160        if (tableErrorModelEnabled)
 
  162            plotExtra << 
"set style line " << +lineNumber++
 
  163                      << 
" linewidth 5 linecolor rgb \"red\" \n";
 
  165        if (yansErrorModelEnabled)
 
  167            plotExtra << 
"set style line " << +lineNumber++
 
  168                      << 
" linewidth 5 linecolor rgb \"green\" \n";
 
  170        if (nistErrorModelEnabled)
 
  172            plotExtra << 
"set style line " << +lineNumber++
 
  173                      << 
" linewidth 5 linecolor rgb \"blue\" \n";
 
  177    plotExtra << 
"set style increment user";
 
  181    errormodelfile.close();
 
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.