examples: Update wifi OFDM validation examples with table-based error model

This commit is contained in:
Sébastien Deronne
2020-07-14 18:27:15 +02:00
committed by Sebastien Deronne
parent 3d21933f2c
commit be8a4fe60a
5 changed files with 171 additions and 30 deletions

View File

@@ -27,6 +27,7 @@
#include "ns3/command-line.h"
#include "ns3/yans-error-rate-model.h"
#include "ns3/nist-error-rate-model.h"
#include "ns3/table-based-error-rate-model.h"
#include "ns3/wifi-tx-vector.h"
using namespace ns3;
@@ -50,6 +51,7 @@ int main (int argc, char *argv[])
Ptr <YansErrorRateModel> yans = CreateObject<YansErrorRateModel> ();
Ptr <NistErrorRateModel> nist = CreateObject<NistErrorRateModel> ();
Ptr <TableBasedErrorRateModel> table = CreateObject<TableBasedErrorRateModel> ();
WifiTxVector txVector;
for (uint32_t i = 0; i < modes.size (); i++)
@@ -60,13 +62,13 @@ int main (int argc, char *argv[])
for (double snr = -10.0; snr <= 20.0; snr += 0.1)
{
double psYans = yans->GetChunkSuccessRate (WifiMode (modes[i]), txVector, std::pow (10.0,snr / 10.0), FrameSize * 8);
double psYans = yans->GetChunkSuccessRate (WifiMode (modes[i]), txVector, std::pow (10.0, snr / 10.0), FrameSize * 8);
if (psYans < 0.0 || psYans > 1.0)
{
//error
exit (1);
}
double psNist = nist->GetChunkSuccessRate (WifiMode (modes[i]), txVector, std::pow (10.0,snr / 10.0), FrameSize * 8);
double psNist = nist->GetChunkSuccessRate (WifiMode (modes[i]), txVector, std::pow (10.0, snr / 10.0), FrameSize * 8);
if (psNist < 0.0 || psNist > 1.0)
{
std::cout<<psNist<<std::endl;
@@ -77,7 +79,18 @@ int main (int argc, char *argv[])
{
exit (1);
}
dataset.Add (snr, psNist);
double psTable = table->GetChunkSuccessRate (WifiMode (modes[i]), txVector, std::pow (10.0, snr / 10.0), FrameSize * 8);
if (psTable < 0.0 || psTable > 1.0)
{
std::cout << psTable << std::endl;
//error
exit (1);
}
if (psTable != psYans)
{
exit (1);
}
dataset.Add (snr, psYans);
}
plot.AddDataset (dataset);

View File

@@ -16,10 +16,10 @@
* Author: Sébastien Deronne <sebastien.deronne@gmail.com>
*/
// This example is used to validate NIST and YANS error rate models for HE rates.
// This example is used to validate Nist, Yans and Table-based error rate models for HE rates.
//
// It outputs plots of the Frame Success Rate versus the Signal-to-noise ratio for
// both NIST and YANS error rate models and for every HE MCS value.
// Nist, Yans and Table-based error rate models and for every HE MCS value.
#include <fstream>
#include <cmath>
@@ -27,6 +27,7 @@
#include "ns3/command-line.h"
#include "ns3/yans-error-rate-model.h"
#include "ns3/nist-error-rate-model.h"
#include "ns3/table-based-error-rate-model.h"
#include "ns3/wifi-tx-vector.h"
using namespace ns3;
@@ -36,6 +37,7 @@ int main (int argc, char *argv[])
uint32_t FrameSize = 1500; //bytes
std::ofstream yansfile ("yans-frame-success-rate-ax.plt");
std::ofstream nistfile ("nist-frame-success-rate-ax.plt");
std::ofstream tablefile ("table-frame-success-rate-ax.plt");
std::vector <std::string> modes;
modes.push_back ("HeMcs0");
@@ -57,9 +59,11 @@ int main (int argc, char *argv[])
Gnuplot yansplot = Gnuplot ("yans-frame-success-rate-ax.eps");
Gnuplot nistplot = Gnuplot ("nist-frame-success-rate-ax.eps");
Gnuplot tableplot = Gnuplot ("table-frame-success-rate-ax.eps");
Ptr <YansErrorRateModel> yans = CreateObject<YansErrorRateModel> ();
Ptr <NistErrorRateModel> nist = CreateObject<NistErrorRateModel> ();
Ptr <TableBasedErrorRateModel> table = CreateObject<TableBasedErrorRateModel> ();
WifiTxVector txVector;
for (uint32_t i = 0; i < modes.size (); i++)
@@ -67,11 +71,12 @@ int main (int argc, char *argv[])
std::cout << modes[i] << std::endl;
Gnuplot2dDataset yansdataset (modes[i]);
Gnuplot2dDataset nistdataset (modes[i]);
Gnuplot2dDataset tabledataset (modes[i]);
txVector.SetMode (modes[i]);
for (double snr = -5.0; snr <= 40.0; snr += 0.1)
{
double ps = yans->GetChunkSuccessRate (WifiMode (modes[i]), txVector, std::pow (10.0,snr / 10.0), FrameSize * 8);
double ps = yans->GetChunkSuccessRate (WifiMode (modes[i]), txVector, std::pow (10.0, snr / 10.0), FrameSize * 8);
if (ps < 0.0 || ps > 1.0)
{
//error
@@ -79,17 +84,26 @@ int main (int argc, char *argv[])
}
yansdataset.Add (snr, ps);
ps = nist->GetChunkSuccessRate (WifiMode (modes[i]), txVector, std::pow (10.0,snr / 10.0), FrameSize * 8);
ps = nist->GetChunkSuccessRate (WifiMode (modes[i]), txVector, std::pow (10.0, snr / 10.0), FrameSize * 8);
if (ps < 0.0 || ps > 1.0)
{
//error
exit (1);
}
nistdataset.Add (snr, ps);
ps = table->GetChunkSuccessRate (WifiMode (modes[i]), txVector, std::pow (10.0, snr / 10.0), FrameSize * 8);
if (ps < 0.0 || ps > 1.0)
{
//error
exit (1);
}
tabledataset.Add (snr, ps);
}
yansplot.AddDataset (yansdataset);
nistplot.AddDataset (nistdataset);
tableplot.AddDataset (tabledataset);
}
yansplot.SetTerminal ("postscript eps color enh \"Times-BoldItalic\"");
@@ -107,7 +121,8 @@ set style line 8 linewidth 5\n\
set style line 9 linewidth 5\n\
set style line 10 linewidth 5\n\
set style line 11 linewidth 5\n\
set style increment user" );
set style line 12 linewidth 5\n\
set style increment user");
yansplot.GenerateOutput (yansfile);
yansfile.close ();
@@ -126,9 +141,30 @@ set style line 8 linewidth 5\n\
set style line 9 linewidth 5\n\
set style line 10 linewidth 5\n\
set style line 11 linewidth 5\n\
set style increment user" );
set style line 12 linewidth 5\n\
set style increment user");
nistplot.GenerateOutput (nistfile);
nistfile.close ();
}
tableplot.SetTerminal ("postscript eps color enh \"Times-BoldItalic\"");
tableplot.SetLegend ("SNR(dB)", "Frame Success Rate");
tableplot.SetExtra ("set xrange [-5:55]\n\
set yrange [0:1]\n\
set style line 1 linewidth 5\n\
set style line 2 linewidth 5\n\
set style line 3 linewidth 5\n\
set style line 4 linewidth 5\n\
set style line 5 linewidth 5\n\
set style line 6 linewidth 5\n\
set style line 7 linewidth 5\n\
set style line 8 linewidth 5\n\
set style line 9 linewidth 5\n\
set style line 10 linewidth 5\n\
set style line 11 linewidth 5\n\
set style line 12 linewidth 5\n\
set style increment user");
tableplot.GenerateOutput (tablefile);
tablefile.close ();
}

