src/devices/wifi/yans-error-rate-model.h
author Pavel Boyko <boyko@iitp.ru>
Tue, 16 Jun 2009 17:58:16 +0400
changeset 5074 355de6af8ea9
parent 4477 b21fc5b07644
child 6357 5d6d511ce4e9
permissions -rw-r--r--
merged with nsnam
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3903
714f93024a37 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
     1
/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
714f93024a37 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
     2
/*
714f93024a37 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
     3
 * Copyright (c) 2005,2006 INRIA
714f93024a37 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
     4
 *
714f93024a37 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
714f93024a37 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
     6
 * it under the terms of the GNU General Public License version 2 as 
714f93024a37 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
     7
 * published by the Free Software Foundation;
714f93024a37 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
     8
 *
714f93024a37 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
714f93024a37 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
714f93024a37 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
714f93024a37 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
    12
 * GNU General Public License for more details.
714f93024a37 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
    13
 *
714f93024a37 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
    14
 * You should have received a copy of the GNU General Public License
714f93024a37 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
    15
 * along with this program; if not, write to the Free Software
714f93024a37 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
714f93024a37 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
    17
 *
714f93024a37 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
    18
 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
714f93024a37 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3902
diff changeset
    19
 */
4038
c6f634d0fc6f virtualize ErrorRateModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3905
diff changeset
    20
#ifndef YANS_ERROR_RATE_MODEL_H
c6f634d0fc6f virtualize ErrorRateModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3905
diff changeset
    21
#define YANS_ERROR_RATE_MODEL_H
3902
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    22
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    23
#include <stdint.h>
4470
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4038
diff changeset
    24
#ifdef ENABLE_GSL
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4038
diff changeset
    25
#include <gsl/gsl_math.h>
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4038
diff changeset
    26
#include <gsl/gsl_integration.h>
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4038
diff changeset
    27
#include <gsl/gsl_cdf.h>
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4038
diff changeset
    28
#include <gsl/gsl_sf_bessel.h>
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4038
diff changeset
    29
#endif
3902
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    30
#include "wifi-mode.h"
4038
c6f634d0fc6f virtualize ErrorRateModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3905
diff changeset
    31
