A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
lr-wpan-error-model.cc
Go to the documentation of this file.
1
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2011 The Boeing Company
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: Gary Pei <guangyu.pei@boeing.com>
19
*/
20
#include "
lr-wpan-error-model.h
"
21
#include <ns3/log.h>
22
23
#include <cmath>
24
25
namespace
ns3
{
26
27
NS_LOG_COMPONENT_DEFINE
(
"LrWpanErrorModel"
);
28
29
NS_OBJECT_ENSURE_REGISTERED
(LrWpanErrorModel);
30
31
TypeId
32
LrWpanErrorModel::GetTypeId
(
void
)
33
{
34
static
TypeId
tid =
TypeId
(
"ns3::LrWpanErrorModel"
)
35
.
SetParent
<
Object
> ()
36
.AddConstructor<LrWpanErrorModel> ()
37
;
38
return
tid;
39
}
40
41
LrWpanErrorModel::LrWpanErrorModel
(
void
)
42
{
43
m_binomialCoefficients
[0] = 1;
44
m_binomialCoefficients
[1] = -16;
45
m_binomialCoefficients
[2] = 120;
46
m_binomialCoefficients
[3] = -560;
47
m_binomialCoefficients
[4] = 1820;
48
m_binomialCoefficients
[5] = -4368;
49
m_binomialCoefficients
[6] = 8008;
50
m_binomialCoefficients
[7] = -11440;
51
m_binomialCoefficients
[8] = 12870;
52
m_binomialCoefficients
[9] = -11440;
53
m_binomialCoefficients
[10] = 8008;
54
m_binomialCoefficients
[11] = -4368;
55
m_binomialCoefficients
[12] = 1820;
56
m_binomialCoefficients
[13] = -560;
57
m_binomialCoefficients
[14] = 120;
58
m_binomialCoefficients
[15] = -16;
59
m_binomialCoefficients
[16] = 1;
60
}
61
62
double
63
LrWpanErrorModel::GetChunkSuccessRate
(
double
snr, uint32_t nbits)
const
64
{
65
double
ber = 0.0;
66
67
for
(uint32_t k = 2; k <= 16; k++)
68
{
69
ber +=
m_binomialCoefficients
[k] * exp (20.0 * snr * (1.0 / k - 1.0));
70
}
71
72
ber = ber * 8.0 / 15.0 / 16.0;
73
74
ber = std::min (ber, 1.0);
75
double
retval = pow (1.0 - ber, nbits);
76
return
retval;
77
}
78
79
}
// namespace ns3
ns3::LrWpanErrorModel::GetChunkSuccessRate
double GetChunkSuccessRate(double snr, uint32_t nbits) const
Return chunk success rate for given SNR.
Definition:
lr-wpan-error-model.cc:63
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition:
object-base.h:44
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition:
log.h:201
ns3::LrWpanErrorModel::m_binomialCoefficients
double m_binomialCoefficients[17]
Array of precalculated binomial coefficients.
Definition:
lr-wpan-error-model.h:59
ns3::LrWpanErrorModel::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition:
lr-wpan-error-model.cc:32
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::LrWpanErrorModel::LrWpanErrorModel
LrWpanErrorModel(void)
Definition:
lr-wpan-error-model.cc:41
lr-wpan-error-model.h
ns3::Object
A base class which provides memory management and object aggregation.
Definition:
object.h:87
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:51
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Definition:
type-id.cc:631
src
lr-wpan
model
lr-wpan-error-model.cc
Generated on Thu Feb 5 2015 18:33:41 for ns-3 by
1.8.9.1