A Discrete-Event Network Simulator
API
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 <map>
31 
32 namespace ns3
33 {
34 
45 class MobilityModel;
46 
56 {
57  public:
63  static TypeId GetTypeId();
64 
66  ~PropagationLossModel() override;
67 
68  // Delete copy constructor and assignment operator to avoid misuse
71 
81 
92 
102  double CalcRxPower(double txPowerDbm, Ptr<MobilityModel> a, Ptr<MobilityModel> b) const;
103 
115  int64_t AssignStreams(int64_t stream);
116 
117  protected:
127  virtual int64_t DoAssignStreams(int64_t stream) = 0;
128 
129  private:
138  virtual double DoCalcRxPower(double txPowerDbm,
140  Ptr<MobilityModel> b) const = 0;
141 
143 };
144 
151 {
152  public:
157  static TypeId GetTypeId();
158 
160  ~RandomPropagationLossModel() override;
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 
253 {
254  public:
259  static TypeId GetTypeId();
261 
262  // Delete copy constructor and assignment operator to avoid misuse
265 
272  void SetFrequency(double frequency);
278  void SetSystemLoss(double systemLoss);
279 
286  void SetMinLoss(double minLoss);
287 
291  double GetMinLoss() const;
292 
296  double GetFrequency() const;
300  double GetSystemLoss() const;
301 
302  private:
303  double DoCalcRxPower(double txPowerDbm,
305  Ptr<MobilityModel> b) const override;
306  int64_t DoAssignStreams(int64_t stream) override;
307 
313  double DbmToW(double dbm) const;
314 
320  double DbmFromW(double w) const;
321 
322  double m_lambda;
323  double m_frequency;
324  double m_systemLoss;
325  double m_minLoss;
326 };
327 
357 {
358  public:
363  static TypeId GetTypeId();
365 
366  // Delete copy constructor and assignment operator to avoid misuse
369 
376  void SetFrequency(double frequency);
377 
383  void SetSystemLoss(double systemLoss);
390  void SetMinDistance(double minDistance);
394  double GetMinDistance() const;
395 
399  double GetFrequency() const;
400 
404  double GetSystemLoss() const;
410  void SetHeightAboveZ(double heightAboveZ);
411 
412  private:
413  double DoCalcRxPower(double txPowerDbm,
415  Ptr<MobilityModel> b) const override;
416  int64_t DoAssignStreams(int64_t stream) override;
417 
423  double DbmToW(double dbm) const;
424 
430  double DbmFromW(double w) const;
431 
432  double m_lambda;
433  double m_frequency;
434  double m_systemLoss;
435  double m_minDistance;
436  double m_heightAboveZ;
437 };
438 
460 {
461  public:
466  static TypeId GetTypeId();
468 
469  // Delete copy constructor and assignment operator to avoid misuse
472 
477  void SetPathLossExponent(double n);
481  double GetPathLossExponent() const;
482 
488  void SetReference(double referenceDistance, double referenceLoss);
489 
490  private:
491  double DoCalcRxPower(double txPowerDbm,
493  Ptr<MobilityModel> b) const override;
494 
495  int64_t DoAssignStreams(int64_t stream) override;
496 
502 
503  double m_exponent;
506 };
507 
550 {
551  public:
556  static TypeId GetTypeId();
558 
559  // Delete copy constructor and assignment operator to avoid misuse
562  delete;
563 
564  // Parameters are all accessible via attributes.
565 
566  private:
567  double DoCalcRxPower(double txPowerDbm,
569  Ptr<MobilityModel> b) const override;
570 
571  int64_t DoAssignStreams(int64_t stream) override;
572 
573  double m_distance0;
574  double m_distance1;
575  double m_distance2;
576 
577  double m_exponent0;
578  double m_exponent1;
579  double m_exponent2;
580 
582 };
583 
613 {
614  public:
619  static TypeId GetTypeId();
620 
622 
623  // Delete copy constructor and assignment operator to avoid misuse
626 
627  // Parameters are all accessible via attributes.
628 
629  private:
630  double DoCalcRxPower(double txPowerDbm,
632  Ptr<MobilityModel> b) const override;
633 
634  int64_t DoAssignStreams(int64_t stream) override;
635 
636  double m_distance1;
637  double m_distance2;
638 
639  double m_m0;
640  double m_m1;
641  double m_m2;
642 
645 };
646 
661 {
662  public:
667  static TypeId GetTypeId();
668 
670  ~FixedRssLossModel() override;
671 
672  // Delete copy constructor and assignment operator to avoid misuse
675 
681  void SetRss(double rss);
682 
683  private:
684  double DoCalcRxPower(double txPowerDbm,
686  Ptr<MobilityModel> b) const override;
687 
688  int64_t DoAssignStreams(int64_t stream) override;
689 
690  double m_rss;
691 };
692 
703 {
704  public:
709  static TypeId GetTypeId();
710 
712  ~MatrixPropagationLossModel() override;
713 
714  // Delete copy constructor and assignment operator to avoid misuse
717 
727  void SetLoss(Ptr<MobilityModel> a, Ptr<MobilityModel> b, double loss, bool symmetric = true);
728 
733  void SetDefaultLoss(double defaultLoss);
734 
735  private:
736  double DoCalcRxPower(double txPowerDbm,
738  Ptr<MobilityModel> b) const override;
739 
740  int64_t DoAssignStreams(int64_t stream) override;
741 
742  double m_default;
743 
745  typedef std::pair<Ptr<MobilityModel>, Ptr<MobilityModel>> MobilityPair;
746 
747  std::map<MobilityPair, double> m_loss;
748 };
749 
762 {
763  public:
768  static TypeId GetTypeId();
770 
771  // Delete copy constructor and assignment operator to avoid misuse
774 
775  private:
776  double DoCalcRxPower(double txPowerDbm,
778  Ptr<MobilityModel> b) const override;
779 
780  int64_t DoAssignStreams(int64_t stream) override;
781 
782  double m_range;
783 };
784 
785 } // namespace ns3
786 
787 #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.
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
FixedRssLossModel & operator=(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.
FriisPropagationLossModel & operator=(const FriisPropagationLossModel &)=delete
static TypeId GetTypeId()
Get the type ID.
a log distance propagation model.
LogDistancePropagationLossModel(const LogDistancePropagationLossModel &)=delete
static Ptr< PropagationLossModel > CreateDefaultReference()
Creates a default reference loss 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.
LogDistancePropagationLossModel & operator=(const LogDistancePropagationLossModel &)=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.
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.
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.
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
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.
virtual int64_t DoAssignStreams(int64_t stream)=0
Assign a fixed random variable stream number to the random variables used by this model.
PropagationLossModel & operator=(const PropagationLossModel &)=delete
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.
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.
RandomPropagationLossModel & operator=(const RandomPropagationLossModel &)=delete
RandomPropagationLossModel(const RandomPropagationLossModel &)=delete
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.
RangePropagationLossModel(const RangePropagationLossModel &)=delete
double DoCalcRxPower(double txPowerDbm, Ptr< MobilityModel > a, Ptr< MobilityModel > b) const override
PropagationLossModel.
RangePropagationLossModel & operator=(const RangePropagationLossModel &)=delete
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 & operator=(const ThreeLogDistancePropagationLossModel &)=delete
ThreeLogDistancePropagationLossModel(const ThreeLogDistancePropagationLossModel &)=delete
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.
TwoRayGroundPropagationLossModel(const TwoRayGroundPropagationLossModel &)=delete
TwoRayGroundPropagationLossModel & operator=(const TwoRayGroundPropagationLossModel &)=delete
a unique identifier for an interface.
Definition: type-id.h:60
Every class exported by the ns3 library is enclosed in the ns3 namespace.