View File

@@ -16,10 +16,10 @@
* Author: Sébastien Deronne <sebastien.deronne@gmail.com>
*/
// This example is used to validate NIST and YANS error rate models for HT rates.
// This example is used to validate Nist, Yans and Table-based error rate models for HT rates.
//
// It outputs plots of the Frame Success Rate versus the Signal-to-noise ratio for
// both NIST and YANS error rate models and for every HT MCS value.
// Nist, Yans and Table-based error rate models and for every HT MCS value.
#include <fstream>
#include <cmath>
@@ -27,6 +27,7 @@
#include "ns3/command-line.h"
#include "ns3/yans-error-rate-model.h"
#include "ns3/nist-error-rate-model.h"
#include "ns3/table-based-error-rate-model.h"
#include "ns3/wifi-tx-vector.h"
using namespace ns3;
@@ -36,6 +37,7 @@ int main (int argc, char *argv[])
uint32_t FrameSize = 1500; //bytes
std::ofstream yansfile ("yans-frame-success-rate-n.plt");
std::ofstream nistfile ("nist-frame-success-rate-n.plt");
std::ofstream tablefile ("table-frame-success-rate-n.plt");
std::vector <std::string> modes;
modes.push_back ("HtMcs0");
@@ -54,21 +56,24 @@ int main (int argc, char *argv[])
Gnuplot yansplot = Gnuplot ("yans-frame-success-rate-n.eps");
Gnuplot nistplot = Gnuplot ("nist-frame-success-rate-n.eps");
Gnuplot tableplot = Gnuplot ("table-frame-success-rate-n.eps");
WifiTxVector txVector;
Ptr <YansErrorRateModel> yans = CreateObject<YansErrorRateModel> ();
Ptr <NistErrorRateModel> nist = CreateObject<NistErrorRateModel> ();
Ptr <TableBasedErrorRateModel> table = CreateObject<TableBasedErrorRateModel> ();
for (uint32_t i = 0; i < modes.size (); i++)
{
std::cout << modes[i] << std::endl;
Gnuplot2dDataset yansdataset (modes[i]);
Gnuplot2dDataset nistdataset (modes[i]);
Gnuplot2dDataset tabledataset (modes[i]);
txVector.SetMode (modes[i]);
for (double snr = -5.0; snr <= 30.0; snr += 0.1)
{
double ps = yans->GetChunkSuccessRate (WifiMode (modes[i]), txVector, std::pow (10.0,snr / 10.0), FrameSize * 8);
double ps = yans->GetChunkSuccessRate (WifiMode (modes[i]), txVector, std::pow (10.0, snr / 10.0), FrameSize * 8);
if (ps < 0.0 || ps > 1.0)
{
//error
@@ -76,17 +81,26 @@ int main (int argc, char *argv[])
}
yansdataset.Add (snr, ps);
ps = nist->GetChunkSuccessRate (WifiMode (modes[i]), txVector, std::pow (10.0,snr / 10.0), FrameSize * 8);
ps = nist->GetChunkSuccessRate (WifiMode (modes[i]), txVector, std::pow (10.0, snr / 10.0), FrameSize * 8);
if (ps < 0.0 || ps > 1.0)
{
//error
exit (1);
}
nistdataset.Add (snr, ps);
ps = table->GetChunkSuccessRate (WifiMode (modes[i]), txVector, std::pow (10.0, snr / 10.0), FrameSize * 8);
if (ps < 0.0 || ps > 1.0)
{
//error
exit (1);
}
tabledataset.Add (snr, ps);
}
yansplot.AddDataset (yansdataset);
nistplot.AddDataset (nistdataset);
tableplot.AddDataset (tabledataset);
}
yansplot.SetTerminal ("postscript eps color enh \"Times-BoldItalic\"");
@@ -101,7 +115,7 @@ set style line 5 linewidth 5\n\
set style line 6 linewidth 5\n\
set style line 7 linewidth 5\n\
set style line 8 linewidth 5\n\
set style increment user" );
set style increment user");
yansplot.GenerateOutput (yansfile);
yansfile.close ();
@@ -117,9 +131,25 @@ set style line 5 linewidth 5\n\
set style line 6 linewidth 5\n\
set style line 7 linewidth 5\n\
set style line 8 linewidth 5\n\
set style increment user" );
set style increment user");
nistplot.GenerateOutput (nistfile);
nistfile.close ();
}
tableplot.SetTerminal ("postscript eps color enh \"Times-BoldItalic\"");
tableplot.SetLegend ("SNR(dB)", "Frame Success Rate");
tableplot.SetExtra ("set xrange [-5:30]\n\
set yrange [0:1.2]\n\
set style line 1 linewidth 5\n\
set style line 2 linewidth 5\n\
set style line 3 linewidth 5\n\
set style line 4 linewidth 5\n\
set style line 5 linewidth 5\n\
set style line 6 linewidth 5\n\
set style line 7 linewidth 5\n\
set style line 8 linewidth 5\n\
set style increment user");
tableplot.GenerateOutput (tablefile);
tablefile.close ();
}

