diff --git a/RELEASE_NOTES b/RELEASE_NOTES index b41583385..a4d2a7af7 100644 --- a/RELEASE_NOTES +++ b/RELEASE_NOTES @@ -26,6 +26,10 @@ http://www.nsnam.org/wiki/index.php/Installation New user-visible features ------------------------- + - A new OFDM error rate model for WiFi (NistErrorRateModel); this model + has been validated in clear-channel testbed tests. For 802.11b, it + uses the same underlying model as the YansErrorRateModel, but it differs + from YansErrorRateModel for OFDM modes (802.11a/g). Bugs fixed ---------- diff --git a/examples/wireless/ofdm-validation.cc b/examples/wireless/ofdm-validation.cc new file mode 100644 index 000000000..b8cf69513 --- /dev/null +++ b/examples/wireless/ofdm-validation.cc @@ -0,0 +1,106 @@ +/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2010 The Boeing Company + * + * 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: Gary Pei + */ +#include "ns3/core-module.h" +#include "ns3/yans-error-rate-model.h" +#include "ns3/nist-error-rate-model.h" +#include "ns3/gnuplot.h" + +#include +#include + +using namespace ns3; + +int main (int argc, char *argv[]) +{ + uint32_t FrameSize = 2000; + std::ofstream yansfile ("yans-frame-success-rate.plt"); + std::ofstream nistfile ("nist-frame-success-rate.plt"); + std::vector modes; + + modes.push_back ("wifia-6mbs"); + modes.push_back ("wifia-9mbs"); + modes.push_back ("wifia-12mbs"); + modes.push_back ("wifia-18mbs"); + modes.push_back ("wifia-24mbs"); + modes.push_back ("wifia-36mbs"); + modes.push_back ("wifia-48mbs"); + modes.push_back ("wifia-54mbs"); + + CommandLine cmd; + cmd.AddValue ("FrameSize", "The frame size", FrameSize); + cmd.Parse (argc, argv); + + Gnuplot yansplot = Gnuplot ("yans-frame-success-rate.eps"); + Gnuplot nistplot = Gnuplot ("nist-frame-success-rate.eps"); + + Ptr yans = CreateObject (); + Ptr nist = CreateObject (); + + for (uint32_t i = 0; i < modes.size(); i++) + { + std::cout << modes[i] << std::endl; + Gnuplot2dDataset yansdataset (modes[i]); + Gnuplot2dDataset nistdataset (modes[i]); + + for (double snr = -5.0; snr <= 30.0; snr += 0.1) + { + double ps = yans->GetChunkSuccessRate(WifiMode(modes[i]), pow(10.0,snr/10.0), FrameSize*8); + yansdataset.Add (snr, ps); + ps = nist->GetChunkSuccessRate(WifiMode(modes[i]), pow(10.0,snr/10.0), FrameSize*8); + nistdataset.Add (snr, ps); + } + + yansplot.AddDataset (yansdataset); + nistplot.AddDataset (nistdataset); + } + + yansplot.SetTerminal ("postscript eps color enh \"Times-BoldItalic\""); + yansplot.SetLegend ("SNR(dB)", "Frame Success Rate"); + yansplot.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"); + yansplot.GenerateOutput (yansfile); + yansfile.close (); + + nistplot.SetTerminal ("postscript eps color enh \"Times-BoldItalic\""); + nistplot.SetLegend ("SNR(dB)", "Frame Success Rate"); + nistplot.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"); + + nistplot.GenerateOutput (nistfile); + nistfile.close (); +} diff --git a/examples/wireless/wscript b/examples/wireless/wscript index 855e8ec45..7590258d5 100644 --- a/examples/wireless/wscript +++ b/examples/wireless/wscript @@ -37,7 +37,9 @@ def build(bld): obj = bld.create_ns3_program('wifi-blockack', ['core', 'simulator', 'mobility', 'wifi']) obj.source = 'wifi-blockack.cc' - + + obj = bld.create_ns3_program('ofdm-validation', ['core', 'simulator', 'mobility', 'wifi']) + obj.source = 'ofdm-validation.cc' + obj = bld.create_ns3_program('wifi-hidden-terminal', ['core', 'simulator', 'mobility', 'wifi', 'flow-monitor']) obj.source = 'wifi-hidden-terminal.cc' - diff --git a/src/devices/wifi/nist-error-rate-model.cc b/src/devices/wifi/nist-error-rate-model.cc new file mode 100644 index 000000000..818777e0b --- /dev/null +++ b/src/devices/wifi/nist-error-rate-model.cc @@ -0,0 +1,268 @@ +/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2010 The Boeing Company + * + * 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: Gary Pei + */ +#include "nist-error-rate-model.h" +#include "wifi-phy.h" +#include "ns3/log.h" + +NS_LOG_COMPONENT_DEFINE ("NistErrorRateModel"); + +namespace ns3 { + +NS_OBJECT_ENSURE_REGISTERED (NistErrorRateModel); + +TypeId +NistErrorRateModel::GetTypeId (void) +{ + static TypeId tid = TypeId ("ns3::NistErrorRateModel") + .SetParent () + .AddConstructor () + ; + return tid; +} + +NistErrorRateModel::NistErrorRateModel () +{ +} + +double +NistErrorRateModel::GetBpskBer (double snr) const +{ + double z = sqrt(snr); + double ber = 0.5 * erfc(z); + NS_LOG_INFO ("bpsk snr="< + */ +#ifndef NIST_ERROR_RATE_MODEL_H +#define NIST_ERROR_RATE_MODEL_H + +#include +#include "wifi-mode.h" +#include "error-rate-model.h" +#include "dsss-error-rate-model.h" + +namespace ns3 { + +/** + * Model the error rate for different modulations. For OFDM modulation, + * the model description and validation can be found in + * http://www.nsnam.org/~pei/80211ofdm.pdf. For DSSS modulations (802.11b), + * the model uses the DsssErrorRateModel. + */ +class NistErrorRateModel : public ErrorRateModel +{ +public: + static TypeId GetTypeId (void); + + NistErrorRateModel (); + + virtual double GetChunkSuccessRate (WifiMode mode, double snr, uint32_t nbits) const; + +private: + double CalculatePe (double p, uint32_t bValue) const; + double GetBpskBer (double snr) const; + double GetQpskBer (double snr) const; + double Get16QamBer (double snr) const; + double Get64QamBer (double snr) const; + double GetFecBpskBer (double snr, double nbits, + uint32_t bValue) const; + double GetFecQpskBer (double snr, double nbits, + uint32_t bValue) const; + double GetFec16QamBer (double snr, uint32_t nbits, + uint32_t bValue) const; + double GetFec64QamBer (double snr, uint32_t nbits, + uint32_t bValue) const; +}; + + +} // namespace ns3 + +#endif /* NIST_ERROR_RATE_MODEL_H */ diff --git a/src/devices/wifi/wscript b/src/devices/wifi/wscript index 182e1d3ca..070c5a7bc 100644 --- a/src/devices/wifi/wscript +++ b/src/devices/wifi/wscript @@ -10,6 +10,8 @@ def build(bld): 'wifi-phy-state-helper.cc', 'error-rate-model.cc', 'yans-error-rate-model.cc', + 'nist-error-rate-model.cc', + 'dsss-error-rate-model.cc', 'interference-helper.cc', 'interference-helper-tx-duration-test.cc', 'yans-wifi-phy.cc', @@ -94,6 +96,8 @@ def build(bld): 'supported-rates.h', 'error-rate-model.h', 'yans-error-rate-model.h', + 'nist-error-rate-model.h', + 'dsss-error-rate-model.h', 'dca-txop.h', 'wifi-mac-header.h', 'qadhoc-wifi-mac.h',