[PATCH] scan: evaluate AP-reported channel load

David Bauer mail at david-bauer.net
Sun Oct 3 10:04:05 PDT 2021


When determining the expected throughput from a AP, take the AP-reported
channel utilization (QBSS Load element) into consideration.

Signed-off-by: David Bauer <mail at david-bauer.net>
---
 wpa_supplicant/scan.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/wpa_supplicant/scan.c b/wpa_supplicant/scan.c
index 97a8d9a63..e8cc8b623 100644
--- a/wpa_supplicant/scan.c
+++ b/wpa_supplicant/scan.c
@@ -2617,7 +2617,7 @@ void scan_est_throughput(struct wpa_supplicant *wpa_s,
 {
 	int rate; /* max legacy rate in 500 kb/s units */
 	int snr = res->snr;
-	const u8 *ies = (const void *) (res + 1);
+	const u8 *ies = (const void *) (res + 1), *ie;
 	size_t ie_len = res->ie_len;
 
 	if (res->est_throughput)
@@ -2631,7 +2631,19 @@ void scan_est_throughput(struct wpa_supplicant *wpa_s,
 	res->est_throughput =
 		wpas_get_est_tpt(wpa_s, ies, ie_len, rate, snr, res->freq);
 
-	/* TODO: channel utilization and AP load (e.g., from AP Beacon) */
+	/* Estimate throughput based on channel load reported by AP.
+	 * Assume that a load of 255 (100%) means no throughput is
+	 * possible. A load of 0 equals to the full estimated throughput
+	 * being achievable.
+	 *
+	 * Use the calculated throughput without any panilty, in case
+	 * BSS load element is not present.
+	 */
+	ie = get_ie(ies, ie_len, WLAN_EID_BSS_LOAD);
+	if (ie == NULL || ie[1] < 5)
+		return; /* No BSS Load advertised */
+
+	res->est_throughput = (res->est_throughput * (255 - ie[4])) / 255;
 }
 
 
-- 
2.33.0




More information about the Hostap mailing list