Skip to content

Commit

Permalink
batman-adv: throughput meter implementation
Browse files Browse the repository at this point in the history
The throughput meter module is a simple, kernel-space replacement for
throughtput measurements tool like iperf and netperf. It is intended to
approximate TCP behaviour.

It is invoked through batctl: the protocol is connection oriented, with
cumulative acknowledgment and a dynamic-size sliding window.

The test *can* be interrupted by batctl. A receiver side timeout avoids
unlimited waitings for sender packets: after one second of inactivity, the
receiver abort the ongoing test.

Based on a prototype from Edo Monticelli <[email protected]>

Signed-off-by: Antonio Quartulli <[email protected]>
Signed-off-by: Sven Eckelmann <[email protected]>
Signed-off-by: Marek Lindner <[email protected]>
Signed-off-by: Simon Wunderlich <[email protected]>
  • Loading branch information
ordex authored and simonwunderlich committed Jul 4, 2016
1 parent f50ca95 commit 33a3bb4
Show file tree
Hide file tree
Showing 13 changed files with 2,021 additions and 10 deletions.
43 changes: 43 additions & 0 deletions include/uapi/linux/batman_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

#define BATADV_NL_NAME "batadv"

#define BATADV_NL_MCAST_GROUP_TPMETER "tpmeter"

