From: "Linus Lüssing" <linus.luessing@c0d3.blue>
To: The list for a Better Approach To Mobile Ad-hoc Networking
<b.a.t.m.a.n@lists.open-mesh.org>
Cc: Marek Lindner <mareklindner@neomailbox.ch>
Subject: Re: [B.A.T.M.A.N.] [PATCH v2 6/7] batman-adv: ELP - use tp meter to estimate the throughput if otherwise not available
Date: Mon, 21 May 2018 15:17:11 +0200 [thread overview]
Message-ID: <20180521131711.GK7162@otheros> (raw)
In-Reply-To: <20180518014754.23644-7-mareklindner@neomailbox.ch>
On Fri, May 18, 2018 at 09:47:53AM +0800, Marek Lindner wrote:
> @@ -251,6 +253,21 @@ static void batadv_tp_caller_notify(struct batadv_priv *bat_priv,
>
> break;
> case BATADV_TP_ELP:
> + if (reason_is_error) {
> + batadv_v_elp_tp_fail(tp_vars->hardif_neigh);
> + return;
> + }
> +
> + test_time = jiffies_to_msecs(jiffies - tp_vars->start_time);
> + total_bytes = atomic64_read(&tp_vars->tot_sent);
> +
> + /* The following calculation includes these steps:
> + * - convert bytes to bits
> + * - divide bits by the test length (msecs)
> + * - convert result from bits/ms to 0.1Mb/s (* 1024 * 10 / 1000)
> + */
> + throughput = total_bytes * 8 >> ilog2(test_time) / 10;
> + batadv_v_elp_tp_finish(tp_vars->hardif_neigh, throughput);
I find the throughput calculation quite hard to read here, would
it be possible to put this into an extra (inline?) function?
Also the comment for the "convert result..." seems wrong,
"[bits/ms]*1024*10/1000" would be 0.01Mb/s, not 0.1Mb/s?
What is the advantage of using the ilog2 and shift operator here
compared to plain multiplications and divisions?
Also, when trying this in a small C program I get weird results:
-----
#include <stdio.h>
#include <math.h>
int main()
{
unsigned long test_time = 10000; // 10s
unsigned long total_bytes = 20000000; // 16MBit/s
unsigned long throughput, throughput2;
unsigned long log_test_time = log(test_time) / log(2);
throughput = total_bytes * 8 >> log_test_time / 10;
// Straightforward approach?
throughput2 = total_bytes * 8 / test_time * 1000 / 1024 / 100;
printf("Result: %lu (log_test_time: %lu)\n", throughput, log_test_time);
printf("Result2: %lu\n", throughput2);
return 0;
}
-----
$ ./test
Result: 80000000 (log_test_time: 13)
Result2: 156
$ file ./test
./test: ELF 32-bit LSB pie executable ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, for GNU/Linux 3.2.0, BuildID[sha1]=d18f32829cdd2bc42cf744cdcafde7cdbd315cb0, not stripped
-----
Regards, Linus
next prev parent reply other threads:[~2018-05-21 13:17 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-18 1:47 [B.A.T.M.A.N.] [PATCH v2 0/7] B.A.T.M.A.N. V - fallback to tp meter estimation if throughput otherwise not available Marek Lindner
2018-05-18 1:47 ` [B.A.T.M.A.N.] [PATCH v2 1/7] batman-adv: tp_meter - prevent concurrent tp_meter sessions by using workqueue Marek Lindner
2018-08-29 6:56 ` Sven Eckelmann
2018-05-18 1:47 ` [B.A.T.M.A.N.] [PATCH v2 2/7] batman-adv: tp_meter - don't check for existing session Marek Lindner
2018-05-18 1:47 ` [B.A.T.M.A.N.] [PATCH v2 3/7] batman-adv: tp_meter - allow up to 10 queued sessions Marek Lindner
2018-05-18 1:47 ` [B.A.T.M.A.N.] [PATCH v2 4/7] batman-adv: tp_meter - add caller distinction Marek Lindner
2018-05-18 1:47 ` [B.A.T.M.A.N.] [PATCH v2 5/7] batman-adv: tp_meter - add option to perform one-hop test Marek Lindner
2018-05-18 1:47 ` [B.A.T.M.A.N.] [PATCH v2 6/7] batman-adv: ELP - use tp meter to estimate the throughput if otherwise not available Marek Lindner
2018-05-21 13:17 ` Linus Lüssing [this message]
2018-05-21 17:51 ` Sven Eckelmann
2018-05-21 19:06 ` Sven Eckelmann
2018-08-04 9:31 ` Antonio Quartulli
2018-05-21 14:43 ` Linus Lüssing
2018-08-04 9:35 ` Marek Lindner
2018-05-21 14:48 ` Linus Lüssing
2018-08-04 9:39 ` Antonio Quartulli
2018-05-21 15:01 ` Linus Lüssing
2018-08-04 8:59 ` Antonio Quartulli
2018-05-21 16:36 ` Sven Eckelmann
2018-05-18 1:47 ` [B.A.T.M.A.N.] [PATCH v2 7/7] batman-adv: ELP - add throughput meter test duration attribute Marek Lindner
2018-05-21 13:46 ` Linus Lüssing
2018-05-21 13:57 ` Linus Lüssing
2018-08-04 9:05 ` Marek Lindner
2018-05-21 14:34 ` Sven Eckelmann
2018-08-04 8:41 ` Antonio Quartulli
2018-08-04 9:02 ` Sven Eckelmann
2018-08-04 9: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=20180521131711.GK7162@otheros \
--to=linus.luessing@c0d3.blue \
--cc=b.a.t.m.a.n@lists.open-mesh.org \
--cc=mareklindner@neomailbox.ch \
/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;
as well as URLs for NNTP newsgroup(s).