src/devices/wifi/yans-error-rate-model.cc
author Dean Armstrong <deanarm@gmail.com>
Wed, 01 Dec 2010 22:13:26 +0000
changeset 6674 52f8688d6d01
parent 6597 7fbc895f7361
permissions -rw-r--r--
Bug 978: Run check-style.py on files touched in the reorganisation Cosmetic changes only in this one (hence the reason I wanted them kept separate from the the previous changeset).
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
3902
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    30
TypeId 
4038
c6f634d0fc6f virtualize ErrorRateModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3905
diff changeset
    31
YansErrorRateModel::GetTypeId (void)
3902
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    32
{
4038
c6f634d0fc6f virtualize ErrorRateModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3905
diff changeset
    33
  static TypeId tid = TypeId ("ns3::YansErrorRateModel")
c6f634d0fc6f virtualize ErrorRateModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3905
diff changeset
    34
    .SetParent<ErrorRateModel> ()
c6f634d0fc6f virtualize ErrorRateModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3905
diff changeset
    35
    .AddConstructor<YansErrorRateModel> ()
3902
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    36
    ;
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    37
  return tid;
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    38
}
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    39
4038
c6f634d0fc6f virtualize ErrorRateModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3905
diff changeset
    40
YansErrorRateModel::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
3905
99c9346b5d71 split interference calculation from YansWifiPhy. Move them to InterferenceHelper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3903
diff changeset
    43
