INET Framework for OMNeT++/OMNEST
inet::physicallayer::TwoRayInterference Class Reference

Two-Ray interference model borrowed from Veins (default parameterization) More...

#include <TwoRayInterference.h>

Inheritance diagram for inet::physicallayer::TwoRayInterference:
inet::physicallayer::IPathLoss inet::IPrintableObject

Public Member Functions

 TwoRayInterference ()
 Literature referenced here: Rappaport, Theodore: Wireless Communications - Principles and Practice, 2nd edition, 2002 Jakes, William C. More...
 
void initialize (int stage) override
 
double computePathLoss (const ITransmission *, const IArrival *) const override
 Returns the loss factor for the provided transmission and arrival. More...
 
double computePathLoss (mps propagation, Hz frequency, m distance) const override
 Returns the loss factor as a function of propagation speed, carrier frequency and distance. More...
 
m computeRange (mps propagation, Hz frequency, double loss) const override
 Returns the range for the given loss factor. More...
 
std::ostream & printToStream (std::ostream &, int level, int evFlags=0) const override
 Prints this object to the provided output stream. More...
 
- Public Member Functions inherited from inet::IPrintableObject
virtual ~IPrintableObject ()
 
virtual std::string printToString () const
 
virtual std::string printToString (int level, int evFlags=0) const
 
virtual std::string getInfoStringRepresentation (int evFlags=0) const
 
virtual std::string getDetailStringRepresentation (int evFlags=0) const
 
virtual std::string getDebugStringRepresentation (int evFlags=0) const
 
virtual std::string getTraceStringRepresentation (int evFlags=0) const
 
virtual std::string getCompleteStringRepresentation (int evFlags=0) const
 

Protected Member Functions

virtual double computeTwoRayInterference (const Coord &posTx, const Coord &posRx, m waveLength) const
 
virtual double reflectionCoefficient (double cos_theta, double sin_theta) const
 

Protected Attributes

double epsilon_r
 
char polarization
 

Additional Inherited Members

- Public Types inherited from inet::IPrintableObject
enum  PrintLevel {
  PRINT_LEVEL_TRACE, PRINT_LEVEL_DEBUG, PRINT_LEVEL_DETAIL, PRINT_LEVEL_INFO,
  PRINT_LEVEL_COMPLETE = INT_MIN
}
 
enum  PrintFlag { PRINT_FLAG_FORMATTED = (1 << 0), PRINT_FLAG_MULTILINE = (1 << 1) }
 

Detailed Description

Two-Ray interference model borrowed from Veins (default parameterization)

See "Using the Right Two-Way Model? A Measurement-based Evaluation of PHY Models in VANETs" by C. Sommer and F. Dressler (2011) or "On the Applicability of Two-Ray Path Loss Models for Vehicular Network Simulation" by C. Sommer, S. Joerer and F. Dressler (2012)

Constructor & Destructor Documentation

◆ TwoRayInterference()

inet::physicallayer::TwoRayInterference::TwoRayInterference ( )

Literature referenced here: Rappaport, Theodore: Wireless Communications - Principles and Practice, 2nd edition, 2002 Jakes, William C.

: "Microwave Mobile Communications", 1974

20  :
21  epsilon_r(1.0), polarization('h')
22 {
23 }

Member Function Documentation

◆ computePathLoss() [1/2]

double inet::physicallayer::TwoRayInterference::computePathLoss ( const ITransmission transmission,
const IArrival arrival 
) const
overridevirtual

Returns the loss factor for the provided transmission and arrival.

The value is in the range [0, 1] where 1 means no loss at all and 0 means all power is lost.

Implements inet::physicallayer::IPathLoss.

51 {
52  auto radioMedium = transmission->getMedium();
53  auto narrowbandSignalAnalogModel = check_and_cast<const INarrowbandSignal *>(transmission->getAnalogModel());
54  mps propagationSpeed = radioMedium->getPropagation()->getPropagationSpeed();
55  Hz centerFrequency = Hz(narrowbandSignalAnalogModel->getCenterFrequency());
56  const m waveLength = propagationSpeed / centerFrequency;
57 
58  return computeTwoRayInterference(transmission->getStartPosition(), arrival->getStartPosition(), waveLength);
59 }

◆ computePathLoss() [2/2]

double inet::physicallayer::TwoRayInterference::computePathLoss ( mps  propagationSpeed,
Hz  frequency,
m  distance 
) const
overridevirtual

Returns the loss factor as a function of propagation speed, carrier frequency and distance.

The value is in the range [0, 1] where 1 means no loss at all and 0 means all power is lost.

Implements inet::physicallayer::IPathLoss.

103 {
104  return NaN;
105 }

◆ computeRange()

m inet::physicallayer::TwoRayInterference::computeRange ( mps  propagationSpeed,
Hz  frequency,
double  loss 
) const
overridevirtual

Returns the range for the given loss factor.

The value is in the range [0, +infinity) or NaN if unspecified.

Implements inet::physicallayer::IPathLoss.

108 {
109  return m(NaN);
110 }

◆ computeTwoRayInterference()

