Commit 3c12de9a authored by Martin Hundebøll's avatar Martin Hundebøll Committed by Antonio Quartulli

batman-adv: network coding - code and transmit packets if possible

Before adding forward-skbs to the coding buffer, the buffer is searched
for a potential coding opportunity. If one is found, the two packets are
network coded and transmitted right away. If not, the forward-skb is
added to the buffer.

Network coded packets are transmitted with information about the two
receivers and the two coded packets. The first receiver is given by the
MAC header, while the second is given in the payload/bat-header. The
second receiver uses promiscuous mode to receive the packet and check
the second destination.
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 95332477
...@@ -302,4 +302,10 @@ static inline uint64_t batadv_sum_counter(struct batadv_priv *bat_priv, ...@@ -302,4 +302,10 @@ static inline uint64_t batadv_sum_counter(struct batadv_priv *bat_priv,
return sum; return sum;
} }
/* Define a macro to reach the control buffer of the skb. The members of the
* control buffer are defined in struct batadv_skb_cb in types.h.
* The macro is inspired by the similar macro TCP_SKB_CB() in tcp.h.
*/
#define BATADV_SKB_CB(__skb) ((struct batadv_skb_cb *)&((__skb)->cb[0]))
#endif /* _NET_BATMAN_ADV_MAIN_H_ */ #endif /* _NET_BATMAN_ADV_MAIN_H_ */
This diff is collapsed.
...@@ -30,6 +30,7 @@ enum batadv_packettype { ...@@ -30,6 +30,7 @@ enum batadv_packettype {
BATADV_TT_QUERY = 0x07, BATADV_TT_QUERY = 0x07,
BATADV_ROAM_ADV = 0x08, BATADV_ROAM_ADV = 0x08,
BATADV_UNICAST_4ADDR = 0x09, BATADV_UNICAST_4ADDR = 0x09,
BATADV_CODED = 0x0a,
}; };
/** /**
...@@ -278,4 +279,36 @@ struct batadv_tt_change { ...@@ -278,4 +279,36 @@ struct batadv_tt_change {
uint8_t addr[ETH_ALEN]; uint8_t addr[ETH_ALEN];
} __packed; } __packed;
/**
* struct batadv_coded_packet - network coded packet
* @header: common batman packet header and ttl of first included packet
* @reserved: Align following fields to 2-byte boundaries
* @first_source: original source of first included packet
* @first_orig_dest: original destinal of first included packet
* @first_crc: checksum of first included packet
* @first_ttvn: tt-version number of first included packet
* @second_ttl: ttl of second packet
* @second_dest: second receiver of this coded packet
* @second_source: original source of second included packet
* @second_orig_dest: original destination of second included packet
* @second_crc: checksum of second included packet
* @second_ttvn: tt version number of second included packet
* @coded_len: length of network coded part of the payload
*/
struct batadv_coded_packet {
struct batadv_header header;
uint8_t first_ttvn;
/* uint8_t first_dest[ETH_ALEN]; - saved in mac header destination */
uint8_t first_source[ETH_ALEN];
uint8_t first_orig_dest[ETH_ALEN];
__be32 first_crc;
uint8_t second_ttl;
uint8_t second_ttvn;
uint8_t second_dest[ETH_ALEN];
uint8_t second_source[ETH_ALEN];
uint8_t second_orig_dest[ETH_ALEN];
__be32 second_crc;
uint16_t coded_len;
};
#endif /* _NET_BATMAN_ADV_PACKET_H_ */ #endif /* _NET_BATMAN_ADV_PACKET_H_ */
...@@ -665,6 +665,12 @@ static const struct { ...@@ -665,6 +665,12 @@ static const struct {
{ "dat_put_rx" }, { "dat_put_rx" },
{ "dat_cached_reply_tx" }, { "dat_cached_reply_tx" },
#endif #endif
#ifdef CONFIG_BATMAN_ADV_NC
{ "nc_code" },
{ "nc_code_bytes" },
{ "nc_recode" },
{ "nc_recode_bytes" },
#endif
}; };
static void batadv_get_strings(struct net_device *dev, uint32_t stringset, static void batadv_get_strings(struct net_device *dev, uint32_t stringset,
......
...@@ -275,6 +275,10 @@ struct batadv_bcast_duplist_entry { ...@@ -275,6 +275,10 @@ struct batadv_bcast_duplist_entry {
* @BATADV_CNT_DAT_PUT_RX: received dht PUT traffic packet counter * @BATADV_CNT_DAT_PUT_RX: received dht PUT traffic packet counter
* @BATADV_CNT_DAT_CACHED_REPLY_TX: transmitted dat cache reply traffic packet * @BATADV_CNT_DAT_CACHED_REPLY_TX: transmitted dat cache reply traffic packet
* counter * counter
* @BATADV_CNT_NC_CODE: transmitted nc-combined traffic packet counter
* @BATADV_CNT_NC_CODE_BYTES: transmitted nc-combined traffic bytes counter
* @BATADV_CNT_NC_RECODE: transmitted nc-recombined traffic packet counter
* @BATADV_CNT_NC_RECODE_BYTES: transmitted nc-recombined traffic bytes counter
* @BATADV_CNT_NUM: number of traffic counters * @BATADV_CNT_NUM: number of traffic counters
*/ */
enum batadv_counters { enum batadv_counters {
...@@ -301,6 +305,12 @@ enum batadv_counters { ...@@ -301,6 +305,12 @@ enum batadv_counters {
BATADV_CNT_DAT_PUT_TX, BATADV_CNT_DAT_PUT_TX,
BATADV_CNT_DAT_PUT_RX, BATADV_CNT_DAT_PUT_RX,
BATADV_CNT_DAT_CACHED_REPLY_TX, BATADV_CNT_DAT_CACHED_REPLY_TX,
#endif
#ifdef CONFIG_BATMAN_ADV_NC
BATADV_CNT_NC_CODE,
BATADV_CNT_NC_CODE_BYTES,
BATADV_CNT_NC_RECODE,
BATADV_CNT_NC_RECODE_BYTES,
#endif #endif
BATADV_CNT_NUM, BATADV_CNT_NUM,
}; };
...@@ -796,6 +806,16 @@ struct batadv_nc_packet { ...@@ -796,6 +806,16 @@ struct batadv_nc_packet {
struct batadv_nc_path *nc_path; struct batadv_nc_path *nc_path;
}; };
/**
* batadv_skb_cb - control buffer structure used to store private data relevant
* to batman-adv in the skb->cb buffer in skbs.
* @decoded: Marks a skb as decoded, which is checked when searching for coding
* opportunities in network-coding.c
*/
struct batadv_skb_cb {
bool decoded;
};
/** /**
* struct batadv_forw_packet - structure for bcast packets to be sent/forwarded * struct batadv_forw_packet - structure for bcast packets to be sent/forwarded
* @list: list node for batadv_socket_client::queue_list * @list: list node for batadv_socket_client::queue_list
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment