aboutsummaryrefslogtreecommitdiffstats
path: root/net/batman-adv/network-coding.c
diff options
context:
space:
mode:
authorMartin Hundebøll <martin@hundeboll.net>2013-01-25 05:12:38 -0500
committerAntonio Quartulli <ordex@autistici.org>2013-03-13 17:53:48 -0400
commitd353d8d4d9f0184ac43a90c6e04b593c33bd28ea (patch)
treeb38d3477b0daab818b41fbb36664d1f8c0789801 /net/batman-adv/network-coding.c
parentc1d07431b9f7fe3c5eb372f3a35d7cd7a18c3b15 (diff)
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: Martin Hundebøll <martin@hundeboll.net> Signed-off-by: Marek Lindner <lindner_marek@yahoo.de> Signed-off-by: Antonio Quartulli <ordex@autistici.org>
Diffstat (limited to 'net/batman-adv/network-coding.c')
-rw-r--r--net/batman-adv/network-coding.c81
1 files changed, 81 insertions, 0 deletions
diff --git a/net/batman-adv/network-coding.c b/net/batman-adv/network-coding.c
new file mode 100644
index 000000000000..9c2d54bdd2ce
--- /dev/null
+++ b/net/batman-adv/network-coding.c
@@ -0,0 +1,81 @@
1/* Copyright (C) 2012-2013 B.A.T.M.A.N. contributors:
2 *
3 * Martin Hundebøll, Jeppe Ledet-Pedersen
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of version 2 of the GNU General Public
7 * License as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 * 02110-1301, USA
18 */
19
20#include "main.h"
21#include "network-coding.h"
22
23static void batadv_nc_worker(struct work_struct *work);
24
25/**
26 * batadv_nc_start_timer - initialise the nc periodic worker
27 * @bat_priv: the bat priv with all the soft interface information
28 */
29static void batadv_nc_start_timer(struct batadv_priv *bat_priv)
30{
31 queue_delayed_work(batadv_event_workqueue, &bat_priv->nc.work,
32 msecs_to_jiffies(10));
33}
34
35/**
36 * batadv_nc_init - initialise coding hash table and start house keeping
37 * @bat_priv: the bat priv with all the soft interface information
38 */
39int batadv_nc_init(struct batadv_priv *bat_priv)
40{
41 INIT_DELAYED_WORK(&bat_priv->nc.work, batadv_nc_worker);
42 batadv_nc_start_timer(bat_priv);
43
44 return 0;
45}
46
47/**
48 * batadv_nc_init_bat_priv - initialise the nc specific bat_priv variables
49 * @bat_priv: the bat priv with all the soft interface information
50 */
51void batadv_nc_init_bat_priv(struct batadv_priv *bat_priv)
52{
53 atomic_set(&bat_priv->network_coding, 1);
54}
55
56/**
57 * batadv_nc_worker - periodic task for house keeping related to network coding
58 * @work: kernel work struct
59 */
60static void batadv_nc_worker(struct work_struct *work)
61{
62 struct delayed_work *delayed_work;
63 struct batadv_priv_nc *priv_nc;
64 struct batadv_priv *bat_priv;
65
66 delayed_work = container_of(work, struct delayed_work, work);
67 priv_nc = container_of(delayed_work, struct batadv_priv_nc, work);
68 bat_priv = container_of(priv_nc, struct batadv_priv, nc);
69
70 /* Schedule a new check */
71 batadv_nc_start_timer(bat_priv);
72}
73
74/**
75 * batadv_nc_free - clean up network coding memory
76 * @bat_priv: the bat priv with all the soft interface information
77 */
78void batadv_nc_free(struct batadv_priv *bat_priv)
79{
80 cancel_delayed_work_sync(&bat_priv->nc.work);
81}