Add NistErrorRateModel for wifi
This commit is contained in:
@@ -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
|
||||
----------
|
||||
|
||||
106
examples/wireless/ofdm-validation.cc
Normal file
106
examples/wireless/ofdm-validation.cc
Normal file
@@ -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 <guangyu.pei@boeing.com>
|
||||
*/
|
||||
#include "ns3/core-module.h"
|
||||
#include "ns3/yans-error-rate-model.h"
|
||||
#include "ns3/nist-error-rate-model.h"
|
||||
#include "ns3/gnuplot.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <vector>
|
||||
|
||||
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 <std::string> 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 <YansErrorRateModel> yans = CreateObject<YansErrorRateModel> ();
|
||||
Ptr <NistErrorRateModel> nist = CreateObject<NistErrorRateModel> ();
|
||||
|
||||
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 ();
|
||||
}
|
||||
@@ -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'
|
||||
|
||||
|
||||
268
src/devices/wifi/nist-error-rate-model.cc
Normal file
268
src/devices/wifi/nist-error-rate-model.cc
Normal file
@@ -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 <guangyu.pei@boeing.com>
|
||||
*/
|
||||
#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<ErrorRateModel> ()
|
||||
.AddConstructor<NistErrorRateModel> ()
|
||||
;
|
||||
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="<<snr<<" ber="<<ber);
|
||||
return ber;
|
||||
}
|
||||
double
|
||||
NistErrorRateModel::GetQpskBer (double snr) const
|
||||
{
|
||||
double z = sqrt(snr/2.0);
|
||||
double ber = 0.5 * erfc(z);
|
||||
NS_LOG_INFO ("qpsk snr="<<snr<<" ber="<<ber);
|
||||
return ber;
|
||||
}
|
||||
double
|
||||
NistErrorRateModel::Get16QamBer (double snr) const
|
||||
{
|
||||
double z = sqrt(snr/(5.0 * 2.0));
|
||||
double ber = 0.75 * 0.5 * erfc(z);
|
||||
NS_LOG_INFO ("16-Qam" << " snr="<<snr<<" ber="<<ber);
|
||||
return ber;
|
||||
}
|
||||
double
|
||||
NistErrorRateModel::Get64QamBer (double snr) const
|
||||
{
|
||||
double z = sqrt(snr/(21.0 * 2.0));
|
||||
double ber = 7.0 / 12.0 * 0.5 * erfc(z);
|
||||
NS_LOG_INFO ("64-Qam" << " snr="<<snr<<" ber="<<ber);
|
||||
return ber;
|
||||
}
|
||||
double
|
||||
NistErrorRateModel::GetFecBpskBer (double snr, double nbits,
|
||||
uint32_t bValue) const
|
||||
{
|
||||
double ber = GetBpskBer (snr);
|
||||
if (ber == 0.0)
|
||||
{
|
||||
return 1.0;
|
||||
}
|
||||
double pe = CalculatePe (ber, bValue);
|
||||
pe = std::min (pe, 1.0);
|
||||
double pms = pow (1 - pe, nbits);
|
||||
return pms;
|
||||
}
|
||||
double
|
||||
NistErrorRateModel::GetFecQpskBer (double snr, double nbits,
|
||||
uint32_t bValue) const
|
||||
{
|
||||
double ber = GetQpskBer (snr);
|
||||
if (ber == 0.0)
|
||||
{
|
||||
return 1.0;
|
||||
}
|
||||
double pe = CalculatePe (ber, bValue);
|
||||
pe = std::min (pe, 1.0);
|
||||
double pms = pow (1 - pe, nbits);
|
||||
return pms;
|
||||
}
|
||||
double
|
||||
NistErrorRateModel::CalculatePe (double p, uint32_t bValue) const
|
||||
{
|
||||
double D = sqrt (4.0 * p * (1.0 -p));
|
||||
double pe = 1.0;
|
||||
if (bValue == 1)
|
||||
{
|
||||
// code rate 1/2, use table 3.1.1
|
||||
pe = 0.5 * ( 36.0 * pow (D, 10.0)
|
||||
+ 211.0 * pow (D, 12.0)
|
||||
+ 1404.0 * pow (D, 14.0)
|
||||
+ 11633.0 * pow (D, 16.0)
|
||||
+ 77433.0 * pow (D, 18.0)
|
||||
+ 502690.0 * pow (D, 20.0)
|
||||
+ 3322763.0 * pow (D, 22.0)
|
||||
+ 21292910.0 * pow (D, 24.0)
|
||||
+ 134365911.0 * pow (D, 26.0)
|
||||
);
|
||||
}
|
||||
else if (bValue == 2)
|
||||
{
|
||||
// code rate 2/3, use table 3.1.2
|
||||
pe = 1.0 / (2.0 * bValue) *
|
||||
( 3.0 * pow (D, 6.0)
|
||||
+ 70.0 * pow (D, 7.0)
|
||||
+ 285.0 * pow (D, 8.0)
|
||||
+ 1276.0 * pow (D, 9.0)
|
||||
+ 6160.0 * pow (D, 10.0)
|
||||
+ 27128.0 * pow (D, 11.0)
|
||||
+ 117019.0 * pow (D, 12.0)
|
||||
+ 498860.0 * pow (D, 13.0)
|
||||
+ 2103891.0 * pow (D, 14.0)
|
||||
+ 8784123.0 * pow (D, 15.0)
|
||||
);
|
||||
}
|
||||
else if (bValue == 3)
|
||||
{
|
||||
// code rate 3/4, use table 3.1.2
|
||||
pe = 1.0 / (2.0 * bValue) *
|
||||
( 42.0 * pow (D, 5.0)
|
||||
+ 201.0 * pow (D, 6.0)
|
||||
+ 1492.0 * pow (D, 7.0)
|
||||
+ 10469.0 * pow (D, 8.0)
|
||||
+ 62935.0 * pow (D, 9.0)
|
||||
+ 379644.0 * pow (D, 10.0)
|
||||
+ 2253373.0 * pow (D, 11.0)
|
||||
+ 13073811.0 * pow (D, 12.0)
|
||||
+ 75152755.0 * pow (D, 13.0)
|
||||
+ 428005675.0 * pow (D, 14.0)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
NS_ASSERT (false);
|
||||
}
|
||||
return pe;
|
||||
}
|
||||
|
||||
double
|
||||
NistErrorRateModel::GetFec16QamBer (double snr, uint32_t nbits,
|
||||
uint32_t bValue) const
|
||||
{
|
||||
double ber = Get16QamBer (snr);
|
||||
if (ber == 0.0)
|
||||
{
|
||||
return 1.0;
|
||||
}
|
||||
double pe = CalculatePe (ber, bValue);
|
||||
pe = std::min (pe, 1.0);
|
||||
double pms = pow (1 - pe, nbits);
|
||||
return pms;
|
||||
}
|
||||
double
|
||||
NistErrorRateModel::GetFec64QamBer (double snr, uint32_t nbits,
|
||||
uint32_t bValue) const
|
||||
{
|
||||
double ber = Get64QamBer (snr);
|
||||
if (ber == 0.0)
|
||||
{
|
||||
return 1.0;
|
||||
}
|
||||
double pe = CalculatePe (ber, bValue);
|
||||
pe = std::min (pe, 1.0);
|
||||
double pms = pow (1 - pe, nbits);
|
||||
return pms;
|
||||
}
|
||||
double
|
||||
NistErrorRateModel::GetChunkSuccessRate (WifiMode mode, double snr, uint32_t nbits) const
|
||||
{
|
||||
if (mode == WifiPhy::Get6mba () || mode == WifiPhy::Get3mb10Mhz () || mode == WifiPhy::Get1_5mb5Mhz ())
|
||||
{
|
||||
return GetFecBpskBer (snr,
|
||||
nbits,
|
||||
1 // b value
|
||||
);
|
||||
}
|
||||
else if (mode == WifiPhy::Get9mba () || mode == WifiPhy::Get4_5mb10Mhz () || mode == WifiPhy::Get2_25mb5Mhz ())
|
||||
{
|
||||
return GetFecBpskBer (snr,
|
||||
nbits,
|
||||
3 // b value
|
||||
);
|
||||
}
|
||||
else if (mode == WifiPhy::Get12mba () || mode == WifiPhy::Get6mb10Mhz () || mode == WifiPhy::Get3mb5Mhz ())
|
||||
{
|
||||
return GetFecQpskBer (snr,
|
||||
nbits,
|
||||
1 // b value
|
||||
);
|
||||
}
|
||||
else if (mode == WifiPhy::Get18mba () || mode == WifiPhy::Get9mb10Mhz () || mode == WifiPhy::Get4_5mb5Mhz ())
|
||||
{
|
||||
return GetFecQpskBer (snr,
|
||||
nbits,
|
||||
3 // b value
|
||||
);
|
||||
}
|
||||
else if (mode == WifiPhy::Get24mba () || mode == WifiPhy::Get12mb10Mhz () || mode == WifiPhy::Get6mb5Mhz ())
|
||||
{
|
||||
return GetFec16QamBer (snr,
|
||||
nbits,
|
||||
1 // b value
|
||||
);
|
||||
}
|
||||
else if (mode == WifiPhy::Get36mba () || mode == WifiPhy::Get18mb10Mhz () || mode == WifiPhy::Get9mb5Mhz ())
|
||||
{
|
||||
return GetFec16QamBer (snr,
|
||||
nbits,
|
||||
3 // b value
|
||||
);
|
||||
}
|
||||
else if (mode == WifiPhy::Get48mba () || mode == WifiPhy::Get24mb10Mhz () || mode == WifiPhy::Get12mb5Mhz ())
|
||||
{
|
||||
return GetFec64QamBer (snr,
|
||||
nbits,
|
||||
2 // b value
|
||||
);
|
||||
}
|
||||
else if (mode == WifiPhy::Get54mba () || mode == WifiPhy::Get27mb10Mhz () || mode == WifiPhy::Get13_5mb5Mhz ())
|
||||
{
|
||||
return GetFec64QamBer (snr,
|
||||
nbits,
|
||||
3 // b value
|
||||
);
|
||||
}
|
||||
else if (mode == WifiPhy::Get1mbb ())
|
||||
{
|
||||
return DsssErrorRateModel::GetDsssDbpskSuccessRate (snr,nbits);
|
||||
}
|
||||
else if (mode == WifiPhy::Get2mbb ())
|
||||
{
|
||||
return DsssErrorRateModel::GetDsssDqpskSuccessRate (snr,nbits);
|
||||
}
|
||||
else if (mode == WifiPhy::Get5_5mbb ())
|
||||
{
|
||||
return DsssErrorRateModel::GetDsssDqpskCck5_5SuccessRate (snr,nbits);
|
||||
}
|
||||
else if (mode == WifiPhy::Get11mbb ())
|
||||
{
|
||||
return DsssErrorRateModel::GetDsssDqpskCck11SuccessRate (snr,nbits);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace ns3
|
||||
64
src/devices/wifi/nist-error-rate-model.h
Normal file
64
src/devices/wifi/nist-error-rate-model.h
Normal file
@@ -0,0 +1,64 @@
|
||||
/* -*- 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 <guangyu.pei@boeing.com>
|
||||
*/
|
||||
#ifndef NIST_ERROR_RATE_MODEL_H
|
||||
#define NIST_ERROR_RATE_MODEL_H
|
||||
|
||||
#include <stdint.h>
|
||||
#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 */
|
||||
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user