A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
uan-prop-model.h
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
20#ifndef UAN_PROP_MODEL_H
21#define UAN_PROP_MODEL_H
22
23#include "ns3/mobility-model.h"
24#include "ns3/nstime.h"
25#include "ns3/object.h"
26
27#include <complex>
28#include <utility>
29#include <vector>
30
31namespace ns3
32{
33
34class UanTxMode;
35
36/**
37 * \ingroup uan
38 *
39 * Holds PDP Tap information (amplitude and delay)
40 */
41class Tap
42{
43 public:
44 /**
45 * Default constructor. Creates Tap with delay=0, amp=0
46 */
47 Tap();
48 /**
49 * Constructor
50 *
51 * \param delay Time delay (usually from first arrival) of signal
52 * \param amp Complex amplitude of arrival
53 */
54 Tap(Time delay, std::complex<double> amp);
55 /**
56 * Get the complex amplitude of arrival.
57 *
58 * \return The amplitude.
59 */
60 std::complex<double> GetAmp() const;
61 /**
62 * Get the delay time, usually from first arrival of signal.
63 * \return The time delay.
64 */
65 Time GetDelay() const;
66
67 private:
68 std::complex<double> m_amplitude; //!< The amplitude.
69 Time m_delay; //!< The time delay.
70
71}; // class Tap
72
73/**
74 * \ingroup uan
75 *
76 * The power delay profile returned by propagation models.
77 *
78 * Container class to describe power delay profile returned
79 * from UAN propagation models using tapped delay line model.
80 * This should model a channel impulse response as a set of
81 * equally spaced signal arrivals.
82 *
83 * Generally, the profile should be normalized, such that
84 * the sum of all taps should equal 1. The received signal
85 * power on any interval (t1, t2) can then be found from
86 * summing the taps on the interval and multiplying by
87 * the total received power at the receiver.
88 */
89class UanPdp
90{
91 public:
92 /**
93 * Convenience iterator typedef.
94 */
95 typedef std::vector<Tap>::const_iterator Iterator;
96 /**
97 * Create empty PDP object.
98 */
99 UanPdp();
100 /**
101 * Create PDP object from a vector of Tap objects.
102 *
103 * \param taps Taps to include in this PDP.
104 * \param resolution Resolution of PDP object.
105 */
106 UanPdp(std::vector<Tap> taps, Time resolution);
107 /**
108 * Create PDP object from vector of arrival amplitudes.
109 *
110 * \param arrivals Vector of complex amplitude arrivals.
111 * \param resolution Time duration between arrivals in vector.
112 */
113 UanPdp(std::vector<std::complex<double>> arrivals, Time resolution);
114 /**
115 * Create PDP object from real valued arrival amplitudes.
116 *
117 * \param arrivals Vector of real valued arrivals.
118 * \param resolution Time duration between arrivals in vector.
119 */
120 UanPdp(std::vector<double> arrivals, Time resolution);
121 /** Dummy destructor, see DoDispose. */
122 ~UanPdp();
123
124 /**
125 * Set the arrival value for a tap.
126 *
127 * The delay time is the index multiplied by the resolution.
128 * The tap vector will be expanded to accommodate the requested
129 * index.
130 *
131 * \param arrival Complex arrival value.
132 * \param index Index of arrival.
133 */
134 void SetTap(std::complex<double> arrival, uint32_t index);
135 /**
136 * Resize the tap vector.
137 *
138 * \param nTaps Number of taps in this PDP
139 */
140 void SetNTaps(uint32_t nTaps);
141 /**
142 * Set the time duration (resolution) between arrivals.
143 *
144 * \param resolution The resolution.
145 */
146 void SetResolution(Time resolution);
147 /**
148 * Get the beginning of the tap vector.
149 *
150 * \return Iterator positioned at first arrival.
151 */
152 Iterator GetBegin() const;
153 /**
154 * Get the end of the tap list (one beyond the last entry).
155 *
156 * \return Iterator positioned after last arrival
157 */
158 Iterator GetEnd() const;
159 /**
160 * Get the number of taps.
161 *
162 * \return Number of taps in PDP.
163 */
164 uint32_t GetNTaps() const;
165 /**
166 * Get the Tap at the specified delay index.
167 *
168 * \param i Index number of tap to return (0 based).
169 * \return Tap object at index i.
170 */
171 const Tap& GetTap(uint32_t i) const;
172 /**
173 * Get the delay time resolution (time duration between arrivals).
174 *
175 * \return Resolution of PDP.
176 */
177 Time GetResolution() const;
178 /**
179 * Compute the non-coherent sum of tap amplitudes
180 * between a start and end time.
181 *
182 * Assuming that Tap at index 0 arrives at time 0,
183 * this function sums non-coherently (sums amplitude of arrivals
184 * ignoring phase difference) all arrivals between a start
185 * and end time.
186 *
187 * \param begin Time value to begin summing arrivals.
188 * \param end Time value to end summing arrivals.
189 * \return Non-coherent sum of arrivals between two time values.
190 */
191 double SumTapsNc(Time begin, Time end) const;
192 /**
193 * Compute the coherent sum of tap amplitudes
194 * between a start and end time.
195 *
196 * Assuming that Tap at index 0 arrives at time 0,
197 * this function sums coherently (sums amplitude of arrivals
198 * considering phase difference) all arrivals between a start
199 * and end time.
200 *
201 * \param begin Time value to begin summing arrivals.
202 * \param end Time value to end summing arrivals.
203 * \return Coherent sum of arrivals between two time values.
204 */
205 std::complex<double> SumTapsC(Time begin, Time end) const;
206 /**
207 * Compute the non-coherent sum of tap amplitudes
208 * starting after a delay from the maximum amplitude
209 * for a total time duration.
210 *
211 * This function sums non-coherently (sums amplitude of arrivals
212 * ignoring phase difference) all arrivals in a given duration
213 * starting the given time after the maximum amplitude arrival received.
214 *
215 * \param delay Time duratation after max to begin summing arrivals.
216 * \param duration Time duration to sum arrivals for.
217 * \return Non-coherent sum of arrivals after max in given window.
218 */
219 double SumTapsFromMaxNc(Time delay, Time duration) const;
220 /**
221 * Compute the coherent sum of tap amplitudes
222 * starting after a delay from the maximum amplitude
223 * for a total duration.
224 *
225 * this function sums coherently (sums amplitude of arrivals
226 * considering phase difference) all arrivals in a given duration
227 * starting the given time after the maximum amplitude arrival received
228 *
229 * \param delay Time duratation after max to begin summing arrivals.
230 * \param duration Time duration to sum arrivals for.
231 * \return Coherent sum of arrivals after max in given window.
232 */
233 std::complex<double> SumTapsFromMaxC(Time delay, Time duration) const;
234 /**
235 * Creates a new UanPdp normalized to its non coherent sum.
236 * \see SumTapsNc
237 * \returns the new PDP
238 */
239 UanPdp NormalizeToSumNc() const;
240 /**
241 * Get a unit impulse PDP at time 0.
242 *
243 * \return The unit impulse.
244 */
245 static UanPdp CreateImpulsePdp();
246
247 private:
248 friend std::ostream& operator<<(std::ostream& os, const UanPdp& pdp);
249 friend std::istream& operator>>(std::istream& is, UanPdp& pdp);
250
251 std::vector<Tap> m_taps; //!< The vector of Taps.
252 Time m_resolution; //!< The time resolution.
253
254}; // class UanPdp
255
256/**
257 * \ingroup uan
258 *
259 * Writes PDP to stream as list of arrivals
260 *
261 * \param os The output stream.
262 * \param pdp The PDP.
263 * \return The output stream.
264 */
265std::ostream& operator<<(std::ostream& os, const UanPdp& pdp);
266/**
267 * \ingroup uan
268 *
269 * Reads in list of arrivals from stream is
270 *
271 * \param is The input stream.
272 * \param pdp The PDP variable to set.
273 * \return The input stream.
274 */
275std::istream& operator>>(std::istream& is, UanPdp& pdp);
276
277/**
278 * \ingroup uan
279 *
280 * Base class for implemented underwater propagation models
281 */
282class UanPropModel : public Object
283{
284 public:
285 /**
286 * Register this type.
287 * \return The object TypeId.
288 */
289 static TypeId GetTypeId();
290
291 /**
292 * Computes pathloss between nodes a and b.
293 *
294 * \param a Ptr to mobility model of node a
295 * \param b Ptr to mobility model of node b
296 * \param txMode TX mode of transmission between a and b
297 * \return Pathloss in dB re 1 uPa
298 */
300
301 /**
302 * Get the PDP for the path between two nodes.
303 *
304 * \param a Ptr to mobility model of node a.
305 * \param b Ptr to mobility model of node b.
306 * \param mode TX mode of transmission from a to b.
307 * \return PDP for link between nodes a and b.
308 */
310 /**
311 * Finds propagation delay between nodes a and b.
312 *
313 * \param a Ptr to mobility model of node a.
314 * \param b Ptr to mobility model of node b.
315 * \param mode TX mode of transmission.
316 * \return Propagation delay.
317 */
319
320 /** Clear all pointer references. */
321 virtual void Clear();
322
323 void DoDispose() override;
324
325}; // class UanPropModel
326
327} // namespace ns3
328
329#endif /* UAN_PROP_MODEL_H */
A base class which provides memory management and object aggregation.
Definition: object.h:89
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
Holds PDP Tap information (amplitude and delay)
Time m_delay
The time delay.
std::complex< double > GetAmp() const
Get the complex amplitude of arrival.
Tap()
Default constructor.
Time GetDelay() const
Get the delay time, usually from first arrival of signal.
std::complex< double > m_amplitude
The amplitude.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
a unique identifier for an interface.
Definition: type-id.h:59
The power delay profile returned by propagation models.
static UanPdp CreateImpulsePdp()
Get a unit impulse PDP at time 0.
Iterator GetEnd() const
Get the end of the tap list (one beyond the last entry).
void SetResolution(Time resolution)
Set the time duration (resolution) between arrivals.
UanPdp NormalizeToSumNc() const
Creates a new UanPdp normalized to its non coherent sum.
friend std::istream & operator>>(std::istream &is, UanPdp &pdp)
Reads in list of arrivals from stream is.
void SetTap(std::complex< double > arrival, uint32_t index)
Set the arrival value for a tap.
std::vector< Tap > m_taps
The vector of Taps.
double SumTapsFromMaxNc(Time delay, Time duration) const
Compute the non-coherent sum of tap amplitudes starting after a delay from the maximum amplitude for ...
std::vector< Tap >::const_iterator Iterator
Convenience iterator typedef.
void SetNTaps(uint32_t nTaps)
Resize the tap vector.
Time GetResolution() const
Get the delay time resolution (time duration between arrivals).
UanPdp()
Create empty PDP object.
double SumTapsNc(Time begin, Time end) const
Compute the non-coherent sum of tap amplitudes between a start and end time.
Time m_resolution
The time resolution.
uint32_t GetNTaps() const
Get the number of taps.
const Tap & GetTap(uint32_t i) const
Get the Tap at the specified delay index.
friend std::ostream & operator<<(std::ostream &os, const UanPdp &pdp)
Writes PDP to stream as list of arrivals.
Iterator GetBegin() const
Get the beginning of the tap vector.
std::complex< double > SumTapsC(Time begin, Time end) const
Compute the coherent sum of tap amplitudes between a start and end time.
std::complex< double > SumTapsFromMaxC(Time delay, Time duration) const
Compute the coherent sum of tap amplitudes starting after a delay from the maximum amplitude for a to...
~UanPdp()
Dummy destructor, see DoDispose.
Base class for implemented underwater propagation models.
virtual Time GetDelay(Ptr< MobilityModel > a, Ptr< MobilityModel > b, UanTxMode mode)=0
Finds propagation delay between nodes a and b.
virtual void Clear()
Clear all pointer references.
virtual UanPdp GetPdp(Ptr< MobilityModel > a, Ptr< MobilityModel > b, UanTxMode mode)=0
Get the PDP for the path between two nodes.
virtual double GetPathLossDb(Ptr< MobilityModel > a, Ptr< MobilityModel > b, UanTxMode txMode)=0
Computes pathloss between nodes a and b.
static TypeId GetTypeId()
Register this type.
void DoDispose() override
Destructor implementation.
Abstraction of packet modulation information.
Definition: uan-tx-mode.h:43
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition: angles.cc:159
std::istream & operator>>(std::istream &is, Angles &a)
Definition: angles.cc:183