b.a.t.m.a.n.lists.open-mesh.org archive mirror
 help / color / mirror / Atom feed
From: Remi Pommarel <repk@triplefau.lt>
To: b.a.t.m.a.n@lists.open-mesh.org
Cc: Remi Pommarel <repk@triplefau.lt>
Subject: [PATCH RFC 1/2] batman-adv: Keep half duplex penalty on OGM receiving side also
Date: Thu, 28 Sep 2023 14:39:35 +0200	[thread overview]
Message-ID: <267dc235e8a1587ce469794ad9a69c651f59a613.1695904299.git.repk@triplefau.lt> (raw)
In-Reply-To: <cover.1695904299.git.repk@triplefau.lt>

Considering the following topology:

+-------+         +-------+         +-------+
| Orig0 | <------ | Orig1 | <------ | Orig2 |
+-------+   T01   +-------+   T12   +-------+

Where T01 and T12 are throughput estimations for link between Orig0 and
Orig1 and the one between Orig1 and Orig2 respectively. And where Orig1
is using the same WiFi interface to reach Orig0 and Orig2.

In this case Orig2 will receive an OGM for Orig0 from Orig1 with a
throughput of T01/2 to take into account store & forward charactersitic
of WiFi interface. But if T12 is lower that T01/2 this penalty is
dropped and end-to-end throughput for Orig2 to Orig0 path will be
estimated to be T12.

This patch adds a flag in OGM packet that indicates the OGM needs half
duplex penalty. Thus the node receiving it (i.e. Orig2 in the situation
above) can correctly apply the penalty on its throughput.

In the case above Orig2 will received from Orig1 a OGM for Orig0 with
BATADV_V_HALF_DUPLEX flag set, so it could use T12/2 as its end-to-end
path throughput instead of T12.

Signed-off-by: Remi Pommarel <repk@triplefau.lt>
---
 include/uapi/linux/batadv_packet.h |  8 ++++++
 net/batman-adv/bat_v_ogm.c         | 42 +++++++++++++++++++++++++-----
 net/batman-adv/types.h             |  3 +++
 3 files changed, 47 insertions(+), 6 deletions(-)

diff --git a/include/uapi/linux/batadv_packet.h b/include/uapi/linux/batadv_packet.h
index ea4692c339ce..9c711d149a45 100644
--- a/include/uapi/linux/batadv_packet.h
+++ b/include/uapi/linux/batadv_packet.h
@@ -84,6 +84,14 @@ enum batadv_iv_flags {
 	BATADV_DIRECTLINK          = 1UL << 2,
 };
 
+/**
+ * enum batadv_v_flags - flags used in B.A.T.M.A.N. V OGM2 packets
+ * @BATADV_V_HALF_DUPLEX: Half Duplex penalty should be applied to throughput
+ */
+enum batadv_v_flags {
+	BATADV_V_HALF_DUPLEX   = 1UL << 0,
+};
+
 /**
  * enum batadv_icmp_packettype - ICMP message types
  * @BATADV_ECHO_REPLY: success reply to BATADV_ECHO_REQUEST
diff --git a/net/batman-adv/bat_v_ogm.c b/net/batman-adv/bat_v_ogm.c
index 1d750f3cb2e4..27597f4cdf3e 100644
--- a/net/batman-adv/bat_v_ogm.c
+++ b/net/batman-adv/bat_v_ogm.c
@@ -474,12 +474,14 @@ void batadv_v_ogm_primary_iface_set(struct batadv_hard_iface *primary_iface)
 static u32 batadv_v_forward_penalty(struct batadv_priv *bat_priv,
 				    struct batadv_hard_iface *if_incoming,
 				    struct batadv_hard_iface *if_outgoing,
-				    u32 throughput)
+				    u32 throughput, bool *half_duplex)
 {
 	int if_hop_penalty = atomic_read(&if_incoming->hop_penalty);
 	int hop_penalty = atomic_read(&bat_priv->hop_penalty);
 	int hop_penalty_max = BATADV_TQ_MAX_VALUE;
 
+	*half_duplex = false;
+
 	/* Apply per hardif hop penalty */
 	throughput = throughput * (hop_penalty_max - if_hop_penalty) /
 		     hop_penalty_max;
@@ -494,8 +496,10 @@ static u32 batadv_v_forward_penalty(struct batadv_priv *bat_priv,
 	 */
 	if (throughput > 10 &&
 	    if_incoming == if_outgoing &&
-	    !(if_incoming->bat_v.flags & BATADV_FULL_DUPLEX))
+	    !(if_incoming->bat_v.flags & BATADV_FULL_DUPLEX)) {
+		*half_duplex = true;
 		return throughput / 2;
+	}
 
 	/* hop penalty of 255 equals 100% */
 	return throughput * (hop_penalty_max - hop_penalty) / hop_penalty_max;
