src/wifi/model/dsss-error-rate-model.h
author Junling Bu <linlinjavaer@gmail.com>
Tue, 03 Dec 2013 11:25:59 -0800
changeset 10459 f2e90c12a44f
parent 10424 9d29c9a5ddcb
child 11450 9f4ae69f12b7
permissions -rw-r--r--
base implementation of the IEEE 802.11p standard
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7385
10beb0e53130 standardize emacs c++ mode comments
Vedran Miletić <rivanvx@gmail.com>
parents: 7141
diff changeset
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
6357
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
     2
/*
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
     3
 * Copyright (c) 2010 The Boeing Company
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
     4
 *
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
7141
072fb225b714 run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents: 7139
diff changeset
     6
 * it under the terms of the GNU General Public License version 2 as
6357
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
     7
 * published by the Free Software Foundation;
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
     8
 *
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
    12
 * GNU General Public License for more details.
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
    13
 *
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
    17
 *
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
    18
 * Author: Gary Pei <guangyu.pei@boeing.com>
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
    19
 */
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
    20
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
    21
#ifndef DSS_ERROR_RATE_MODEL_H
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
    22
#define DSS_ERROR_RATE_MODEL_H
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
    23
#include <stdint.h>
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
    24
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
    25
#ifdef ENABLE_GSL
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
    26
#include <gsl/gsl_math.h>
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
    27
#include <gsl/gsl_integration.h>
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
    28
#include <gsl/gsl_cdf.h>
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
    29
#include <gsl/gsl_sf_bessel.h>
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
    30
#endif
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
    31
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
    32