/**
* enum batadv_nl_attrs - batman-adv netlink attributes
*
Expand All @@ -32,6 +34,12 @@
* @BATADV_ATTR_HARD_IFINDEX: index of the non-batman-adv interface
* @BATADV_ATTR_HARD_IFNAME: name of the non-batman-adv interface
* @BATADV_ATTR_HARD_ADDRESS: mac address of the non-batman-adv interface
* @BATADV_ATTR_ORIG_ADDRESS: originator mac address
* @BATADV_ATTR_TPMETER_RESULT: result of run (see batadv_tp_meter_status)
* @BATADV_ATTR_TPMETER_TEST_TIME: time (msec) the run took
* @BATADV_ATTR_TPMETER_BYTES: amount of acked bytes during run
* @BATADV_ATTR_TPMETER_COOKIE: session cookie to match tp_meter session
* @BATADV_ATTR_PAD: attribute used for padding for 64-bit alignment
* @__BATADV_ATTR_AFTER_LAST: internal use
* @NUM_BATADV_ATTR: total number of batadv_nl_attrs available
* @BATADV_ATTR_MAX: highest attribute number currently defined
Expand All @@ -46,6 +54,12 @@ enum batadv_nl_attrs {
BATADV_ATTR_HARD_IFINDEX,
BATADV_ATTR_HARD_IFNAME,
BATADV_ATTR_HARD_ADDRESS,
BATADV_ATTR_ORIG_ADDRESS,
BATADV_ATTR_TPMETER_RESULT,
BATADV_ATTR_TPMETER_TEST_TIME,
BATADV_ATTR_TPMETER_BYTES,
BATADV_ATTR_TPMETER_COOKIE,
BATADV_ATTR_PAD,
/* add attributes above here, update the policy in netlink.c */
__BATADV_ATTR_AFTER_LAST,
NUM_BATADV_ATTR = __BATADV_ATTR_AFTER_LAST,
Expand All @@ -57,15 +71,44 @@ enum batadv_nl_attrs {
*
* @BATADV_CMD_UNSPEC: unspecified command to catch errors
* @BATADV_CMD_GET_MESH_INFO: Query basic information about batman-adv device
* @BATADV_CMD_TP_METER: Start a tp meter session
* @BATADV_CMD_TP_METER_CANCEL: Cancel a tp meter session
* @__BATADV_CMD_AFTER_LAST: internal use
* @BATADV_CMD_MAX: highest used command number
*/
enum batadv_nl_commands {
BATADV_CMD_UNSPEC,
BATADV_CMD_GET_MESH_INFO,
BATADV_CMD_TP_METER,
BATADV_CMD_TP_METER_CANCEL,
/* add new commands above here */
__BATADV_CMD_AFTER_LAST,
BATADV_CMD_MAX = __BATADV_CMD_AFTER_LAST - 1
};

/**
* enum batadv_tp_meter_reason - reason of a tp meter test run stop
* @BATADV_TP_REASON_COMPLETE: sender finished tp run
* @BATADV_TP_REASON_CANCEL: sender was stopped during run
* @BATADV_TP_REASON_DST_UNREACHABLE: receiver could not be reached or didn't
* answer
* @BATADV_TP_REASON_RESEND_LIMIT: (unused) sender retry reached limit
* @BATADV_TP_REASON_ALREADY_ONGOING: test to or from the same node already
* ongoing
* @BATADV_TP_REASON_MEMORY_ERROR: test was stopped due to low memory
* @BATADV_TP_REASON_CANT_SEND: failed to send via outgoing interface
* @BATADV_TP_REASON_TOO_MANY: too many ongoing sessions
*/
enum batadv_tp_meter_reason {
BATADV_TP_REASON_COMPLETE = 3,
BATADV_TP_REASON_CANCEL = 4,
/* error status >= 128 */
BATADV_TP_REASON_DST_UNREACHABLE = 128,
BATADV_TP_REASON_RESEND_LIMIT = 129,
BATADV_TP_REASON_ALREADY_ONGOING = 130,
BATADV_TP_REASON_MEMORY_ERROR = 131,
BATADV_TP_REASON_CANT_SEND = 132,
BATADV_TP_REASON_TOO_MANY = 133,
};

#endif /* _UAPI_LINUX_BATMAN_ADV_H_ */
1 change: 1 addition & 0 deletions net/batman-adv/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,6 @@ batman-adv-y += routing.o
batman-adv-y += send.o
batman-adv-y += soft-interface.o
batman-adv-y += sysfs.o
batman-adv-y += tp_meter.o
batman-adv-y += translation-table.o
batman-adv-y += tvlv.o
18 changes: 10 additions & 8 deletions net/batman-adv/log.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,19 @@ static inline void batadv_debug_log_cleanup(struct batadv_priv *bat_priv)
* @BATADV_DBG_DAT: ARP snooping and DAT related messages
* @BATADV_DBG_NC: network coding related messages
* @BATADV_DBG_MCAST: multicast related messages
* @BATADV_DBG_TP_METER: throughput meter messages
* @BATADV_DBG_ALL: the union of all the above log levels
*/
enum batadv_dbg_level {
BATADV_DBG_BATMAN = BIT(0),
BATADV_DBG_ROUTES = BIT(1),
BATADV_DBG_TT = BIT(2),
BATADV_DBG_BLA = BIT(3),
BATADV_DBG_DAT = BIT(4),
BATADV_DBG_NC = BIT(5),
BATADV_DBG_MCAST = BIT(6),
BATADV_DBG_ALL = 127,
BATADV_DBG_BATMAN = BIT(0),
BATADV_DBG_ROUTES = BIT(1),
BATADV_DBG_TT = BIT(2),
BATADV_DBG_BLA = BIT(3),
BATADV_DBG_DAT = BIT(4),
BATADV_DBG_NC = BIT(5),
BATADV_DBG_MCAST = BIT(6),
BATADV_DBG_TP_METER = BIT(7),
BATADV_DBG_ALL = 127,
};

#ifdef CONFIG_BATMAN_ADV_DEBUG
Expand Down
4 changes: 4 additions & 0 deletions net/batman-adv/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
#include "routing.h"
#include "send.h"
#include "soft-interface.h"
#include "tp_meter.h"
#include "translation-table.h"

/* List manipulations on hardif_list have to be rtnl_lock()'ed,
Expand All @@ -89,6 +90,7 @@ static int __init batadv_init(void)
batadv_v_init();
batadv_iv_init();
batadv_nc_init();
batadv_tp_meter_init();

batadv_event_workqueue = create_singlethread_workqueue("bat_events");

Expand Down Expand Up @@ -142,6 +144,7 @@ int batadv_mesh_init(struct net_device *soft_iface)
spin_lock_init(&bat_priv->tvlv.container_list_lock);
spin_lock_init(&bat_priv->tvlv.handler_list_lock);
spin_lock_init(&bat_priv->softif_vlan_list_lock);
spin_lock_init(&bat_priv->tp_list_lock);

INIT_HLIST_HEAD(&bat_priv->forw_bat_list);
INIT_HLIST_HEAD(&bat_priv->forw_bcast_list);
Expand All @@ -160,6 +163,7 @@ int batadv_mesh_init(struct net_device *soft_iface)
INIT_HLIST_HEAD(&bat_priv->tvlv.container_list);
INIT_HLIST_HEAD(&bat_priv->tvlv.handler_list);
INIT_HLIST_HEAD(&bat_priv->softif_vlan_list);
INIT_HLIST_HEAD(&bat_priv->tp_list);

ret = batadv_v_mesh_init(bat_priv);
if (ret < 0)
Expand Down
8 changes: 8 additions & 0 deletions net/batman-adv/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@
#define BATADV_NUM_BCASTS_WIRELESS 3
#define BATADV_NUM_BCASTS_MAX 3

/* length of the single packet used by the TP meter */
#define BATADV_TP_PACKET_LEN ETH_DATA_LEN

/* msecs after which an ARP_REQUEST is sent in broadcast as fallback */
#define ARP_REQ_DELAY 250
/* numbers of originator to contact for any PUT/GET DHT operation */
Expand Down Expand Up @@ -131,6 +134,11 @@

#define BATADV_NC_NODE_TIMEOUT 10000 /* Milliseconds */

/**
* BATADV_TP_MAX_NUM - maximum number of simultaneously active tp sessions
*/
#define BATADV_TP_MAX_NUM 5

enum batadv_mesh_state {
BATADV_MESH_INACTIVE,
BATADV_MESH_ACTIVE,
Expand Down
Loading

0 comments on commit 33a3bb4

Please sign in to comment.