A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
dsss-error-rate-model.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2010 The Boeing Company
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Gary Pei <guangyu.pei@boeing.com>
7
*/
8
9
#include "
dsss-error-rate-model.h
"
10
11
#include "ns3/log.h"
12
13
#include <cmath>
14
15
#ifdef HAVE_GSL
16
#include <gsl/gsl_cdf.h>
17
#include <gsl/gsl_integration.h>
18
#include <gsl/gsl_math.h>
19
#include <gsl/gsl_sf_bessel.h>
20
#endif
21
22
namespace
ns3
23
{
24
25
NS_LOG_COMPONENT_DEFINE
(
"DsssErrorRateModel"
);
26
27
#ifndef HAVE_GSL
28
const
double
DsssErrorRateModel::WLAN_SIR_PERFECT
= 10.0;
29
const
double
DsssErrorRateModel::WLAN_SIR_IMPOSSIBLE
= 0.1;
30
#endif
31
32
double
33
DsssErrorRateModel::DqpskFunction
(
double
x)
34
{
35
NS_LOG_FUNCTION_NOARGS
();
36
return
((
M_SQRT2
+ 1.0) / std::sqrt(8.0 *
M_PI
*
M_SQRT2
)) * (1.0 / std::sqrt(x)) *
37
std::exp(-(2.0 -
M_SQRT2
) * x);
38
}
39
40
double
41
DsssErrorRateModel::GetDsssDbpskSuccessRate
(
double
sinr
, uint64_t
nbits
)
42
{
43
NS_LOG_FUNCTION_NOARGS
();
44
double
EbN0
=
sinr
* 22000000.0 / 1000000.0;
// 1 bit per symbol with 1 MSPS
45
double
ber
= 0.5 * std::exp(-
EbN0
);
46
return
std::pow((1.0 -
ber
),
static_cast<
double
>
(
nbits
));
47
}
48
49
double
50
DsssErrorRateModel::GetDsssDqpskSuccessRate
(
double
sinr
, uint64_t
nbits
)
51
{
52
NS_LOG_FUNCTION_NOARGS
();
53
double
EbN0
=
sinr
* 22000000.0 / 1000000.0 / 2.0;
// 2 bits per symbol, 1 MSPS
54
double
ber
=
DqpskFunction
(
EbN0
);
55
return
std::pow((1.0 -
ber
),
static_cast<
double
>
(
nbits
));
56
}
57
58
double
59
DsssErrorRateModel::GetDsssDqpskCck5_5SuccessRate
(
double
sinr
, uint64_t
nbits
)
60
{
61
NS_LOG_FUNCTION_NOARGS
();
62
#ifdef HAVE_GSL
63
// symbol error probability
64
double
EbN0
=
sinr
* 22000000.0 / 1375000.0 / 4.0;
65
double
sep =
SymbolErrorProb16Cck
(4.0 *
EbN0
/ 2.0);
66
return
std::min(1.0, std::pow(1.0 - sep,
nbits
/ 4.0));
67
#else
68
NS_LOG_WARN
(
"Running a 802.11b CCK Matlab model less accurate than GSL model"
);
69
// The Matlab model
70
double
ber
;
71
if
(
sinr
>
WLAN_SIR_PERFECT
)
72
{
73
ber
= 0.0;
74
}
75
else
if
(
sinr
<
WLAN_SIR_IMPOSSIBLE
)
76
{
77
ber
= 0.5;
78
}
79
else
80
{
81
// fitprops.coeff from Matlab berfit
82
double
a1 = 5.3681634344056195e-001;
83
double
a2 = 3.3092430025608586e-003;
84
double
a3
= 4.1654372361004000e-001;
85
double
a4
= 1.0288981434358866e+000;
86
ber
= a1 * std::exp(-std::pow((
sinr
- a2) /
a3
,
a4
));
87
}
88
return
std::min(1.0, std::pow((1.0 -
ber
),
static_cast<
double
>
(
nbits
)));
89
#endif
90
}
91
92
double
93
DsssErrorRateModel::GetDsssDqpskCck11SuccessRate
(
double
sinr
, uint64_t
nbits
)
94
{
95
NS_LOG_FUNCTION_NOARGS
();
96
#ifdef HAVE_GSL
97
NS_LOG_DEBUG
(
"GSL enabled "
);
98
// symbol error probability
99
double
EbN0
=
sinr
* 22000000.0 / 1375000.0 / 8.0;
100
double
sep =
SymbolErrorProb256Cck
(8.0 *
EbN0
/ 2.0);
101
return
std::min(1.0, std::pow(1.0 - sep,
nbits
/ 8.0));
102
#else
103
NS_LOG_WARN
(
"Running a 802.11b CCK Matlab model less accurate than GSL model"
);
104
// The Matlab model
105
double
ber
;
106
if
(
sinr
>
WLAN_SIR_PERFECT
)
107
{
108
ber
= 0.0;
109
}
110
else
if
(
sinr
<
WLAN_SIR_IMPOSSIBLE
)
111
{
112
ber
= 0.5;
113
}
114
else
115
{
116
// fitprops.coeff from Matlab berfit
117
double
a1 = 7.9056742265333456e-003;
118
double
a2 = -1.8397449399176360e-001;
119
double
a3
= 1.0740689468707241e+000;
120
double
a4
= 1.0523316904502553e+000;
121
double
a5
= 3.0552298746496687e-001;
122
double
a6
= 2.2032715128698435e+000;
123
ber
= (a1 *
sinr
*
sinr
+ a2 *
sinr
+
a3
) /
124
(
sinr
*
sinr
*
sinr
+
a4
*
sinr
*
sinr
+
a5
*
sinr
+
a6
);
125
}
126
return
std::min(1.0, std::pow((1.0 -
ber
),
static_cast<
double
>
(
nbits
)));
127
#endif
128
}
129
130
#ifdef HAVE_GSL
131
double
132
IntegralFunction
(
double
x,
void
* params)
133
{
134
double
beta
= ((
FunctionParameters
*)params)->beta;
135
double
n = ((
FunctionParameters
*)params)->n;
136
double
IntegralFunction
= std::pow(2 *
gsl_cdf_ugaussian_P
(x +
beta
) - 1, n - 1) *
137
std::exp(-x * x / 2.0) / std::sqrt(2.0 *
M_PI
);
138
return
IntegralFunction
;
139
}
140
141
double
142
DsssErrorRateModel::SymbolErrorProb16Cck(
double
e2
)
143
{
144
double
sep;
145
double
error;
146
147
FunctionParameters
params;
148
params.beta = std::sqrt(2.0 *
e2
);
149
params.n = 8.0;
150
151
gsl_integration_workspace
* w =
gsl_integration_workspace_alloc
(1000);
152
153
gsl_function
F
;
154
F
.function = &
IntegralFunction
;
155
F
.params = ¶ms;
156
157
gsl_integration_qagiu
(&
F
, -params.beta, 0, 1e-7, 1000, w, &sep, &error);
158
gsl_integration_workspace_free
(w);
159
if
(error == 0.0)
160
{
161
sep = 1.0;
162
}
163
164
return
1.0 -
sep
;
165
}
166
167
double
168
DsssErrorRateModel::SymbolErrorProb256Cck(
double
e1
)
169
{
170
return
1.0 - std::pow(1.0 -
SymbolErrorProb16Cck
(
e1
/ 2.0), 2.0);
171
}
172
173
#endif
174
175
}
// namespace ns3
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:50
ns3::DsssErrorRateModel::WLAN_SIR_PERFECT
static const double WLAN_SIR_PERFECT
WLAN perfect.
Definition
dsss-error-rate-model.h:117
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:41
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:59
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:93
ns3::DsssErrorRateModel::WLAN_SIR_IMPOSSIBLE
static const double WLAN_SIR_IMPOSSIBLE
WLAN impossible.
Definition
dsss-error-rate-model.h:119
ns3::DsssErrorRateModel::DqpskFunction
static double DqpskFunction(double x)
A function DQPSK.
Definition
dsss-error-rate-model.cc:33
dsss-error-rate-model.h
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition
log.h:191
NS_LOG_DEBUG
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition
log.h:257
NS_LOG_FUNCTION_NOARGS
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
Definition
log-macros-enabled.h:195
NS_LOG_WARN
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Definition
log.h:250
ns3::Create
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Definition
ptr.h:436
check-style-clang-format.sep
sep
Definition
check-style-clang-format.py:1126
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
src
wifi
model
non-ht
dsss-error-rate-model.cc
Generated on Mon Dec 15 2025 15:22:07 for ns-3 by
1.9.8