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",
165 DoubleValue(1.0),
167 MakeDoubleChecker<double>())
168 .AddAttribute("MinLoss",
169 "The minimum value (dB) of the total loss, used at short ranges.",
170 DoubleValue(0.0),
173 MakeDoubleChecker<double>());
174 return tid;
175}
176
178{
179}
180
181void
183{
184 m_systemLoss = systemLoss;
185}
186
187double
189{
190 return m_systemLoss;
191}
192
193void
195{
196 m_minLoss = minLoss;
197}
198
199double
201{
202 return m_minLoss;
203}
204
205void
207{
208 m_frequency = frequency;
209 static const double C = 299792458.0; // speed of light in vacuum
210 m_lambda = C / frequency;
211}
212
213double
215{
216 return m_frequency;
217}
218
219double
221{
222 double mw = std::pow(10.0, dbm / 10.0);
223 return mw / 1000.0;
224}
225
226double
228{
229 double dbm = std::log10(w * 1000.0) * 10.0;
230 return dbm;
231}
232
233double
236 Ptr<MobilityModel> b) const
237{
238 /*
239 * Friis free space equation:
240 * where Pt, Gr, Gr and P are in Watt units
241 * L is in meter units.
242 *
243 * P Gt * Gr * (lambda^2)
244 * --- = ---------------------
245 * Pt (4 * pi * d)^2 * L
246 *
247 * Gt: tx gain (unit-less)
248 * Gr: rx gain (unit-less)
249 * Pt: tx power (W)
250 * d: distance (m)
251 * L: system loss
252 * lambda: wavelength (m)
253 *
254 * Here, we ignore tx and rx gain and the input and output values
255 * are in dB or dBm:
256 *
257 * lambda^2
258 * rx = tx + 10 log10 (-------------------)
259 * (4 * pi * d)^2 * L
260 *
261 * rx: rx power (dB)
262 * tx: tx power (dB)
263 * d: distance (m)
264 * L: system loss (unit-less)
265 * lambda: wavelength (m)
266 */
267 double distance = a->GetDistanceFrom(b);
268 if (distance < 3 * m_lambda)
269 {
271 "distance not within the far field region => inaccurate propagation loss value");
272 }
273 if (distance <= 0)
274 {
275 return txPowerDbm - m_minLoss;
276 }
277 double numerator = m_lambda * m_lambda;
278 double denominator = 16 * M_PI * M_PI * distance * distance * m_systemLoss;
279 double lossDb = -10 * log10(numerator / denominator);
280 NS_LOG_DEBUG("distance=" << distance << "m, loss=" << lossDb << "dB");
281 return txPowerDbm - std::max(lossDb, m_minLoss);
282}
283
284int64_t
286{
287 return 0;
288}
289
290// ------------------------------------------------------------------------- //
291// -- Two-Ray Ground Model ported from NS-2 -- tomhewer@mac.com -- Nov09 //
292
294
295TypeId
297{
298 static TypeId tid =
299 TypeId("ns3::TwoRayGroundPropagationLossModel")
301 .SetGroupName("Propagation")
302 .AddConstructor<TwoRayGroundPropagationLossModel>()
303 .AddAttribute(
304 "Frequency",
305 "The carrier frequency (in Hz) at which propagation occurs (default is 5.15 GHz).",
306 DoubleValue(5.150e9),
309 MakeDoubleChecker<double>())
310 .AddAttribute("SystemLoss",
311 "The system loss",
312 DoubleValue(1.0),
314 MakeDoubleChecker<double>())
315 .AddAttribute(
316 "MinDistance",
317 "The distance under which the propagation model refuses to give results (m)",
318 DoubleValue(0.5),
321 MakeDoubleChecker<double>())
322 .AddAttribute("HeightAboveZ",
323 "The height of the antenna (m) above the node's Z coordinate",
324 DoubleValue(0),
326 MakeDoubleChecker<double>());
327 return tid;
328}
329
331{
332}
333
334void
336{
337 m_systemLoss = systemLoss;
338}
339
340double
342{
343 return m_systemLoss;
344}
345
346void
348{
349 m_minDistance = minDistance;
350}
351
352double
354{
355 return m_minDistance;
356}
357
358void
360{
361 m_heightAboveZ = heightAboveZ;
362}
363
364void
366{
367 m_frequency = frequency;
368 static const double C = 299792458.0; // speed of light in vacuum
369 m_lambda = C / frequency;
370}
371
372double
374{
375 return m_frequency;
376}
377
378double
380{
381 double mw = std::pow(10.0, dbm / 10.0);
382 return mw / 1000.0;
383}
384
385double
387{
388 double dbm = std::log10(w * 1000.0) * 10.0;
389 return dbm;
390}
391
392double
395 Ptr<MobilityModel> b) const
396{
397 /*
398 * Two-Ray Ground equation:
399 *
400 * where Pt, Gt and Gr are in dBm units
401 * L, Ht and Hr are in meter units.
402 *
403 * Pr Gt * Gr * (Ht^2 * Hr^2)
404 * -- = (-------------------------)
405 * Pt d^4 * L
406 *
407 * Gt: tx gain (unit-less)
408 * Gr: rx gain (unit-less)
409 * Pt: tx power (dBm)
410 * d: distance (m)
411 * L: system loss
412 * Ht: Tx antenna height (m)
413 * Hr: Rx antenna height (m)
414 * lambda: wavelength (m)
415 *
416 * As with the Friis model we ignore tx and rx gain and output values
417 * are in dB or dBm
418 *
419 * (Ht * Ht) * (Hr * Hr)
420 * rx = tx + 10 log10 (-----------------------)
421 * (d * d * d * d) * L
422 */
423 double distance = a->GetDistanceFrom(b);
424 if (distance <= m_minDistance)
425 {
426 return txPowerDbm;
427 }
428
429 // Set the height of the Tx and Rx antennae
430 double txAntHeight = a->GetPosition().z + m_heightAboveZ;
431 double rxAntHeight = b->GetPosition().z + m_heightAboveZ;
432
433 // Calculate a crossover distance, under which we use Friis
434 /*
435 *
436 * dCross = (4 * pi * Ht * Hr) / lambda
437 *
438 */
439
440 double dCross = (4 * M_PI * txAntHeight * rxAntHeight) / m_lambda;
441 double tmp = 0;
442 if (distance <= dCross)
443 {
444 // We use Friis
445 double numerator = m_lambda * m_lambda;
446 tmp = M_PI * distance;
447 double denominator = 16 * tmp * tmp * m_systemLoss;
448 double pr = 10 * std::log10(numerator / denominator);
449 NS_LOG_DEBUG("Receiver within crossover (" << dCross << "m) for Two_ray path; using Friis");
450 NS_LOG_DEBUG("distance=" << distance << "m, attenuation coefficient=" << pr << "dB");
451 return txPowerDbm + pr;
452 }
453 else // Use Two-Ray Pathloss
454 {
455 tmp = txAntHeight * rxAntHeight;
456 double rayNumerator = tmp * tmp;
457 tmp = distance * distance;
458 double rayDenominator = tmp * tmp * m_systemLoss;
459 double rayPr = 10 * std::log10(rayNumerator / rayDenominator);
460 NS_LOG_DEBUG("distance=" << distance << "m, attenuation coefficient=" << rayPr << "dB");
461 return txPowerDbm + rayPr;
462 }
463}
464
465int64_t
467{
468 return 0;
469}
470
471// ------------------------------------------------------------------------- //
472
474
475TypeId
477{
478 static TypeId tid =
479 TypeId("ns3::LogDistancePropagationLossModel")
481 .SetGroupName("Propagation")
482 .AddConstructor<LogDistancePropagationLossModel>()
483 .AddAttribute("Exponent",
484 "The exponent of the Path Loss propagation model",
485 DoubleValue(3.0),
487 MakeDoubleChecker<double>())
488 .AddAttribute("ReferenceDistance",
489 "The distance at which the reference loss is calculated (m)",
490 DoubleValue(1.0),
492 MakeDoubleChecker<double>())
493 .AddAttribute("ReferenceLoss",
494 "The reference loss at reference distance (dB). (Default is Friis at 1m "
495 "with 5.15 GHz)",
496 DoubleValue(46.6777),
498 MakeDoubleChecker<double>());
499 return tid;
500}
501
503{
504}
505
506void
508{
509 m_exponent = n;
510}
511
512void
513LogDistancePropagationLossModel::SetReference(double referenceDistance, double referenceLoss)
514{
515 m_referenceDistance = referenceDistance;
516 m_referenceLoss = referenceLoss;
517}
518
519double
521{
522 return m_exponent;
523}
524
525double
528 Ptr<MobilityModel> b) const
529{
530 double distance = a->GetDistanceFrom(b);
531 if (distance <= m_referenceDistance)
532 {
533 return txPowerDbm - m_referenceLoss;
534 }
549 double pathLossDb = 10 * m_exponent * std::log10(distance / m_referenceDistance);
550 double rxc = -m_referenceLoss - pathLossDb;
551 NS_LOG_DEBUG("distance=" << distance << "m, reference-attenuation=" << -m_referenceLoss
552 << "dB, "
553 << "attenuation coefficient=" << rxc << "db");
554 return txPowerDbm + rxc;
555}
556
557int64_t
559{
560 return 0;
561}
562
563// ------------------------------------------------------------------------- //
564
566
567TypeId
569{
570 static TypeId tid =
571 TypeId("ns3::ThreeLogDistancePropagationLossModel")
573 .SetGroupName("Propagation")
574 .AddConstructor<ThreeLogDistancePropagationLossModel>()
575 .AddAttribute("Distance0",
576 "Beginning of the first (near) distance field",
577 DoubleValue(1.0),
579 MakeDoubleChecker<double>())
580 .AddAttribute("Distance1",
581 "Beginning of the second (middle) distance field.",
582 DoubleValue(200.0),
584 MakeDoubleChecker<double>())
585 .AddAttribute("Distance2",
586 "Beginning of the third (far) distance field.",
587 DoubleValue(500.0),
589 MakeDoubleChecker<double>())
590 .AddAttribute("Exponent0",
591 "The exponent for the first field.",
592 DoubleValue(1.9),
594 MakeDoubleChecker<double>())
595 .AddAttribute("Exponent1",
596 "The exponent for the second field.",
597 DoubleValue(3.8),
599 MakeDoubleChecker<double>())
600 .AddAttribute("Exponent2",
601 "The exponent for the third field.",
602 DoubleValue(3.8),
604 MakeDoubleChecker<double>())
605 .AddAttribute(
606 "ReferenceLoss",
607 "The reference loss at distance d0 (dB). (Default is Friis at 1m with 5.15 GHz)",
608 DoubleValue(46.6777),
610 MakeDoubleChecker<double>());
611 return tid;
612}
613
615{
616}
617
618double
621 Ptr<MobilityModel> b) const
622{
623 double distance = a->GetDistanceFrom(b);
624 NS_ASSERT(distance >= 0);
625
626 // See doxygen comments for the formula and explanation
627
628 double pathLossDb;
629
630 if (distance < m_distance0)
631 {
632 pathLossDb = 0;
633 }
634 else if (distance < m_distance1)
635 {
636 pathLossDb = m_referenceLoss + 10 * m_exponent0 * std::log10(distance / m_distance0);
637 }
638 else if (distance < m_distance2)
639 {
640 pathLossDb = m_referenceLoss + 10 * m_exponent0 * std::log10(m_distance1 / m_distance0) +
641 10 * m_exponent1 * std::log10(distance / m_distance1);
642 }
643 else
644 {
645 pathLossDb = m_referenceLoss + 10 * m_exponent0 * std::log10(m_distance1 / m_distance0) +
646 10 * m_exponent1 * std::log10(m_distance2 / m_distance1) +
647 10 * m_exponent2 * std::log10(distance / m_distance2);
648 }
649
650 NS_LOG_DEBUG("ThreeLogDistance distance=" << distance << "m, "
651 << "attenuation=" << pathLossDb << "dB");
652
653 return txPowerDbm - pathLossDb;
654}
655
656int64_t
658{
659 return 0;
660}
661
662// ------------------------------------------------------------------------- //
663
665
666TypeId
668{
669 static TypeId tid =
670 TypeId("ns3::NakagamiPropagationLossModel")
672 .SetGroupName("Propagation")
673 .AddConstructor<NakagamiPropagationLossModel>()
674 .AddAttribute("Distance1",
675 "Beginning of the second distance field. Default is 80m.",
676 DoubleValue(80.0),
678 MakeDoubleChecker<double>())
679 .AddAttribute("Distance2",
680 "Beginning of the third distance field. Default is 200m.",
681 DoubleValue(200.0),
683 MakeDoubleChecker<double>())
684 .AddAttribute("m0",
685 "m0 for distances smaller than Distance1. Default is 1.5.",
686 DoubleValue(1.5),
688 MakeDoubleChecker<double>())
689 .AddAttribute("m1",
690 "m1 for distances smaller than Distance2. Default is 0.75.",
691 DoubleValue(0.75),
693 MakeDoubleChecker<double>())
694 .AddAttribute("m2",
695 "m2 for distances greater than Distance2. Default is 0.75.",
696 DoubleValue(0.75),
698 MakeDoubleChecker<double>())
699 .AddAttribute(
700 "ErlangRv",
701 "Access to the underlying ErlangRandomVariable",
702 StringValue("ns3::ErlangRandomVariable"),
704 MakePointerChecker<ErlangRandomVariable>())
705 .AddAttribute("GammaRv",
706 "Access to the underlying GammaRandomVariable",
707 StringValue("ns3::GammaRandomVariable"),
709 MakePointerChecker<GammaRandomVariable>());
710 ;
711 return tid;
712}
713
715{
716}
717
718double
721 Ptr<MobilityModel> b) const
722{
723 // select m parameter
724
725 double distance = a->GetDistanceFrom(b);
726 NS_ASSERT(distance >= 0);
727
728 double m;
729 if (distance < m_distance1)
730 {
731 m = m_m0;
732 }
733 else if (distance < m_distance2)
734 {
735 m = m_m1;
736 }
737 else
738 {
739 m = m_m2;
740 }
741
742 // the current power unit is dBm, but Watt is put into the Nakagami /
743 // Rayleigh distribution.
744 double powerW = std::pow(10, (txPowerDbm - 30) / 10);
745
746 double resultPowerW;
747
748 // switch between Erlang- and Gamma distributions: this is only for
749 // speed. (Gamma is equal to Erlang for any positive integer m.)
750 unsigned int int_m = static_cast<unsigned int>(std::floor(m));
751
752 if (int_m == m)
753 {
754 resultPowerW = m_erlangRandomVariable->GetValue(int_m, powerW / m);
755 }
756 else
757 {
758 resultPowerW = m_gammaRandomVariable->GetValue(m, powerW / m);
759 }
760
761 double resultPowerDbm = 10 * std::log10(resultPowerW) + 30;
762
763 NS_LOG_DEBUG("Nakagami distance=" << distance << "m, "
764 << "power=" << powerW << "W, "
765 << "resultPower=" << resultPowerW << "W=" << resultPowerDbm
766 << "dBm");
767
768 return resultPowerDbm;
769}
770
771int64_t
773{
774 m_erlangRandomVariable->SetStream(stream);
775 m_gammaRandomVariable->SetStream(stream + 1);
776 return 2;
777}
778
779// ------------------------------------------------------------------------- //
780
782
783TypeId
785{
786 static TypeId tid = TypeId("ns3::FixedRssLossModel")
788 .SetGroupName("Propagation")
789 .AddConstructor<FixedRssLossModel>()
790 .AddAttribute("Rss",
791 "The fixed receiver Rss.",
792 DoubleValue(-150.0),
794 MakeDoubleChecker<double>());
795 return tid;
796}
797
800{
801}
802
804{
805}
806
807void
809{
810 m_rss = rss;
811}
812
813double
816 Ptr<MobilityModel> b) const
817{
818 return m_rss;
819}
820
821int64_t
823{
824 return 0;
825}
826
827// ------------------------------------------------------------------------- //
828
830
831TypeId
833{
834 static TypeId tid =
835 TypeId("ns3::MatrixPropagationLossModel")
837 .SetGroupName("Propagation")
838 .AddConstructor<MatrixPropagationLossModel>()
839 .AddAttribute("DefaultLoss",
840 "The default value for propagation loss, dB.",
841 DoubleValue(std::numeric_limits<double>::max()),
843 MakeDoubleChecker<double>());
844 return tid;
845}
846
849 m_default(std::numeric_limits<double>::max())
850{
851}
852
854{
855}
856
857void
859{
860 m_default = loss;
861}
862
863void
866 double loss,
867 bool symmetric)
868{
869 NS_ASSERT(ma && mb);
870
871 MobilityPair p = std::make_pair(ma, mb);
872 std::map<MobilityPair, double>::iterator i = m_loss.find(p);
873
874 if (i == m_loss.end())
875 {
876 m_loss.insert(std::make_pair(p, loss));
877 }
878 else
879 {
880 i->second = loss;
881 }
882
883 if (symmetric)
884 {
885 SetLoss(mb, ma, loss, false);
886 }
887}
888
889double
892 Ptr<MobilityModel> b) const
893{
894 std::map<MobilityPair, double>::const_iterator i = m_loss.find(std::make_pair(a, b));
895
896 if (i != m_loss.end())
897 {
898 return txPowerDbm - i->second;
899 }
900 else
901 {
902 return txPowerDbm - m_default;
903 }
904}
905
906int64_t
908{
909 return 0;
910}
911
912// ------------------------------------------------------------------------- //
913
915
916TypeId
918{
919 static TypeId tid = TypeId("ns3::RangePropagationLossModel")
921 .SetGroupName("Propagation")
922 .AddConstructor<RangePropagationLossModel>()
923 .AddAttribute("MaxRange",
924 "Maximum Transmission Range (meters)",
925 DoubleValue(250),
927 MakeDoubleChecker<double>());
928 return tid;
929}
930
932{
933}
934
935double
938 Ptr<MobilityModel> b) const
939{
940 double distance = a->GetDistanceFrom(b);
941 if (distance <= m_range)
942 {
943 return txPowerDbm;
944 }
945 else
946 {
947 return -1000;
948 }
949}
950
951int64_t
953{
954 return 0;
955}
956
957// ------------------------------------------------------------------------- //
958
959} // namespace ns3
#define max(a, b)
Definition: 80211b.c:42
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.
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::pair< Ptr< MobilityModel >, Ptr< MobilityModel > > MobilityPair
Typedef: Mobility models pair.
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.
std::map< MobilityPair, double > m_loss
Propagation loss between pair of nodes.
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:78
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 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:936
#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 > MakeDoubleAccessor(T1 a1)
Definition: double.h:43
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Definition: pointer.h:227
#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.
STL namespace.