diff --git a/examples/wireless/wifi-dsss-validation.cc b/examples/wireless/wifi-dsss-validation.cc index 7e706ea83..f89a8204b 100644 --- a/examples/wireless/wifi-dsss-validation.cc +++ b/examples/wireless/wifi-dsss-validation.cc @@ -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 yans = CreateObject (); Ptr nist = CreateObject (); + Ptr table = CreateObject (); 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<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); diff --git a/examples/wireless/wifi-ofdm-he-validation.cc b/examples/wireless/wifi-ofdm-he-validation.cc index 07f432377..f1a927c76 100644 --- a/examples/wireless/wifi-ofdm-he-validation.cc +++ b/examples/wireless/wifi-ofdm-he-validation.cc @@ -16,10 +16,10 @@ * Author: Sébastien Deronne */ -// 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 #include @@ -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 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 yans = CreateObject (); Ptr nist = CreateObject (); + Ptr table = CreateObject (); 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 (); +} diff --git a/examples/wireless/wifi-ofdm-ht-validation.cc b/examples/wireless/wifi-ofdm-ht-validation.cc index 3d4c154c5..34c0787ba 100644 --- a/examples/wireless/wifi-ofdm-ht-validation.cc +++ b/examples/wireless/wifi-ofdm-ht-validation.cc @@ -16,10 +16,10 @@ * Author: Sébastien Deronne */ -// 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 #include @@ -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 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 yans = CreateObject (); Ptr nist = CreateObject (); + Ptr table = CreateObject (); 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 (); +} diff --git a/examples/wireless/wifi-ofdm-validation.cc b/examples/wireless/wifi-ofdm-validation.cc index eac80f686..7fee37e88 100644 --- a/examples/wireless/wifi-ofdm-validation.cc +++ b/examples/wireless/wifi-ofdm-validation.cc @@ -18,10 +18,10 @@ * Author: Gary Pei */ -// 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 #include @@ -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 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 yans = CreateObject (); Ptr nist = CreateObject (); + Ptr table = CreateObject (); 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 (); } diff --git a/examples/wireless/wifi-ofdm-vht-validation.cc b/examples/wireless/wifi-ofdm-vht-validation.cc index 684bc6711..8744d46da 100644 --- a/examples/wireless/wifi-ofdm-vht-validation.cc +++ b/examples/wireless/wifi-ofdm-vht-validation.cc @@ -16,10 +16,10 @@ * Author: Sébastien Deronne */ -// 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 @@ -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 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 yans = CreateObject (); Ptr nist = CreateObject (); + Ptr table = CreateObject (); 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 (); +}