View File

@@ -18,10 +18,10 @@
* Author: Gary Pei <guangyu.pei@boeing.com>
*/
// This example is used to validate NIST and YANS error rate models for OFDM rates.
// This example is used to validate Nist, Yans and Table-based error rate models for OFDM rates.
//
// It outputs plots of the Frame Success Rate versus the Signal-to-noise ratio for
// both NIST and YANS error rate models and for every OFDM mode.
// Nist, Yans and Table-based error rate models and for every OFDM mode.
#include <fstream>
#include <cmath>
@@ -29,6 +29,7 @@
#include "ns3/command-line.h"
#include "ns3/yans-error-rate-model.h"
#include "ns3/nist-error-rate-model.h"
#include "ns3/table-based-error-rate-model.h"
#include "ns3/wifi-tx-vector.h"
using namespace ns3;
@@ -38,6 +39,7 @@ int main (int argc, char *argv[])
uint32_t FrameSize = 1500; //bytes
std::ofstream yansfile ("yans-frame-success-rate-ofdm.plt");
std::ofstream nistfile ("nist-frame-success-rate-ofdm.plt");
std::ofstream tablefile ("table-frame-success-rate-ofdm.plt");
std::vector <std::string> modes;
modes.push_back ("OfdmRate6Mbps");
@@ -55,9 +57,11 @@ int main (int argc, char *argv[])
Gnuplot yansplot = Gnuplot ("yans-frame-success-rate-ofdm.eps");
Gnuplot nistplot = Gnuplot ("nist-frame-success-rate-ofdm.eps");
Gnuplot tableplot = Gnuplot ("table-frame-success-rate-ofdm.eps");
Ptr <YansErrorRateModel> yans = CreateObject<YansErrorRateModel> ();
Ptr <NistErrorRateModel> nist = CreateObject<NistErrorRateModel> ();
Ptr <TableBasedErrorRateModel> table = CreateObject<TableBasedErrorRateModel> ();
WifiTxVector txVector;
for (uint32_t i = 0; i < modes.size (); i++)
@@ -65,11 +69,12 @@ int main (int argc, char *argv[])
std::cout << modes[i] << std::endl;
Gnuplot2dDataset yansdataset (modes[i]);
Gnuplot2dDataset nistdataset (modes[i]);
Gnuplot2dDataset tabledataset (modes[i]);
txVector.SetMode (modes[i]);
for (double snr = -5.0; snr <= 30.0; snr += 0.1)
{
double ps = yans->GetChunkSuccessRate (WifiMode (modes[i]), txVector, std::pow (10.0,snr / 10.0), FrameSize * 8);
double ps = yans->GetChunkSuccessRate (WifiMode (modes[i]), txVector, std::pow (10.0, snr / 10.0), FrameSize * 8);
if (ps < 0.0 || ps > 1.0)
{
//error
@@ -77,17 +82,26 @@ int main (int argc, char *argv[])
}
yansdataset.Add (snr, ps);
ps = nist->GetChunkSuccessRate (WifiMode (modes[i]), txVector, std::pow (10.0,snr / 10.0), FrameSize * 8);
ps = nist->GetChunkSuccessRate (WifiMode (modes[i]), txVector, std::pow (10.0, snr / 10.0), FrameSize * 8);
if (ps < 0.0 || ps > 1.0)
{
//error
exit (1);
}
nistdataset.Add (snr, ps);
ps = table->GetChunkSuccessRate (WifiMode (modes[i]), txVector, std::pow (10.0, snr / 10.0), FrameSize * 8);
if (ps < 0.0 || ps > 1.0)
{
//error
exit (1);
}
tabledataset.Add (snr, ps);
}
yansplot.AddDataset (yansdataset);
nistplot.AddDataset (nistdataset);
tableplot.AddDataset (tabledataset);
}
yansplot.SetTerminal ("postscript eps color enh \"Times-BoldItalic\"");
@@ -102,7 +116,7 @@ set style line 5 linewidth 5\n\
set style line 6 linewidth 5\n\
set style line 7 linewidth 5\n\
set style line 8 linewidth 5\n\
set style increment user" );
set style increment user");
yansplot.GenerateOutput (yansfile);
yansfile.close ();
@@ -118,8 +132,25 @@ set style line 5 linewidth 5\n\
set style line 6 linewidth 5\n\
set style line 7 linewidth 5\n\
set style line 8 linewidth 5\n\
set style increment user" );
set style increment user");
nistplot.GenerateOutput (nistfile);
nistfile.close ();
tableplot.SetTerminal ("postscript eps color enh \"Times-BoldItalic\"");
tableplot.SetLegend ("SNR(dB)", "Frame Success Rate");
tableplot.SetExtra ("set xrange [-5:30]\n\
set yrange [0:1.2]\n\
set style line 1 linewidth 5\n\
set style line 2 linewidth 5\n\
set style line 3 linewidth 5\n\
set style line 4 linewidth 5\n\
set style line 5 linewidth 5\n\
set style line 6 linewidth 5\n\
set style line 7 linewidth 5\n\
set style line 8 linewidth 5\n\
set style increment user");
tableplot.GenerateOutput (tablefile);
tablefile.close ();
}

