PropagationLossModel::GetRxPower -> PropagationLossModel::GetLoss
authorFederico Maguolo <maguolof@dei.unipd.it>
Fri, 21 Mar 2008 04:49:23 +0100
changeset 2677 28dfd0c7510d
parent 2676 076b8636fea9
child 2678 22aa62a108ed
PropagationLossModel::GetRxPower -> PropagationLossModel::GetLoss
samples/main-propagation-loss.cc
src/devices/wifi/propagation-loss-model.cc
src/devices/wifi/propagation-loss-model.h
src/devices/wifi/wifi-channel.cc
--- a/samples/main-propagation-loss.cc	Fri Mar 21 04:38:09 2008 +0100
+++ b/samples/main-propagation-loss.cc	Fri Mar 21 04:49:23 2008 +0100
@@ -41,7 +41,7 @@
       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;
--- a/src/devices/wifi/propagation-loss-model.cc	Fri Mar 21 04:38:09 2008 +0100
+++ b/src/devices/wifi/propagation-loss-model.cc	Fri Mar 21 04:49:23 2008 +0100
@@ -54,13 +54,12 @@
 {}
 
 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 @@
 
 
 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 @@
   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 @@
 }
   
 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 @@
   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
--- a/src/devices/wifi/propagation-loss-model.h	Fri Mar 21 04:38:09 2008 +0100
+++ b/src/devices/wifi/propagation-loss-model.h	Fri Mar 21 04:49:23 2008 +0100
@@ -38,14 +38,12 @@
 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 @@
   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 @@
    */
   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 @@
 
   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);
 
--- a/src/devices/wifi/wifi-channel.cc	Fri Mar 21 04:38:09 2008 +0100
+++ b/src/devices/wifi/wifi-channel.cc	Fri Mar 21 04:49:23 2008 +0100
@@ -93,7 +93,7 @@
         {
           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 ();