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