A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
uan-noise-model-default.cc
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 UanNoiseModelDefault::UanNoiseModelDefault ()
31 {
32 
33 }
34 
35 UanNoiseModelDefault::~UanNoiseModelDefault ()
36 {
37 }
38 
39 TypeId
40 UanNoiseModelDefault::GetTypeId (void)
41 {
42  static TypeId tid = TypeId ("ns3::UanNoiseModelDefault")
43  .SetParent<Object> ()
44  .AddConstructor<UanNoiseModelDefault> ()
45  .AddAttribute ("Wind", "Wind speed in m/s",
46  DoubleValue (1),
47  MakeDoubleAccessor (&UanNoiseModelDefault::m_wind),
48  MakeDoubleChecker<double> (0))
49  .AddAttribute ("Shipping", "Shipping contribution to noise between 0 and 1",
50  DoubleValue (0),
51  MakeDoubleAccessor (&UanNoiseModelDefault::m_shipping),
52  MakeDoubleChecker<double> (0,1))
53  ;
54  return tid;
55 }
56 
57 // Common acoustic noise formulas. These can be found
58 // in "Priniciples of Underwater Sound" by Robert J. Urick
59 double
61 {
62  double turb, wind, ship, thermal;
63  double turbDb, windDb, shipDb, thermalDb, noiseDb;
64 
65  turbDb = 17.0 - 30.0 * std::log10 (fKhz);
66  turb = std::pow (10.0, turbDb * 0.1);
67 
68  shipDb = 40.0 + 20.0 * (m_shipping - 0.5) + 26.0 * std::log10 (fKhz) - 60.0 * std::log10 (fKhz + 0.03);
69  ship = std::pow (10.0, (shipDb * 0.1));
70 
71  windDb = 50.0 + 7.5 * std::pow (m_wind, 0.5) + 20.0 * std::log10 (fKhz) - 40.0 * std::log10 (fKhz + 0.4);
72  wind = std::pow (10.0, windDb * 0.1);
73 
74  thermalDb = -15 + 20 * std::log10 (fKhz);
75  thermal = std::pow (10, thermalDb * 0.1);
76 
77  noiseDb = 10 * std::log10 (turb + ship + wind + thermal);
78 
79  return noiseDb;
80 }
81 
82 } // namespace ns3
virtual double GetNoiseDbHz(double fKhz) const