From: Antonio Quartulli <ordex@autistici.org>
To: The list for a Better Approach To Mobile Ad-hoc Networking
<b.a.t.m.a.n@lists.open-mesh.org>
Subject: Re: [B.A.T.M.A.N.] [RFC 05/10] batman-adv: add bat_metric_is_similar API function
Date: Wed, 26 Jun 2013 10:59:34 +0200 [thread overview]
Message-ID: <20130626085934.GL3136@ritirata.org> (raw)
In-Reply-To: <20130529145754.GT3333@ritirata.org>
[-- Attachment #1: Type: text/plain, Size: 2831 bytes --]
On Wed, May 29, 2013 at 04:57:54PM +0200, Antonio Quartulli wrote:
> > > > > +static bool batadv_iv_ogm_metric_is_similar(uint32_t metric,
> > > > > + uint32_t new_metric)
> > > > > +{
> > > > > + return (metric - new_metric < BATADV_TQ_SIMILARITY_THRESHOLD);
> > > >
> > > > You might want to use abs(metric - new_metric) here, otherwise is_similar(a, b) output
> > > > might differ from is_similar(b, a).
> > >
> > > Mh..imho the name of the function is bad because this has been done on purpose.
> >
> > agreed, the function name is not really good. You could rename it to something like
> > "is_almost_or_better()" if you keep the current semantics, although this is not an
> > "easy name" either. Or rename it to "similar_or_greater()". Something like that
> >
> > Although ...
> > >
> > > The idea is that we want to see if 'b' is at least
> > > as good as 'a', therefore what we want to check if is b is greater than
> > > 'a - threshold' only.
> > >
> > > Imagine that 'b' is greater than (a + threshold), for me the function has to
> > > return true, because the metric b is at least as good as a, but if I introduce
> > > the abs() the function would return false.
> > >
> > > Example:
> > >
> > > a=190
> > > b=240
> > > threshold=20
> > >
> > > a - b = -50 < 20 => b is at least as good as a!
> > >
> > > using abs:
> > >
> > > abs(a - b) = 50 < 20 => NO! b is worse than a....and this is not true.
> > >
> > >
> > > this situation can happen in the code because usually 'a' will represents some
> > > kind of current metric and this is not supposed to be the best ever (maybe we
> > > still have to switch to a new best).
> >
> > ... we actually compare to the biggest value (e.g. highest gateway rank, highest
> > bonding candidate), so I wonder if this can really happen. So adding abs() would
> > just make the semantics more clear without breaking the current code when we simply
> > replace. Although we need to check all occurences again, I'm not completely sure
> > that it's always compared to the greatest member.
>
> well the current code uses the semantic that I implemented in the API (IIRC) and
> this is why I've done so: I wanted to keep the very same behaviour.
>
> I'm also not entirely sure that we always compare to the greatest member.
>
> What you are thinking about is the compare() function taking a threshold as
> parameter. We can do that with the compare() API if you want, but I think we
> should keep this "~is_similar()" API in order to avoid behavioural changes in
> the code.
>
so I'll go for "bat_metric_is_alike_or_better"...we couldn't find a better
name..but if you have one :) let me know
Cheers,
--
Antonio Quartulli
..each of us alone is worth nothing..
Ernesto "Che" Guevara
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
next prev parent reply other threads:[~2013-06-26 8:59 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-28 22:20 [B.A.T.M.A.N.] [RFC 00/10] Improving the routing protocol abstraction Antonio Quartulli
2013-05-28 22:20 ` [B.A.T.M.A.N.] [RFC 01/10] batman-adv: make struct batadv_neigh_node algorithm agnostic Antonio Quartulli
2013-05-28 22:20 ` [B.A.T.M.A.N.] [RFC 02/10] batman-adv: make struct batadv_orig_node " Antonio Quartulli
2013-05-29 14:09 ` Simon Wunderlich
2013-05-29 14:12 ` Antonio Quartulli
2013-05-28 22:20 ` [B.A.T.M.A.N.] [RFC 03/10] batman-adv: add bat_orig_print function API Antonio Quartulli
2013-05-28 22:20 ` [B.A.T.M.A.N.] [RFC 04/10] batman-adv: add bat_get_metric API function Antonio Quartulli
2013-05-29 14:17 ` Simon Wunderlich
2013-05-29 14:29 ` Antonio Quartulli
2013-05-28 22:20 ` [B.A.T.M.A.N.] [RFC 04/10] batman-adv: add bat_metric_get " Antonio Quartulli
2013-05-28 22:20 ` [B.A.T.M.A.N.] [RFC 05/10] batman-adv: add bat_metric_is_similar " Antonio Quartulli
2013-05-29 14:16 ` Simon Wunderlich
2013-05-29 14:28 ` Antonio Quartulli
2013-05-29 14:55 ` Simon Wunderlich
2013-05-29 14:57 ` Antonio Quartulli
2013-06-26 8:59 ` Antonio Quartulli [this message]
2013-05-28 22:20 ` [B.A.T.M.A.N.] [RFC 06/10] batman-adv: add bat_metric_compare " Antonio Quartulli
2013-05-28 22:20 ` [B.A.T.M.A.N.] [RFC 07/10] batman-adv: adapt bonding to use the new API functions Antonio Quartulli
2013-05-28 22:20 ` [B.A.T.M.A.N.] [RFC 08/10] batman-adv: adapt the gateway feature " Antonio Quartulli
2013-05-29 14:32 ` Simon Wunderlich
2013-05-29 14:48 ` Antonio Quartulli
2013-05-30 11:29 ` Antonio Quartulli
2013-05-28 22:20 ` [B.A.T.M.A.N.] [RFC 09/10] batman-adv: adapt the neighbor purging routine " Antonio Quartulli
2013-05-28 22:23 ` [B.A.T.M.A.N.] [RFC 00/10] Improving the routing protocol abstraction Antonio Quartulli
2013-05-28 23:19 ` [B.A.T.M.A.N.] [RFC 10/10] batman-adv: provide orig_node routing API Antonio Quartulli
2013-05-29 6:20 ` [B.A.T.M.A.N.] [RFC 00/10] Improving the routing protocol abstraction Martin Hundebøll
2013-05-29 7:08 ` Antonio Quartulli
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130626085934.GL3136@ritirata.org \
--to=ordex@autistici.org \
--cc=b.a.t.m.a.n@lists.open-mesh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox