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
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Gary Pei <guangyu.pei@boeing.com>
7
*/
8
#include "
lr-wpan-error-model.h
"
9
10
#include <ns3/log.h>
11
12
#include <cmath>
13
14
namespace
ns3
15
{
16
namespace
lrwpan
17
{
18
19
NS_LOG_COMPONENT_DEFINE
(
"LrWpanErrorModel"
);
20
NS_OBJECT_ENSURE_REGISTERED
(LrWpanErrorModel);
21
22
TypeId
23
LrWpanErrorModel::GetTypeId
()
24
{
25
static
TypeId
tid =
TypeId
(
"ns3::lrwpan::LrWpanErrorModel"
)
26
.
AddDeprecatedName
(
"ns3::LrWpanErrorModel"
)
27
.
SetParent
<
Object
>()
28
.SetGroupName(
"LrWpan"
)
29
.AddConstructor<
LrWpanErrorModel
>();
30
return
tid;
31
}
32
33
LrWpanErrorModel::LrWpanErrorModel
()
34
{
35
m_binomialCoefficients
[0] = 1;
36
m_binomialCoefficients
[1] = -16;
37
m_binomialCoefficients
[2] = 120;
38
m_binomialCoefficients
[3] = -560;
39
m_binomialCoefficients
[4] = 1820;
40
m_binomialCoefficients
[5] = -4368;
41
m_binomialCoefficients
[6] = 8008;
42
m_binomialCoefficients
[7] = -11440;
43
m_binomialCoefficients
[8] = 12870;
44
m_binomialCoefficients
[9] = -11440;
45
m_binomialCoefficients
[10] = 8008;
46
m_binomialCoefficients
[11] = -4368;
47
m_binomialCoefficients
[12] = 1820;
48
m_binomialCoefficients
[13] = -560;
49
m_binomialCoefficients
[14] = 120;
50
m_binomialCoefficients
[15] = -16;
51
m_binomialCoefficients
[16] = 1;
52
}
53
54
double
55
LrWpanErrorModel::GetChunkSuccessRate
(
double
snr,
uint32_t
nbits)
const
56
{
57
double
ber = 0.0;
58
59
for
(
uint32_t
k = 2; k <= 16; k++)
60
{
61
ber +=
m_binomialCoefficients
[k] * exp(20.0 * snr * (1.0 / k - 1.0));
62
}
63
64
ber = ber * 8.0 / 15.0 / 16.0;
65
66
ber = std::min(ber, 1.0);
67
double
retval = pow(1.0 - ber, nbits);
68
return
retval;
69
}
70
}
// namespace lrwpan
71
}
// namespace ns3
ns3::Object
A base class which provides memory management and object aggregation.
Definition
object.h:78
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:48
ns3::TypeId::AddDeprecatedName
TypeId AddDeprecatedName(const std::string &name)
Add an deprecated name for a TypeId.
Definition
type-id.cc:862
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition
type-id.cc:1001
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:26
ns3::lrwpan::LrWpanErrorModel::m_binomialCoefficients
double m_binomialCoefficients[17]
Array of precalculated binomial coefficients.
Definition
lr-wpan-error-model.h:50
ns3::lrwpan::LrWpanErrorModel::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition
lr-wpan-error-model.cc:23
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:55
ns3::lrwpan::LrWpanErrorModel::LrWpanErrorModel
LrWpanErrorModel()
Definition
lr-wpan-error-model.cc:33
uint32_t
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition
log.h:191
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition
object-base.h:35
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 Sat Nov 2 2024 19:37:25 for ns-3 by
1.11.0