A Discrete-Event Network Simulator
API
error-rate-model.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2005,2006 INRIA
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19  */
20 
21 #include "error-rate-model.h"
22 #include "ns3/dsss-error-rate-model.h"
23 #include "wifi-tx-vector.h"
24 
25 namespace ns3 {
26 
27 NS_OBJECT_ENSURE_REGISTERED (ErrorRateModel);
28 
30 {
31  static TypeId tid = TypeId ("ns3::ErrorRateModel")
32  .SetParent<Object> ()
33  .SetGroupName ("Wifi")
34  ;
35  return tid;
36 }
37 
38 double
39 ErrorRateModel::CalculateSnr (const WifiTxVector& txVector, double ber) const
40 {
41  //This is a very simple binary search.
42  double low, high, precision;
43  low = 1e-25;
44  high = 1e25;
45  precision = 2e-12;
46  while (high - low > precision)
47  {
48  NS_ASSERT (high >= low);
49  double middle = low + (high - low) / 2;
50  if ((1 - GetChunkSuccessRate (txVector.GetMode (), txVector, middle, 1)) > ber)
51  {
52  low = middle;
53  }
54  else
55  {
56  high = middle;
57  }
58  }
59  return low;
60 }
61 
62 double
63 ErrorRateModel::GetChunkSuccessRate (WifiMode mode, const WifiTxVector& txVector, double snr, uint64_t nbits, uint8_t numRxAntennas, WifiPpduField field, uint16_t staId) const
64 {
66  {
67  switch (mode.GetDataRate (22, 0, 1))
68  {
69  case 1000000:
71  case 2000000:
73  case 5500000:
75  case 11000000:
77  default:
78  NS_ASSERT ("undefined DSSS/HR-DSSS datarate");
79  }
80  }
81  else
82  {
83  return DoGetChunkSuccessRate (mode, txVector, snr, nbits, numRxAntennas, field, staId);
84  }
85  return 0;
86 }
87 
88 bool
90 {
91  return true;
92 }
93 
94 int64_t
96 {
97  // Override this method if the error model uses random variables
98  return 0;
99 }
100 
101 } //namespace ns3
ns3::TypeId
a unique identifier for an interface.
Definition: type-id.h:59
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
NS_ASSERT
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition: assert.h:67
ns3::ErrorRateModel::CalculateSnr
double CalculateSnr(const WifiTxVector &txVector, double ber) const
Definition: error-rate-model.cc:39
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::WifiMode::GetModulationClass
WifiModulationClass GetModulationClass() const
Definition: wifi-mode.cc:159
ns3::ErrorRateModel::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition: error-rate-model.cc:29
ns3::WifiTxVector
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
Definition: wifi-tx-vector.h:71
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:923
ns3::ErrorRateModel::AssignStreams
virtual int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
Definition: error-rate-model.cc:95
ns3::ErrorRateModel::GetChunkSuccessRate
double GetChunkSuccessRate(WifiMode mode, const WifiTxVector &txVector, double snr, uint64_t nbits, uint8_t numRxAntennas=1, WifiPpduField field=WIFI_PPDU_FIELD_DATA, uint16_t staId=SU_STA_ID) const
This method returns the probability that the given 'chunk' of the packet will be successfully receive...
Definition: error-rate-model.cc:63
ns3::WIFI_MOD_CLASS_HR_DSSS
@ WIFI_MOD_CLASS_HR_DSSS
HR/DSSS (Clause 16)
Definition: wifi-phy-common.h:122
ns3::DsssErrorRateModel::GetDsssDqpskCck11SuccessRate
static double GetDsssDqpskCck11SuccessRate(double sinr, uint64_t nbits)
Return the chunk success rate of the differential encoded QPSK for 11Mbps data rate.
Definition: dsss-error-rate-model.cc:95
ns3::WifiMode
represent a single transmission mode
Definition: wifi-mode.h:48
ns3::DsssErrorRateModel::GetDsssDqpskCck5_5SuccessRate
static double GetDsssDqpskCck5_5SuccessRate(double sinr, uint64_t nbits)
Return the chunk success rate of the differential encoded QPSK for 5.5Mbps data rate.
Definition: dsss-error-rate-model.cc:61
ns3::Object
A base class which provides memory management and object aggregation.
Definition: object.h:88
wifi-tx-vector.h
ns3::WifiPpduField
WifiPpduField
The type of PPDU field (grouped for convenience)
Definition: wifi-phy-common.h:166
ns3::ErrorRateModel::IsAwgn
virtual bool IsAwgn(void) const
Definition: error-rate-model.cc:89
ns3::ErrorRateModel::DoGetChunkSuccessRate
virtual double DoGetChunkSuccessRate(WifiMode mode, const WifiTxVector &txVector, double snr, uint64_t nbits, uint8_t numRxAntennas, WifiPpduField field, uint16_t staId) const =0
A pure virtual method that must be implemented in the subclass.
ns3::DsssErrorRateModel::GetDsssDqpskSuccessRate
static double GetDsssDqpskSuccessRate(double sinr, uint64_t nbits)
Return the chunk success rate of the differential encoded QPSK.
Definition: dsss-error-rate-model.cc:52
ns3::WifiMode::GetDataRate
uint64_t GetDataRate(uint16_t channelWidth, uint16_t guardInterval, uint8_t nss) const
Definition: wifi-mode.cc:100
ns3::DsssErrorRateModel::GetDsssDbpskSuccessRate
static double GetDsssDbpskSuccessRate(double sinr, uint64_t nbits)
Return the chunk success rate of the differential BPSK.
Definition: dsss-error-rate-model.cc:43
error-rate-model.h
ns3::WIFI_MOD_CLASS_DSSS
@ WIFI_MOD_CLASS_DSSS
DSSS (Clause 15)
Definition: wifi-phy-common.h:121
ns3::WifiTxVector::GetMode
WifiMode GetMode(uint16_t staId=SU_STA_ID) const
If this TX vector is associated with an SU PPDU, return the selected payload transmission mode.
Definition: wifi-tx-vector.cc:111