b.a.t.m.a.n.lists.open-mesh.org archive mirror
 help / color / mirror / Atom feed
From: Marek Lindner <mareklindner@neomailbox.ch>
To: b.a.t.m.a.n@lists.open-mesh.org
Cc: Antonio Quartulli <antonio@open-mesh.com>
Subject: [B.A.T.M.A.N.] [PATCH 10/13] batman-adv: ELP - send unicast ELP packets for throughput sampling
Date: Wed, 30 Dec 2015 20:40:11 +0800	[thread overview]
Message-ID: <1451479214-28034-10-git-send-email-mareklindner@neomailbox.ch> (raw)
In-Reply-To: <2457136.iz2mu7y0Mc@voltaire>

From: Antonio Quartulli <antonio@open-mesh.com>

In case of an unused wireless link, the mac80211 throughput estimation
won't get updated further. Consequently, the reported throughput metric
will become obsolete.

With this patch unicast sampling is introduced by periodically sending
unicast ELP packets to each neighbor on idle WiFi links. These sampling
packets will fill an entire frame, so that the measurement is as
reliable as possible

Signed-off-by: Antonio Quartulli <antonio@open-mesh.com>
---
 net/batman-adv/bat_v_elp.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++
 net/batman-adv/main.h      |  3 ++
 2 files changed, 72 insertions(+)

diff --git a/net/batman-adv/bat_v_elp.c b/net/batman-adv/bat_v_elp.c
index a6d7449..7046c59 100644
--- a/net/batman-adv/bat_v_elp.c
+++ b/net/batman-adv/bat_v_elp.c
@@ -162,6 +162,69 @@ void batadv_v_elp_throughput_metric_update(struct work_struct *work)
 }
 
 /**
+ * batadv_v_elp_wifi_neigh_probe - send link probing packets to a neighbour
+ * @neigh: the neighbour to probe
+ *
+ * Sends a predefined number of unicast wifi packets to a given neighbour in
+ * order to trigger the throughput estimation on this link by the RC algorithm.
+ * Packets are sent only if there there is not enough payload unicast traffic
+ * towards this neighbour..
+ *
+ * Return: True on success and false in case of error during skb preparation.
+ */
+static bool
+batadv_v_elp_wifi_neigh_probe(struct batadv_hardif_neigh_node *neigh)
+{
+	struct batadv_hard_iface *hard_iface = neigh->if_incoming;
+	struct batadv_priv *bat_priv = netdev_priv(hard_iface->soft_iface);
+	unsigned long last_tx_diff;
+	struct sk_buff *skb;
+	int probe_len, i;
+	int elp_skb_len;
+
+	/* this probing routine is for Wifi neighbours only */
+	if (!batadv_is_wifi_netdev(hard_iface->net_dev))
+		return true;
+
+	/* probe the neighbor only if no unicast packets have been sent
+	 * to it in the last 100 milliseconds: this is the rate control
+	 * algorithm sampling interval (minstrel). In this way, if not
+	 * enough traffic has been sent to the neighbor, batman-adv can
+	 * generate 2 probe packets and push the RC algorithm to perform
+	 * the sampling
+	 */
+	last_tx_diff = jiffies_to_msecs(jiffies - neigh->bat_v.last_unicast_tx);
+	if (last_tx_diff <= BATADV_ELP_PROBE_MAX_TX_DIFF)
+		return true;
+
+	probe_len = max_t(int, sizeof(struct batadv_elp_packet),
+			  BATADV_ELP_MIN_PROBE_SIZE);
+
+	for (i = 0; i < BATADV_ELP_PROBES_PER_NODE; i++) {
+		elp_skb_len = hard_iface->bat_v.elp_skb->len;
+		skb = skb_copy_expand(hard_iface->bat_v.elp_skb, 0,
+				      probe_len - elp_skb_len,
+				      GFP_ATOMIC);
+		if (!skb)
+			return false;
+
+		/* Tell the skb to get as big as the allocated space (we want
+		 * the packet to be exactly of that size to make the link
+		 * throughput estimation effective.
+		 */
+		skb_put(skb, probe_len - hard_iface->bat_v.elp_skb->len);
+
+		batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
+			   "Sending unicast (probe) ELP packet on interface %s to %pM\n",
+			   hard_iface->net_dev->name, neigh->addr);
+
+		batadv_send_skb_packet(skb, hard_iface, neigh->addr);
+	}
+
+	return true;
+}
+
+/**
  * batadv_v_elp_periodic_work - ELP periodic task per interface
  * @work: work queue item
  *
@@ -224,6 +287,12 @@ static void batadv_v_elp_periodic_work(struct work_struct *work)
 	 */
 	rcu_read_lock();
 	hlist_for_each_entry_rcu(hardif_neigh, &hard_iface->neigh_list, list) {
+		if (!batadv_v_elp_wifi_neigh_probe(hardif_neigh))
+			/* if something goes wrong while probing, better to stop
+			 * sending packets immediately and reschedule the task
+			 */
+			break;
+
 		if (!atomic_inc_not_zero(&hardif_neigh->refcount))
 			continue;
 
diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h
index a32312a..20ac264 100644
--- a/net/batman-adv/main.h
+++ b/net/batman-adv/main.h
@@ -63,6 +63,9 @@
 
 /* B.A.T.M.A.N. V */
 #define BATADV_THROUGHPUT_DEFAULT_VALUE 10
+#define BATADV_ELP_PROBES_PER_NODE 2
+#define BATADV_ELP_MIN_PROBE_SIZE 200 /* bytes */
+#define BATADV_ELP_PROBE_MAX_TX_DIFF 100 /* milliseconds */
 #define BATADV_ELP_MAX_AGE 64
 #define BATADV_OGM_MAX_ORIGDIFF 5
 #define BATADV_OGM_MAX_AGE 64
-- 
2.6.4


  parent reply	other threads:[~2015-12-30 12:40 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-30 12:38 [B.A.T.M.A.N.] B.A.T.M.A.N. V leaves the nest Marek Lindner
2015-12-30 12:40 ` [B.A.T.M.A.N.] [PATCH 01/13] batman-adv: Add hard_iface specific sysfs wrapper macros for UINT Marek Lindner
2015-12-30 12:40 ` [B.A.T.M.A.N.] [PATCH 02/13] batman-adv: ELP - adding basic infrastructure Marek Lindner
2015-12-30 12:40 ` [B.A.T.M.A.N.] [PATCH 03/13] batman-adv: ELP - creating neighbor structures Marek Lindner
2015-12-30 12:40 ` [B.A.T.M.A.N.] [PATCH 04/13] batman-adv: ELP - adding sysfs parameter for elp interval Marek Lindner
2015-12-30 12:40 ` [B.A.T.M.A.N.] [PATCH 05/13] batman-adv: OGMv2 - add basic infrastructure Marek Lindner
2015-12-30 12:40 ` [B.A.T.M.A.N.] [PATCH 06/13] batman-adv: OGMv2 - implement originators logic Marek Lindner
2015-12-30 12:40 ` [B.A.T.M.A.N.] [PATCH 07/13] batman-adv: add throughput override attribute to hard_ifaces Marek Lindner
2015-12-30 12:40 ` [B.A.T.M.A.N.] [PATCH 08/13] batman-adv: keep track of when unicast packets are sent Marek Lindner
2015-12-30 12:40 ` [B.A.T.M.A.N.] [PATCH 09/13] batman-adv: ELP - compute the metric based on the estimated throughput Marek Lindner
2015-12-30 12:40 ` Marek Lindner [this message]
2015-12-30 12:40 ` [B.A.T.M.A.N.] [PATCH 11/13] batman-adv: B.A.T.M.A.N. V - implement neighbor comparison API calls Marek Lindner
2015-12-30 12:40 ` [B.A.T.M.A.N.] [PATCH 12/13] batman-adv: B.A.T.M.A.N. V - implement bat_orig_print API Marek Lindner
2015-12-30 12:40 ` [B.A.T.M.A.N.] [PATCH 13/13] batman-adv: B.A.T.M.A.N. V - implement bat_neigh_print API Marek Lindner
2015-12-31 11:07 ` [B.A.T.M.A.N.] B.A.T.M.A.N. V leaves the nest Linus Lüssing
2016-01-04 13:08   ` Linus Lüssing
2016-01-09  2:29   ` Linus Lüssing
2016-01-09 13:43     ` Antonio Quartulli
2016-01-15 10:58   ` Marek Lindner

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=1451479214-28034-10-git-send-email-mareklindner@neomailbox.ch \
    --to=mareklindner@neomailbox.ch \
    --cc=antonio@open-mesh.com \
    --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;
as well as URLs for NNTP newsgroup(s).