Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d353d8d4 authored by Martin Hundebøll's avatar Martin Hundebøll Committed by Antonio Quartulli
Browse files

batman-adv: network coding - add the initial infrastructure code

Network coding exploits the 802.11 shared medium to allow multiple
packets to be sent in a single transmission. In brief, a relay can XOR
two packets, and send the coded packet to two destinations. The
receivers can decode one of the original packets by XOR'ing the coded
packet with the other original packet. This will lead to increased
throughput in topologies where two packets cross one relay.

In a simple topology with three nodes, it takes four transmissions
without network coding to get one packet from Node A to Node B and one
from Node B to Node A:

 1.  Node A  ---- p1 --->  Node R                Node B
 2.  Node A                Node R  <--- p2 ----  Node B
 3.  Node A  <--- p2 ----  Node R                Node B
 4.  Node A                Node R  ---- p1 --->  Node B

With network coding, the relay only needs one transmission, which saves
us one slot of valuable airtime:

 1.  Node A  ---- p1 --->  Node R                Node B
 2.  Node A                Node R  <--- p2 ----  Node B
 3.  Node A  <- p1 x p2 -  Node R  - p1 x p2 ->  Node B

The same principle holds for a topology including five nodes. Here the
packets from Node A and Node B are overheard by Node C and Node D,
respectively. This allows Node R to send a network coded packet to save
one transmission:

   Node A                  Node B

    |     \              /    |
    |      p1          p2     |
    |       \          /      |
    p1       > Node R <       p2
    |                         |
    |         /      \        |
    |    p1 x p2    p1 x p2   |
    v       /          \      v
           /            \
   Node C <              > Node D

More information is available on the open-mesh.org wiki[1].

This patch adds the initial code to support network coding in
batman-adv. It sets up a worker thread to do house keeping and adds a
sysfs file to enable/disable network coding. The feature is disabled by
default, as it requires a wifi-driver with working promiscuous mode, and
also because it adds a small delay at each hop.

[1] http://www.open-mesh.org/projects/batman-adv/wiki/Catwoman



Signed-off-by: default avatarMartin Hundebøll <martin@hundeboll.net>
Signed-off-by: default avatarMarek Lindner <lindner_marek@yahoo.de>
Signed-off-by: default avatarAntonio Quartulli <ordex@autistici.org>
parent c1d07431
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -67,6 +67,14 @@ Description:
                Defines the penalty which will be applied to an
                originator message's tq-field on every hop.

What:           /sys/class/net/<mesh_iface>/mesh/network_coding
Date:           Nov 2012
Contact:        Martin Hundeboll <martin@hundeboll.net>
Description:
                Controls whether Network Coding (using some magic
                to send fewer wifi packets but still the same
                content) is enabled or not.

What:           /sys/class/net/<mesh_iface>/mesh/orig_interval
Date:           May 2010
Contact:        Marek Lindner <lindner_marek@yahoo.de>
+14 −0
Original line number Diff line number Diff line
@@ -36,6 +36,20 @@ config BATMAN_ADV_DAT
	  mesh networks. If you think that your network does not need
	  this option you can safely remove it and save some space.

config BATMAN_ADV_NC
	bool "Network Coding"
	depends on BATMAN_ADV
	default n
	help
	  This option enables network coding, a mechanism that aims to
	  increase the overall network throughput by fusing multiple
	  packets in one transmission.
	  Note that interfaces controlled by batman-adv must be manually
	  configured to have promiscuous mode enabled in order to make
	  network coding work.
	  If you think that your network does not need this feature you
	  can safely disable it and save some space.

config BATMAN_ADV_DEBUG
	bool "B.A.T.M.A.N. debugging"
	depends on BATMAN_ADV
+1 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ batman-adv-y += hard-interface.o
batman-adv-y += hash.o
batman-adv-y += icmp_socket.o
batman-adv-y += main.o
batman-adv-$(CONFIG_BATMAN_ADV_NC) += network-coding.o
batman-adv-y += originator.o
batman-adv-y += ring_buffer.o
batman-adv-y += routing.o
+6 −0
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@
#include "vis.h"
#include "hash.h"
#include "bat_algo.h"
#include "network-coding.h"


/* List manipulations on hardif_list have to be rtnl_lock()'ed,
@@ -135,6 +136,10 @@ int batadv_mesh_init(struct net_device *soft_iface)
	if (ret < 0)
		goto err;

	ret = batadv_nc_init(bat_priv);
	if (ret < 0)
		goto err;

	atomic_set(&bat_priv->gw.reselect, 0);
	atomic_set(&bat_priv->mesh_state, BATADV_MESH_ACTIVE);

@@ -157,6 +162,7 @@ void batadv_mesh_free(struct net_device *soft_iface)

	batadv_gw_node_purge(bat_priv);
	batadv_originator_free(bat_priv);
	batadv_nc_free(bat_priv);

	batadv_tt_free(bat_priv);

+3 −1
Original line number Diff line number Diff line
@@ -185,6 +185,7 @@ __be32 batadv_skb_crc32(struct sk_buff *skb, u8 *payload_ptr);
 * @BATADV_DBG_TT: translation table messages
 * @BATADV_DBG_BLA: bridge loop avoidance messages
 * @BATADV_DBG_DAT: ARP snooping and DAT related messages
 * @BATADV_DBG_NC: network coding related messages
 * @BATADV_DBG_ALL: the union of all the above log levels
 */
enum batadv_dbg_level {
@@ -193,7 +194,8 @@ enum batadv_dbg_level {
	BATADV_DBG_TT	  = BIT(2),
	BATADV_DBG_BLA    = BIT(3),
	BATADV_DBG_DAT    = BIT(4),
	BATADV_DBG_ALL    = 31,
	BATADV_DBG_NC	  = BIT(5),
	BATADV_DBG_ALL    = 63,
};

#ifdef CONFIG_BATMAN_ADV_DEBUG
Loading