From patchwork Fri Mar 29 18:31:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Greear X-Patchwork-Id: 1070026 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=candelatech.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="tU9l7YS3"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=candelatech.com header.i=@candelatech.com header.b="aMLbJEqm"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44W9Lb6wzkz9sPq for ; Sat, 30 Mar 2019 05:31:51 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=37eWgic7xRZZ03Fjzsxu35vIAaPSCHtI/kTp4HR12RM=; b=tU9 l7YS3mwLe7yQ5zn7ggtJoBzI/9jQLaLrG+KgsKuwuZoFnGO0jv6ujdoB8HiXP0Qa3Y/eXfoomctF/ VpwxHZCFv1hDup1UEobhzb4KZL4uPqDKO1K1o5O8BRibayDhX+oYbmWQwRDBmLIA0E3EVIev5Skft /Gzswjqqyz9l500vA5grbDSv08VpfCSclifODOFrJA9ojHv8wbrSoWGKuZwJnLoESgRHjLOJtciRq CUJYdN6ER3lQCr/7wI79tDEyeY4q9bCAoSIlc8p03RIzFEmhzXgvM5Gb/JeGLZ0icN1Y71shhs/Di CUUAzpe5fwN9CDDrE9u5X5WUTCUpnWQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1h9wHu-0000fI-3l; Fri, 29 Mar 2019 18:31:34 +0000 Received: from [208.74.158.174] (helo=mail3.candelatech.com) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1h9wHq-0000eH-4J for hostap@lists.infradead.org; Fri, 29 Mar 2019 18:31:31 +0000 Received: from v-f24-64.candelatech.com (50-251-239-81-static.hfc.comcastbusiness.net [50.251.239.81]) by mail3.candelatech.com (Postfix) with ESMTP id E351513755A; Fri, 29 Mar 2019 11:31:28 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 mail3.candelatech.com E351513755A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=candelatech.com; s=default; t=1553884289; bh=JeGBWPBD6RzyDKyk3+SLGyTLQqixu8hOcOWsZsNc4Ek=; h=From:To:Cc:Subject:Date:From; b=aMLbJEqm8CkAexEqkhgCJ32dqDqnKma5j11xqg0Nj0N6CPqpo34O9u58JDrqWemMM rTpT9yXq2A0zV81ZNgwRKT34/Z+VhJlr9Sl1/NHgc4DIaBKX6auHaV+gJQ9/iAx2qM 5+6v1ipXomT8pdSUG6NQd849gUDLfQGLzbceYmas= From: greearb@candelatech.com To: hostap@lists.infradead.org Subject: [PATCH] supplicant: Tune auto-roaming based on scan results, allow configuring thresholds. Date: Fri, 29 Mar 2019 11:31:27 -0700 Message-Id: <1553884287-23430-1-git-send-email-greearb@candelatech.com> X-Mailer: git-send-email 2.7.5 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190329_113130_222720_42F387FC X-CRM114-Status: GOOD ( 17.36 ) X-Spam-Score: 1.1 (+) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (1.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 1.3 RDNS_NONE Delivered to internal network by a host with no rDNS X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ben Greear MIME-Version: 1.0 Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Ben Greear While trying to force an .11r roam, I noticed that when I scanned, the station went back to the original AP. The RSSI was around -25 for one and -35 for the other, but the RSSI threshold was 5, so it flipped. I believe that the performance difference between RSSI 25 and 35 is negligible, so I modified the algorithm to basically not auto-roam if both signals are good. I'm not certain my new automatic thresholds are perfect, so maybe they need more tuning. At the least, we should not auto roam between an RSSI 25 and RSSI 35 AP based on RSSI. And, allow user overrides in case we want the thresholds even higher. In addition, add a note regarding the estimated bandwidth calculation, as it does not appear to take NSS into account. Signed-off-by: Ben Greear --- wpa_supplicant/config.c | 4 ++++ wpa_supplicant/config.h | 15 +++++++++++++++ wpa_supplicant/events.c | 34 +++++++++++++++++++++++++++------- wpa_supplicant/scan.c | 1 + wpa_supplicant/wpa_supplicant.conf | 9 +++++++++ 5 files changed, 56 insertions(+), 7 deletions(-) diff --git a/wpa_supplicant/config.c b/wpa_supplicant/config.c index 41d71ba..b9728ef 100644 --- a/wpa_supplicant/config.c +++ b/wpa_supplicant/config.c @@ -4174,6 +4174,8 @@ struct wpa_config * wpa_config_alloc_empty(const char *ctrl_interface, config->bss_max_count = DEFAULT_BSS_MAX_COUNT; config->bss_expiration_age = DEFAULT_BSS_EXPIRATION_AGE; config->bss_expiration_scan_count = DEFAULT_BSS_EXPIRATION_SCAN_COUNT; + config->reassoc_throughput_level_th = DEFAULT_REASSOC_THROUGHPUT_THRESHOLD; + config->reassoc_rssi_level_th = DEFAULT_REASSOC_RSSI_THRESHOLD; config->max_num_sta = DEFAULT_MAX_NUM_STA; config->ap_isolate = DEFAULT_AP_ISOLATE; config->access_network_type = DEFAULT_ACCESS_NETWORK_TYPE; @@ -4972,6 +4974,8 @@ static const struct global_parse_data global_fields[] = { { INT(pmf), 0 }, { FUNC(sae_groups), 0 }, { INT(dtim_period), 0 }, + { INT(reassoc_throughput_level_th), 0 }, + { INT(reassoc_rssi_level_th), 0 }, { INT(beacon_int), 0 }, { FUNC(ap_vendor_elements), 0 }, { FUNC(probe_req_ie), 0 }, diff --git a/wpa_supplicant/config.h b/wpa_supplicant/config.h index 7694132..46a6bc9 100644 --- a/wpa_supplicant/config.h +++ b/wpa_supplicant/config.h @@ -31,6 +31,8 @@ #define DEFAULT_BSS_MAX_COUNT 200 #define DEFAULT_BSS_EXPIRATION_AGE 180 #define DEFAULT_BSS_EXPIRATION_SCAN_COUNT 2 +#define DEFAULT_REASSOC_THROUGHPUT_THRESHOLD 5000 +#define DEFAULT_REASSOC_RSSI_THRESHOLD 0 #define DEFAULT_MIN_SCAN_GAP 0 #define DEFAULT_MAX_ASSOC_PER_SCAN 25 #define DEFAULT_DISABLE_ESS_ROAMING 0 @@ -1259,6 +1261,19 @@ struct wpa_config { */ int dtim_period; + + /** + * The throughput difference at which a station will roam based on + * scan results. Set to 5000 for default behaviour. + */ + int reassoc_throughput_level_th; + + /** + * The minimum rssi level difference that can cause a roam based on + * scan results. Set to zero for default behaviour. + */ + int reassoc_rssi_level_th; + /** * beacon_int - Default Beacon interval in TU * diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c index 808c4b2..6153b9a 100644 --- a/wpa_supplicant/events.c +++ b/wpa_supplicant/events.c @@ -1728,10 +1728,12 @@ static int wpa_supplicant_need_to_roam(struct wpa_supplicant *wpa_s, wpa_dbg(wpa_s, MSG_DEBUG, "Considering within-ESS reassociation"); wpa_dbg(wpa_s, MSG_DEBUG, "Current BSS: " MACSTR - " freq=%d level=%d snr=%d est_throughput=%u", + " freq=%d level=%d snr=%d est_throughput=%u throughput_threshold=%d min_rssi_threshold=%d", MAC2STR(current_bss->bssid), current_bss->freq, current_bss->level, - current_bss->snr, current_bss->est_throughput); + current_bss->snr, current_bss->est_throughput, + wpa_s->conf->reassoc_throughput_level_th, + wpa_s->conf->reassoc_rssi_level_th); wpa_dbg(wpa_s, MSG_DEBUG, "Selected BSS: " MACSTR " freq=%d level=%d snr=%d est_throughput=%u", MAC2STR(selected->bssid), selected->freq, selected->level, @@ -1745,9 +1747,11 @@ static int wpa_supplicant_need_to_roam(struct wpa_supplicant *wpa_s, return 1; } - if (selected->est_throughput > current_bss->est_throughput + 5000) { + if (selected->est_throughput > current_bss->est_throughput + wpa_s->conf->reassoc_throughput_level_th) { wpa_dbg(wpa_s, MSG_DEBUG, - "Allow reassociation - selected BSS has better estimated throughput"); + "Allow reassociation - selected BSS has better estimated throughput: %d vs %d, trigger-level: %d", + selected->est_throughput, current_bss->est_throughput, + wpa_s->conf->reassoc_throughput_level_th); return 1; } @@ -1760,9 +1764,11 @@ static int wpa_supplicant_need_to_roam(struct wpa_supplicant *wpa_s, return 0; } - if (current_bss->est_throughput > selected->est_throughput + 5000) { + if (current_bss->est_throughput > selected->est_throughput + wpa_s->conf->reassoc_throughput_level_th) { wpa_dbg(wpa_s, MSG_DEBUG, - "Skip roam - Current BSS has better estimated throughput"); + "Skip roam - Current BSS has good enough estimated throughput: %d vs %d, trigger-level: %d", + current_bss->est_throughput, selected->est_throughput, + wpa_s->conf->reassoc_throughput_level_th); return 0; } @@ -1778,8 +1784,17 @@ static int wpa_supplicant_need_to_roam(struct wpa_supplicant *wpa_s, min_diff = 3; else if (current_bss->level < -70) min_diff = 4; - else + else if (current_bss->level < -60) min_diff = 5; + else if (current_bss->level < -50) + min_diff = 8; + else if (current_bss->level < -40) + min_diff = 10; + else if (current_bss->level < -30) + min_diff = 20; + else + min_diff = 30; + if (cur_est > sel_est * 1.5) min_diff += 10; else if (cur_est > sel_est * 1.2) @@ -1805,6 +1820,11 @@ static int wpa_supplicant_need_to_roam(struct wpa_supplicant *wpa_s, else min_diff = 0; } + + /* Let user override this so we can force roaming and still scan. */ + if (wpa_s->conf->reassoc_rssi_level_th > min_diff) + min_diff = wpa_s->conf->reassoc_rssi_level_th; + diff = abs(current_bss->level - selected->level); if (diff < min_diff) { wpa_dbg(wpa_s, MSG_DEBUG, diff --git a/wpa_supplicant/scan.c b/wpa_supplicant/scan.c index 1442823..4fbbf1a 100644 --- a/wpa_supplicant/scan.c +++ b/wpa_supplicant/scan.c @@ -2383,6 +2383,7 @@ void scan_est_throughput(struct wpa_supplicant *wpa_s, } } + /* TODO: Take number of spatial streams into account */ /* TODO: channel utilization and AP load (e.g., from AP Beacon) */ res->est_throughput = est; diff --git a/wpa_supplicant/wpa_supplicant.conf b/wpa_supplicant/wpa_supplicant.conf index 957838d..fd6b89e 100644 --- a/wpa_supplicant/wpa_supplicant.conf +++ b/wpa_supplicant/wpa_supplicant.conf @@ -1415,6 +1415,15 @@ fast_reauth=1 # Beacon interval (default: 100 TU) #beacon_int=100 +# RSSI threshold for making automatic roam decisions based on RSSI +# The supplicant tries to make a good decision on this already, so the +# setting below sets the lower-level of the threshold, not the upper. +#reassoc_rssi_level_th=0 + +# Estimated throughput threshold for making automatic roam decisions based on RSSI +# The default is 5000. +#reassoc_throughput_level_th=5000 + # WPS in AP mode # 0 = WPS enabled and configured (default) # 1 = WPS disabled