datastorage: use signal strength as a metric

This adds a few options to use the signal strength as a metric, band
dependent:

 - rssi_weight: every db of signal increases the score by this much.
 - rssi_center: if the signal is stronger than this, the score becomes
                positive; below this, it is negative.
 - initial_score:  since we are capping negative scores, it may be
   beneficial to have a positive base score to offset a possible
   negative signal value.  This is replacing the 'freq' metric.

To avoid a single-digit RSSI increase resulting in a kick, we add a
global threshold value to act as a buffer:

 - kicking_threshold: a candidate AP must have a score larger than that
                      of the current AP plus the value here.

The kicking_threshold also applies when assembling the list of roaming
neighbors we send with the "wnm_disassoc_imminent" command.

Signed-off-by: Eneas U de Queiroz <cotequeiroz@gmail.com>
This commit is contained in:
Eneas U de Queiroz 2021-08-04 09:11:06 -03:00 committed by Polynomdivision
parent 14e0f8386c
commit c70773a171
6 changed files with 89 additions and 32 deletions

View file

@ -244,7 +244,7 @@ struct probe_metric_s uci_get_dawn_metric() {
.no_vht_support = { 0, 0 },
.rssi = { 10, 10 },
.rssi_val = { -60, -60 },
.freq = { 0, 100 },
.initial_score = { 0, 100 },
.chan_util = { 0, 0 },
.max_chan_util = { -500, -500 },
.chan_util_val = { 140, 140 },
@ -267,6 +267,7 @@ struct probe_metric_s uci_get_dawn_metric() {
if (global_s) {
// True global configuration
DAWN_SET_CONFIG_INT(ret, global_s, kicking);
DAWN_SET_CONFIG_INT(ret, global_s, kicking_threshold);
DAWN_SET_CONFIG_INT(ret, global_s, min_probe_count);
DAWN_SET_CONFIG_INT(ret, global_s, use_station_count);
DAWN_SET_CONFIG_INT(ret, global_s, eval_auth_req);
@ -291,6 +292,7 @@ struct probe_metric_s uci_get_dawn_metric() {
ret.neighbors[band] = uci_lookup_mac_list(neighbors ? : global_neighbors);
}
DAWN_SET_BANDS_CONFIG_INT(ret, global_s, band_s, initial_score);
DAWN_SET_BANDS_CONFIG_INT(ret, global_s, band_s, ap_weight);
DAWN_SET_BANDS_CONFIG_INT(ret, global_s, band_s, ht_support);
DAWN_SET_BANDS_CONFIG_INT(ret, global_s, band_s, vht_support);
@ -298,13 +300,14 @@ struct probe_metric_s uci_get_dawn_metric() {
DAWN_SET_BANDS_CONFIG_INT(ret, global_s, band_s, no_vht_support);
DAWN_SET_BANDS_CONFIG_INT(ret, global_s, band_s, rssi);
DAWN_SET_BANDS_CONFIG_INT(ret, global_s, band_s, rssi_val);
DAWN_SET_BANDS_CONFIG_INT(ret, global_s, band_s, freq);
DAWN_SET_BANDS_CONFIG_INT(ret, global_s, band_s, chan_util);
DAWN_SET_BANDS_CONFIG_INT(ret, global_s, band_s, max_chan_util);
DAWN_SET_BANDS_CONFIG_INT(ret, global_s, band_s, chan_util_val);
DAWN_SET_BANDS_CONFIG_INT(ret, global_s, band_s, max_chan_util_val);
DAWN_SET_BANDS_CONFIG_INT(ret, global_s, band_s, low_rssi);
DAWN_SET_BANDS_CONFIG_INT(ret, global_s, band_s, low_rssi_val);
DAWN_SET_BANDS_CONFIG_INT(ret, global_s, band_s, rssi_weight);
DAWN_SET_BANDS_CONFIG_INT(ret, global_s, band_s, rssi_center);
return ret;
}

View file

@ -580,6 +580,7 @@ enum {
UCI_EVAL_AUTH_REQ,
UCI_EVAL_ASSOC_REQ,
UCI_KICKING,
UCI_KICKING_THRESHOLD,
UCI_DENY_AUTH_REASON,
UCI_DENY_ASSOC_REASON,
UCI_USE_DRIVER_RECOG,
@ -594,7 +595,7 @@ enum {
enum {
UCI_BAND,
UCI_FREQ,
UCI_INITIAL_SCORE,
UCI_AP_WEIGHT,
UCI_HT_SUPPORT,
UCI_VHT_SUPPORT,
@ -608,6 +609,8 @@ enum {
UCI_LOW_RSSI_VAL,
UCI_CHAN_UTIL_VAL,
UCI_MAX_CHAN_UTIL_VAL,
UCI_RSSI_WEIGHT,
UCI_RSSI_CENTER,
__UCI_BAND_METRIC_MAX
};
@ -639,6 +642,7 @@ static const struct blobmsg_policy uci_metric_policy[__UCI_METRIC_MAX] = {
[UCI_EVAL_AUTH_REQ] = {.name = "eval_auth_req", .type = BLOBMSG_TYPE_INT32},
[UCI_EVAL_ASSOC_REQ] = {.name = "eval_assoc_req", .type = BLOBMSG_TYPE_INT32},
[UCI_KICKING] = {.name = "kicking", .type = BLOBMSG_TYPE_INT32},
[UCI_KICKING_THRESHOLD] = {.name = "kicking_threshold", .type = BLOBMSG_TYPE_INT32},
[UCI_DENY_AUTH_REASON] = {.name = "deny_auth_reason", .type = BLOBMSG_TYPE_INT32},
[UCI_DENY_ASSOC_REASON] = {.name = "deny_assoc_reason", .type = BLOBMSG_TYPE_INT32},
[UCI_USE_DRIVER_RECOG] = {.name = "use_driver_recog", .type = BLOBMSG_TYPE_INT32},
@ -651,7 +655,7 @@ static const struct blobmsg_policy uci_metric_policy[__UCI_METRIC_MAX] = {
};
static const struct blobmsg_policy uci_band_metric_policy[__UCI_METRIC_MAX] = {
[UCI_FREQ] = {.name = "freq", .type = BLOBMSG_TYPE_INT32},
[UCI_INITIAL_SCORE] = {.name = "initial_score", .type = BLOBMSG_TYPE_INT32},
[UCI_HT_SUPPORT] = {.name = "ht_support", .type = BLOBMSG_TYPE_INT32},
[UCI_VHT_SUPPORT] = {.name = "vht_support", .type = BLOBMSG_TYPE_INT32},
[UCI_NO_HT_SUPPORT] = {.name = "no_ht_support", .type = BLOBMSG_TYPE_INT32},
@ -664,6 +668,8 @@ static const struct blobmsg_policy uci_band_metric_policy[__UCI_METRIC_MAX] = {
[UCI_MAX_CHAN_UTIL] = {.name = "max_chan_util", .type = BLOBMSG_TYPE_INT32},
[UCI_CHAN_UTIL_VAL] = {.name = "chan_util_val", .type = BLOBMSG_TYPE_INT32},
[UCI_MAX_CHAN_UTIL_VAL] = {.name = "max_chan_util_val", .type = BLOBMSG_TYPE_INT32},
[UCI_RSSI_WEIGHT] = {.name = "rssi_weight", .type = BLOBMSG_TYPE_INT32},
[UCI_RSSI_CENTER] = {.name = "rssi_center", .type = BLOBMSG_TYPE_INT32},
};
static const struct blobmsg_policy uci_times_policy[__UCI_TIMES_MAX] = {
@ -723,6 +729,9 @@ static int handle_uci_config(struct blob_attr* msg) {
sprintf(cmd_buffer, "dawn.global.kicking=%d", blobmsg_get_u32(tb_metric[UCI_KICKING]));
uci_set_network(cmd_buffer);
sprintf(cmd_buffer, "dawn.global.kicking_threshold=%d", blobmsg_get_u32(tb_metric[UCI_KICKING_THRESHOLD]));
uci_set_network(cmd_buffer);
sprintf(cmd_buffer, "dawn.global.deny_auth_reason=%d", blobmsg_get_u32(tb_metric[UCI_DENY_AUTH_REASON]));
uci_set_network(cmd_buffer);
@ -770,7 +779,7 @@ static int handle_uci_config(struct blob_attr* msg) {
sprintf(cmd_buffer, "dawn.%s=metric", band_name);
uci_set_network(cmd_buffer);
sprintf(cmd_buffer, "dawn.%s.freq=%d", band_name, blobmsg_get_u32(tb_band_metric[UCI_FREQ]));
sprintf(cmd_buffer, "dawn.%s.initial_score=%d", band_name, blobmsg_get_u32(tb_band_metric[UCI_INITIAL_SCORE]));
uci_set_network(cmd_buffer);
sprintf(cmd_buffer, "dawn.%s.ht_support=%d", band_name, blobmsg_get_u32(tb_band_metric[UCI_HT_SUPPORT]));
@ -808,6 +817,12 @@ static int handle_uci_config(struct blob_attr* msg) {
sprintf(cmd_buffer, "dawn.%s.max_chan_util_val=%d", band_name, blobmsg_get_u32(tb_band_metric[UCI_MAX_CHAN_UTIL_VAL]));
uci_set_network(cmd_buffer);
sprintf(cmd_buffer, "dawn.%s.rssi_weight=%d", band_name, blobmsg_get_u32(tb_band_metric[UCI_RSSI_WEIGHT]));
uci_set_network(cmd_buffer);
sprintf(cmd_buffer, "dawn.%s.rssi_center=%d", band_name, blobmsg_get_u32(tb_band_metric[UCI_RSSI_CENTER]));
uci_set_network(cmd_buffer);
}
struct blob_attr* tb_times[__UCI_TIMES_MAX];

View file

@ -1448,6 +1448,7 @@ int uci_send_via_network()
blobmsg_add_u32(&b, "eval_auth_req", dawn_metric.eval_auth_req);
blobmsg_add_u32(&b, "eval_assoc_req", dawn_metric.eval_assoc_req);
blobmsg_add_u32(&b, "kicking", dawn_metric.kicking);
blobmsg_add_u32(&b, "kicking_threshold", dawn_metric.kicking_threshold);
blobmsg_add_u32(&b, "deny_auth_reason", dawn_metric.deny_auth_reason);
blobmsg_add_u32(&b, "deny_assoc_reason", dawn_metric.deny_assoc_reason);
blobmsg_add_u32(&b, "use_driver_recog", dawn_metric.use_driver_recog);
@ -1460,6 +1461,7 @@ int uci_send_via_network()
for (int band=0; band < __DAWN_BAND_MAX; band++) {
band_entry = blobmsg_open_table(&b, band_config_name[band]);
blobmsg_add_u32(&b, "initial_score", dawn_metric.initial_score[band]);
blobmsg_add_u32(&b, "ap_weight", dawn_metric.ap_weight[band]);
blobmsg_add_u32(&b, "ht_support", dawn_metric.ht_support[band]);
blobmsg_add_u32(&b, "vht_support", dawn_metric.vht_support[band]);
@ -1469,11 +1471,12 @@ int uci_send_via_network()
blobmsg_add_u32(&b, "rssi_val", dawn_metric.rssi_val[band]);
blobmsg_add_u32(&b, "low_rssi", dawn_metric.low_rssi[band]);
blobmsg_add_u32(&b, "low_rssi_val", dawn_metric.low_rssi_val[band]);
blobmsg_add_u32(&b, "freq", dawn_metric.freq[band]);
blobmsg_add_u32(&b, "chan_util", dawn_metric.chan_util[band]);
blobmsg_add_u32(&b, "max_chan_util", dawn_metric.max_chan_util[band]);
blobmsg_add_u32(&b, "chan_util_val", dawn_metric.chan_util_val[band]);
blobmsg_add_u32(&b, "max_chan_util_val", dawn_metric.max_chan_util_val[band]);
blobmsg_add_u32(&b, "rssi_weight", dawn_metric.rssi_weight[band]);
blobmsg_add_u32(&b, "rssi_center", dawn_metric.rssi_center[band]);
blobmsg_close_table(&b, band_entry);
}
blobmsg_close_table(&b, band_table);