View File

@@ -16,10 +16,10 @@
* Author: Sébastien Deronne <sebastien.deronne@gmail.com>
*/
// This example is used to validate NIST and YANS error rate models for VHT rates.
// This example is used to validate Nist, Yans and Table-based error rate models for VHT rates.
//
// It outputs plots of the Frame Success Rate versus the Signal-to-noise ratio for
// both NIST and YANS error rate models and for every VHT MCS value (MCS 9 is not
// Nist, Yans and Table-based error rate models and for every VHT MCS value (MCS 9 is not
// included since it is forbidden for 20 MHz channels).
#include <fstream>
@@ -28,6 +28,7 @@
#include "ns3/command-line.h"
#include "ns3/yans-error-rate-model.h"
#include "ns3/nist-error-rate-model.h"
#include "ns3/table-based-error-rate-model.h"
#include "ns3/wifi-tx-vector.h"
using namespace ns3;
@@ -37,6 +38,7 @@ int main (int argc, char *argv[])
uint32_t FrameSize = 1500; //bytes
std::ofstream yansfile ("yans-frame-success-rate-ac.plt");
std::ofstream nistfile ("nist-frame-success-rate-ac.plt");
std::ofstream tablefile ("table-frame-success-rate-ac.plt");
std::vector <std::string> modes;
modes.push_back ("VhtMcs0");
@@ -55,9 +57,11 @@ int main (int argc, char *argv[])
Gnuplot yansplot = Gnuplot ("yans-frame-success-rate-ac.eps");
Gnuplot nistplot = Gnuplot ("nist-frame-success-rate-ac.eps");
Gnuplot tableplot = Gnuplot ("table-frame-success-rate-ac.eps");
Ptr <YansErrorRateModel> yans = CreateObject<YansErrorRateModel> ();
Ptr <NistErrorRateModel> nist = CreateObject<NistErrorRateModel> ();
Ptr <TableBasedErrorRateModel> table = CreateObject<TableBasedErrorRateModel> ();
WifiTxVector txVector;
for (uint32_t i = 0; i < modes.size (); i++)
@@ -65,11 +69,12 @@ int main (int argc, char *argv[])
std::cout << modes[i] << std::endl;
Gnuplot2dDataset yansdataset (modes[i]);
Gnuplot2dDataset nistdataset (modes[i]);
Gnuplot2dDataset tabledataset (modes[i]);
txVector.SetMode (modes[i]);
for (double snr = -5.0; snr <= 30.0; snr += 0.1)
{
double ps = yans->GetChunkSuccessRate (WifiMode (modes[i]), txVector, std::pow (10.0,snr / 10.0), FrameSize * 8);
double ps = yans->GetChunkSuccessRate (WifiMode (modes[i]), txVector, std::pow (10.0, snr / 10.0), FrameSize * 8);
if (ps < 0.0 || ps > 1.0)
{
//error
@@ -77,17 +82,26 @@ int main (int argc, char *argv[])
}
yansdataset.Add (snr, ps);
ps = nist->GetChunkSuccessRate (WifiMode (modes[i]), txVector, std::pow (10.0,snr / 10.0), FrameSize * 8);
ps = nist->GetChunkSuccessRate (WifiMode (modes[i]), txVector, std::pow (10.0, snr / 10.0), FrameSize * 8);
if (ps < 0.0 || ps > 1.0)
{
//error
exit (1);
}
nistdataset.Add (snr, ps);
ps = table->GetChunkSuccessRate (WifiMode (modes[i]), txVector, std::pow (10.0, snr / 10.0), FrameSize * 8);
if (ps < 0.0 || ps > 1.0)
{
//error
exit (1);
}
tabledataset.Add (snr, ps);
}
yansplot.AddDataset (yansdataset);
nistplot.AddDataset (nistdataset);
tableplot.AddDataset (tabledataset);
}
yansplot.SetTerminal ("postscript eps color enh \"Times-BoldItalic\"");
@@ -103,7 +117,7 @@ set style line 6 linewidth 5\n\
set style line 7 linewidth 5\n\
set style line 8 linewidth 5\n\
set style line 9 linewidth 5\n\
set style increment user" );
set style increment user");
yansplot.GenerateOutput (yansfile);
yansfile.close ();
@@ -120,9 +134,26 @@ set style line 6 linewidth 5\n\
set style line 7 linewidth 5\n\
set style line 8 linewidth 5\n\
set style line 9 linewidth 5\n\
set style increment user" );
set style increment user");
nistplot.GenerateOutput (nistfile);
nistfile.close ();
}
tableplot.SetTerminal ("postscript eps color enh \"Times-BoldItalic\"");
tableplot.SetLegend ("SNR(dB)", "Frame Success Rate");
tableplot.SetExtra ("set xrange [-5:55]\n\
set yrange [0:1]\n\
set style line 1 linewidth 5\n\
set style line 2 linewidth 5\n\
set style line 3 linewidth 5\n\
set style line 4 linewidth 5\n\
set style line 5 linewidth 5\n\
set style line 6 linewidth 5\n\
set style line 7 linewidth 5\n\
set style line 8 linewidth 5\n\
set style line 9 linewidth 5\n\
set style increment user");
tableplot.GenerateOutput (tablefile);
tablefile.close ();
}