A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
propagation-loss-model.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2005,2006,2007 INRIA
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: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
18 * Contributions: Timo Bingmann <timo.bingmann@student.kit.edu>
19 * Contributions: Gary Pei <guangyu.pei@boeing.com> for fixed RSS
20 * Contributions: Tom Hewer <tomhewer@mac.com> for two ray ground model
21 * Pavel Boyko <boyko@iitp.ru> for matrix
22 */
23
24#ifndef PROPAGATION_LOSS_MODEL_H
25#define PROPAGATION_LOSS_MODEL_H
26
27#include "ns3/object.h"
28#include "ns3/random-variable-stream.h"
29
30#include <unordered_map>
31
32namespace ns3
33{
34
35/**
36 * \defgroup propagation Propagation Models
37 */
38
39/**
40 * \ingroup propagation
41 * \ingroup tests
42 * \defgroup propagation-tests Propagation module tests
43 */
44
45class MobilityModel;
46
47/**
48 * \ingroup propagation
49 *
50 * \brief Models the propagation loss through a transmission medium
51 *
52 * Calculate the receive power (dbm) from a transmit power (dbm)
53 * and a mobility model for the source and destination positions.
54 */
56{
57 public:
58 /**
59 * Get the type ID.
60 * \brief Get the type ID.
61 * \return the object TypeId
62 */
63 static TypeId GetTypeId();
64
66 ~PropagationLossModel() override;
67
68 // Delete copy constructor and assignment operator to avoid misuse
71
72 /**
73 * \brief Enables a chain of loss models to act on the signal
74 * \param next The next PropagationLossModel to add to the chain
75 *
76 * This method of chaining propagation loss models only works commutatively
77 * if the propagation loss of all models in the chain are independent
78 * of transmit power.
79 */
81
82 /**
83 * \brief Gets the next PropagationLossModel in the chain of loss models
84 * that act on the signal.
85 * \returns The next PropagationLossModel in the chain
86 *
87 * This method of chaining propagation loss models only works commutatively
88 * if the propagation loss of all models in the chain are independent
89 * of transmit power.
90 */
92
93 /**
94 * Returns the Rx Power taking into account all the PropagationLossModel(s)
95 * chained to the current one.
96 *
97 * \param txPowerDbm current transmission power (in dBm)
98 * \param a the mobility model of the source
99 * \param b the mobility model of the destination
100 * \returns the reception power after adding/multiplying propagation loss (in dBm)
101 */
102 double CalcRxPower(double txPowerDbm, Ptr<MobilityModel> a, Ptr<MobilityModel> b) const;
103
104 /**
105 * If this loss model uses objects of type RandomVariableStream,
106 * set the stream numbers to the integers starting with the offset
107 * 'stream'. Return the number of streams (possibly zero) that
108 * have been assigned. If there are PropagationLossModels chained
109 * together, this method will also assign streams to the
110 * downstream models.
111 *
112 * \param stream the stream index offset start
113 * \return the number of stream indices assigned by this model
114 */
115 int64_t AssignStreams(int64_t stream);
116
117 protected:
118 /**
119 * Assign a fixed random variable stream number to the random variables used by this model.
120 *
121 * Subclasses must implement this; those not using random variables
122 * can return zero.
123 *
124 * \param stream first stream index to use
125 * \return the number of stream indices assigned by this model
126 */
127 virtual int64_t DoAssignStreams(int64_t stream) = 0;
128
129 private:
130 /**
131 * PropagationLossModel.
132 *
133 * \param txPowerDbm current transmission power (in dBm)
134 * \param a the mobility model of the source
135 * \param b the mobility model of the destination
136 * \returns the reception power after adding/multiplying propagation loss (in dBm)
137 */
138 virtual double DoCalcRxPower(double txPowerDbm,
140 Ptr<MobilityModel> b) const = 0;
141
142 Ptr<PropagationLossModel> m_next; //!< Next propagation loss model in the list
143};
144
145/**
146 * \ingroup propagation
147 *
148 * \brief The propagation loss follows a random distribution.
149 */
151{
152 public:
153 /**
154 * \brief Get the type ID.
155 * \return the object TypeId
156 */
157 static TypeId GetTypeId();
158
161
162 // Delete copy constructor and assignment operator to avoid misuse
165
166 private:
167 double DoCalcRxPower(double txPowerDbm,
169 Ptr<MobilityModel> b) const override;
170 int64_t DoAssignStreams(int64_t stream) override;
171
173};
174
175/**
176 * \ingroup propagation
177 *
178 * \brief a Friis propagation loss model
179 *
180 * The Friis propagation loss model was first described in
181 * "A Note on a Simple Transmission Formula", by
182 * "Harald T. Friis".
183 *
184 * The original equation was described as:
185 * \f$ \frac{P_r}{P_t} = \frac{A_r A_t}{d^2\lambda^2} \f$
186 * with the following equation for the case of an
187 * isotropic antenna with no heat loss:
188 * \f$ A_{isotr.} = \frac{\lambda^2}{4\pi} \f$
189 *
190 * The final equation becomes:
191 * \f$ \frac{P_r}{P_t} = \frac{\lambda^2}{(4 \pi d)^2} \f$
192 *
193 * Modern extensions to this original equation are:
194 * \f$ P_r = \frac{P_t G_t G_r \lambda^2}{(4 \pi d)^2 L}\f$
195 *
196 * With:
197 * - \f$ P_r \f$ : reception power (W)
198 * - \f$ P_t \f$ : transmission power (W)
199 * - \f$ G_t \f$ : transmission gain (unit-less)
200 * - \f$ G_r \f$ : reception gain (unit-less)
201 * - \f$ \lambda \f$ : wavelength (m)
202 * - \f$ d \f$ : distance (m)
203 * - \f$ L \f$ : system loss (unit-less)
204 *
205 * In the implementation, \f$ \lambda \f$ is calculated as
206 * \f$ \frac{C}{f} \f$, where \f$ C = 299792458\f$ m/s is the speed of light in
207 * vacuum, and \f$ f \f$ is the frequency in Hz which can be configured by
208 * the user via the Frequency attribute.
209 *
210 * The Friis model is valid only for propagation in free space within
211 * the so-called far field region, which can be considered
212 * approximately as the region for \f$ d > 3 \lambda \f$.
213 * The model will still return a value for \f$ d < 3 \lambda \f$, as
214 * doing so (rather than triggering a fatal error) is practical for
215 * many simulation scenarios. However, we stress that the values
216 * obtained in such conditions shall not be considered realistic.
217 *
218 * Related with this issue, we note that the Friis formula is
219 * undefined for \f$ d = 0 \f$, and results in
220 * \f$ P_r > P_t \f$ for \f$ d < \lambda / 2 \sqrt{\pi} \f$.
221 * Both these conditions occur outside of the far field region, so in
222 * principle the Friis model shall not be used in these conditions.
223 * In practice, however, Friis is often used in scenarios where accurate
224 * propagation modeling is not deemed important, and values of \f$ d =
225 * 0 \f$ can occur. To allow practical use of the model in such
226 * scenarios, we have to 1) return some value for \f$ d = 0 \f$, and
227 * 2) avoid large discontinuities in propagation loss values (which
228 * could lead to artifacts such as bogus capture effects which are
229 * much worse than inaccurate propagation loss values). The two issues
230 * are conflicting, as, according to the Friis formula,
231 * \f$\lim_{d \to 0 } P_r = +\infty \f$;
232 * so if, for \f$ d = 0 \f$, we use a fixed loss value, we end up with an infinitely large
233 * discontinuity, which as we discussed can cause undesirable
234 * simulation artifacts.
235 *
236 * To avoid these artifact, this implementation of the Friis model
237 * provides an attribute called MinLoss which allows to specify the
238 * minimum total loss (in dB) returned by the model. This is used in
239 * such a way that
240 * \f$ P_r \f$ continuously increases for \f$ d \to 0 \f$, until
241 * MinLoss is reached, and then stay constant; this allow to
242 * return a value for \f$ d = 0 \f$ and at the same time avoid
243 * discontinuities. The model won't be much realistic, but at least
244 * the simulation artifacts discussed before are avoided. The default value of
245 * MinLoss is 0 dB, which means that by default the model will return
246 * \f$ P_r = P_t \f$ for \f$ d <= \lambda / 2 \sqrt{\pi} \f$. We note
247 * that this value of \f$ d \f$ is outside of the far field
248 * region, hence the validity of the model in the far field region is
249 * not affected.
250 *
251 */
253{
254 public:
255 /**
256 * \brief Get the type ID.
257 * \return the object TypeId
258 */
259 static TypeId GetTypeId();
261
262 // Delete copy constructor and assignment operator to avoid misuse
265
266 /**
267 * \param frequency (Hz)
268 *
269 * Set the carrier frequency used in the Friis model
270 * calculation.
271 */
272 void SetFrequency(double frequency);
273 /**
274 * \param systemLoss (linear factor, dimension-less)
275 *
276 * Set the system loss used by the Friis propagation model.
277 * Value should be greater than or equal to 1; the default of 1
278 * corresponds to no system loss.
279 */
280 void SetSystemLoss(double systemLoss);
281
282 /**
283 * \param minLoss the minimum loss (dB)
284 *
285 * no matter how short the distance, the total propagation loss (in
286 * dB) will always be greater or equal than this value
287 */
288 void SetMinLoss(double minLoss);
289
290 /**
291 * \return the minimum loss.
292 */
293 double GetMinLoss() const;
294
295 /**
296 * \returns the current frequency (Hz)
297 */
298 double GetFrequency() const;
299 /**
300 * \returns the current system loss (linear factor, dimension-less)
301 */
302 double GetSystemLoss() const;
303
304 private:
305 double DoCalcRxPower(double txPowerDbm,
307 Ptr<MobilityModel> b) const override;
308 int64_t DoAssignStreams(int64_t stream) override;
309
310 /**
311 * Transforms a Dbm value to Watt
312 * \param dbm the Dbm value
313 * \return the Watts
314 */
315 double DbmToW(double dbm) const;
316
317 /**
318 * Transforms a Watt value to Dbm
319 * \param w the Watt value
320 * \return the Dbm
321 */
322 double DbmFromW(double w) const;
323
324 double m_lambda; //!< the carrier wavelength
325 double m_frequency; //!< the carrier frequency
326 double m_systemLoss; //!< the system loss (linear factor)
327 double m_minLoss; //!< the minimum loss
328};
329
330/**
331 * \ingroup propagation
332 *
333 * \brief a Two-Ray Ground propagation loss model ported from NS2
334 *
335 * Two-ray ground reflection model.
336 *
337 * \f$ Pr = \frac{P_t * G_t * G_r * (H_t^2 * H_r^2)}{d^4 * L} \f$
338 *
339 * The original equation in Rappaport's book assumes L = 1.
340 * To be consistent with the free space equation, L is added here.
341 *
342 * Ht and Hr are set at the respective nodes z coordinate plus a model parameter
343 * set via SetHeightAboveZ.
344 *
345 * The two-ray model does not give a good result for short distances, due to the
346 * oscillation caused by constructive and destructive combination of the two
347 * rays. Instead the Friis free-space model is used for small distances.
348 *
349 * The crossover distance, below which Friis is used, is calculated as follows:
350 *
351 * \f$ dCross = \frac{(4 * \pi * H_t * H_r)}{\lambda} \f$
352 *
353 * In the implementation, \f$ \lambda \f$ is calculated as
354 * \f$ \frac{C}{f} \f$, where \f$ C = 299792458\f$ m/s is the speed of light in
355 * vacuum, and \f$ f \f$ is the frequency in Hz which can be configured by
356 * the user via the Frequency attribute.
357 */
359{
360 public:
361 /**
362 * \brief Get the type ID.
363 * \return the object TypeId
364 */
365 static TypeId GetTypeId();
367
368 // Delete copy constructor and assignment operator to avoid misuse
371
372 /**
373 * \param frequency (Hz)
374 *
375 * Set the carrier frequency used in the TwoRayGround model
376 * calculation.
377 */
378 void SetFrequency(double frequency);
379
380 /**
381 * \param systemLoss (linear factor, dimension-less)
382 *
383 * Set the system loss used by the TwoRayGround propagation model.
384 * Value should be greater than or equal to 1; the default of 1
385 * corresponds to no system loss.
386 */
387 void SetSystemLoss(double systemLoss);
388 /**
389 * \param minDistance the minimum distance
390 *
391 * Below this distance, the txpower is returned
392 * unmodified as the rxpower.
393 */
394 void SetMinDistance(double minDistance);
395 /**
396 * \returns the minimum distance.
397 */
398 double GetMinDistance() const;
399
400 /**
401 * \returns the current frequency (Hz)
402 */
403 double GetFrequency() const;
404
405 /**
406 * \returns the current system loss (linear factor, dimension-less)
407 */
408 double GetSystemLoss() const;
409 /**
410 * \param heightAboveZ the model antenna height above the node's Z coordinate
411 *
412 * Set the model antenna height above the node's Z coordinate
413 */
414 void SetHeightAboveZ(double heightAboveZ);
415
416 private:
417 double DoCalcRxPower(double txPowerDbm,
419 Ptr<MobilityModel> b) const override;
420 int64_t DoAssignStreams(int64_t stream) override;
421
422 /**
423 * Transforms a Dbm value to Watt
424 * \param dbm the Dbm value
425 * \return the Watts
426 */
427 double DbmToW(double dbm) const;
428
429 /**
430 * Transforms a Watt value to Dbm
431 * \param w the Watt value
432 * \return the Dbm
433 */
434 double DbmFromW(double w) const;
435
436 double m_lambda; //!< the carrier wavelength
437 double m_frequency; //!< the carrier frequency
438 double m_systemLoss; //!< the system loss (linear factor)
439 double m_minDistance; //!< minimum distance for the model
440 double m_heightAboveZ; //!< antenna height above the node's Z coordinate
441};
442
443/**
444 * \ingroup propagation
445 *
446 * \brief a log distance propagation model.
447 *
448 * This model calculates the reception power with a so-called
449 * log-distance propagation model:
450 * \f$ L = L_0 + 10 n log_{10}(\frac{d}{d_0})\f$
451 *
452 * where:
453 * - \f$ n \f$ : the path loss distance exponent
454 * - \f$ d_0 \f$ : reference distance (m)
455 * - \f$ L_0 \f$ : path loss at reference distance (dB)
456 * - \f$ d \f$ : distance (m)
457 * - \f$ L \f$ : path loss (dB)
458 *
459 * When the path loss is requested at a distance smaller than
460 * the reference distance, the tx power is returned.
461 *
462 */
464{
465 public:
466 /**
467 * \brief Get the type ID.
468 * \return the object TypeId
469 */
470 static TypeId GetTypeId();
472
473 // Delete copy constructor and assignment operator to avoid misuse
476
477 /**
478 * \param n the path loss exponent.
479 * Set the path loss exponent.
480 */
481 void SetPathLossExponent(double n);
482 /**
483 * \returns the current path loss exponent.
484 */
485 double GetPathLossExponent() const;
486
487 /**
488 * Set the reference path loss at a given distance
489 * \param referenceDistance reference distance
490 * \param referenceLoss reference path loss
491 */
492 void SetReference(double referenceDistance, double referenceLoss);
493
494 private:
495 double DoCalcRxPower(double txPowerDbm,
497 Ptr<MobilityModel> b) const override;
498
499 int64_t DoAssignStreams(int64_t stream) override;
500
501 /**
502 * Creates a default reference loss model
503 * \return a default reference loss model
504 */
506
507 double m_exponent; //!< model exponent
508 double m_referenceDistance; //!< reference distance
509 double m_referenceLoss; //!< reference loss
510};
511
512/**
513 * \ingroup propagation
514 *
515 * \brief A log distance path loss propagation model with three distance
516 * fields. This model is the same as ns3::LogDistancePropagationLossModel
517 * except that it has three distance fields: near, middle and far with
518 * different exponents.
519 *
520 * Within each field the reception power is calculated using the log-distance
521 * propagation equation:
522 * \f[ L = L_0 + 10 \cdot n_0 log_{10}(\frac{d}{d_0})\f]
523 * Each field begins where the previous ends and all together form a continuous function.
524 *
525 * There are three valid distance fields: near, middle, far. Actually four: the
526 * first from 0 to the reference distance is invalid and returns txPowerDbm.
527 *
528 * \f[ \underbrace{0 \cdots\cdots}_{=0} \underbrace{d_0 \cdots\cdots}_{n_0} \underbrace{d_1
529\cdots\cdots}_{n_1} \underbrace{d_2 \cdots\cdots}_{n_2} \infty \f]
530 *
531 * Complete formula for the path loss in dB:
532 *
533 * \f[\displaystyle L =
534\begin{cases}
5350 & d < d_0 \\
536L_0 + 10 \cdot n_0 \log_{10}(\frac{d}{d_0}) & d_0 \leq d < d_1 \\
537L_0 + 10 \cdot n_0 \log_{10}(\frac{d_1}{d_0}) + 10 \cdot n_1 \log_{10}(\frac{d}{d_1}) & d_1 \leq d <
538d_2 \\ L_0 + 10 \cdot n_0 \log_{10}(\frac{d_1}{d_0}) + 10 \cdot n_1 \log_{10}(\frac{d_2}{d_1}) + 10
539\cdot n_2 \log_{10}(\frac{d}{d_2})& d_2 \leq d \end{cases}\f]
540 *
541 * where:
542 * - \f$ L \f$ : resulting path loss (dB)
543 * - \f$ d \f$ : distance (m)
544 * - \f$ d_0, d_1, d_2 \f$ : three distance fields (m)
545 * - \f$ n_0, n_1, n_2 \f$ : path loss distance exponent for each field (unitless)
546 * - \f$ L_0 \f$ : path loss at reference distance (dB)
547 *
548 * When the path loss is requested at a distance smaller than the reference
549 * distance \f$ d_0 \f$, the tx power (with no path loss) is returned. The
550 * reference distance defaults to 1m and reference loss defaults to
551 * ns3::FriisPropagationLossModel with 5.15 GHz and is thus \f$ L_0 \f$ = 46.67 dB.
552 */
554{
555 public:
556 /**
557 * \brief Get the type ID.
558 * \return the object TypeId
559 */
560 static TypeId GetTypeId();
562
563 // Delete copy constructor and assignment operator to avoid misuse
566 delete;
567
568 // Parameters are all accessible via attributes.
569
570 private:
571 double DoCalcRxPower(double txPowerDbm,
573 Ptr<MobilityModel> b) const override;
574
575 int64_t DoAssignStreams(int64_t stream) override;
576
577 double m_distance0; //!< Beginning of the first (near) distance field
578 double m_distance1; //!< Beginning of the second (middle) distance field.
579 double m_distance2; //!< Beginning of the third (far) distance field.
580
581 double m_exponent0; //!< The exponent for the first field.
582 double m_exponent1; //!< The exponent for the second field.
583 double m_exponent2; //!< The exponent for the third field.
584
585 double m_referenceLoss; //!< The reference loss at distance d0 (dB).
586};
587
588/**
589 * \ingroup propagation
590 *
591 * \brief Nakagami-m fast fading propagation loss model.
592 *
593 * This propagation loss model implements the Nakagami-m fast fading
594 * model, which accounts for the variations in signal strength due to multipath
595 * fading. The model does not account for the path loss due to the
596 * distance traveled by the signal, hence for typical simulation usage it
597 * is recommended to consider using it in combination with other models
598 * that take into account this aspect.
599 *
600 * The Nakagami-m distribution is applied to the power level. The probability
601 * density function is defined as
602 * \f[ p(x; m, \omega) = \frac{2 m^m}{\Gamma(m) \omega^m} x^{2m - 1} e^{-\frac{m}{\omega} x^2} \f]
603 * with \f$ m \f$ the fading depth parameter and \f$ \omega \f$ the average received power.
604 *
605 * It is implemented by either a ns3::GammaRandomVariable or a
606 * ns3::ErlangRandomVariable random variable.
607 *
608 * The implementation of the model allows to specify different values of the m parameter (and hence
609 * different fading profiles) for three different distance ranges: \f[ \underbrace{0
610 * \cdots\cdots}_{m_0} \underbrace{d_1 \cdots\cdots}_{m_1} \underbrace{d_2 \cdots\cdots}_{m_2}
611 * \infty \f]
612 *
613 * For m = 1 the Nakagami-m distribution equals the Rayleigh distribution. Thus
614 * this model also implements Rayleigh distribution based fast fading.
615 */
617{
618 public:
619 /**
620 * \brief Get the type ID.
621 * \return the object TypeId
622 */
623 static TypeId GetTypeId();
624
626
627 // Delete copy constructor and assignment operator to avoid misuse
630
631 // Parameters are all accessible via attributes.
632
633 private:
634 double DoCalcRxPower(double txPowerDbm,
636 Ptr<MobilityModel> b) const override;
637
638 int64_t DoAssignStreams(int64_t stream) override;
639
640 double m_distance1; //!< Distance1
641 double m_distance2; //!< Distance2
642
643 double m_m0; //!< m for distances smaller than Distance1
644 double m_m1; //!< m for distances smaller than Distance2
645 double m_m2; //!< m for distances greater than Distance2
646
649};
650
651/**
652 * \ingroup propagation
653 *
654 * \brief Return a constant received power level independent of the transmit
655 * power
656 *
657 * The received power is constant independent of the transmit power. The user
658 * must set received power level through the Rss attribute or public
659 * SetRss() method. Note that if this loss model is chained to other loss
660 * models via SetNext() method, it can only be the first loss model in such
661 * a chain, or else it will disregard the losses computed by loss models
662 * that precede it in the chain.
663 */
665{
666 public:
667 /**
668 * \brief Get the type ID.
669 * \return the object TypeId
670 */
671 static TypeId GetTypeId();
672
674 ~FixedRssLossModel() override;
675
676 // Delete copy constructor and assignment operator to avoid misuse
679
680 /**
681 * \param rss (dBm) the received signal strength
682 *
683 * Set the received signal strength (RSS) in dBm.
684 */
685 void SetRss(double rss);
686
687 private:
688 double DoCalcRxPower(double txPowerDbm,
690 Ptr<MobilityModel> b) const override;
691
692 int64_t DoAssignStreams(int64_t stream) override;
693
694 double m_rss; //!< the received signal strength
695};
696
697/**
698 * \ingroup propagation
699 *
700 * \brief The propagation loss is fixed for each pair of nodes and doesn't depend on their actual
701 * positions.
702 *
703 * This is supposed to be used by synthetic tests. Note that by default propagation loss is assumed
704 * to be symmetric.
705 */
707{
708 public:
709 /**
710 * \brief Get the type ID.
711 * \return the object TypeId
712 */
713 static TypeId GetTypeId();
714
717
718 // Delete copy constructor and assignment operator to avoid misuse
721
722 /**
723 * \brief Set loss (in dB, positive) between pair of ns-3 objects
724 * (typically, nodes).
725 *
726 * \param a ma Source mobility model
727 * \param b mb Destination mobility model
728 * \param loss a -> b path loss, positive in dB
729 * \param symmetric If true (default), both a->b and b->a paths will be affected
730 */
731 void SetLoss(Ptr<MobilityModel> a, Ptr<MobilityModel> b, double loss, bool symmetric = true);
732
733 /**
734 * Set the default propagation loss (in dB, positive) to be used, infinity if not set
735 * \param defaultLoss the default proagation loss
736 */
737 void SetDefaultLoss(double defaultLoss);
738
739 private:
740 double DoCalcRxPower(double txPowerDbm,
742 Ptr<MobilityModel> b) const override;
743
744 int64_t DoAssignStreams(int64_t stream) override;
745
746 double m_default; //!< default loss
747
748 /// Typedef: Mobility models pair
749 typedef std::pair<const Ptr<MobilityModel>, const Ptr<MobilityModel>> MobilityPair;
750
751 /**
752 * \ingroup propagation
753 *
754 * \brief Hasher for a pair of mobility models.
755 */
757 {
758 public:
759 /**
760 * \brief Get the hash for a MobilityPair.
761 * \param key MobilityPair reference to hash
762 * \return the MobilityPair hash
763 */
764 size_t operator()(const MobilityPair& key) const
765 {
766 return uint64_t(key.first.operator->()) ^ uint64_t(key.second.operator->());
767 }
768 };
769
770 std::unordered_map<MobilityPair, double, MobilityPairHasher>
771 m_loss; //!< Propagation loss between pair of nodes
772};
773
774/**
775 * \ingroup propagation
776 *
777 * \brief The propagation loss depends only on the distance (range) between transmitter and
778 * receiver.
779 *
780 * The single MaxRange attribute (units of meters) determines path loss.
781 * Receivers at or within MaxRange meters receive the transmission at the
782 * transmit power level. Receivers beyond MaxRange receive at power
783 * -1000 dBm (effectively zero).
784 */
786{
787 public:
788 /**
789 * \brief Get the type ID.
790 * \return the object TypeId
791 */
792 static TypeId GetTypeId();
794
795 // Delete copy constructor and assignment operator to avoid misuse
798
799 private:
800 double DoCalcRxPower(double txPowerDbm,
802 Ptr<MobilityModel> b) const override;
803
804 int64_t DoAssignStreams(int64_t stream) override;
805
806 double m_range; //!< Maximum Transmission Range (meters)
807};
808
809} // namespace ns3
810
811#endif /* PROPAGATION_LOSS_MODEL_H */
Return a constant received power level independent of the transmit power.
double m_rss
the received signal strength
double DoCalcRxPower(double txPowerDbm, Ptr< MobilityModel > a, Ptr< MobilityModel > b) const override
PropagationLossModel.
FixedRssLossModel & operator=(const FixedRssLossModel &)=delete
int64_t DoAssignStreams(int64_t stream) override
Assign a fixed random variable stream number to the random variables used by this model.
FixedRssLossModel(const FixedRssLossModel &)=delete
static TypeId GetTypeId()
Get the type ID.
a Friis propagation loss model
double m_lambda
the carrier wavelength
double DbmFromW(double w) const
Transforms a Watt value to Dbm.
double m_frequency
the carrier frequency
int64_t DoAssignStreams(int64_t stream) override
Assign a fixed random variable stream number to the random variables used by this model.
FriisPropagationLossModel(const FriisPropagationLossModel &)=delete
double DbmToW(double dbm) const
Transforms a Dbm value to Watt.
double DoCalcRxPower(double txPowerDbm, Ptr< MobilityModel > a, Ptr< MobilityModel > b) const override
PropagationLossModel.
static TypeId GetTypeId()
Get the type ID.
double m_systemLoss
the system loss (linear factor)
FriisPropagationLossModel & operator=(const FriisPropagationLossModel &)=delete
a log distance propagation model.
LogDistancePropagationLossModel & operator=(const LogDistancePropagationLossModel &)=delete
LogDistancePropagationLossModel(const LogDistancePropagationLossModel &)=delete
void SetReference(double referenceDistance, double referenceLoss)
Set the reference path loss at a given distance.
double DoCalcRxPower(double txPowerDbm, Ptr< MobilityModel > a, Ptr< MobilityModel > b) const override
PropagationLossModel.
static TypeId GetTypeId()
Get the type ID.
static Ptr< PropagationLossModel > CreateDefaultReference()
Creates a default reference loss model.
int64_t DoAssignStreams(int64_t stream) override
Assign a fixed random variable stream number to the random variables used by this model.
size_t operator()(const MobilityPair &key) const
Get the hash for a MobilityPair.
The propagation loss is fixed for each pair of nodes and doesn't depend on their actual positions.
void SetLoss(Ptr< MobilityModel > a, Ptr< MobilityModel > b, double loss, bool symmetric=true)
Set loss (in dB, positive) between pair of ns-3 objects (typically, nodes).
void SetDefaultLoss(double defaultLoss)
Set the default propagation loss (in dB, positive) to be used, infinity if not set.
std::unordered_map< MobilityPair, double, MobilityPairHasher > m_loss
Propagation loss between pair of nodes.
MatrixPropagationLossModel(const MatrixPropagationLossModel &)=delete
MatrixPropagationLossModel & operator=(const MatrixPropagationLossModel &)=delete
int64_t DoAssignStreams(int64_t stream) override
Assign a fixed random variable stream number to the random variables used by this model.
std::pair< const Ptr< MobilityModel >, const Ptr< MobilityModel > > MobilityPair
Typedef: Mobility models pair.
double DoCalcRxPower(double txPowerDbm, Ptr< MobilityModel > a, Ptr< MobilityModel > b) const override
PropagationLossModel.
static TypeId GetTypeId()
Get the type ID.
Nakagami-m fast fading propagation loss model.
Ptr< ErlangRandomVariable > m_erlangRandomVariable
Erlang random variable.
double m_m0
m for distances smaller than Distance1
NakagamiPropagationLossModel(const NakagamiPropagationLossModel &)=delete
Ptr< GammaRandomVariable > m_gammaRandomVariable
Gamma random variable.
int64_t DoAssignStreams(int64_t stream) override
Assign a fixed random variable stream number to the random variables used by this model.
NakagamiPropagationLossModel & operator=(const NakagamiPropagationLossModel &)=delete
double m_m1
m for distances smaller than Distance2
double m_m2
m for distances greater than Distance2
double DoCalcRxPower(double txPowerDbm, Ptr< MobilityModel > a, Ptr< MobilityModel > b) const override
PropagationLossModel.
static TypeId GetTypeId()
Get the type ID.
A base class which provides memory management and object aggregation.
Definition: object.h:89
Models the propagation loss through a transmission medium.
PropagationLossModel & operator=(const PropagationLossModel &)=delete
virtual int64_t DoAssignStreams(int64_t stream)=0
Assign a fixed random variable stream number to the random variables used by this model.
Ptr< PropagationLossModel > m_next
Next propagation loss model in the list.
double CalcRxPower(double txPowerDbm, Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
Returns the Rx Power taking into account all the PropagationLossModel(s) chained to the current one.
static TypeId GetTypeId()
Get the type ID.
virtual double DoCalcRxPower(double txPowerDbm, Ptr< MobilityModel > a, Ptr< MobilityModel > b) const =0
PropagationLossModel.
int64_t AssignStreams(int64_t stream)
If this loss model uses objects of type RandomVariableStream, set the stream numbers to the integers ...
void SetNext(Ptr< PropagationLossModel > next)
Enables a chain of loss models to act on the signal.
PropagationLossModel(const PropagationLossModel &)=delete
Ptr< PropagationLossModel > GetNext()
Gets the next PropagationLossModel in the chain of loss models that act on the signal.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
The propagation loss follows a random distribution.
RandomPropagationLossModel & operator=(const RandomPropagationLossModel &)=delete
static TypeId GetTypeId()
Get the type ID.
double DoCalcRxPower(double txPowerDbm, Ptr< MobilityModel > a, Ptr< MobilityModel > b) const override
PropagationLossModel.
Ptr< RandomVariableStream > m_variable
random generator
int64_t DoAssignStreams(int64_t stream) override
Assign a fixed random variable stream number to the random variables used by this model.
RandomPropagationLossModel(const RandomPropagationLossModel &)=delete
The propagation loss depends only on the distance (range) between transmitter and receiver.
RangePropagationLossModel & operator=(const RangePropagationLossModel &)=delete
static TypeId GetTypeId()
Get the type ID.
int64_t DoAssignStreams(int64_t stream) override
Assign a fixed random variable stream number to the random variables used by this model.
RangePropagationLossModel(const RangePropagationLossModel &)=delete
double DoCalcRxPower(double txPowerDbm, Ptr< MobilityModel > a, Ptr< MobilityModel > b) const override
PropagationLossModel.
double m_range
Maximum Transmission Range (meters)
A log distance path loss propagation model with three distance fields.
double m_referenceLoss
The reference loss at distance d0 (dB).
int64_t DoAssignStreams(int64_t stream) override
Assign a fixed random variable stream number to the random variables used by this model.
double m_distance0
Beginning of the first (near) distance field.
double m_distance2
Beginning of the third (far) distance field.
ThreeLogDistancePropagationLossModel(const ThreeLogDistancePropagationLossModel &)=delete
double m_exponent2
The exponent for the third field.
double m_distance1
Beginning of the second (middle) distance field.
ThreeLogDistancePropagationLossModel & operator=(const ThreeLogDistancePropagationLossModel &)=delete
double m_exponent0
The exponent for the first field.
double m_exponent1
The exponent for the second field.
double DoCalcRxPower(double txPowerDbm, Ptr< MobilityModel > a, Ptr< MobilityModel > b) const override
PropagationLossModel.
a Two-Ray Ground propagation loss model ported from NS2
double DbmToW(double dbm) const
Transforms a Dbm value to Watt.
double m_minDistance
minimum distance for the model
double m_heightAboveZ
antenna height above the node's Z coordinate
static TypeId GetTypeId()
Get the type ID.
double DbmFromW(double w) const
Transforms a Watt value to Dbm.
int64_t DoAssignStreams(int64_t stream) override
Assign a fixed random variable stream number to the random variables used by this model.
double m_systemLoss
the system loss (linear factor)
double DoCalcRxPower(double txPowerDbm, Ptr< MobilityModel > a, Ptr< MobilityModel > b) const override
PropagationLossModel.
TwoRayGroundPropagationLossModel(const TwoRayGroundPropagationLossModel &)=delete
TwoRayGroundPropagationLossModel & operator=(const TwoRayGroundPropagationLossModel &)=delete
a unique identifier for an interface.
Definition: type-id.h:59
Every class exported by the ns3 library is enclosed in the ns3 namespace.