A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
uan-prop-model-thorp.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 */
20
21#include "uan-tx-mode.h"
22
23#include "ns3/double.h"
24#include "ns3/log.h"
25
26namespace ns3
27{
28
29NS_LOG_COMPONENT_DEFINE("UanPropModelThorp");
30
31NS_OBJECT_ENSURE_REGISTERED(UanPropModelThorp);
32
34{
35}
36
38{
39}
40
43{
44 static TypeId tid =
45 TypeId("ns3::UanPropModelThorp")
47 .SetGroupName("Uan")
48 .AddConstructor<UanPropModelThorp>()
49 .AddAttribute("SpreadCoef",
50 "Spreading coefficient used in calculation of Thorp's approximation.",
51 DoubleValue(1.5),
53 MakeDoubleChecker<double>());
54 return tid;
55}
56
57double
59{
60 double dist = a->GetDistanceFrom(b);
61
62 return m_SpreadCoef * 10.0 * std::log10(dist) +
63 (dist / 1000.0) * GetAttenDbKm(mode.GetCenterFreqHz() / 1000.0);
64}
65
68{
70}
71
72Time
74{
75 return Seconds(a->GetDistanceFrom(b) / 1500.0);
76}
77
78double
80{
81 return GetAttenDbKm(freqKhz) / 1.093613298;
82}
83
84double
86{
87 double fsq = freqKhz * freqKhz;
88 double atten;
89
90 if (freqKhz >= 0.4)
91 {
92 atten = 0.11 * fsq / (1 + fsq) + 44 * fsq / (4100 + fsq) + 2.75 * 0.0001 * fsq + 0.003;
93 }
94 else
95 {
96 atten = 0.002 + 0.11 * (freqKhz / (1 + freqKhz)) + 0.011 * freqKhz;
97 }
98
99 return atten;
100}
101
102} // namespace ns3
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition: double.h:42
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:932
The power delay profile returned by propagation models.
static UanPdp CreateImpulsePdp()
Get a unit impulse PDP at time 0.
Base class for implemented underwater propagation models.
Uses Thorp's approximation to compute pathloss.
~UanPropModelThorp() override
Destructor.
UanPropModelThorp()
Default constructor.
double GetAttenDbKm(double freqKhz)
Get the attenuation in dB / km.
UanPdp GetPdp(Ptr< MobilityModel > a, Ptr< MobilityModel > b, UanTxMode mode) override
Get the PDP for the path between two nodes.
double GetPathLossDb(Ptr< MobilityModel > a, Ptr< MobilityModel > b, UanTxMode mode) override
Computes pathloss between nodes a and b.
double m_SpreadCoef
Spreading coefficient used in calculation of Thorp's approximation.
static TypeId GetTypeId()
Register this type.
double GetAttenDbKyd(double freqKhz)
Get the attenuation in dB / 1000 yards.
Time GetDelay(Ptr< MobilityModel > a, Ptr< MobilityModel > b, UanTxMode mode) override
Finds propagation delay between nodes a and b.
Abstraction of packet modulation information.
Definition: uan-tx-mode.h:43
uint32_t GetCenterFreqHz() const
Get the transmission center frequency.
Definition: uan-tx-mode.cc:58
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Definition: double.h:43
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:46
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1326
Every class exported by the ns3 library is enclosed in the ns3 namespace.