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
lr-wpan-error-model.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2011 The Boeing Company
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: Gary Pei <guangyu.pei@boeing.com>
18
*/
19
#include "
lr-wpan-error-model.h
"
20
21
#include <ns3/log.h>
22
23
#include <cmath>
24
25
namespace
ns3
26
{
27
namespace
lrwpan
28
{
29
30
NS_LOG_COMPONENT_DEFINE
(
"LrWpanErrorModel"
);
31
NS_OBJECT_ENSURE_REGISTERED
(
LrWpanErrorModel
);
32
33
TypeId
34
LrWpanErrorModel::GetTypeId
()
35
{
36
static
TypeId
tid =
TypeId
(
"ns3::LrWpanErrorModel"
)
37
.
SetParent
<
Object
>()
38
.SetGroupName(
"LrWpan"
)
39
.AddConstructor<
LrWpanErrorModel
>();
40
return
tid;
41
}
42
43
LrWpanErrorModel::LrWpanErrorModel
()
44
{
45
m_binomialCoefficients
[0] = 1;
46
m_binomialCoefficients
[1] = -16;
47
m_binomialCoefficients
[2] = 120;
48
m_binomialCoefficients
[3] = -560;
49
m_binomialCoefficients
[4] = 1820;
50
m_binomialCoefficients
[5] = -4368;
51
m_binomialCoefficients
[6] = 8008;
52
m_binomialCoefficients
[7] = -11440;
53
m_binomialCoefficients
[8] = 12870;
54
m_binomialCoefficients
[9] = -11440;
55
m_binomialCoefficients
[10] = 8008;
56
m_binomialCoefficients
[11] = -4368;
57
m_binomialCoefficients
[12] = 1820;
58
m_binomialCoefficients
[13] = -560;
59
m_binomialCoefficients
[14] = 120;
60
m_binomialCoefficients
[15] = -16;
61
m_binomialCoefficients
[16] = 1;
62
}
63
64
double
65
LrWpanErrorModel::GetChunkSuccessRate
(
double
snr,
uint32_t
nbits)
const
66
{
67
double
ber = 0.0;
68
69
for
(
uint32_t
k = 2; k <= 16; k++)
70
{
71
ber +=
m_binomialCoefficients
[k] * exp(20.0 * snr * (1.0 / k - 1.0));
72
}
73
74
ber = ber * 8.0 / 15.0 / 16.0;
75
76
ber = std::min(ber, 1.0);
77
double
retval = pow(1.0 - ber, nbits);
78
return
retval;
79
}
80
}
// namespace lrwpan
81
}
// namespace ns3
LrWpanErrorModel
Introspection did not find any typical Config paths.
ns3::Object
A base class which provides memory management and object aggregation.
Definition:
object.h:89
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:59
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition:
type-id.cc:932
ns3::lrwpan::LrWpanErrorModel
Model the error rate for IEEE 802.15.4 2.4 GHz AWGN channel for OQPSK the model description can be fo...
Definition:
lr-wpan-error-model.h:37
ns3::lrwpan::LrWpanErrorModel::m_binomialCoefficients
double m_binomialCoefficients[17]
Array of precalculated binomial coefficients.
Definition:
lr-wpan-error-model.h:61
ns3::lrwpan::LrWpanErrorModel::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition:
lr-wpan-error-model.cc:34
ns3::lrwpan::LrWpanErrorModel::GetChunkSuccessRate
double GetChunkSuccessRate(double snr, uint32_t nbits) const
Return chunk success rate for given SNR.
Definition:
lr-wpan-error-model.cc:65
ns3::lrwpan::LrWpanErrorModel::LrWpanErrorModel
LrWpanErrorModel()
Definition:
lr-wpan-error-model.cc:43
uint32_t
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition:
log.h:202
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition:
object-base.h:46
lr-wpan-error-model.h
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
src
lr-wpan
model
lr-wpan-error-model.cc
Generated on Tue May 28 2024 23:36:49 for ns-3 by
1.9.6