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
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.
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 bool IsAwgn(void) const
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.
static TypeId GetTypeId(void)
Get the type ID.
double CalculateSnr(const WifiTxVector &txVector, double ber) const
A base class which provides memory management and object aggregation.
Definition: object.h:88
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:922
represent a single transmission mode
Definition: wifi-mode.h:48
WifiModulationClass GetModulationClass() const
Definition: wifi-mode.cc:177
uint64_t GetDataRate(uint16_t channelWidth, uint16_t guardInterval, uint8_t nss) const
Definition: wifi-mode.cc:114
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:67
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
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.