PropagationLossModel::GetRxPower -> PropagationLossModel::GetLoss
This commit is contained in:
@@ -41,7 +41,7 @@ PrintOne (double minTxpower, double maxTxpower, double stepTxpower, double min,
|
||||
std::cout << x << " ";
|
||||
for (double txpower = minTxpower; txpower < maxTxpower; txpower += stepTxpower)
|
||||
{
|
||||
double rxPowerDbm = model->GetRxPower (txpower, a, b);
|
||||
double rxPowerDbm = txpower + model->GetLoss (a, b);
|
||||
std::cout << rxPowerDbm << " ";
|
||||
}
|
||||
std::cout << std::endl;
|
||||
|
||||
@@ -54,13 +54,12 @@ RandomPropagationLossModel::~RandomPropagationLossModel ()
|
||||
{}
|
||||
|
||||
double
|
||||
RandomPropagationLossModel::GetRxPower (double txPowerDbm,
|
||||
Ptr<MobilityModel> a,
|
||||
Ptr<MobilityModel> b) const
|
||||
RandomPropagationLossModel::GetLoss (Ptr<MobilityModel> a,
|
||||
Ptr<MobilityModel> b) const
|
||||
{
|
||||
double rxPower = txPowerDbm - m_variable.GetValue ();
|
||||
NS_LOG_DEBUG ("tx power="<<txPowerDbm<<"dbm, rx power="<<rxPower<<"Dbm");
|
||||
return rxPower;
|
||||
double rxc = -m_variable.GetValue ();
|
||||
NS_LOG_DEBUG ("attenuation coefficent="<<rxc<<"Db");
|
||||
return rxc;
|
||||
}
|
||||
|
||||
TypeId
|
||||
@@ -131,18 +130,17 @@ FriisPropagationLossModel::DbmFromW (double w) const
|
||||
|
||||
|
||||
double
|
||||
FriisPropagationLossModel::GetRxPower (double txPowerDbm,
|
||||
Ptr<MobilityModel> a,
|
||||
Ptr<MobilityModel> b) const
|
||||
FriisPropagationLossModel::GetLoss (Ptr<MobilityModel> a,
|
||||
Ptr<MobilityModel> b) const
|
||||
{
|
||||
/*
|
||||
* Friis free space equation:
|
||||
* where Pt, Gr, Gr and P are in Watt units
|
||||
* L is in meter units.
|
||||
*
|
||||
* Gt * Gr * (lambda^2)
|
||||
* P = Pt ---------------------
|
||||
* (4 * pi * d)^2 * L
|
||||
* P Gt * Gr * (lambda^2)
|
||||
* --- = ---------------------
|
||||
* Pt (4 * pi * d)^2 * L
|
||||
*
|
||||
* Gt: tx gain (unit-less)
|
||||
* Gr: rx gain (unit-less)
|
||||
@@ -167,14 +165,13 @@ FriisPropagationLossModel::GetRxPower (double txPowerDbm,
|
||||
double distance = a->GetDistanceFrom (b);
|
||||
if (distance <= m_minDistance)
|
||||
{
|
||||
return txPowerDbm;
|
||||
return 0.0;
|
||||
}
|
||||
double numerator = m_lambda * m_lambda;
|
||||
double denominator = 16 * PI * PI * distance * distance * m_systemLoss;
|
||||
double pr = 10 * log10 (numerator / denominator);
|
||||
double rxPowerDbm = txPowerDbm + pr;
|
||||
NS_LOG_DEBUG ("distance="<<distance<<"m, tx power="<<txPowerDbm<<"dbm, rx power="<<rxPowerDbm<<"dbm");
|
||||
return rxPowerDbm;
|
||||
NS_LOG_DEBUG ("distance="<<distance<<"m, attenuation coefficient="<<pr<<"dB");
|
||||
return pr;
|
||||
}
|
||||
|
||||
TypeId
|
||||
@@ -228,14 +225,13 @@ LogDistancePropagationLossModel::GetPathLossExponent (void) const
|
||||
}
|
||||
|
||||
double
|
||||
LogDistancePropagationLossModel::GetRxPower (double txPowerDbm,
|
||||
Ptr<MobilityModel> a,
|
||||
Ptr<MobilityModel> b) const
|
||||
LogDistancePropagationLossModel::GetLoss (Ptr<MobilityModel> a,
|
||||
Ptr<MobilityModel> b) const
|
||||
{
|
||||
double distance = a->GetDistanceFrom (b);
|
||||
if (distance <= m_referenceDistance)
|
||||
{
|
||||
return txPowerDbm;
|
||||
return 0.0;
|
||||
}
|
||||
/**
|
||||
* The formula is:
|
||||
@@ -257,13 +253,12 @@ LogDistancePropagationLossModel::GetRxPower (double txPowerDbm,
|
||||
static Ptr<StaticMobilityModel> reference =
|
||||
CreateObject<StaticMobilityModel> ("Position",
|
||||
Vector (m_referenceDistance, 0.0, 0.0));
|
||||
double rx0 = m_reference->GetRxPower (txPowerDbm, zero, reference);
|
||||
double ref = m_reference->GetLoss (zero, reference);
|
||||
double pathLossDb = 10 * m_exponent * log10 (distance / m_referenceDistance);
|
||||
double rxPowerDbm = rx0 - pathLossDb;
|
||||
NS_LOG_DEBUG ("distance="<<distance<<"m, tx-power="<<txPowerDbm<<"dbm, "<<
|
||||
"reference-rx-power="<<rx0<<"dbm, "<<
|
||||
"rx-power="<<rxPowerDbm<<"dbm");
|
||||
return rxPowerDbm;
|
||||
double rxc = ref - pathLossDb;
|
||||
NS_LOG_DEBUG ("distance="<<distance<<"m, reference-attenuation="<<ref<<"dB, "<<
|
||||
"attenuation coefficient="<<rxc<<"dbm");
|
||||
return rxc;
|
||||
}
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
@@ -38,14 +38,12 @@ class PropagationLossModel : public Object
|
||||
public:
|
||||
virtual ~PropagationLossModel ();
|
||||
/**
|
||||
* \param txPowerDbm the tx power
|
||||
* \param a the mobility model of the source
|
||||
* \param b the mobility model of the destination
|
||||
* \returns the receive power (dbm)
|
||||
* \returns the attenuation coefficient (dB)
|
||||
*/
|
||||
virtual double GetRxPower (double txPowerDbm,
|
||||
Ptr<MobilityModel> a,
|
||||
Ptr<MobilityModel> b) const = 0;
|
||||
virtual double GetLoss (Ptr<MobilityModel> a,
|
||||
Ptr<MobilityModel> b) const = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -59,9 +57,8 @@ public:
|
||||
RandomPropagationLossModel ();
|
||||
virtual ~RandomPropagationLossModel ();
|
||||
|
||||
virtual double GetRxPower (double txPowerDbm,
|
||||
Ptr<MobilityModel> a,
|
||||
Ptr<MobilityModel> b) const;
|
||||
virtual double GetLoss (Ptr<MobilityModel> a,
|
||||
Ptr<MobilityModel> b) const;
|
||||
private:
|
||||
RandomVariable m_variable;
|
||||
};
|
||||
@@ -143,9 +140,8 @@ public:
|
||||
*/
|
||||
double GetSystemLoss (void) const;
|
||||
|
||||
virtual double GetRxPower (double txPowerDbm,
|
||||
Ptr<MobilityModel> a,
|
||||
Ptr<MobilityModel> b) const;
|
||||
virtual double GetLoss (Ptr<MobilityModel> a,
|
||||
Ptr<MobilityModel> b) const;
|
||||
private:
|
||||
double DbmToW (double dbm) const;
|
||||
double DbmFromW (double w) const;
|
||||
@@ -197,9 +193,8 @@ public:
|
||||
|
||||
void SetReferenceDistance (double referenceDistance);
|
||||
|
||||
virtual double GetRxPower (double txPowerDbm,
|
||||
Ptr<MobilityModel> a,
|
||||
Ptr<MobilityModel> b) const;
|
||||
virtual double GetLoss (Ptr<MobilityModel> a,
|
||||
Ptr<MobilityModel> b) const;
|
||||
private:
|
||||
static Ptr<PropagationLossModel> CreateDefaultReference (void);
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ WifiChannel::Send (Ptr<WifiPhy> sender, Ptr<const Packet> packet, double txPower
|
||||
{
|
||||
Ptr<MobilityModel> receiverMobility = i->first->GetNode ()->GetObject<MobilityModel> ();
|
||||
Time delay = m_delay->GetDelay (senderMobility, receiverMobility);
|
||||
double rxPowerDbm = m_loss->GetRxPower (txPowerDbm, senderMobility, receiverMobility);
|
||||
double rxPowerDbm = txPowerDbm + m_loss->GetLoss (senderMobility, receiverMobility);
|
||||
NS_LOG_DEBUG ("propagation: txPower="<<txPowerDbm<<"dbm, rxPower="<<rxPowerDbm<<"dbm, "<<
|
||||
"distance="<<senderMobility->GetDistanceFrom (receiverMobility)<<"m, delay="<<delay);
|
||||
Ptr<Packet> copy = packet->Copy ();
|
||||
|
||||
Reference in New Issue
Block a user