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