[PATCH] Improve roaming logic

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Currently, wpa_supplicant roams too aggressively; the need_to_roam()
function will return early with a roaming decision if the difference
in signal level or throughput between the current and selected APs
is "sufficiently large." In particular, if the selected AP's
estimated throughput is more than 5k greater than the current AP's
estimated throughput, supplicant will decide to roam. Otherwise, if
the selected AP's signal level is less than the current AP's signal
level, or the selected AP's estimated throughput is at least 5k
less than the current AP's estimated throughput, supplicant will
skip the roam. These decisions are based only on one factor and can
lead to poor roaming choices (e.g. a roam should not happen if the
selected AP's estimated througput meets the threshold but the
current signal and throughput are already good, whereas a roam
should happen if the signal is slightly worse but the estimated
throughput is significantly better).

This change standardizes the roaming heuristic and will hopefully
improve user WiFi experience. The change can be summarized as
follows: based on the current signal level, a certain roaming
difficulty is assigned. Based on the selected AP's estimated
throughput relative to the current AP's estimated throughput, the
difficulty is adjusted up or down. If the difference in signal
level meets the threshold, a roam happens.

The hard-coded values were selected purely based on the previous
version of this function. They may eventually need to be fine-tuned
for optimal performance.

Signed-off-by: Matthew Wang <matthewmwang@xxxxxxxxxxxx>
---
 wpa_supplicant/events.c | 65 +++++++++++++----------------------------
 1 file changed, 21 insertions(+), 44 deletions(-)

diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c
index 66d9f88db..a095ee02f 100644
--- a/wpa_supplicant/events.c
+++ b/wpa_supplicant/events.c
@@ -1683,27 +1683,8 @@ static int wpa_supplicant_need_to_roam(struct wpa_supplicant *wpa_s,
 		return 1;
 	}
 
-	if (selected->est_throughput > current_bss->est_throughput + 5000) {
-		wpa_dbg(wpa_s, MSG_DEBUG,
-			"Allow reassociation - selected BSS has better estimated throughput");
-		return 1;
-	}
-
 	to_5ghz = selected->freq > 4000 && current_bss->freq < 4000;
 
-	if (current_bss->level < 0 &&
-	    current_bss->level > selected->level + to_5ghz * 2) {
-		wpa_dbg(wpa_s, MSG_DEBUG, "Skip roam - Current BSS has better "
-			"signal level");
-		return 0;
-	}
-
-	if (current_bss->est_throughput > selected->est_throughput + 5000) {
-		wpa_dbg(wpa_s, MSG_DEBUG,
-			"Skip roam - Current BSS has better estimated throughput");
-		return 0;
-	}
-
 	cur_est = current_bss->est_throughput;
 	sel_est = selected->est_throughput;
 	min_diff = 2;
@@ -1718,32 +1699,28 @@ static int wpa_supplicant_need_to_roam(struct wpa_supplicant *wpa_s,
 			min_diff = 4;
 		else
 			min_diff = 5;
-		if (cur_est > sel_est * 1.5)
-			min_diff += 10;
-		else if (cur_est > sel_est * 1.2)
-			min_diff += 5;
-		else if (cur_est > sel_est * 1.1)
-			min_diff += 2;
-		else if (cur_est > sel_est)
-			min_diff++;
-	}
-	if (to_5ghz) {
-		int reduce = 2;
-
-		/* Make it easier to move to 5 GHz band */
-		if (sel_est > cur_est * 1.5)
-			reduce = 5;
-		else if (sel_est > cur_est * 1.2)
-			reduce = 4;
-		else if (sel_est > cur_est * 1.1)
-			reduce = 3;
-
-		if (min_diff > reduce)
-			min_diff -= reduce;
-		else
-			min_diff = 0;
 	}
-	diff = abs(current_bss->level - selected->level);
+
+	if (cur_est > sel_est * 1.5)
+		min_diff += 10;
+	else if (cur_est > sel_est * 1.2)
+		min_diff += 5;
+	else if (cur_est > sel_est * 1.1)
+		min_diff += 2;
+	else if (cur_est > sel_est)
+		min_diff++;
+	else if (sel_est > cur_est * 1.5)
+		min_diff -= 10;
+	else if (sel_est > cur_est * 1.2)
+		min_diff -= 5;
+	else if (sel_est > cur_est * 1.1)
+		min_diff -= 2;
+	else if (sel_est > cur_est)
+		min_diff--;
+
+	if (to_5ghz)
+		min_diff -= 2;
+	diff = selected->level - current_bss->level;
 	if (diff < min_diff) {
 		wpa_dbg(wpa_s, MSG_DEBUG,
 			"Skip roam - too small difference in signal level (%d < %d)",
-- 
2.18.0.203.gfac676dfb9-goog


_______________________________________________
Hostap mailing list
Hostap@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/hostap



[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux