From 73ea5d6192e5ed71120c0648eb2a49f14deb2896 Mon Sep 17 00:00:00 2001 From: Federico Maguolo Date: Fri, 21 Mar 2008 04:49:23 +0100 Subject: [PATCH] PropagationLossModel::GetRxPower -> PropagationLossModel::GetLoss --- samples/main-propagation-loss.cc | 2 +- src/devices/wifi/propagation-loss-model.cc | 47 ++++++++++------------ src/devices/wifi/propagation-loss-model.h | 23 +++++------ src/devices/wifi/wifi-channel.cc | 2 +- 4 files changed, 32 insertions(+), 42 deletions(-) diff --git a/samples/main-propagation-loss.cc b/samples/main-propagation-loss.cc index 0972153b0..7f998a8ad 100644 --- a/samples/main-propagation-loss.cc +++ b/samples/main-propagation-loss.cc @@ -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; diff --git a/src/devices/wifi/propagation-loss-model.cc b/src/devices/wifi/propagation-loss-model.cc index 7327795b7..e522f0517 100644 --- a/src/devices/wifi/propagation-loss-model.cc +++ b/src/devices/wifi/propagation-loss-model.cc @@ -54,13 +54,12 @@ RandomPropagationLossModel::~RandomPropagationLossModel () {} double -RandomPropagationLossModel::GetRxPower (double txPowerDbm, - Ptr a, - Ptr b) const +RandomPropagationLossModel::GetLoss (Ptr a, + Ptr b) const { - double rxPower = txPowerDbm - m_variable.GetValue (); - NS_LOG_DEBUG ("tx power="< a, - Ptr b) const +FriisPropagationLossModel::GetLoss (Ptr a, + Ptr 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="< a, - Ptr b) const +LogDistancePropagationLossModel::GetLoss (Ptr a, + Ptr 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 reference = CreateObject ("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="< a, - Ptr b) const = 0; + virtual double GetLoss (Ptr a, + Ptr b) const = 0; }; /** @@ -59,9 +57,8 @@ public: RandomPropagationLossModel (); virtual ~RandomPropagationLossModel (); - virtual double GetRxPower (double txPowerDbm, - Ptr a, - Ptr b) const; + virtual double GetLoss (Ptr a, + Ptr b) const; private: RandomVariable m_variable; }; @@ -143,9 +140,8 @@ public: */ double GetSystemLoss (void) const; - virtual double GetRxPower (double txPowerDbm, - Ptr a, - Ptr b) const; + virtual double GetLoss (Ptr a, + Ptr 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 a, - Ptr b) const; + virtual double GetLoss (Ptr a, + Ptr b) const; private: static Ptr CreateDefaultReference (void); diff --git a/src/devices/wifi/wifi-channel.cc b/src/devices/wifi/wifi-channel.cc index aa8301c97..1cc9d9076 100644 --- a/src/devices/wifi/wifi-channel.cc +++ b/src/devices/wifi/wifi-channel.cc @@ -93,7 +93,7 @@ WifiChannel::Send (Ptr sender, Ptr packet, double txPower { Ptr receiverMobility = i->first->GetNode ()->GetObject (); 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="<