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