#include "error-rate-model.h"
3902
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    32
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    33
namespace ns3 {
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    34
4470
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4038
diff changeset
    35
#ifdef ENABLE_GSL
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4038
diff changeset
    36
typedef struct FunctionParameterType
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4038
diff changeset
    37
{
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4038
diff changeset
    38
 double beta;
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4038
diff changeset
    39
 double n;
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4038
diff changeset
    40
} FunctionParameters;
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4038
diff changeset
    41
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4038
diff changeset
    42
double IntegralFunction (double x, void *params);
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4038
diff changeset
    43
#endif
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4038
diff changeset
    44
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4038
diff changeset
    45
/**
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4038
diff changeset
    46
 * \brief Model the error rate for different modulations.
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4038
diff changeset
    47
 *
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4038
diff changeset
    48
 * A packet of interest (e.g., a packet can potentially be received by the MAC) 
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4038
diff changeset
    49
 * is divided into chunks. Each chunk is related to an start/end receiving event. 
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4038
diff changeset
    50
 * For each chunk, it calculates the ratio (SINR) between received power of packet 
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4038
diff changeset
    51
 * of interest and summation of noise and interfering power of all the other incoming 
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4038
diff changeset
    52
 * packets. Then, it will calculate the success rate of the chunk based on 
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4038
diff changeset
    53
 * BER of the modulation. The success reception rate of the packet is derived from 
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4038
diff changeset
    54
 * the success rate of all chunks.
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4038
diff changeset
    55
 *
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4038
diff changeset
    56
 * The 802.11b modulations:
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4038
diff changeset
    57
 *    - 1 Mbps mode is based on DBPSK. BER is from equation 5.2-69 from John G. Proakis
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4038
diff changeset
    58
 *      Digitial Communications, 2001 edition
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4038
diff changeset
    59
 *    - 2 Mbps model is based on DQPSK. Equation 8 from "Tight bounds and accurate 
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4038
diff changeset
    60
 *      approximations for dqpsk transmission bit error rate", G. Ferrari and G.E. Corazza 
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4038
diff changeset
    61
 *      ELECTRONICS LETTERS, 40(20):1284-1285, September 2004
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4038
diff changeset
    62
 *    - 5.5 Mbps and 11 Mbps are based on equations (18) and (17) from "Properties and 
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4038
diff changeset
    63
 *      performance of the ieee 802.11b complementarycode-key signal sets", 
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4038
diff changeset
    64
 *      Michael B. Pursley and Thomas C. Royster. IEEE TRANSACTIONS ON COMMUNICATIONS, 
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4038
diff changeset
    65
 *      57(2):440-449, February 2009.
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4038
diff changeset
    66
 *    - More detailed description and validation can be found in 
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4038
diff changeset
    67
 *      http://www.nsnam.org/~pei/80211b.pdf
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4038
diff changeset
    68
 */
4038
c6f634d0fc6f virtualize ErrorRateModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3905
diff changeset
    69
class YansErrorRateModel : public ErrorRateModel
3902
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    70
{
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    71
public:
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    72
  static TypeId GetTypeId (void);
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    73
4038
c6f634d0fc6f virtualize ErrorRateModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3905
diff changeset
    74
  YansErrorRateModel ();
3902
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    75
4038
c6f634d0fc6f virtualize ErrorRateModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3905
diff changeset
    76
  virtual double GetChunkSuccessRate (WifiMode mode, double snr, uint32_t nbits) const;
3902
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    77
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    78
private:
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    79
  double Log2 (double val) const;
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    80
  double GetBpskBer (double snr, uint32_t signalSpread, uint32_t phyRate) const;
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    81
  double GetQamBer (double snr, unsigned int m, uint32_t signalSpread, uint32_t phyRate) const;
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    82
  uint32_t Factorial (uint32_t k) const;
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    83
  double Binomial (uint32_t k, double p, uint32_t n) const;
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    84
  double CalculatePdOdd (double ber, unsigned int d) const;
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    85
  double CalculatePdEven (double ber, unsigned int d) const;
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    86
  double CalculatePd (double ber, unsigned int d) const;
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    87
  double GetFecBpskBer (double snr, double nbits, 
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    88
                        uint32_t signalSpread, uint32_t phyRate,
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    89
                        uint32_t dFree, uint32_t adFree) const;
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    90
  double GetFecQamBer (double snr, uint32_t nbits, 
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    91
                       uint32_t signalSpread,
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    92
                       uint32_t phyRate,
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    93
                       uint32_t m, uint32_t dfree,
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    94
                       uint32_t adFree, uint32_t adFreePlusOne) const;
4470
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4038
diff changeset
    95
  double DqpskFunction (double x) const;
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4038
diff changeset
    96
  double Get80211bDsssDbpskSuccessRate (double sinr, uint32_t nbits) const;
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4038
diff changeset
    97
  double Get80211bDsssDqpskSuccessRate (double sinr,uint32_t nbits) const;
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4038
diff changeset
    98
  double Get80211bDsssDqpskCck5_5SuccessRate (double sinr,uint32_t nbits) const;
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4038
diff changeset
    99
  double Get80211bDsssDqpskCck11SuccessRate (double sinr,uint32_t nbits) const;
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4038
diff changeset
   100
#ifdef ENABLE_GSL
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4038
diff changeset
   101
  double SymbolErrorProb16Cck (double e2) const; /// equation (18) in Pursley's paper
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4038
diff changeset
   102
  double SymbolErrorProb256Cck (double e1) const; /// equation (17) in Pursley's paper
4477
b21fc5b07644 fix link on osx
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4470
diff changeset
   103
#else
4470
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4038
diff changeset
   104
private:
4477
b21fc5b07644 fix link on osx
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4470
diff changeset
   105
  static const double WLAN_SIR_PERFECT;
b21fc5b07644 fix link on osx
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4470
diff changeset
   106
  static const double WLAN_SIR_IMPOSSIBLE;
b21fc5b07644 fix link on osx
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4470
diff changeset
   107
#endif
3902
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   108
};
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   109
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   110
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   111
} // namespace ns3
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   112
4038
c6f634d0fc6f virtualize ErrorRateModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3905
diff changeset
   113
#endif /* YANS_ERROR_RATE_MODEL_H */