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
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
uan-noise-model-default.cc
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2009 University of Washington
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: Leonard Tracy <lentracy@gmail.com>
19
*/
20
21
#include "
uan-noise-model-default.h
"
22
#include "ns3/double.h"
23
24
#include <cmath>
25
26
namespace
ns3 {
27
28
NS_OBJECT_ENSURE_REGISTERED
(UanNoiseModelDefault)
29
;
30
31
UanNoiseModelDefault::UanNoiseModelDefault
()
32
{
33
34
}
35
36
UanNoiseModelDefault::~UanNoiseModelDefault
()
37
{
38
}
39
40
TypeId
41
UanNoiseModelDefault::GetTypeId
(
void
)
42
{
43
static
TypeId
tid =
TypeId
(
"ns3::UanNoiseModelDefault"
)
44
.
SetParent
<
Object
> ()
45
.AddConstructor<UanNoiseModelDefault> ()
46
.AddAttribute (
"Wind"
,
"Wind speed in m/s."
,
47
DoubleValue
(1),
48
MakeDoubleAccessor (&
UanNoiseModelDefault::m_wind
),
49
MakeDoubleChecker<double> (0))
50
.AddAttribute (
"Shipping"
,
"Shipping contribution to noise between 0 and 1."
,
51
DoubleValue
(0),
52
MakeDoubleAccessor (&
UanNoiseModelDefault::m_shipping
),
53
MakeDoubleChecker<double> (0,1))
54
;
55
return
tid;
56
}
57
58
// Common acoustic noise formulas. These can be found
59
// in "Priniciples of Underwater Sound" by Robert J. Urick
60
double
61
UanNoiseModelDefault::GetNoiseDbHz
(
double
fKhz)
const
62
{
63
double
turb, wind, ship, thermal;
64
double
turbDb, windDb, shipDb, thermalDb, noiseDb;
65
66
turbDb = 17.0 - 30.0 * std::log10 (fKhz);
67
turb = std::pow (10.0, turbDb * 0.1);
68
69
shipDb = 40.0 + 20.0 * (
m_shipping
- 0.5) + 26.0 * std::log10 (fKhz) - 60.0 * std::log10 (fKhz + 0.03);
70
ship = std::pow (10.0, (shipDb * 0.1));
71
72
windDb = 50.0 + 7.5 * std::pow (
m_wind
, 0.5) + 20.0 * std::log10 (fKhz) - 40.0 * std::log10 (fKhz + 0.4);
73
wind = std::pow (10.0, windDb * 0.1);
74
75
thermalDb = -15 + 20 * std::log10 (fKhz);
76
thermal = std::pow (10, thermalDb * 0.1);
77
78
noiseDb = 10 * std::log10 (turb + ship + wind + thermal);
79
80
return
noiseDb;
81
}
82
83
}
// namespace ns3
ns3::UanNoiseModelDefault::m_shipping
double m_shipping
Shipping contribution to noise between 0 and 1.
Definition:
uan-noise-model-default.h:65
ns3::UanNoiseModelDefault::m_wind
double m_wind
Wind speed in m/s.
Definition:
uan-noise-model-default.h:64
ns3::NS_OBJECT_ENSURE_REGISTERED
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
uan-noise-model-default.h
ns3::UanNoiseModelDefault::GetTypeId
static TypeId GetTypeId(void)
Register this type.
Definition:
uan-noise-model-default.cc:41
ns3::UanNoiseModelDefault::GetNoiseDbHz
virtual double GetNoiseDbHz(double fKhz) const
Compute the noise power at a given frequency.
Definition:
uan-noise-model-default.cc:61
ns3::UanNoiseModelDefault::~UanNoiseModelDefault
virtual ~UanNoiseModelDefault()
Dummy destructor, DoDispose.
Definition:
uan-noise-model-default.cc:36
ns3::Object
a base class which provides memory management and object aggregation
Definition:
object.h:63
ns3::DoubleValue
Hold a floating point type.
Definition:
double.h:41
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:49
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Definition:
type-id.cc:611
ns3::UanNoiseModelDefault::UanNoiseModelDefault
UanNoiseModelDefault()
Default constructor.
Definition:
uan-noise-model-default.cc:31
src
uan
model
uan-noise-model-default.cc
Generated on Sat Apr 19 2014 14:07:09 for ns-3 by
1.8.6