A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
error-rate-model.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2005,2006 INRIA
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
7 */
8
9#include "error-rate-model.h"
10
11#include "wifi-tx-vector.h"
12
13#include "ns3/dsss-error-rate-model.h"
14
15namespace ns3
16{
17
18NS_OBJECT_ENSURE_REGISTERED(ErrorRateModel);
19
20TypeId
22{
23 static TypeId tid = TypeId("ns3::ErrorRateModel").SetParent<Object>().SetGroupName("Wifi");
24 return tid;
25}
26
27double
28ErrorRateModel::CalculateSnr(const WifiTxVector& txVector, double ber) const
29{
30 // This is a very simple binary search.
31 double low;
32 double high;
33 double precision;
34 low = 1e-25;
35 high = 1e25;
36 precision = 8e-12;
37 while (high - low > precision)
38 {
39 NS_ASSERT(high >= low);
40 double middle = low + (high - low) / 2;
41 if ((1 - GetChunkSuccessRate(txVector.GetMode(), txVector, middle, 1)) > ber)
42 {
43 low = middle;
44 }
45 else
46 {
47 high = middle;
48 }
49 }
50 return low;
51}
52
53double
55 const WifiTxVector& txVector,
56 double snr,
57 uint64_t nbits,
58 uint8_t numRxAntennas,
59 WifiPpduField field,
60 uint16_t staId) const
61{
64 {
65 switch (mode.GetDataRate(22))
66 {
67 case 1000000:
69 case 2000000:
71 case 5500000:
73 case 11000000:
75 default:
76 NS_ASSERT("undefined DSSS/HR-DSSS datarate");
77 }
78 }
79 else
80 {
81 return DoGetChunkSuccessRate(mode, txVector, snr, nbits, numRxAntennas, field, staId);
82 }
83 return 0;
84}
85
86bool
88{
89 return true;
90}
91
92int64_t
94{
95 // Override this method if the error model uses random variables
96 return 0;
97}
98
99} // 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:78
a unique identifier for an interface.
Definition type-id.h:48
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
represent a single transmission mode
Definition wifi-mode.h:40
WifiModulationClass GetModulationClass() const
Definition wifi-mode.cc:174
uint64_t GetDataRate(MHz_u channelWidth, Time guardInterval, uint8_t nss) const
Definition wifi-mode.cc:111
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:55
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition object-base.h:35
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.