diff --git a/examples/wireless/dsss-validation.cc b/examples/wireless/dsss-validation.cc new file mode 100644 index 000000000..1c2b55585 --- /dev/null +++ b/examples/wireless/dsss-validation.cc @@ -0,0 +1,99 @@ +/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Sébastien Deronne + */ + +// This example is used to validate error rate models for DSSS rates. +// +// It outputs plots of the Frame Success Rate versus the Signal-to-noise ratio +// for the DSSS error rate models and for every DSSS mode. + +#include "ns3/gnuplot.h" +#include "ns3/core-module.h" +#include "ns3/yans-error-rate-model.h" +#include "ns3/nist-error-rate-model.h" +#include "ns3/wifi-tx-vector.h" + +using namespace ns3; + +int main (int argc, char *argv[]) +{ + uint32_t FrameSize = 1500; //bytes + std::ofstream file ("frame-success-rate-dsss.plt"); + std::vector modes; + + modes.push_back ("DsssRate1Mbps"); + modes.push_back ("DsssRate2Mbps"); + modes.push_back ("DsssRate5_5Mbps"); + modes.push_back ("DsssRate11Mbps"); + + CommandLine cmd; + cmd.AddValue ("FrameSize", "The frame size in bytes", FrameSize); + cmd.Parse (argc, argv); + + Gnuplot plot = Gnuplot ("frame-success-rate-dsss.eps"); + + Ptr yans = CreateObject (); + Ptr nist = CreateObject (); + WifiTxVector txVector; + + for (uint32_t i = 0; i < modes.size (); i++) + { + std::cout << modes[i] << std::endl; + Gnuplot2dDataset dataset (modes[i]); + txVector.SetMode (modes[i]); + + 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); + 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); + if (psNist < 0.0 || psNist > 1.0) + { + std::cout<