A Discrete-Event Network Simulator
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 */
9
10#include <ns3/log.h>
11
12#include <cmath>
13
14namespace ns3
15{
16namespace lrwpan
17{
18
19NS_LOG_COMPONENT_DEFINE("LrWpanErrorModel");
20NS_OBJECT_ENSURE_REGISTERED(LrWpanErrorModel);
21
22TypeId
24{
25 static TypeId tid = TypeId("ns3::lrwpan::LrWpanErrorModel")
26 .AddDeprecatedName("ns3::LrWpanErrorModel")
28 .SetGroupName("LrWpan")
29 .AddConstructor<LrWpanErrorModel>();
30 return tid;
31}
32
53
54double
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
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 AddDeprecatedName(const std::string &name)
Add an deprecated name for a TypeId.
Definition type-id.cc:862
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
Model the error rate for IEEE 802.15.4 2.4 GHz AWGN channel for OQPSK the model description can be fo...
double m_binomialCoefficients[17]
Array of precalculated binomial coefficients.
static TypeId GetTypeId()
Get the type ID.
double GetChunkSuccessRate(double snr, uint32_t nbits) const
Return chunk success rate for given SNR.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition object-base.h:35
Every class exported by the ns3 library is enclosed in the ns3 namespace.