A Discrete-Event Network Simulator
API
propagation-loss-model.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2005,2006,2007 INRIA
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19  * Contributions: Timo Bingmann <timo.bingmann@student.kit.edu>
20  * Contributions: Gary Pei <guangyu.pei@boeing.com> for fixed RSS
21  * Contributions: Tom Hewer <tomhewer@mac.com> for two ray ground model
22  * Pavel Boyko <boyko@iitp.ru> for matrix
23  */
24 
25 #ifndef PROPAGATION_LOSS_MODEL_H
26 #define PROPAGATION_LOSS_MODEL_H
27 
28 #include "ns3/object.h"
29 #include "ns3/random-variable-stream.h"
30 #include <map>
31 
32 namespace ns3 {
33 
39 class MobilityModel;
40 
50 {
51 public:
57  static TypeId GetTypeId (void);
58 
60  virtual ~PropagationLossModel ();
61 
71 
82 
92  double CalcRxPower (double txPowerDbm,
94  Ptr<MobilityModel> b) const;
95 
107  int64_t AssignStreams (int64_t stream);
108 
109 private:
123 
133  virtual double DoCalcRxPower (double txPowerDbm,
135  Ptr<MobilityModel> b) const = 0;
136 
141  virtual int64_t DoAssignStreams (int64_t stream) = 0;
142 
144 };
145 
152 {
153 public:
158  static TypeId GetTypeId (void);
159 
161  virtual ~RandomPropagationLossModel ();
162 
163 private:
177  virtual double DoCalcRxPower (double txPowerDbm,
179  Ptr<MobilityModel> b) const;
180  virtual int64_t DoAssignStreams (int64_t stream);
182 };
183 
262 {
263 public:
268  static TypeId GetTypeId (void);
276  void SetFrequency (double frequency);
282  void SetSystemLoss (double systemLoss);
283 
290  void SetMinLoss (double minLoss);
291 
295  double GetMinLoss (void) const;
296 
300  double GetFrequency (void) const;
304  double GetSystemLoss (void) const;
305 
306 private:
320 
321  virtual double DoCalcRxPower (double txPowerDbm,
323  Ptr<MobilityModel> b) const;
324  virtual int64_t DoAssignStreams (int64_t stream);
325 
331  double DbmToW (double dbm) const;
332 
338  double DbmFromW (double w) const;
339 
340  double m_lambda;
341  double m_frequency;
342  double m_systemLoss;
343  double m_minLoss;
344 };
345 
375 {
376 public:
381  static TypeId GetTypeId (void);
383 
390  void SetFrequency (double frequency);
391 
397  void SetSystemLoss (double systemLoss);
404  void SetMinDistance (double minDistance);
408  double GetMinDistance (void) const;
409 
413  double GetFrequency (void) const;
414 
418  double GetSystemLoss (void) const;
424  void SetHeightAboveZ (double heightAboveZ);
425 
426 private:
440 
441  virtual double DoCalcRxPower (double txPowerDbm,
443  Ptr<MobilityModel> b) const;
444  virtual int64_t DoAssignStreams (int64_t stream);
445 
451  double DbmToW (double dbm) const;
452 
458  double DbmFromW (double w) const;
459 
460  double m_lambda;
461  double m_frequency;
462  double m_systemLoss;
463  double m_minDistance;
464  double m_heightAboveZ;
465 };
466 
488 {
489 public:
494  static TypeId GetTypeId (void);
496 
501  void SetPathLossExponent (double n);
505  double GetPathLossExponent (void) const;
506 
512  void SetReference (double referenceDistance, double referenceLoss);
513 
514 private:
528 
529  virtual double DoCalcRxPower (double txPowerDbm,
531  Ptr<MobilityModel> b) const;
532  virtual int64_t DoAssignStreams (int64_t stream);
533 
539 
540  double m_exponent;
543 };
544 
586 {
587 public:
592  static TypeId GetTypeId (void);
594 
595  // Parameters are all accessible via attributes.
596 
597 private:
611 
612  virtual double DoCalcRxPower (double txPowerDbm,
614  Ptr<MobilityModel> b) const;
615  virtual int64_t DoAssignStreams (int64_t stream);
616 
617  double m_distance0;
618  double m_distance1;
619  double m_distance2;
620 
621  double m_exponent0;
622  double m_exponent1;
623  double m_exponent2;
624 
626 };
627 
656 {
657 public:
662  static TypeId GetTypeId (void);
663 
665 
666  // Parameters are all accessible via attributes.
667 
668 private:
682 
683  virtual double DoCalcRxPower (double txPowerDbm,
685  Ptr<MobilityModel> b) const;
686  virtual int64_t DoAssignStreams (int64_t stream);
687 
688  double m_distance1;
689  double m_distance2;
690 
691  double m_m0;
692  double m_m1;
693  double m_m2;
694 
697 };
698 
713 {
714 public:
719  static TypeId GetTypeId (void);
720 
722  virtual ~FixedRssLossModel ();
728  void SetRss (double rss);
729 
730 private:
744 
745  virtual double DoCalcRxPower (double txPowerDbm,
747  Ptr<MobilityModel> b) const;
748 
749  virtual int64_t DoAssignStreams (int64_t stream);
750  double m_rss;
751 };
752 
761 {
762 public:
767  static TypeId GetTypeId (void);
768 
770  virtual ~MatrixPropagationLossModel ();
771 
781  void SetLoss (Ptr<MobilityModel> a, Ptr<MobilityModel> b, double loss, bool symmetric = true);
782 
787  void SetDefaultLoss (double defaultLoss);
788 
789 private:
803 
804  virtual double DoCalcRxPower (double txPowerDbm,
806  Ptr<MobilityModel> b) const;
807 
808  virtual int64_t DoAssignStreams (int64_t stream);
809 private:
810  double m_default;
811 
813  typedef std::pair< Ptr<MobilityModel>, Ptr<MobilityModel> > MobilityPair;
814 
815  std::map<MobilityPair, double> m_loss;
816 };
817 
829 {
830 public:
835  static TypeId GetTypeId (void);
837 private:
851  virtual double DoCalcRxPower (double txPowerDbm,
853  Ptr<MobilityModel> b) const;
854  virtual int64_t DoAssignStreams (int64_t stream);
855 private:
856  double m_range;
857 };
858 
859 } // namespace ns3
860 
861 #endif /* PROPAGATION_LOSS_MODEL_H */
Return a constant received power level independent of the transmit power.
double m_rss
the received signal strength
FixedRssLossModel(const FixedRssLossModel &)
Copy constructor.
FixedRssLossModel & operator=(const FixedRssLossModel &)
Copy constructor.
static TypeId GetTypeId(void)
Get the type ID.
virtual double DoCalcRxPower(double txPowerDbm, Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
Returns the Rx Power taking into account only the particular PropagationLossModel.
virtual int64_t DoAssignStreams(int64_t stream)
Subclasses must implement this; those not using random variables can return zero.
a Friis propagation loss model
virtual int64_t DoAssignStreams(int64_t stream)
Subclasses must implement this; those not using random variables can return zero.
double m_lambda
the carrier wavelength
double DbmFromW(double w) const
Transforms a Watt value to Dbm.
FriisPropagationLossModel & operator=(const FriisPropagationLossModel &)
Copy constructor.
double m_frequency
the carrier frequency
double DbmToW(double dbm) const
Transforms a Dbm value to Watt.
static TypeId GetTypeId(void)
Get the type ID.
FriisPropagationLossModel(const FriisPropagationLossModel &)
Copy constructor.
virtual double DoCalcRxPower(double txPowerDbm, Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
Returns the Rx Power taking into account only the particular PropagationLossModel.
a log distance propagation model.
LogDistancePropagationLossModel & operator=(const LogDistancePropagationLossModel &)
Copy constructor.
static Ptr< PropagationLossModel > CreateDefaultReference(void)
Creates a default reference loss model.
void SetReference(double referenceDistance, double referenceLoss)
Set the reference path loss at a given distance.
virtual int64_t DoAssignStreams(int64_t stream)
Subclasses must implement this; those not using random variables can return zero.
virtual double DoCalcRxPower(double txPowerDbm, Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
Returns the Rx Power taking into account only the particular PropagationLossModel.
static TypeId GetTypeId(void)
Get the type ID.
LogDistancePropagationLossModel(const LogDistancePropagationLossModel &)
Copy constructor.
The propagation loss is fixed for each pair of nodes and doesn't depend on their actual positions.
virtual int64_t DoAssignStreams(int64_t stream)
Subclasses must implement this; those not using random variables can return zero.
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.
static TypeId GetTypeId(void)
Get the type ID.
virtual double DoCalcRxPower(double txPowerDbm, Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
Returns the Rx Power taking into account only the particular PropagationLossModel.
MatrixPropagationLossModel(const MatrixPropagationLossModel &)
Copy constructor.
std::pair< Ptr< MobilityModel >, Ptr< MobilityModel > > MobilityPair
Typedef: Mobility models pair.
MatrixPropagationLossModel & operator=(const MatrixPropagationLossModel &)
Copy constructor.
std::map< MobilityPair, double > m_loss
Propagation loss between pair of nodes.
Nakagami-m fast fading propagation loss model.
NakagamiPropagationLossModel & operator=(const NakagamiPropagationLossModel &)
Copy constructor.
Ptr< ErlangRandomVariable > m_erlangRandomVariable
Erlang random variable.
double m_m0
m for distances smaller than Distance1
Ptr< GammaRandomVariable > m_gammaRandomVariable
Gamma random variable.
virtual double DoCalcRxPower(double txPowerDbm, Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
Returns the Rx Power taking into account only the particular PropagationLossModel.
NakagamiPropagationLossModel(const NakagamiPropagationLossModel &)
Copy constructor.
static TypeId GetTypeId(void)
Get the type ID.
virtual int64_t DoAssignStreams(int64_t stream)
Subclasses must implement this; those not using random variables can return zero.
double m_m1
m for distances smaller than Distance2
double m_m2
m for distances greater than Distance2
A base class which provides memory management and object aggregation.
Definition: object.h:88
Models the propagation loss through a transmission medium.
virtual int64_t DoAssignStreams(int64_t stream)=0
Subclasses must implement this; those not using random variables can return zero.
PropagationLossModel(const PropagationLossModel &)
Copy constructor.
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.
virtual double DoCalcRxPower(double txPowerDbm, Ptr< MobilityModel > a, Ptr< MobilityModel > b) const =0
Returns the Rx Power taking into account only the particular PropagationLossModel.
PropagationLossModel & operator=(const PropagationLossModel &)
Copy constructor.
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.
static TypeId GetTypeId(void)
Get the type ID.
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.
virtual double DoCalcRxPower(double txPowerDbm, Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
Returns the Rx Power taking into account only the particular PropagationLossModel.
static TypeId GetTypeId(void)
Get the type ID.
virtual int64_t DoAssignStreams(int64_t stream)
Subclasses must implement this; those not using random variables can return zero.
RandomPropagationLossModel(const RandomPropagationLossModel &)
Copy constructor.
Ptr< RandomVariableStream > m_variable
random generator
RandomPropagationLossModel & operator=(const RandomPropagationLossModel &)
Copy constructor.
The propagation loss depends only on the distance (range) between transmitter and receiver.
virtual int64_t DoAssignStreams(int64_t stream)
Subclasses must implement this; those not using random variables can return zero.
static TypeId GetTypeId(void)
Get the type ID.
RangePropagationLossModel & operator=(const RangePropagationLossModel &)
Copy constructor.
RangePropagationLossModel(const RangePropagationLossModel &)
Copy constructor.
virtual double DoCalcRxPower(double txPowerDbm, Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
Returns the Rx Power taking into account only the particular PropagationLossModel.
double m_range
Maximum Transmission Range (meters)
A log distance path loss propagation model with three distance fields.
ThreeLogDistancePropagationLossModel & operator=(const ThreeLogDistancePropagationLossModel &)
Copy constructor.
virtual int64_t DoAssignStreams(int64_t stream)
Subclasses must implement this; those not using random variables can return zero.
virtual double DoCalcRxPower(double txPowerDbm, Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
Returns the Rx Power taking into account only the particular PropagationLossModel.
double m_referenceLoss
The reference loss at distance d0 (dB).
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.
static TypeId GetTypeId(void)
Get the type ID.
double m_exponent0
The exponent for the first field.
ThreeLogDistancePropagationLossModel(const ThreeLogDistancePropagationLossModel &)
Copy constructor.
double m_exponent1
The exponent for the second field.
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
TwoRayGroundPropagationLossModel(const TwoRayGroundPropagationLossModel &)
Copy constructor.
double m_heightAboveZ
antenna height above the node's Z coordinate
virtual double DoCalcRxPower(double txPowerDbm, Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
Returns the Rx Power taking into account only the particular PropagationLossModel.
double DbmFromW(double w) const
Transforms a Watt value to Dbm.
static TypeId GetTypeId(void)
Get the type ID.
TwoRayGroundPropagationLossModel & operator=(const TwoRayGroundPropagationLossModel &)
Copy constructor.
virtual int64_t DoAssignStreams(int64_t stream)
Subclasses must implement this; those not using random variables can return zero.
a unique identifier for an interface.
Definition: type-id.h:59
Every class exported by the ns3 library is enclosed in the ns3 namespace.