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 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Leonard Tracy <lentracy@gmail.com>
7 */
9
10#include "uan-tx-mode.h"
11
12#include "ns3/double.h"
13#include "ns3/log.h"
14
15namespace ns3
16{
17
18NS_LOG_COMPONENT_DEFINE("UanPropModelThorp");
19
20NS_OBJECT_ENSURE_REGISTERED(UanPropModelThorp);
21
25
29
32{
33 static TypeId tid =
34 TypeId("ns3::UanPropModelThorp")
36 .SetGroupName("Uan")
37 .AddConstructor<UanPropModelThorp>()
38 .AddAttribute("SpreadCoef",
39 "Spreading coefficient used in calculation of Thorp's approximation.",
40 DoubleValue(1.5),
43 return tid;
44}
45
46double
48{
49 double dist = a->GetDistanceFrom(b);
50
51 return m_SpreadCoef * 10.0 * std::log10(dist) +
52 (dist / 1000.0) * GetAttenDbKm(mode.GetCenterFreqHz() / 1000.0);
53}
54
60
61Time
63{
64 return Seconds(a->GetDistanceFrom(b) / 1500.0);
65}
66
67double
69{
70 return GetAttenDbKm(freqKhz) / 1.093613298;
71}
72
73double
75{
76 double fsq = freqKhz * freqKhz;
77 double atten;
78
79 if (freqKhz >= 0.4)
80 {
81 atten = 0.11 * fsq / (1 + fsq) + 44 * fsq / (4100 + fsq) + 2.75 * 0.0001 * fsq + 0.003;
82 }
83 else
84 {
85 atten = 0.002 + 0.11 * (fsq / (1 + fsq)) + 0.011 * fsq;
86 }
87
88 return atten;
89}
90
91} // namespace ns3
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition double.h:31
Smart pointer class similar to boost::intrusive_ptr.
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
a unique identifier for an interface.
Definition type-id.h:48
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
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:32
uint32_t GetCenterFreqHz() const
Get the transmission center frequency.
#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
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition nstime.h:1308
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeDoubleChecker()
Definition double.h:82
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Definition double.h:32