Bug 1443 - m_minDistance in FriisPropagationLossModel
m_minDistance in FriisPropagationLossModel
Status: RESOLVED FIXED
Product: ns-3
Classification: Unclassified
Component: propagation
ns-3-dev
All All
: P5 normal
Assigned To: Kirill Andreev
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-06-11 10:15 UTC by Nicola Baldo
Modified: 2014-02-21 10:20 UTC (History)
2 users (show)

See Also:


Attachments
proposed patch (3.43 KB, patch)
2012-06-11 10:38 UTC, Nicola Baldo
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Nicola Baldo 2012-06-11 10:15:03 UTC
Reported on ns-3-users on this thread:
https://groups.google.com/d/msg/ns-3-users/pk1gu4wt7Gk/cLLHdqPhuNMJ

the cause is the following code in FriisPropagationLossModel::DoCalcRxPower :

  if (distance <= m_minDistance)
    {
      return txPowerDbm;
    }

I think the above code is bad, as it introduces a discontinuity. We shall find another way to handle short distances that does not introduce such discontinuity.
Comment 1 Nicola Baldo 2012-06-11 10:38:29 UTC
Created attachment 1412 [details]
proposed patch
Comment 2 Tommaso Pecorella 2012-11-15 16:27:14 UTC
I like the idea, but I'd kinda disagree on it.

The point is that the Friis model is an approximate model (very approximate) and it does have a number of hypotheses. One of them is to be in the so-called "far field" region, as is where the wave can be considered uniform.
Now, most engineers are used to set this ration to 2*D^2/lambda or 3*lambda (depending on the kind of antenna) and lambda is the max wavelength.
Below this limit the formula simply does not hold, so the value returned is simply to return *something*, not to have a meaningful value.

Rephrasing: the Friis model should return a warning if the antenna distance is below the limit, as it can't compute a meaningful value and the model should be changed to a way more complex one.

Based on this, I'd reject the proposed change, even if it sounds good.

I'm, on the opposite, favourable adding a warning and an automatic set of the minimum distance to 3*lambda, since this is the default value for wire-antennas.

T.
Comment 3 Tommaso Pecorella 2014-02-20 16:19:37 UTC
I don't like too much open bugs. And I like even less them if they're patch pending.

Either we apply it or we close it as WONTFIX.
I already expressed my opinion about the proposed patch.

What should we do with this ?
Comment 4 Nicola Baldo 2014-02-21 07:44:36 UTC
(In reply to Tommaso Pecorella from comment #3)
> I don't like too much open bugs. And I like even less them if they're patch
> pending.

Me neither. So I went ahead and pushed the fix as changeset 9d057a27ede2 :-)

I added the NS_LOG_WARNING as you suggested, plus I added a pretty verbose description of the arguments for this change in the doxygen documentation. I am pasting it here below. I hope you find it convincing!


 * The Friis model is valid only for propagation in free space within
 * the so-called far field region, which can be considered
 * approximately as the region for \f$ d > 3 \lambda \f$.
 * The model will still return a value for \f$ d < 3 \lambda \f$, as
 * doing so (rather than triggering a fatal error) is practical for
 * many simulation scenarios. However, we stress that the values
 * obtained in such conditions shall not be considered realistic. 
 * 
 * Related with this issue, we note that the Friis formula is
 * undefined for \f$ d = 0 \f$, and results in 
 * \f$ P_r > P_t \f$ for \f$ d < \lambda / 2 \sqrt{\pi} \f$.
 * Both these conditions occur outside of the far field region, so in
 * principle the Friis model shall not be used in these conditions. 
 * In practice, however, Friis is often used in scenarios where accurate
 * propagation modeling is not deemed important, and values of \f$ d =
 * 0 \f$ can occur. To allow practical use of the model in such
 * scenarios, we have to 1) return some value for \f$ d = 0 \f$, and
 * 2) avoid large discontinuities in propagation loss values (which
 * could lead to artifacts such as bogus capture effects which are
 * much worse than inaccurate propagation loss values). The two issues
 * are conflicting, as, according to the Friis formula, 
 * \f$\lim_{d \to 0 }  P_r = +\infty \f$;
 * so if, for \f$ d = 0 \f$, we use a fixed loss value, we end up with an infinitely large
 * discontinuity, which as we discussed can cause undesireable
 * simulation artifacts.
 *
 * To avoid these artifact, this implmentation of the Friis model
 * provides an attribute called MinLoss which allows to specify the
 * minimum total loss (in dB) returned by the model. This is used in
 * such a way that 
 * \f$ P_r \f$ continuously increases for \f$ d \to 0 \f$, until
 * MinLoss is reached, and then stay constant; this allow to
 * return a value for \f$ d  = 0 \f$ and at the same time avoid
 * discontinuities. The model won't be much realistic, but at least
 * the simulation artifacts discussed before are avoided. The default value of
 * MinLoss is 0 dB, which means that by default the model will return 
 * \f$ P_r = P_t \f$ for \f$ d <= \lambda / 2 \sqrt{\pi} \f$. We note
 * that this value of \f$ d \f$ is outside of the far field
 * region, hence the validity of the model in the far field region is
 * not affected.
 *
Comment 5 Nicola Baldo 2014-02-21 07:51:41 UTC
Note that from a practical point of view the patch returns Pr = Pt for d = 0, which is exactly the same as before. The main difference is that before the distance at which the model started to return Pr = Pt was arbitrary, hence it caused a discontinuity of path loss vs distance, while now the distance is exactly that for which Friis' formula returns Pr = Pt, hence the discontinuity is eliminated. That's the only change in behavior, at least when default attribute values are used.
Comment 6 Tommaso Pecorella 2014-02-21 10:20:30 UTC
+1 (in ratification)