@@ -573,6 +577,9 @@ static void batadv_v_ogm_forward(struct batadv_priv *bat_priv,
 
 	/* apply forward penalty */
 	ogm_forward = (struct batadv_ogm2_packet *)skb_buff;
+	ogm_forward->flags &= ~BATADV_V_HALF_DUPLEX;
+	if (neigh_ifinfo->bat_v.half_duplex)
+		ogm_forward->flags |= BATADV_V_HALF_DUPLEX;
 	ogm_forward->throughput = htonl(neigh_ifinfo->bat_v.throughput);
 	ogm_forward->ttl--;
 
@@ -615,6 +622,7 @@ static int batadv_v_ogm_metric_update(struct batadv_priv *bat_priv,
 	bool protection_started = false;
 	int ret = -EINVAL;
 	u32 path_throughput;
+	bool half_duplex;
 	s32 seq_diff;
 
 	orig_ifinfo = batadv_orig_ifinfo_new(orig_node, if_outgoing);
@@ -656,10 +664,12 @@ static int batadv_v_ogm_metric_update(struct batadv_priv *bat_priv,
 
 	path_throughput = batadv_v_forward_penalty(bat_priv, if_incoming,
 						   if_outgoing,
-						   ntohl(ogm2->throughput));
+						   ntohl(ogm2->throughput),
+						   &half_duplex);
 	neigh_ifinfo->bat_v.throughput = path_throughput;
 	neigh_ifinfo->bat_v.last_seqno = ntohl(ogm2->seqno);
 	neigh_ifinfo->last_ttl = ogm2->ttl;
+	neigh_ifinfo->bat_v.half_duplex = half_duplex;
 
 	if (seq_diff > 0 || protection_started)
 		ret = 1;
@@ -842,6 +852,26 @@ batadv_v_ogm_aggr_packet(int buff_pos, int packet_len,
 	       (next_buff_pos <= BATADV_MAX_AGGREGATION_BYTES);
 }
 
+/**
+ * batadv_v_get_throughput() - Compute path throughput from received OGM
+ * @ogm: OGM2 packet received
+ * @neigh: Neighbour OGM packet has been received from
+ * @return: Estimated path throughput
+ */
+static u32 batadv_v_get_throughput(struct batadv_ogm2_packet *ogm,
+				   struct batadv_hardif_neigh_node *neigh)
+{
+	u32 oth, lth;
+
+	oth = ntohl(ogm->throughput);
+	lth = ewma_throughput_read(&neigh->bat_v.throughput);
+
+	if ((ogm->flags & BATADV_V_HALF_DUPLEX) && lth > 10)
+		lth /= 2;
+
+	return min_t(u32, lth, oth);
+}
+
 /**
  * batadv_v_ogm_process() - process an incoming batman v OGM
  * @skb: the skb containing the OGM
@@ -858,7 +888,7 @@ static void batadv_v_ogm_process(const struct sk_buff *skb, int ogm_offset,
 	struct batadv_neigh_node *neigh_node = NULL;
 	struct batadv_hard_iface *hard_iface;
 	struct batadv_ogm2_packet *ogm_packet;
-	u32 ogm_throughput, link_throughput, path_throughput;
+	u32 ogm_throughput, path_throughput;
 	int ret;
 
 	ethhdr = eth_hdr(skb);
@@ -911,9 +941,9 @@ static void batadv_v_ogm_process(const struct sk_buff *skb, int ogm_offset,
 	 *    neighbor) the path throughput metric equals the link throughput.
 	 *  - For OGMs traversing more than hop the path throughput metric is
 	 *    the smaller of the path throughput and the link throughput.
+	 *  - Also apply Half Duplex interfaces penalty
 	 */
-	link_throughput = ewma_throughput_read(&hardif_neigh->bat_v.throughput);
-	path_throughput = min_t(u32, link_throughput, ogm_throughput);
+	path_throughput = batadv_v_get_throughput(ogm_packet, hardif_neigh);
 	ogm_packet->throughput = htonl(path_throughput);
 
 	batadv_v_ogm_process_per_outif(bat_priv, ethhdr, ogm_packet, orig_node,
diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
index 2be5d4a712c5..147b1595d32a 100644
--- a/net/batman-adv/types.h
+++ b/net/batman-adv/types.h
@@ -708,6 +708,9 @@ struct batadv_neigh_ifinfo_bat_v {
 
 	/** @last_seqno: last sequence number known for this neighbor */
 	u32 last_seqno;
+
+	/** @half_duplex: throughput should suffer half duplex penalty */
+	bool half_duplex;
 };
 
 /**
-- 
2.40.0


  reply	other threads:[~2023-09-28 13:51 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-28 12:39 [PATCH RFC 0/2] Better throughput estimation on half duplex interfaces Remi Pommarel
2023-09-28 12:39 ` Remi Pommarel [this message]
2023-09-28 12:39 ` [PATCH RFC 2/2] batman-adv: Better half duplex penalty estimation Remi Pommarel
2023-10-14  5:10   ` Linus Lüssing
2023-10-14  6:03     ` Linus Lüssing
2023-10-18 19:58     ` Remi Pommarel
2023-10-18 21:37       ` Nicolas Escande
2023-10-14  6:24   ` Linus Lüssing
2023-09-28 15:33 ` [PATCH RFC 0/2] Better throughput estimation on half duplex interfaces Marek Lindner
2023-09-28 16:48   ` Remi Pommarel
2023-09-28 17:54     ` Remi Pommarel
2023-09-28 18:10     ` Marek Lindner
2023-09-28 19:16       ` Remi Pommarel
2023-10-03 21:06         ` Marek Lindner
2023-10-11  8:55           ` Remi Pommarel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=267dc235e8a1587ce469794ad9a69c651f59a613.1695904299.git.repk@triplefau.lt \
    --to=repk@triplefau.lt \
    --cc=b.a.t.m.a.n@lists.open-mesh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).