public inbox for b.a.t.m.a.n@lists.open-mesh.org
 help / color / mirror / Atom feed
From: Sven Eckelmann <sven@narfation.org>
To: hlabishi kobo <hlabishik@gmail.com>
Cc: b.a.t.m.a.n@lists.open-mesh.org
Subject: Re: [B.A.T.M.A.N.] BATMAN routing
Date: Mon, 28 Feb 2011 13:03:05 +0100	[thread overview]
Message-ID: <201102281303.07122.sven@narfation.org> (raw)
In-Reply-To: <AANLkTikpz456HY_earyr4=CjOQBCkBUBAaWSsd3FpfDG@mail.gmail.com>

[-- Attachment #1: Type: Text/Plain, Size: 2170 bytes --]

Small clarification at the beginning. In my example I said "received every 8th 
ogm". Of course this should have been every 64th ogm. I wanted to write a more 
detailed example using the 8 bytes but thrown that idea away quite early. In 
the current setup you will have 64 bits in either a single unsigned long or 64 
bits in 2 32-bit unsigned longs. This depends on the target architecture.

Please keep in mind that this can easily increased to 256 or more bits for the 
TQ_LOCAL_WINDOW_SIZE

hlabishi kobo wrote:
> Thanks for the reply, what does hweight_long does? i tried to search
> it but i cant find a clear description of it. My intention is to count
> and add the indexes where an OGM was recorded (where there is a '1' ).

hweight_long == Hamming weight for an unsigned long (sum of bits != 0) [1]

So what you want is to program it using bit shifts, ands and test operations. 
This means that you will calculate for the maximum (all ogms received) using 
your current strategy 2016 ([n+(n-1)]/2; n == number of bits). This of course 
is generated by looking at the bits and not at the bytes like your current 
implementation. The sum is even because you omit the last received ogm (in 
your version it has an index of 0). And it is even a bigger problem that you 
would give the ogms which are more recent a smaller weight than the ogms which 
are received in the past.

I hope that these are enough hints for you.

So lets assume that you implemented a correct weighted version of 
bit_packet_count. The weights are distributed over 64 slots (the bits) were 1 
is the weight for the oldest slot and 64 is the weight for the slot of newest 
ogm. The weights are distributed in a linear fashion (second newest has weight 
63, ...).

What would be the weighted sum (64 bit implementation) for 
{0xCEED2866E2DEE707} and what would be the weighted sum (32 bit 
implementation) of {3806258951, 3471648870}? Write a program which calculates 
those sums. Proof that this can or cannot be implemented in less operations 
per long using clever bit operations which evaluate more than one bit per 
round.

Best regards,
	Sven

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

  reply	other threads:[~2011-02-28 12:03 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.14.1290812292.944.b.a.t.m.a.n@lists.open-mesh.org>
     [not found] ` <AANLkTimR7VU95r3C-=C9rn5ftZahKkNTu3-cU-Vft+VZ@mail.gmail.com>
2010-11-28 22:01   ` [B.A.T.M.A.N.] Fwd: BATMAN routing hlabishi kobo
2010-11-29 20:13     ` Linus Lüssing
2010-11-29 22:23       ` Linus Lüssing
2010-11-29 22:31     ` [B.A.T.M.A.N.] " hlabishi kobo
2010-11-30 17:26       ` Marek Lindner
2010-12-01  9:46       ` hlabishi kobo
2010-12-01 12:30         ` Marek Lindner
2010-12-02 10:27           ` Linus Lüssing
2010-12-02 12:02             ` Antonio Quartulli
2010-12-06 10:40               ` Daniele Furlan
2010-12-06 16:20                 ` Marek Lindner
2010-12-06 17:06                   ` Daniele Furlan
2010-12-07 10:09               ` Linus Lüssing
2010-12-11  9:51         ` hlabishi kobo
2010-12-20  9:05           ` Linus Lüssing
2011-02-24  9:58             ` hlabishi kobo
2011-02-24 10:23               ` Sven Eckelmann
2011-02-28 10:46                 ` hlabishi kobo
2011-02-28 12:03                   ` Sven Eckelmann [this message]
     [not found]                     ` <AANLkTinja_Hq4ze-fOFbHRK-iDzzA3Tk0oAsJ+CB=M2S@mail.gmail.com>
2011-02-28 19:29                       ` Sven Eckelmann
     [not found]                         ` <AANLkTikj8oj26P_F1LTiGWnt2R=29VESfpD1ZsfeL4X0@mail.gmail.com>
2011-03-08  9:52                           ` Sven Eckelmann
2011-03-17 22:40                             ` hlabishi kobo
2011-03-18 11:18                               ` Sven Eckelmann
2011-03-21 22:40                                 ` hlabishi kobo
2011-03-21 23:01                                   ` Sven Eckelmann
2011-04-03 21:10                                     ` hlabishi kobo
2011-04-03 21:25                                       ` Sven Eckelmann
2011-04-19 10:21                                         ` hlabishi kobo
2010-11-29 22:31     ` [B.A.T.M.A.N.] Fwd: " Chris Lang
2010-11-28 21:28 [B.A.T.M.A.N.] " hlabishi kobo

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=201102281303.07122.sven@narfation.org \
    --to=sven@narfation.org \
    --cc=b.a.t.m.a.n@lists.open-mesh.org \
    --cc=hlabishik@gmail.com \
    /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