From patchwork Wed Nov 13 18:14:48 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Wunderlich X-Patchwork-Id: 3556 Return-Path: Received: from mail.mail.packetmixer.de (packetmixer.de [79.140.42.25]) by open-mesh.org (Postfix) with ESMTPS id B6A17601FCA for ; Wed, 13 Nov 2013 19:15:04 +0100 (CET) Received: from kero.packetmixer.de (drsd-4d05f390.pool.mediaWays.net [77.5.243.144]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by mail.mail.packetmixer.de (Postfix) with ESMTPSA id 97B6B6215C; Wed, 13 Nov 2013 18:26:40 +0000 (UTC) From: Simon Wunderlich To: b.a.t.m.a.n@lists.open-mesh.org Date: Wed, 13 Nov 2013 19:14:48 +0100 Message-Id: <1384366492-27310-5-git-send-email-sw@simonwunderlich.de> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1384366492-27310-1-git-send-email-sw@simonwunderlich.de> References: <1384366492-27310-1-git-send-email-sw@simonwunderlich.de> Cc: Simon Wunderlich Subject: [B.A.T.M.A.N.] [PATCHv3 4/8] batman-adv: add WiFi penalty X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Nov 2013 18:15:04 -0000 From: Simon Wunderlich If the same interface is used for sending and receiving, there might be throughput degradation on half-duplex interfaces such as WiFi. Add a penalty if the same interface is used to reflect this problem in the metric. At the same time, change the hop penalty from 30 to 15 so there will be no change for single wifi mesh network. the effective hop penalty will stay at 30 due to the new wifi penalty for these networks. Signed-off-by: Simon Wunderlich --- Changes to PATCHv2: * remove an obsolote check when printing if_incoming to make smatch happy Changes to RFCv2: * various style changes Changes to RFCv1: * use hop penalty for wifi penalty, and use half of the original hop penalty. --- bat_iv_ogm.c | 27 ++++++++++++++++++++++----- hard-interface.h | 1 + soft-interface.c | 2 +- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/bat_iv_ogm.c b/bat_iv_ogm.c index 93d3d9d..9f6cfa5 100644 --- a/bat_iv_ogm.c +++ b/bat_iv_ogm.c @@ -1085,6 +1085,7 @@ static int batadv_iv_ogm_calc_tq(struct batadv_orig_node *orig_node, unsigned int neigh_rq_inv_cube, neigh_rq_max_cube; int tq_asym_penalty, inv_asym_penalty, if_num, ret = 0; unsigned int combined_tq; + int tq_iface_penalty; /* find corresponding one hop neighbor */ rcu_read_lock(); @@ -1166,15 +1167,31 @@ static int batadv_iv_ogm_calc_tq(struct batadv_orig_node *orig_node, inv_asym_penalty /= neigh_rq_max_cube; tq_asym_penalty = BATADV_TQ_MAX_VALUE - inv_asym_penalty; - combined_tq = batadv_ogm_packet->tq * tq_own * tq_asym_penalty; - combined_tq /= BATADV_TQ_MAX_VALUE * BATADV_TQ_MAX_VALUE; + /* penalize if the OGM is forwarded on the same interface. WiFi + * interfaces and other half duplex devices suffer from throughput + * drops as they can't send and receive at the same time. + */ + tq_iface_penalty = BATADV_TQ_MAX_VALUE; + if (if_outgoing && (if_incoming == if_outgoing) && + batadv_is_wifi_netdev(if_outgoing->net_dev)) + tq_iface_penalty = batadv_hop_penalty(BATADV_TQ_MAX_VALUE, + bat_priv); + + combined_tq = batadv_ogm_packet->tq * + tq_own * + tq_asym_penalty * + tq_iface_penalty; + combined_tq /= BATADV_TQ_MAX_VALUE * + BATADV_TQ_MAX_VALUE * + BATADV_TQ_MAX_VALUE; batadv_ogm_packet->tq = combined_tq; batadv_dbg(BATADV_DBG_BATMAN, bat_priv, - "bidirectional: orig = %-15pM neigh = %-15pM => own_bcast = %2i, real recv = %2i, local tq: %3i, asym_penalty: %3i, total tq: %3i\n", + "bidirectional: orig = %-15pM neigh = %-15pM => own_bcast = %2i, real recv = %2i, local tq: %3i, asym_penalty: %3i, iface_penalty: %3i, total tq: %3i, if_incoming = %s, if_outgoing = %s\n", orig_node->orig, orig_neigh_node->orig, total_count, - neigh_rq_count, tq_own, - tq_asym_penalty, batadv_ogm_packet->tq); + neigh_rq_count, tq_own, tq_asym_penalty, tq_iface_penalty, + batadv_ogm_packet->tq, if_incoming->net_dev->name, + if_outgoing ? if_outgoing->net_dev->name : "DEFAULT"); /* if link has the minimum required transmission quality * consider it bidirectional diff --git a/hard-interface.h b/hard-interface.h index 2017e9f..f4a6022 100644 --- a/hard-interface.h +++ b/hard-interface.h @@ -37,6 +37,7 @@ enum batadv_hard_if_cleanup { extern struct notifier_block batadv_hard_if_notifier; bool batadv_is_wifi_netdev(struct net_device *net_device); +bool batadv_is_wifi_iface(int ifindex); struct batadv_hard_iface* batadv_hardif_get_by_netdev(const struct net_device *net_dev); int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface, diff --git a/soft-interface.c b/soft-interface.c index 97441d8..450dd7c 100644 --- a/soft-interface.c +++ b/soft-interface.c @@ -688,7 +688,7 @@ static int batadv_softif_init_late(struct net_device *dev) atomic_set(&bat_priv->gw.bandwidth_down, 100); atomic_set(&bat_priv->gw.bandwidth_up, 20); atomic_set(&bat_priv->orig_interval, 1000); - atomic_set(&bat_priv->hop_penalty, 30); + atomic_set(&bat_priv->hop_penalty, 15); #ifdef CONFIG_BATMAN_ADV_DEBUG atomic_set(&bat_priv->log_level, 0); #endif