double 
4038
c6f634d0fc6f virtualize ErrorRateModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3905
diff changeset
    44
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
    45
{
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    46
  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
    47
}
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    48
double 
4038
c6f634d0fc6f virtualize ErrorRateModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3905
diff changeset
    49
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
    50
{
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    51
  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
    52
  double z = sqrt(EbNo);
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    53
  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
    54
  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
    55
  return ber;
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    56
}
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    57
double 
4038
c6f634d0fc6f virtualize ErrorRateModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3905
diff changeset
    58
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
    59
{
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    60
  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
    61
  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
    62
  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
    63
  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
    64
  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
    65
  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
    66
  return ber;
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    67
}
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    68
uint32_t
4038
c6f634d0fc6f virtualize ErrorRateModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3905
diff changeset
    69
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
    70
{
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    71
  uint32_t fact = 1;
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    72
  while (k > 0) 
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    73
    {
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    74
      fact *= k;
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    75
      k--;
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    76
    }
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    77
  return fact;
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
double 
4038
c6f634d0fc6f virtualize ErrorRateModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3905
diff changeset
    80
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
    81
{
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    82
  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
    83
  return retval;
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    84
}
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    85
double 
4038
c6f634d0fc6f virtualize ErrorRateModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3905
diff changeset
    86
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
    87
{
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    88
  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
    89
  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
    90
  unsigned int dend = d;
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    91
  double pd = 0;
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
  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
    94
    {
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    95
      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
    96
    }
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    97
  return pd;
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    98
}
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    99
double 
4038
c6f634d0fc6f virtualize ErrorRateModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3905
diff changeset
   100
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
   101
{
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   102
  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
   103
  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
   104
  unsigned int dend = d;
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   105
  double pd = 0;
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
  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
   108
    {
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   109
      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
   110
    }
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   111
  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
   112
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   113
  return pd;
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   114
}
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
double 
4038
c6f634d0fc6f virtualize ErrorRateModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3905
diff changeset
   117
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
   118
{
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   119
  double pd;
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   120
  if ((d % 2) == 0) 
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   121
    {
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   122
      pd = CalculatePdEven (ber, d);
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
  else 
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   125
    {
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   126
      pd = CalculatePdOdd (ber, d);
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   127
    }
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   128
  return pd;
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   129
}
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
double
4038
c6f634d0fc6f virtualize ErrorRateModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3905
diff changeset
   132
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
   133
                         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
   134
                         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
   135
{
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   136
  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
   137
  if (ber == 0.0) 
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   138
    {
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   139
      return 1.0;
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 pd = CalculatePd (ber, dFree);
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   142
  double pmu = adFree * pd;
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   143
  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
   144
  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
   145
  return pms;
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   146
}
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   147
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   148
double
4038
c6f634d0fc6f virtualize ErrorRateModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3905
diff changeset
   149
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
   150
                       uint32_t signalSpread,
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   151
                       uint32_t phyRate,
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   152
                       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
   153
                       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
   154
{
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   155
  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
   156
  if (ber == 0.0) 
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   157
    {
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   158
      return 1.0;
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
  /* first term */
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   161
  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
   162
  double pmu = adFree * pd;
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   163
  /* second term */
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   164
  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
   165
  pmu += adFreePlusOne * pd;
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   166
  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
   167
  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
   168
  return pms;
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   169
}
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   170
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   171
double 
4038
c6f634d0fc6f virtualize ErrorRateModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3905
diff changeset
   172
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
   173
{
6597
7fbc895f7361 Bug 852: Support ERP-OFDM rates and thus '802.11g'
Dean Armstrong <deanarm@gmail.com>
parents: 6360
diff changeset
   174
  if (mode.GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM ||
7fbc895f7361 Bug 852: Support ERP-OFDM rates and thus '802.11g'
Dean Armstrong <deanarm@gmail.com>
parents: 6360
diff changeset
   175
      mode.GetModulationClass () == WIFI_MOD_CLASS_OFDM)
3902
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   176
    {
6360
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   177
      if (mode.GetConstellationSize () == 2)
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   178
        {
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   179
          if (mode.GetCodeRate () == WIFI_CODE_RATE_1_2)
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   180
            {
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   181
              return GetFecBpskBer (snr,
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   182
                                    nbits,
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   183
                                    mode.GetBandwidth (), // signal spread
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   184
                                    mode.GetPhyRate (), // phy rate
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   185
                                    10, // dFree
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   186
                                    11 // adFree
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   187
                                    );
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   188
            }
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   189
          else
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   190
            {
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   191
              return GetFecBpskBer (snr,
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   192
                                    nbits,
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   193
                                    mode.GetBandwidth (), // signal spread
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   194
                                    mode.GetPhyRate (), // phy rate
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   195
                                    5, // dFree
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   196
                                    8 // adFree
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   197
                                    );
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   198
            }
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   199
        }
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   200
      else if (mode.GetConstellationSize () == 4)
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   201
        {
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   202
          if (mode.GetCodeRate () == WIFI_CODE_RATE_1_2)
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   203
            {
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   204
              return GetFecQamBer (snr,
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   205
                                   nbits,
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   206
                                   mode.GetBandwidth (), // signal spread
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   207
                                   mode.GetPhyRate (), // phy rate
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   208
                                   4,  // m
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   209
                                   10, // dFree
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   210
                                   11, // adFree
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   211
                                   0   // adFreePlusOne
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   212
                                   );
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   213
            }
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   214
          else
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   215
            {
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   216
              return GetFecQamBer (snr,
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   217
                                   nbits,
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   218
                                   mode.GetBandwidth (), // signal spread
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   219
                                   mode.GetPhyRate (), // phy rate
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   220
                                   4, // m
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   221
                                   5, // dFree
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   222
                                   8, // adFree
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   223
                                   31 // adFreePlusOne
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   224
                                   );
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   225
            }
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   226
        }
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   227
      else if (mode.GetConstellationSize () == 16)
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   228
        {
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   229
          if (mode.GetCodeRate () == WIFI_CODE_RATE_1_2)
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   230
            {
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   231
              return GetFecQamBer (snr,
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   232
                                   nbits,
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   233
                                   mode.GetBandwidth (), // signal spread
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   234
                                   mode.GetPhyRate (), // phy rate
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   235
                                   16, // m
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   236
                                   10, // dFree
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   237
                                   11, // adFree
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   238
                                   0   // adFreePlusOne
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   239
                                   );
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   240
            }
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   241
          else
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   242
            {
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   243
              return GetFecQamBer (snr,
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   244
                                   nbits,
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   245
                                   mode.GetBandwidth (), // signal spread
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   246
                                   mode.GetPhyRate (), // phy rate
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   247
                                   16, // m
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   248
                                   5,  // dFree
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   249
                                   8,  // adFree
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   250
                                   31  // adFreePlusOne
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   251
                                   );
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   252
            }
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   253
        }
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   254
      else if (mode.GetConstellationSize () == 64)
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   255
        {
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   256
          if (mode.GetCodeRate () == WIFI_CODE_RATE_2_3)
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   257
            {
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   258
              return GetFecQamBer (snr,
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   259
                                   nbits,
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   260
                                   mode.GetBandwidth (), // signal spread
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   261
                                   mode.GetPhyRate (), // phy rate
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   262
                                   64, // m
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   263
                                   6,  // dFree
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   264
                                   1,  // adFree
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   265
                                   16  // adFreePlusOne
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   266
                                   );
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   267
            }
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   268
          else
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   269
            {
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   270
              return GetFecQamBer (snr,
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   271
                                   nbits,
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   272
                                   mode.GetBandwidth (), // signal spread
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   273
                                   mode.GetPhyRate (), // phy rate
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   274
                                   64, // m
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   275
                                   5,  // dFree
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   276
                                   8,  // adFree
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   277
                                   31  // adFreePlusOne
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   278
                                   );
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   279
            }
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   280
        }
3902
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   281
    }
6360
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   282
  else if (mode.GetModulationClass () == WIFI_MOD_CLASS_DSSS)
3902
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   283
    {
6360
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   284
      switch (mode.GetDataRate ())
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   285
        {
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   286
        case 1000000:
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   287
          return DsssErrorRateModel::GetDsssDbpskSuccessRate (snr, nbits);
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   288
        case 2000000:
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   289
          return DsssErrorRateModel::GetDsssDqpskSuccessRate (snr, nbits);
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   290
        case 5500000:
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   291
          return DsssErrorRateModel::GetDsssDqpskCck5_5SuccessRate (snr, nbits);
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   292
        case 11000000:
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   293
          return DsssErrorRateModel::GetDsssDqpskCck11SuccessRate (snr, nbits);
d8975477ff6a Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents: 6357
diff changeset
   294
        }
4470
51b5c1a272d3 802.11b PHY support
Gary Pei <guangyu.pei@boeing.com>
parents: 4039
diff changeset
   295
    }
3902
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   296
  return 0;
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   297
}
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   298
9e048e073cf0 split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   299
} // namespace ns3