namespace ns3 {
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
    33
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
    34
#ifdef ENABLE_GSL
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
    35
typedef struct FunctionParameterType
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
    36
{
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
    37
  double beta;
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
    38
  double n;
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
    39
} FunctionParameters;
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
    40
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
    41
double IntegralFunction (double x, void *params);
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
    42
#endif
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
    43
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
    44
/**
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
    45
 * \brief an implementation of DSSS error rate model
7139
79dd02ed46ec doxygen wifi module grouping all wifi classes
Nicola Baldo <nbaldo@cttc.es>
parents: 6852
diff changeset
    46
 * \ingroup wifi
6357
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
    47
 *
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
    48
 * The 802.11b modulations:
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
    49
 *    - 1 Mbps mode is based on DBPSK. BER is from equation 5.2-69 from John G. Proakis
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
    50
 *      Digitial Communications, 2001 edition
7141
072fb225b714 run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents: 7139
diff changeset
    51
 *    - 2 Mbps model is based on DQPSK. Equation 8 from "Tight bounds and accurate
072fb225b714 run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents: 7139
diff changeset
    52
 *      approximations for dqpsk transmission bit error rate", G. Ferrari and G.E. Corazza
6357
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
    53
 *      ELECTRONICS LETTERS, 40(20):1284-1285, September 2004
7141
072fb225b714 run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents: 7139
diff changeset
    54
 *    - 5.5 Mbps and 11 Mbps are based on equations (18) and (17) from "Properties and
072fb225b714 run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents: 7139
diff changeset
    55
 *      performance of the ieee 802.11b complementarycode-key signal sets",
072fb225b714 run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents: 7139
diff changeset
    56
 *      Michael B. Pursley and Thomas C. Royster. IEEE TRANSACTIONS ON COMMUNICATIONS,
6357
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
    57
 *      57(2):440-449, February 2009.
7141
072fb225b714 run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents: 7139
diff changeset
    58
 *
072fb225b714 run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents: 7139
diff changeset
    59
 *  This model is designed to run with highest accuracy using the Gnu
6357
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
    60
 *  Scientific Library (GSL), but if GSL is not installed on the platform,
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
    61
 *  will fall back to (slightly less accurate) Matlab-derived models for
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
    62
 *  the CCK modulation types.
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
    63
 *
7141
072fb225b714 run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents: 7139
diff changeset
    64
 *  More detailed description and validation can be found in
6357
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
    65
 *      http://www.nsnam.org/~pei/80211b.pdf
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
    66
 */
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
    67
class DsssErrorRateModel
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
    68
{
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
    69
public:
10424
9d29c9a5ddcb doxygen warnings for wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    70
  /**
9d29c9a5ddcb doxygen warnings for wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    71
   * A function DQPSK
9d29c9a5ddcb doxygen warnings for wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    72
   *
9d29c9a5ddcb doxygen warnings for wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    73
   * \param x x
9d29c9a5ddcb doxygen warnings for wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    74
   * \return DQPSK(x)
9d29c9a5ddcb doxygen warnings for wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    75
   */
6357
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
    76
  static double DqpskFunction (double x);
10424
9d29c9a5ddcb doxygen warnings for wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    77
  /**
9d29c9a5ddcb doxygen warnings for wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    78
   * Return the chunk success rate of the differential BPSK.
9d29c9a5ddcb doxygen warnings for wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    79
   *
9d29c9a5ddcb doxygen warnings for wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    80
   * \param sinr the SINR of the chunk
9d29c9a5ddcb doxygen warnings for wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    81
   * \param nbits the size of the chunk
9d29c9a5ddcb doxygen warnings for wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    82
   * \return the chunk success rate of the differential BPSK
9d29c9a5ddcb doxygen warnings for wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    83
   */
6357
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
    84
  static double GetDsssDbpskSuccessRate (double sinr, uint32_t nbits);
10424
9d29c9a5ddcb doxygen warnings for wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    85
  /**
9d29c9a5ddcb doxygen warnings for wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    86
   * Return the chunk success rate of the differential encoded QPSK.
9d29c9a5ddcb doxygen warnings for wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    87
   *
9d29c9a5ddcb doxygen warnings for wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    88
   * \param sinr the SINR of the chunk
9d29c9a5ddcb doxygen warnings for wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    89
   * \param nbits the size of the chunk
9d29c9a5ddcb doxygen warnings for wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    90
   * \return the chunk success rate of the differential encoded QPSK.
9d29c9a5ddcb doxygen warnings for wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    91
   */
6357
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
    92
  static double GetDsssDqpskSuccessRate (double sinr,uint32_t nbits);
10424
9d29c9a5ddcb doxygen warnings for wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    93
  /**
9d29c9a5ddcb doxygen warnings for wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    94
   * Return the chunk success rate of the differential encoded QPSK for
9d29c9a5ddcb doxygen warnings for wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    95
   * 5.5Mbps data rate.
9d29c9a5ddcb doxygen warnings for wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    96
   *
9d29c9a5ddcb doxygen warnings for wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    97
   * \param sinr the SINR of the chunk
9d29c9a5ddcb doxygen warnings for wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    98
   * \param nbits the size of the chunk
9d29c9a5ddcb doxygen warnings for wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
    99
   * \return the chunk success rate of the differential encoded QPSK for
9d29c9a5ddcb doxygen warnings for wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   100
   */
6357
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
   101
  static double GetDsssDqpskCck5_5SuccessRate (double sinr,uint32_t nbits);
10424
9d29c9a5ddcb doxygen warnings for wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   102
  /**
9d29c9a5ddcb doxygen warnings for wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   103
   * Return the chunk success rate of the differential encoded QPSK for
9d29c9a5ddcb doxygen warnings for wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   104
   * 11Mbps data rate.
9d29c9a5ddcb doxygen warnings for wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   105
   *
9d29c9a5ddcb doxygen warnings for wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   106
   * \param sinr the SINR of the chunk
9d29c9a5ddcb doxygen warnings for wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   107
   * \param nbits the size of the chunk
9d29c9a5ddcb doxygen warnings for wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   108
   * \return the chunk success rate of the differential encoded QPSK for
9d29c9a5ddcb doxygen warnings for wifi module
Daniel Lertpratchya <nikkipui@gmail.com>
parents: 7385
diff changeset
   109
   */
6357
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
   110
  static double GetDsssDqpskCck11SuccessRate (double sinr,uint32_t nbits);
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
   111
#ifdef ENABLE_GSL
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
   112
  static double SymbolErrorProb16Cck (double e2);  /// equation (18) in Pursley's paper
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
   113
  static double SymbolErrorProb256Cck (double e1);  /// equation (17) in Pursley's paper
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
   114
#else
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
   115
protected:
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
   116
  static const double WLAN_SIR_PERFECT;
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
   117
  static const double WLAN_SIR_IMPOSSIBLE;
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
   118
#endif
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
   119
};
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
   120
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
   121
} // namespace ns3
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
   122
5d6d511ce4e9 Factor out DSSS error rate functions to separate class
Gary Pei <guangyu.pei@boeing.com>
parents:
diff changeset
   123
#endif /* DSSS_ERROR_RATE_MODEL_H */