double inet::physicallayer::TwoRayInterference::computeTwoRayInterference ( const Coord posTx,
const Coord posRx,
m  waveLength 
) const
protectedvirtual
62 {
63  const double h_sum = pos_t.z + pos_r.z;
64  const double h_diff = pos_t.z - pos_r.z;
65 
66  // direct line of sight between Tx and Rx antenna
67  const double d_los = pos_r.distance(pos_t);
68  // distance on flat ground between Tx and Rx
69  const double d_grnd = sqrt(squared(d_los) - squared(h_diff));
70  // length of reflection path between antennas
71  const double d_refl = sqrt(squared(d_grnd) + squared(h_sum));
72 
73  // phi is phase difference of LOS and reflected signal
74  const double phi = 2.0 * M_PI * (d_refl - d_los) / lambda.get();
75  // theta is the angle between reflected ray and ground (angle of incidence)
76  const double sin_theta = h_sum / d_refl;
77  const double cos_theta = d_grnd / d_refl;
78  // reflection coefficient depending on polarization and relative permittivity (epsilon_r)
79  const double Gamma = reflectionCoefficient(cos_theta, sin_theta);
80 
81  /*
82  * Original equation from Jakes (eq 2.1-2) adapted to our variable names:
83  *
84  * P_r = P_t * G_t * G_r * (lambda / (4*pi*d_los))^2 * |1 + Gamma * e^(i phi)|^2
85  *
86  * Notes:
87  * - return value by IPathLoss equals P_r / (P_t * G_t * G_r)
88  * - (lambda / (4*pi*d_los))^2 is the free space path loss (part of Friis equation)
89  * - squared absolute value term could be named "interference term"
90  * - "1" accounts for direct wave (LOS)
91  * - "Gamma * e^(i phi)" accounts for ground reflected wave
92  *
93  * |1 + Gamma * e^(i phi)|^2 = (applying Euler's formula)
94  * (1 + Gamma * cos(phi))^2 - Gamma^2 * sin(phi)^2
95  */
96 
97  const double friis_term = squared(lambda.get() / (4.0 * M_PI * d_los));
98  const double interference_term = squared(1.0 + Gamma * cos(phi)) + squared(Gamma * sin(phi));
99  return friis_term * interference_term;
100 }

Referenced by computePathLoss().

◆ initialize()

void inet::physicallayer::TwoRayInterference::initialize ( int  stage)
override
26 {
27  if (stage == INITSTAGE_LOCAL) {
28  epsilon_r = par("epsilon_r");
29  const std::string polarization_str = par("polarization");
30  if (polarization_str == "horizontal") {
31  polarization = 'h';
32  }
33  else if (polarization_str == "vertical") {
34  polarization = 'v';
35  }
36  else {
37  throw cRuntimeError("Invalid antenna polarization %s", polarization_str.c_str());
38  }
39  }
40 }

◆ printToStream()

std::ostream & inet::physicallayer::TwoRayInterference::printToStream ( std::ostream &  stream,
int  level,
int  evFlags = 0 
) const
overridevirtual

Prints this object to the provided output stream.

Reimplemented from inet::IPrintableObject.

43 {
44  os << "TwoRayInterference";
45  if (level >= PRINT_LEVEL_TRACE)
46  os << ", epsilon_r = " << epsilon_r << EV_FIELD(polarization);
47  return os;
48 }

◆ reflectionCoefficient()

double inet::physicallayer::TwoRayInterference::reflectionCoefficient ( double  cos_theta,
double  sin_theta 
) const
protectedvirtual
113 {
114  double Gamma = 0.0;
115  // sqrt_term is named "z" by Jakes (eq 2.1-3)
116  const double sqrt_term = sqrt(epsilon_r - squared(cos_theta));
117  switch (polarization) {
118  case 'h':
119  // equation 4.25 in Rappaport (Gamma orthogonal)
120  Gamma = (sin_theta - sqrt_term) / (sin_theta + sqrt_term);
121  break;
122  case 'v':
123  // equation 4.24 in Rappaport (Gamma parallel)
124  Gamma = (-epsilon_r * sin_theta + sqrt_term) / (epsilon_r * sin_theta + sqrt_term);
125  break;
126  default:
127  throw cRuntimeError("Unknown polarization");
128  }
129  return Gamma;
130 }

Referenced by computeTwoRayInterference().

Member Data Documentation

◆ epsilon_r

double inet::physicallayer::TwoRayInterference::epsilon_r
protected

◆ polarization

char inet::physicallayer::TwoRayInterference::polarization
protected

The documentation for this class was generated from the following files:
inet::units::units::Hz
pow< s, -1 > Hz
Definition: Units.h:935
inet::units::units::mps
compose< m, pow< s, -1 > > mps
Definition: Units.h:1151
inet::units::cos
Value cos(const value< Value, Unit > &angle)
Definition: Units.h:1524
inet::physicallayer::TwoRayInterference::reflectionCoefficient
virtual double reflectionCoefficient(double cos_theta, double sin_theta) const
Definition: TwoRayInterference.cc:112
inet::units::sqrt
value< Value, pow< Unit, 1, 2 > > sqrt(const value< Value, Unit > &a)
Definition: Units.h:272
EV_FIELD
#define EV_FIELD(...)
Definition: INETDefs.h:112
NaN
#define NaN
Definition: INETMath.h:91
inet::INITSTAGE_LOCAL
INET_API InitStage INITSTAGE_LOCAL
Initialization of local state that don't use or affect other modules includes:
inet::physicallayer::TwoRayInterference::polarization
char polarization
Definition: TwoRayInterference.h:33
inet::IPrintableObject::PRINT_LEVEL_TRACE
@ PRINT_LEVEL_TRACE
Definition: IPrintableObject.h:22
inet::physicallayer::TwoRayInterference::computeTwoRayInterference
virtual double computeTwoRayInterference(const Coord &posTx, const Coord &posRx, m waveLength) const
Definition: TwoRayInterference.cc:61
inet::units::values::m
value< double, units::m > m
Definition: Units.h:1233
M_PI
#define M_PI
Definition: INETMath.h:52
inet::units::sin
Value sin(const value< Value, Unit > &angle)
Definition: Units.h:1518
inet::physicallayer::TwoRayInterference::epsilon_r
double epsilon_r
Definition: TwoRayInterference.h:32