A Discrete-Event Network Simulator
API
uan-noise-model-default.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2009 University of Washington
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: Leonard Tracy <lentracy@gmail.com>
18 */
19
21
22#include "ns3/double.h"
23
24#include <cmath>
25
26namespace ns3
27{
28
29NS_OBJECT_ENSURE_REGISTERED(UanNoiseModelDefault);
30
32{
33}
34
36{
37}
38
41{
42 static TypeId tid = TypeId("ns3::UanNoiseModelDefault")
44 .SetGroupName("Uan")
45 .AddConstructor<UanNoiseModelDefault>()
46 .AddAttribute("Wind",
47 "Wind speed in m/s.",
48 DoubleValue(1),
50 MakeDoubleChecker<double>(0))
51 .AddAttribute("Shipping",
52 "Shipping contribution to noise between 0 and 1.",
53 DoubleValue(0),
55 MakeDoubleChecker<double>(0, 1));
56 return tid;
57}
58
59// Common acoustic noise formulas. These can be found
60// in "Priniciples of Underwater Sound" by Robert J. Urick
61double
63{
64 double turb;
65 double wind;
66 double ship;
67 double thermal;
68 double turbDb;
69 double windDb;
70 double shipDb;
71 double thermalDb;
72 double noiseDb;
73
74 turbDb = 17.0 - 30.0 * std::log10(fKhz);
75 turb = std::pow(10.0, turbDb * 0.1);
76
77 shipDb =
78 40.0 + 20.0 * (m_shipping - 0.5) + 26.0 * std::log10(fKhz) - 60.0 * std::log10(fKhz + 0.03);
79 ship = std::pow(10.0, (shipDb * 0.1));
80
81 windDb = 50.0 + 7.5 * std::pow(m_wind, 0.5) + 20.0 * std::log10(fKhz) -
82 40.0 * std::log10(fKhz + 0.4);
83 wind = std::pow(10.0, windDb * 0.1);
84
85 thermalDb = -15 + 20 * std::log10(fKhz);
86 thermal = std::pow(10, thermalDb * 0.1);
87
88 noiseDb = 10 * std::log10(turb + ship + wind + thermal);
89
90 return noiseDb;
91}
92
93} // namespace ns3
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition: double.h:42
a unique identifier for an interface.
Definition: type-id.h:60
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:935
Standard ambient acoustic noise model.
double m_wind
Wind speed in m/s.
double GetNoiseDbHz(double fKhz) const override
Compute the noise power at a given frequency.
static TypeId GetTypeId()
Register this type.
~UanNoiseModelDefault() override
Dummy destructor, DoDispose.
UanNoiseModelDefault()
Default constructor.
double m_shipping
Shipping contribution to noise between 0 and 1.
UAN Noise Model base class.
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Definition: double.h:43
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:46
Every class exported by the ns3 library is enclosed in the ns3 namespace.