A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
propagation-loss-model.cc
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: Tom Hewer <tomhewer@mac.com> for Two Ray Ground Model
20 * Pavel Boyko <boyko@iitp.ru> for matrix
21 */
22
24
25#include "ns3/boolean.h"
26#include "ns3/double.h"
27#include "ns3/log.h"
28#include "ns3/mobility-model.h"
29#include "ns3/pointer.h"
30#include "ns3/string.h"
31
32#include <cmath>
33
34namespace ns3
35{
36
37NS_LOG_COMPONENT_DEFINE("PropagationLossModel");
38
39// ------------------------------------------------------------------------- //
40
41NS_OBJECT_ENSURE_REGISTERED(PropagationLossModel);
42
43TypeId
45{
46 static TypeId tid =
47 TypeId("ns3::PropagationLossModel").SetParent<Object>().SetGroupName("Propagation");
48 return tid;
49}
50
52 : m_next(nullptr)
53{
54}
55
57{
58}
59
60void
62{
63 m_next = next;
64}
65
68{
69 return m_next;
70}
71
72double
75 Ptr<MobilityModel> b) const
76{
77 double self = DoCalcRxPower(txPowerDbm, a, b);
78 if (m_next)
79 {
80 self = m_next->CalcRxPower(self, a, b);
81 }
82 return self;
83}
84
85int64_t
87{
88 int64_t currentStream = stream;
89 currentStream += DoAssignStreams(stream);
90 if (m_next)
91 {
92 currentStream += m_next->AssignStreams(currentStream);
93 }
94 return (currentStream - stream);
95}
96
97// ------------------------------------------------------------------------- //
98
100
101TypeId
103{
104 static TypeId tid =
105 TypeId("ns3::RandomPropagationLossModel")
107 .SetGroupName("Propagation")
108 .AddConstructor<RandomPropagationLossModel>()
109 .AddAttribute(
110 "Variable",
111 "The random variable used to pick a loss every time CalcRxPower is invoked.",
112 StringValue("ns3::ConstantRandomVariable[Constant=1.0]"),
114 MakePointerChecker<RandomVariableStream>());
115 return tid;
116}
117
120{
121}
122
124{
125}
126
127double
130 Ptr<MobilityModel> b) const
131{
132 double rxc = -m_variable->GetValue();
133 NS_LOG_DEBUG("attenuation coefficient=" << rxc << "Db");
134 return txPowerDbm + rxc;
135}
136
137int64_t
139{
140 m_variable->SetStream(stream);
141 return 1;
142}
143
144// ------------------------------------------------------------------------- //
145
147
148TypeId
150{
151 static TypeId tid =
152 TypeId("ns3::FriisPropagationLossModel")
154 .SetGroupName("Propagation")
155 .AddConstructor<FriisPropagationLossModel>()
156 .AddAttribute(
157 "Frequency",
158 "The carrier frequency (in Hz) at which propagation occurs (default is 5.15 GHz).",
159 DoubleValue(5.150e9),
162 MakeDoubleChecker<double>())
163 .AddAttribute("SystemLoss",
164 "The system loss (linear factor >= 1, not in dB)",
165 DoubleValue(1.0),
168 MakeDoubleChecker<double>())
169 .AddAttribute("MinLoss",
170 "The minimum value (dB) of the total loss, used at short ranges.",
171 DoubleValue(0.0),
174 MakeDoubleChecker<double>());
175 return tid;
176}
177
179{
180}
181
182void
184{
185 NS_ABORT_MSG_UNLESS(systemLoss >= 1, "System loss less than 1 corresponds to gain");
186 m_systemLoss = systemLoss;
187}
188
189double
191{
192 return m_systemLoss;
193}
194
195void
197{
198 m_minLoss = minLoss;
199}
200
201double
203{
204 return m_minLoss;
205}
206
207void
209{
210 m_frequency = frequency;
211 static const double C = 299792458.0; // speed of light in vacuum
212 m_lambda = C / frequency;
213}
214
215double
217{
218 return m_frequency;
219}
220
221double
223{
224 double mw = std::pow(10.0, dbm / 10.0);
225 return mw / 1000.0;
226}
227
228double
230{
231 double dbm = std::log10(w * 1000.0) * 10.0;
232 return dbm;
233}
234
235double
238 Ptr<MobilityModel> b) const
239{
240 /*
241 * Friis free space equation:
242 * where Pt, Gr, Gr and P are in Watt units
243 * L is in meter units.
244 *
245 * P Gt * Gr * (lambda^2)
246 * --- = ---------------------
247 * Pt (4 * pi * d)^2 * L
248 *
249 * Gt: tx gain (unit-less)
250 * Gr: rx gain (unit-less)
251 * Pt: tx power (W)
252 * d: distance (m)
253 * L: system loss
254 * lambda: wavelength (m)
255 *
256 * Here, we ignore tx and rx gain and the input and output values
257 * are in dB or dBm:
258 *
259 * lambda^2
260 * rx = tx + 10 log10 (-------------------)
261 * (4 * pi * d)^2 * L
262 *
263 * rx: rx power (dB)
264 * tx: tx power (dB)
265 * d: distance (m)
266 * L: system loss (unit-less)
267 * lambda: wavelength (m)
268 */
269 double distance = a->GetDistanceFrom(b);
270 if (distance < 3 * m_lambda)
271 {
273 "distance not within the far field region => inaccurate propagation loss value");
274 }
275 if (distance <= 0)
276 {
277 return txPowerDbm - m_minLoss;
278 }
279 double numerator = m_lambda * m_lambda;
280 double denominator = 16 * M_PI * M_PI * distance * distance * m_systemLoss;
281 double lossDb = -10 * log10(numerator / denominator);
282 NS_LOG_DEBUG("distance=" << distance << "m, loss=" << lossDb << "dB");
283 return txPowerDbm - std::max(lossDb, m_minLoss);
284}
285
286int64_t
288{
289 return 0;
290}
291
292// ------------------------------------------------------------------------- //
293// -- Two-Ray Ground Model ported from NS-2 -- tomhewer@mac.com -- Nov09 //
294
296
297TypeId
299{
300 static TypeId tid =
301 TypeId("ns3::TwoRayGroundPropagationLossModel")
303 .SetGroupName("Propagation")
304 .AddConstructor<TwoRayGroundPropagationLossModel>()
305 .AddAttribute(
306 "Frequency",
307 "The carrier frequency (in Hz) at which propagation occurs (default is 5.15 GHz).",
308 DoubleValue(5.150e9),
311 MakeDoubleChecker<double>())
312 .AddAttribute("SystemLoss",
313 "The system loss (linear factor >= 1, not in dB)",
314 DoubleValue(1.0),
317 MakeDoubleChecker<double>())
318 .AddAttribute(
319 "MinDistance",
320 "The distance under which the propagation model refuses to give results (m)",
321 DoubleValue(0.5),
324 MakeDoubleChecker<double>())
325 .AddAttribute("HeightAboveZ",
326 "The height of the antenna (m) above the node's Z coordinate",
327 DoubleValue(0),
329 MakeDoubleChecker<double>());
330 return tid;
331}
332
334{
335}
336
337void
339{
340 NS_ABORT_MSG_UNLESS(systemLoss >= 1, "System loss less than 1 corresponds to gain");
341 m_systemLoss = systemLoss;
342}
343
344double
346{
347 return m_systemLoss;
348}
349
350void
352{
353 m_minDistance = minDistance;
354}
355
356double
358{
359 return m_minDistance;
360}
361
362void
364{
365 m_heightAboveZ = heightAboveZ;
366}
367
368void
370{
371 m_frequency = frequency;
372 static const double C = 299792458.0; // speed of light in vacuum
373 m_lambda = C / frequency;
374}
375
376double
378{
379 return m_frequency;
380}
381
382double
384{
385 double mw = std::pow(10.0, dbm / 10.0);
386 return mw / 1000.0;
387}
388
389double
391{
392 double dbm = std::log10(w * 1000.0) * 10.0;
393 return dbm;
394}
395
396double
399 Ptr<MobilityModel> b) const
400{
401 /*
402 * Two-Ray Ground equation:
403 *
404 * where Pt, Gt and Gr are in dBm units
405 * L, Ht and Hr are in meter units.
406 *
407 * Pr Gt * Gr * (Ht^2 * Hr^2)
408 * -- = (-------------------------)
409 * Pt d^4 * L
410 *
411 * Gt: tx gain (unit-less)
412 * Gr: rx gain (unit-less)
413 * Pt: tx power (dBm)
414 * d: distance (m)
415 * L: system loss
416 * Ht: Tx antenna height (m)
417 * Hr: Rx antenna height (m)
418 * lambda: wavelength (m)
419 *
420 * As with the Friis model we ignore tx and rx gain and output values
421 * are in dB or dBm
422 *
423 * (Ht * Ht) * (Hr * Hr)
424 * rx = tx + 10 log10 (-----------------------)
425 * (d * d * d * d) * L
426 */
427 double distance = a->GetDistanceFrom(b);
428 if (distance <= m_minDistance)
429 {
430 return txPowerDbm;
431 }
432
433 // Set the height of the Tx and Rx antennae
434 double txAntHeight = a->GetPosition().z + m_heightAboveZ;
435 double rxAntHeight = b->GetPosition().z + m_heightAboveZ;
436
437 // Calculate a crossover distance, under which we use Friis
438 /*
439 *
440 * dCross = (4 * pi * Ht * Hr) / lambda
441 *
442 */
443
444 double dCross = (4 * M_PI * txAntHeight * rxAntHeight) / m_lambda;
445 double tmp = 0;
446 if (distance <= dCross)
447 {
448 // We use Friis
449 double numerator = m_lambda * m_lambda;
450 tmp = M_PI * distance;
451 double denominator = 16 * tmp * tmp * m_systemLoss;
452 double pr = 10 * std::log10(numerator / denominator);
453 NS_LOG_DEBUG("Receiver within crossover (" << dCross << "m) for Two_ray path; using Friis");
454 NS_LOG_DEBUG("distance=" << distance << "m, attenuation coefficient=" << pr << "dB");
455 return txPowerDbm + pr;
456 }
457 else // Use Two-Ray Pathloss
458 {
459 tmp = txAntHeight * rxAntHeight;
460 double rayNumerator = tmp * tmp;
461 tmp = distance * distance;
462 double rayDenominator = tmp * tmp * m_systemLoss;
463 double rayPr = 10 * std::log10(rayNumerator / rayDenominator);
464 NS_LOG_DEBUG("distance=" << distance << "m, attenuation coefficient=" << rayPr << "dB");
465 return txPowerDbm + rayPr;
466 }
467}
468
469int64_t
471{
472 return 0;
473}
474
475// ------------------------------------------------------------------------- //
476
478
479TypeId
481{
482 static TypeId tid =
483 TypeId("ns3::LogDistancePropagationLossModel")
485 .SetGroupName("Propagation")
486 .AddConstructor<LogDistancePropagationLossModel>()
487 .AddAttribute("Exponent",
488 "The exponent of the Path Loss propagation model",
489 DoubleValue(3.0),
491 MakeDoubleChecker<double>())
492 .AddAttribute("ReferenceDistance",
493 "The distance at which the reference loss is calculated (m)",
494 DoubleValue(1.0),
496 MakeDoubleChecker<double>())
497 .AddAttribute("ReferenceLoss",
498 "The reference loss at reference distance (dB). (Default is Friis at 1m "
499 "with 5.15 GHz)",
500 DoubleValue(46.6777),
502 MakeDoubleChecker<double>());
503 return tid;
504}
505
507{
508}
509
510void
512{
513 m_exponent = n;
514}
515
516void
517LogDistancePropagationLossModel::SetReference(double referenceDistance, double referenceLoss)
518{
519 m_referenceDistance = referenceDistance;
520 m_referenceLoss = referenceLoss;
521}
522
523double
525{
526 return m_exponent;
527}
528
529double
532 Ptr<MobilityModel> b) const
533{
534 double distance = a->GetDistanceFrom(b);
535 if (distance <= m_referenceDistance)
536 {
537 NS_LOG_DEBUG("distance=" << distance << "m, reference-attenuation=" << -m_referenceLoss
538 << "dB, no further attenuation");
539 return txPowerDbm - m_referenceLoss;
540 }
541 /**
542 * The formula is:
543 * rx = 10 * log (Pr0(tx)) - n * 10 * log (d/d0)
544 *
545 * Pr0: rx power at reference distance d0 (W)
546 * d0: reference distance: 1.0 (m)
547 * d: distance (m)
548 * tx: tx power (dB)
549 * rx: dB
550 *
551 * Which, in our case is:
552 *
553 * rx = rx0(tx) - 10 * n * log (d/d0)
554 */
555 double pathLossDb = 10 * m_exponent * std::log10(distance / m_referenceDistance);
556 double rxc = -m_referenceLoss - pathLossDb;
557 NS_LOG_DEBUG("distance=" << distance << "m, reference-attenuation=" << -m_referenceLoss
558 << "dB, "
559 << "attenuation coefficient=" << rxc << "db");
560 return txPowerDbm + rxc;
561}
562
563int64_t
565{
566 return 0;
567}
568
569// ------------------------------------------------------------------------- //
570
572
573TypeId
575{
576 static TypeId tid =
577 TypeId("ns3::ThreeLogDistancePropagationLossModel")
579 .SetGroupName("Propagation")
580 .AddConstructor<ThreeLogDistancePropagationLossModel>()
581 .AddAttribute("Distance0",
582 "Beginning of the first (near) distance field",
583 DoubleValue(1.0),
585 MakeDoubleChecker<double>())
586 .AddAttribute("Distance1",
587 "Beginning of the second (middle) distance field.",
588 DoubleValue(200.0),
590 MakeDoubleChecker<double>())
591 .AddAttribute("Distance2",
592 "Beginning of the third (far) distance field.",
593 DoubleValue(500.0),
595 MakeDoubleChecker<double>())
596 .AddAttribute("Exponent0",
597 "The exponent for the first field.",
598 DoubleValue(1.9),
600 MakeDoubleChecker<double>())
601 .AddAttribute("Exponent1",
602 "The exponent for the second field.",
603 DoubleValue(3.8),
605 MakeDoubleChecker<double>())
606 .AddAttribute("Exponent2",
607 "The exponent for the third field.",
608 DoubleValue(3.8),
610 MakeDoubleChecker<double>())
611 .AddAttribute(
612 "ReferenceLoss",
613 "The reference loss at distance d0 (dB). (Default is Friis at 1m with 5.15 GHz)",
614 DoubleValue(46.6777),
616 MakeDoubleChecker<double>());
617 return tid;
618}
619
621{
622}
623
624double
627 Ptr<MobilityModel> b) const
628{
629 double distance = a->GetDistanceFrom(b);
630 NS_ASSERT(distance >= 0);
631
632 // See doxygen comments for the formula and explanation
633
634 double pathLossDb;
635
636 if (distance < m_distance0)
637 {
638 pathLossDb = 0;
639 }
640 else if (distance < m_distance1)
641 {
642 pathLossDb = m_referenceLoss + 10 * m_exponent0 * std::log10(distance / m_distance0);
643 }
644 else if (distance < m_distance2)
645 {
646 pathLossDb = m_referenceLoss + 10 * m_exponent0 * std::log10(m_distance1 / m_distance0) +
647 10 * m_exponent1 * std::log10(distance / m_distance1);
648 }
649 else
650 {
651 pathLossDb = m_referenceLoss + 10 * m_exponent0 * std::log10(m_distance1 / m_distance0) +
652 10 * m_exponent1 * std::log10(m_distance2 / m_distance1) +
653 10 * m_exponent2 * std::log10(distance / m_distance2);
654 }
655
656 NS_LOG_DEBUG("ThreeLogDistance distance=" << distance << "m, "
657 << "attenuation=" << pathLossDb << "dB");
658
659 return txPowerDbm - pathLossDb;
660}
661
662int64_t
664{
665 return 0;
666}
667
668// ------------------------------------------------------------------------- //
669
671
672TypeId
674{
675 static TypeId tid =
676 TypeId("ns3::NakagamiPropagationLossModel")
678 .SetGroupName("Propagation")
679 .AddConstructor<NakagamiPropagationLossModel>()
680 .AddAttribute("Distance1",
681 "Beginning of the second distance field. Default is 80m.",
682 DoubleValue(80.0),
684 MakeDoubleChecker<double>())
685 .AddAttribute("Distance2",
686 "Beginning of the third distance field. Default is 200m.",
687 DoubleValue(200.0),
689 MakeDoubleChecker<double>())
690 .AddAttribute("m0",
691 "m0 for distances smaller than Distance1. Default is 1.5.",
692 DoubleValue(1.5),
694 MakeDoubleChecker<double>())
695 .AddAttribute("m1",
696 "m1 for distances smaller than Distance2. Default is 0.75.",
697 DoubleValue(0.75),
699 MakeDoubleChecker<double>())
700 .AddAttribute("m2",
701 "m2 for distances greater than Distance2. Default is 0.75.",
702 DoubleValue(0.75),
704 MakeDoubleChecker<double>())
705 .AddAttribute(
706 "ErlangRv",
707 "Access to the underlying ErlangRandomVariable",
708 StringValue("ns3::ErlangRandomVariable"),
710 MakePointerChecker<ErlangRandomVariable>())
711 .AddAttribute("GammaRv",
712 "Access to the underlying GammaRandomVariable",
713 StringValue("ns3::GammaRandomVariable"),
715 MakePointerChecker<GammaRandomVariable>());
716 ;
717 return tid;
718}
719
721{
722}
723
724double
727 Ptr<MobilityModel> b) const
728{
729 // select m parameter
730
731 double distance = a->GetDistanceFrom(b);
732 NS_ASSERT(distance >= 0);
733
734 double m;
735 if (distance < m_distance1)
736 {
737 m = m_m0;
738 }
739 else if (distance < m_distance2)
740 {
741 m = m_m1;
742 }
743 else
744 {
745 m = m_m2;
746 }
747
748 // the current power unit is dBm, but Watt is put into the Nakagami /
749 // Rayleigh distribution.
750 double powerW = std::pow(10, (txPowerDbm - 30) / 10);
751
752 double resultPowerW;
753
754 // switch between Erlang- and Gamma distributions: this is only for
755 // speed. (Gamma is equal to Erlang for any positive integer m.)
756 auto int_m = static_cast<unsigned int>(std::floor(m));
757
758 if (int_m == m)
759 {
760 resultPowerW = m_erlangRandomVariable->GetValue(int_m, powerW / m);
761 }
762 else
763 {
764 resultPowerW = m_gammaRandomVariable->GetValue(m, powerW / m);
765 }
766
767 double resultPowerDbm = 10 * std::log10(resultPowerW) + 30;
768
769 NS_LOG_DEBUG("Nakagami distance=" << distance << "m, "
770 << "power=" << powerW << "W, "
771 << "resultPower=" << resultPowerW << "W=" << resultPowerDbm
772 << "dBm");
773
774 return resultPowerDbm;
775}
776
777int64_t
779{
780 m_erlangRandomVariable->SetStream(stream);
781 m_gammaRandomVariable->SetStream(stream + 1);
782 return 2;
783}
784
785// ------------------------------------------------------------------------- //
786
788
789TypeId
791{
792 static TypeId tid = TypeId("ns3::FixedRssLossModel")
794 .SetGroupName("Propagation")
795 .AddConstructor<FixedRssLossModel>()
796 .AddAttribute("Rss",
797 "The fixed receiver Rss.",
798 DoubleValue(-150.0),
800 MakeDoubleChecker<double>());
801 return tid;
802}
803
806{
807}
808
810{
811}
812
813void
815{
816 m_rss = rss;
817}
818
819double
822 Ptr<MobilityModel> b) const
823{
824 return m_rss;
825}
826
827int64_t
829{
830 return 0;
831}
832
833// ------------------------------------------------------------------------- //
834
836
837TypeId
839{
840 static TypeId tid =
841 TypeId("ns3::MatrixPropagationLossModel")
843 .SetGroupName("Propagation")
844 .AddConstructor<MatrixPropagationLossModel>()
845 .AddAttribute("DefaultLoss",
846 "The default value for propagation loss, dB.",
847 DoubleValue(std::numeric_limits<double>::max()),
849 MakeDoubleChecker<double>());
850 return tid;
851}
852
855 m_default(std::numeric_limits<double>::max())
856{
857}
858
860{
861}
862
863void
865{
866 m_default = loss;
867}
868
869void
872 double loss,
873 bool symmetric)
874{
875 NS_ASSERT(ma && mb);
876
877 MobilityPair p = std::make_pair(ma, mb);
878 auto i = m_loss.find(p);
879
880 if (i == m_loss.end())
881 {
882 m_loss.insert(std::make_pair(p, loss));
883 }
884 else
885 {
886 i->second = loss;
887 }
888
889 if (symmetric)
890 {
891 SetLoss(mb, ma, loss, false);
892 }
893}
894
895double
898 Ptr<MobilityModel> b) const
899{
900 auto i = m_loss.find(std::make_pair(a, b));
901
902 if (i != m_loss.end())
903 {
904 return txPowerDbm - i->second;
905 }
906 else
907 {
908 return txPowerDbm - m_default;
909 }
910}
911
912int64_t
914{
915 return 0;
916}
917
918// ------------------------------------------------------------------------- //
919
921
922TypeId
924{
925 static TypeId tid = TypeId("ns3::RangePropagationLossModel")
927 .SetGroupName("Propagation")
928 .AddConstructor<RangePropagationLossModel>()
929 .AddAttribute("MaxRange",
930 "Maximum Transmission Range (meters)",
931 DoubleValue(250),
933 MakeDoubleChecker<double>());
934 return tid;
935}
936
938{
939}
940
941double
944 Ptr<MobilityModel> b) const
945{
946 double distance = a->GetDistanceFrom(b);
947 if (distance <= m_range)
948 {
949 return txPowerDbm;
950 }
951 else
952 {
953 return -1000;
954 }
955}
956
957int64_t
959{
960 return 0;
961}
962
963// ------------------------------------------------------------------------- //
964
965} // namespace ns3
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition: double.h:42
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.
int64_t DoAssignStreams(int64_t stream) override
Assign a fixed random variable stream number to the random variables used by this model.
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.
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)
a log distance propagation model.
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.
int64_t DoAssignStreams(int64_t stream) override
Assign a fixed random variable stream number to the random variables used by this model.
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.
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
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.
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.
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.
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.
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.
virtual double GetValue()=0
Get the next random value drawn from the distribution.
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
The propagation loss depends only on the distance (range) between transmitter and receiver.
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.
double DoCalcRxPower(double txPowerDbm, Ptr< MobilityModel > a, Ptr< MobilityModel > b) const override
PropagationLossModel.
double m_range
Maximum Transmission Range (meters)
Hold variables of type string.
Definition: string.h:56
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.
double m_exponent2
The exponent for the third field.
double m_distance1
Beginning of the second (middle) distance field.
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.
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:932
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition: assert.h:66
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Definition: pointer.h:259
#define NS_ABORT_MSG_UNLESS(cond, msg)
Abnormal program termination if a condition is false, with a message.
Definition: abort.h:144
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:268
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Definition: log.h:261
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:46
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Definition: double.h:43
STL namespace.