On Thu, 2007-09-06 at 11:39 +0200, Andreas Jacobs wrote:
[...]
> I think I've found a bug in the calculation of the link quality, which is
> done the following way:
> 
> 1) entry->loss_link_quality =
> 2) (float)(entry->total_packets - entry->lost_packets) /
> 3) (float)(entry->loss_window_size < (2 * 4) ? entry->loss_window_size:
> 4) 4 * ((entry->loss_window_size / 4 - 1) * entry->total_packets +
> entry->loss_window_size) / entry->loss_window_size);

Sven-Ola is the expert on that formula. The last discussion produced the
result that
it works only correctly if "windowsize % 4 == 0" and there was IMHO no
clear agreement
on how to fix it:
- I (personally) would simply require "windowsize % 4 == 0" as I see no
reason that
  every prime number must be usable for this. If I want "50" there, I
can as well
  use "52" (or "48").
  And I would tell that the user upon startup an exit if it is
configured wrongly.
  Of course, defaults and docs must be adapted (if necessary).
  For a transition period, we could add big fat log messages and a 5
seconds penalty
  on startup to motivate folks to fix their config.
- Sven-Ola would automatically increase(IIRC) the configured number to
match the
  above condition.
  I'm not a friend of automatically tweaking the users/admins config so
that it
  works.
  *eg* Well, we could apply the "transition" thing from above here too.
- If your "float" fix is correct (Sven-Ola?), I can live with that too,
if:
  * it is not calculated that often (since floating point operations
tend to be
    slower than bit shifts on integers).
  * we cast some result back to int somewhere so the not 80% of the
formula is
    needlessly float (basic C: if an subexpression is float, the
expression using the
    result uses float).
- Reverting back to the simple one takes a long time to converge if the
window size
  is large.
- Please fill in: _________________________________________

> Please assume a perfect link for now that does not loose any packets. It
> should have a link quality of 1.
> If we set loss_window_size to 10 (the default) and wait for a while, then
> total_packets will become 10, too, and lost_packets will be 0. So the
> numerator (line 2) will equal 10 and so should the denominator, but the
> denominator gives only 8, giving a link quality value of 1.25!
> The reason might be, that "entry->loss_window_size / 4" is an integer
> division, which gives 10 / 4 = 2 and not 2.5!
> 
> Proposed solution:
> 
> Convert that integer division to a floating point division. However, I'm
> not quite sure, if this is correct, because I haven't fully understood the
> formula

	Bernd
-- 
Firmix Software GmbH                   http://www.firmix.at/
mobil: +43 664 4416156                 fax: +43 1 7890849-55
          Embedded Linux Development and Services




