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

Commit 33a3bb4a authored by Antonio Quartulli's avatar Antonio Quartulli Committed by Simon Wunderlich
Browse files

batman-adv: throughput meter implementation



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 <montik@autistici.org>

Signed-off-by: default avatarAntonio Quartulli <antonio.quartulli@open-mesh.com>
Signed-off-by: default avatarSven Eckelmann <sven.eckelmann@open-mesh.com>
Signed-off-by: default avatarMarek Lindner <mareklindner@neomailbox.ch>
Signed-off-by: default avatarSimon Wunderlich <sw@simonwunderlich.de>
parent f50ca95a
Loading
Loading
Loading
Loading
+43 −0
Original line number Diff line number Diff line
@@ -20,6 +20,8 @@

#define BATADV_NL_NAME "batadv"

#define BATADV_NL_MCAST_GROUP_TPMETER	"tpmeter"

/**
 * enum batadv_nl_attrs - batman-adv netlink attributes
 *
@@ -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
@@ -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,
@@ -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 −0
Original line number Diff line number Diff line
@@ -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
+10 −8
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ 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 {
@@ -61,6 +62,7 @@ enum batadv_dbg_level {
	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,
};

+4 −0
Original line number Diff line number Diff line
@@ -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,
@@ -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");

@@ -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);
@@ -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)
+8 −0
Original line number Diff line number Diff line
@@ -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 */
@@ -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,
Loading