src/devices/wifi/yans-error-rate-model.cc
author Pavel Boyko <boyko@iitp.ru>
Tue, 16 Jun 2009 17:58:16 +0400
changeset 5074 355de6af8ea9
parent 4477 b21fc5b07644
child 4680 a52c39181dd4
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
#include "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
    21
#include "wifi-phy.h"
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    22
#include "ns3/log.h"
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    23
4038
c6f634d0fc6f virtualize ErrorRateModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3905
diff changeset
    24
NS_LOG_COMPONENT_DEFINE ("YansErrorRateModel");
3902
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    25
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    26
namespace ns3 {
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    27
4038
c6f634d0fc6f virtualize ErrorRateModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3905
diff changeset
    28
NS_OBJECT_ENSURE_REGISTERED (YansErrorRateModel);
3905
99c9346b5d71 split interference calculation from YansWifiPhy. Move them to InterferenceHelper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3903
diff changeset
    29
4477
b21fc5b07644 fix link on osx
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4470
diff changeset
    30
#ifndef ENABLE_GSL
b21fc5b07644 fix link on osx
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4470
diff changeset
    31
const double YansErrorRateModel::WLAN_SIR_PERFECT = 10.0; 
b21fc5b07644 fix link on osx
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4470
diff changeset
    32
const double YansErrorRateModel::WLAN_SIR_IMPOSSIBLE = 0.1; 
b21fc5b07644 fix link on osx
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4470
diff changeset
    33
#endif
b21fc5b07644 fix link on osx
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4470
diff changeset
    34
3902
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    35
TypeId 
4038
c6f634d0fc6f virtualize ErrorRateModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3905
diff changeset
    36
YansErrorRateModel::GetTypeId (void)
3902
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    37
{
4038
c6f634d0fc6f virtualize ErrorRateModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3905
diff changeset
    38
  static TypeId tid = TypeId ("ns3::YansErrorRateModel")
c6f634d0fc6f virtualize ErrorRateModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3905
diff changeset
    39
    .SetParent<ErrorRateModel> ()
c6f634d0fc6f virtualize ErrorRateModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3905
diff changeset
    40
    .AddConstructor<YansErrorRateModel> ()
3902
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    41
    ;
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    42
  return tid;
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    43
}
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    44
4038
c6f634d0fc6f virtualize ErrorRateModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3905
diff changeset
    45
YansErrorRateModel::YansErrorRateModel ()
3902
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    46
{}
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    47
3905
99c9346b5d71 split interference calculation from YansWifiPhy. Move them to InterferenceHelper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3903
diff changeset
    48
double 
4038
c6f634d0fc6f virtualize ErrorRateModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3905
diff changeset
    49
YansErrorRateModel::Log2 (double val) const
3902
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    50
{
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    51
  return log(val) / log(2.0);
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    52
}
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    53
double 
4038
c6f634d0fc6f virtualize ErrorRateModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3905
diff changeset
    54
YansErrorRateModel::GetBpskBer (double snr, uint32_t signalSpread, uint32_t phyRate) const
3902
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    55
{
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    56
  double EbNo = snr * signalSpread / phyRate;
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    57
  double z = sqrt(EbNo);
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    58
  double ber = 0.5 * erfc(z);
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    59
  NS_LOG_INFO ("bpsk snr="<<snr<<" ber="<<ber);
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    60
  return ber;
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    61
}
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    62
double 
4038
c6f634d0fc6f virtualize ErrorRateModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3905
diff changeset
    63
YansErrorRateModel::GetQamBer (double snr, unsigned int m, uint32_t signalSpread, uint32_t phyRate) const
3902
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    64
{
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    65
  double EbNo = snr * signalSpread / phyRate;
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    66
  double z = sqrt ((1.5 * Log2 (m) * EbNo) / (m - 1.0));
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    67
  double z1 = ((1.0 - 1.0 / sqrt (m)) * erfc (z)) ;
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    68
  double z2 = 1 - pow ((1-z1), 2.0);
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    69
  double ber = z2 / Log2 (m);
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    70
  NS_LOG_INFO ("Qam m="<<m<<" rate=" << phyRate << " snr="<<snr<<" ber="<<ber);
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    71
  return ber;
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    72
}
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    73
uint32_t
4038
c6f634d0fc6f virtualize ErrorRateModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3905
diff changeset
    74
YansErrorRateModel::Factorial (uint32_t k) const
3902
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    75
{
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    76
  uint32_t fact = 1;
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    77
  while (k > 0) 
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    78
    {
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    79
      fact *= k;
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    80
      k--;
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    81
    }
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    82
  return fact;
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    83
}
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    84
double 
4038
c6f634d0fc6f virtualize ErrorRateModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3905
diff changeset
    85
YansErrorRateModel::Binomial (uint32_t k, double p, uint32_t n) const
3902
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    86
{
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    87
  double retval = Factorial (n) / (Factorial (k) * Factorial (n-k)) * pow (p, k) * pow (1-p, n-k);
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    88
  return retval;
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    89
}
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    90
double 
4038
c6f634d0fc6f virtualize ErrorRateModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3905
diff changeset
    91
YansErrorRateModel::CalculatePdOdd (double ber, unsigned int d) const
3902
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    92
{
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    93
  NS_ASSERT ((d % 2) == 1);
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    94
  unsigned int dstart = (d + 1) / 2;
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    95
  unsigned int dend = d;
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    96
  double pd = 0;
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    97
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    98
  for (unsigned int i = dstart; i < dend; i++) 
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    99
    {
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   100
      pd += Binomial (i, ber, d);
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   101
    }
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   102
  return pd;
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   103
}
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   104
double 
4038
c6f634d0fc6f virtualize ErrorRateModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3905
diff changeset
   105
YansErrorRateModel::CalculatePdEven (double ber, unsigned int d) const
3902
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   106
{
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   107
  NS_ASSERT ((d % 2) == 0);
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   108
  unsigned int dstart = d / 2 + 1;
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   109
  unsigned int dend = d;
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   110
  double pd = 0;
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   111
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   112
  for (unsigned int i = dstart; i < dend; i++)
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   113
    {
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   114
      pd +=  Binomial (i, ber, d);
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   115
    }
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   116
  pd += 0.5 * Binomial (d / 2, ber, d);
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   117
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   118
  return pd;
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   119
}
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   120
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   121
double 
4038
c6f634d0fc6f virtualize ErrorRateModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3905
diff changeset
   122
YansErrorRateModel::CalculatePd (double ber, unsigned int d) const
3902
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   123
{
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   124
  double pd;
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   125
  if ((d % 2) == 0) 
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   126
    {
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   127
      pd = CalculatePdEven (ber, d);
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   128
    } 
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   129
  else 
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   130
    {
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   131
      pd = CalculatePdOdd (ber, d);
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   132
    }
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   133
  return pd;
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   134
}
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   135
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   136
double
4038
c6f634d0fc6f virtualize ErrorRateModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3905
diff changeset
   137
YansErrorRateModel::GetFecBpskBer (double snr, double nbits, 
3902
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   138
                         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
   139
                         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
   140
{
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   141
  double ber = GetBpskBer (snr, signalSpread, phyRate);
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   142
  if (ber == 0.0) 
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   143
    {
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   144
      return 1.0;
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   145
    }
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   146
  double pd = CalculatePd (ber, dFree);
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   147
  double pmu = adFree * pd;
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   148
  pmu = std::min (pmu, 1.0);
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   149
  double pms = pow (1 - pmu, nbits);
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   150
  return pms;
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   151
}
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   152
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   153
double
4038
c6f634d0fc6f virtualize ErrorRateModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3905
diff changeset
   154
YansErrorRateModel::GetFecQamBer (double snr, uint32_t nbits, 
3902
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   155
                       uint32_t signalSpread,
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   156
                       uint32_t phyRate,
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   157
                       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
   158
                       uint32_t adFree, uint32_t adFreePlusOne) const
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   159
{
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   160
  double ber = GetQamBer (snr, m, signalSpread, phyRate);
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   161
  if (ber == 0.0) 
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   162
    {
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   163
      return 1.0;
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   164
    }
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   165
  /* first term */
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   166
  double pd = CalculatePd (ber, dFree);
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   167
  double pmu = adFree * pd;
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   168
  /* second term */
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   169
  pd = CalculatePd (ber, dFree + 1);
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   170
  pmu += adFreePlusOne * pd;
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   171
  pmu = std::min (pmu, 1.0);
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   172
  double pms = pow (1 - pmu, nbits);
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   173
  return pms;
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   174
}
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   175
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   176
double 
4038
c6f634d0fc6f virtualize ErrorRateModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3905
diff changeset
   177
YansErrorRateModel::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
   178
{
4039
50a070c2750c remove public static variables. Use public static methods
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4038
diff changeset
   179
  if (mode == WifiPhy::Get6mba ())
3902
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   180
    {
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   181
      return GetFecBpskBer (snr, 
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   182
                            nbits,
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   183
                            mode.GetBandwidth (), // signal spread
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   184
                            mode.GetPhyRate (), // phy rate
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   185
                            10, // dFree
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   186
                            11 // adFree
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   187
                            );      
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   188
    }
4039
50a070c2750c remove public static variables. Use public static methods
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4038
diff changeset
   189
  else if (mode == WifiPhy::Get9mba ())
3902
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   190
    {
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   191
      return GetFecBpskBer (snr, 
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   192
                            nbits,
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   193
                            mode.GetBandwidth (), // signal spread
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   194
                            mode.GetPhyRate (), // phy rate
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   195
                            5, // dFree
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   196
                            8 // adFree
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   197
                            );
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   198
    }
4039
50a070c2750c remove public static variables. Use public static methods
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4038
diff changeset
   199
  else if (mode == WifiPhy::Get12mba ())
3902
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   200
    {
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   201
      return GetFecQamBer (snr, 
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   202
                           nbits,
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   203
                           mode.GetBandwidth (), // signal spread
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   204
                           mode.GetPhyRate (), // phy rate
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   205
                           4,  // m 
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   206
                           10, // dFree
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   207
                           11, // adFree
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   208
                           0   // adFreePlusOne
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   209
                           );
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   210
    }
4039
50a070c2750c remove public static variables. Use public static methods
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4038
diff changeset
   211
  else if (mode == WifiPhy::Get18mba ())
3902
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   212
    {
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   213
      return GetFecQamBer (snr, 
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   214
                           nbits,
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   215
                           mode.GetBandwidth (), // signal spread
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   216
                           mode.GetPhyRate (), // phy rate
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   217
                           4, // m
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   218
                           5, // dFree
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   219
                           8, // adFree
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   220
                           31 // adFreePlusOne
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   221
                           );
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   222
    }
4039
50a070c2750c remove public static variables. Use public static methods
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4038
diff changeset
   223
  else if (mode == WifiPhy::Get24mba ())
3902
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   224
    {
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   225
      return GetFecQamBer (snr, 
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   226
                           nbits,
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   227
                           mode.GetBandwidth (), // signal spread
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   228
                           mode.GetPhyRate (), // phy rate
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   229
                           16, // m
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   230
                           10, // dFree
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   231
                           11, // adFree
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   232
                           0   // adFreePlusOne
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   233
                           );
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   234
    }
4039
50a070c2750c remove public static variables. Use public static methods
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4038
diff changeset
   235
  else if (mode == WifiPhy::Get36mba ())
3902
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   236
    {
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   237
      return GetFecQamBer (snr, 
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   238
                           nbits,
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   239
                           mode.GetBandwidth (), // signal spread
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   240
                           mode.GetPhyRate (), // phy rate
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   241
                           16, // m
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   242
                           5,  // dFree
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   243
                           8,  // adFree
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   244
                           31  // adFreePlusOne
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   245
                           );
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   246
    }
4039
50a070c2750c remove public static variables. Use public static methods
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4038
diff changeset
   247
  else if (mode == WifiPhy::Get48mba ())
3902
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   248
    {
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   249
      return GetFecQamBer (snr, 
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   250
                           nbits,
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   251
                           mode.GetBandwidth (), // signal spread
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   252
                           mode.GetPhyRate (), // phy rate
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   253
                           64, // m
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   254
                           6,  // dFree
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   255
                           1,  // adFree
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   256
                           16  // adFreePlusOne
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   257
                           );
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   258
    }
4039
50a070c2750c remove public static variables. Use public static methods
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4038
diff changeset
   259
  else if (mode == WifiPhy::Get54mba ())
3902
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   260
    {
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   261
      return GetFecQamBer (snr, 
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   262
                           nbits,
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   263
                           mode.GetBandwidth (), // signal spread
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   264
                           mode.GetPhyRate (), // phy rate
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   265
                           64, // m
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   266
                           5,  // dFree
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   267
                           8,  // adFree
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   268
                           31  // adFreePlusOne
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   269
                           );
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   270
    }
4470
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   271
  else if (mode == WifiPhy::Get1mbb ())
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   272
    {
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   273
      return Get80211bDsssDbpskSuccessRate (snr,nbits);
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   274
    }
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   275
  else if (mode == WifiPhy::Get2mbb ())
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   276
    {
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   277
      return Get80211bDsssDqpskSuccessRate (snr,nbits);
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   278
    }
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   279
  else if (mode == WifiPhy::Get5_5mbb ())
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   280
    {
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   281
      return Get80211bDsssDqpskCck5_5SuccessRate (snr,nbits);
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   282
    }
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   283
  else if (mode == WifiPhy::Get11mbb ())
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   284
    {
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   285
      return Get80211bDsssDqpskCck11SuccessRate (snr,nbits);
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   286
    }
3902
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   287
  return 0;
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   288
}
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   289
4470
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   290
// 802.11b ber based on "Wireless Network Coexistence: Wireless
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   291
// LAN in the 21st Century" by Robert Morrow page 187
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   292
double 
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   293
YansErrorRateModel::DqpskFunction (double x) const
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   294
{
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   295
  return ((sqrt (2.0) + 1.0) / sqrt (8.0*3.1415926*sqrt (2.0)))
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   296
         *(1.0/sqrt (x))
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   297
         *exp ( - (2.0 - sqrt (2.0)) * x) ;
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   298
}
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   299
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   300
double 
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   301
YansErrorRateModel::Get80211bDsssDbpskSuccessRate (double sinr, uint32_t nbits) const
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   302
{
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   303
  double EbN0 = sinr * 22000000.0 / 1000000.0; // 1 bit per symbol with 1 MSPS
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   304
  double ber = 0.5 * exp (-EbN0);
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   305
  return pow ((1.0 - ber), nbits);
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   306
}
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   307
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   308
double 
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   309
YansErrorRateModel::Get80211bDsssDqpskSuccessRate (double sinr,uint32_t nbits) const
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   310
{
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   311
  double EbN0 = sinr * 22000000.0 / 1000000.0 / 2.0; // 2 bits per symbol, 1 MSPS
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   312
  double ber = DqpskFunction (EbN0);
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   313
  return pow ((1.0 - ber), nbits);
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   314
}
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   315
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   316
double 
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   317
YansErrorRateModel::Get80211bDsssDqpskCck5_5SuccessRate (double sinr,uint32_t nbits) const
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   318
{
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   319
#ifdef ENABLE_GSL
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   320
  // symbol error probability
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   321
  double EbN0 = sinr * 22000000.0 / 1375000.0 / 4.0;
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   322
  double sep = SymbolErrorProb16Cck (4.0*EbN0/2.0);
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   323
  return pow (1.0-sep,nbits/4.0);
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   324
#else
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   325
  NS_LOG_WARN ("Running a 802.11b CCK Matlab model less accurate than GSL model"); 
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   326
  // The matlab model
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   327
  double ber; 
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   328
  if (sinr > WLAN_SIR_PERFECT)
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   329
    {
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   330
       ber = 0.0 ;
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   331
    }
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   332
  else if (sinr < WLAN_SIR_IMPOSSIBLE)
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   333
    {
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   334
       ber = 0.5;
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   335
    }
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   336
  else
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   337
    { // fitprops.coeff from matlab berfit
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   338
       double a1 =  5.3681634344056195e-001;
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   339
       double a2 =  3.3092430025608586e-003;
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   340
       double a3 =  4.1654372361004000e-001;
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   341
       double a4 =  1.0288981434358866e+000;
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   342
       ber = a1 * exp (-(pow ((sinr-a2)/a3,a4)));
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   343
     }
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   344
  return pow ((1.0 - ber), nbits);
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   345
#endif
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   346
}
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   347
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   348
double 
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   349
YansErrorRateModel::Get80211bDsssDqpskCck11SuccessRate (double sinr,uint32_t nbits) const
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   350
{
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   351
#ifdef ENABLE_GSL
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   352
 // symbol error probability
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   353
  double EbN0 = sinr * 22000000.0 / 1375000.0 / 8.0;
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   354
  double sep = SymbolErrorProb256Cck (8.0*EbN0/2.0);
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   355
  return pow (1.0-sep,nbits/8.0);
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   356
#else
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   357
  NS_LOG_WARN ("Running a 802.11b CCK Matlab model less accurate than GSL model"); 
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   358
  // The matlab model
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   359
  double ber; 
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   360
  if (sinr > WLAN_SIR_PERFECT)
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   361
    {
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   362
       ber = 0.0 ;
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   363
    }
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   364
  else if (sinr < WLAN_SIR_IMPOSSIBLE)
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   365
    {
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   366
       ber = 0.5;
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   367
    }
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   368
  else
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   369
    { // fitprops.coeff from matlab berfit
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   370
       double a1 =  7.9056742265333456e-003;
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   371
       double a2 = -1.8397449399176360e-001;
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   372
       double a3 =  1.0740689468707241e+000;
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   373
       double a4 =  1.0523316904502553e+000;
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   374
       double a5 =  3.0552298746496687e-001;
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   375
       double a6 =  2.2032715128698435e+000;
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   376
       ber =  (a1*sinr*sinr+a2*sinr+a3)/(sinr*sinr*sinr+a4*sinr*sinr+a5*sinr+a6);
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   377
     }
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   378
  return pow ((1.0 - ber), nbits);
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   379
#endif
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   380
}
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   381
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   382
#ifdef ENABLE_GSL
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   383
double 
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   384
IntegralFunction (double x, void *params)
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   385
{
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   386
  double beta = ((FunctionParameters *) params)->beta;
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   387
  double n = ((FunctionParameters *) params)->n;
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   388
  double IntegralFunction = pow (2*gsl_cdf_ugaussian_P (x+ beta) - 1, n-1) 
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   389
                            * exp (-x*x/2.0) / sqrt (2.0 * M_PI);
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   390
  return IntegralFunction;
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   391
}
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   392
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   393
double 
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   394
YansErrorRateModel::SymbolErrorProb16Cck (double e2) const
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   395
{
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   396
  double sep;
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   397
  double error;
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   398
 
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   399
  FunctionParameters params;
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   400
  params.beta = sqrt (2.0*e2);
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   401
  params.n = 8.0;
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   402
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   403
  gsl_integration_workspace * w = gsl_integration_workspace_alloc (1000); 
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   404
 
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   405
  gsl_function F;
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   406
  F.function = &IntegralFunction;
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   407
  F.params = &params;
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   408
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   409
  gsl_integration_qagiu (&F,-params.beta, 0, 1e-7, 1000, w, &sep, &error);
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   410
  gsl_integration_workspace_free (w);
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   411
  if (error == 0.0) 
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   412
    {
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   413
       sep = 1.0;
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   414
    }
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   415
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   416
  return 1.0 - sep;
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   417
}
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   418
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   419
double YansErrorRateModel::SymbolErrorProb256Cck (double e1) const
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   420
{
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   421
  return 1.0 - pow (1.0 - SymbolErrorProb16Cck (e1/2.0), 2.0);
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   422
}
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   423
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   424
#endif
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   425
3902
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   426
} // namespace ns3