From 05565ae1e2558593a51bf830020fa48888a3e110 Mon Sep 17 00:00:00 2001 From: Polynomialdivision Date: Sun, 6 Sep 2020 23:14:44 +0200 Subject: [PATCH] datastorage/uci/msghandler/ubus: add steering with beacon reports The AP periodically asks all clients in the environment with what signal strength they see the other APs. Instead of the RSSI, which can only be collected if the client scans, the 802.11k values are much more up-to-date. In the future it will no longer be necessary to exchange all probe request frames with all APs, which will significantly reduce the message overhead and complexity. Right now there is the issue that clients react very strangely to becaon requests or they do not react at all. The client will hopefully report back the RCPI or the RSNI. Theoretically the values can be converted into each other and so compared, but this did not work well in self-experiments. Therefore, we compare the values like the rssi. We introduce - rcpi: value that is added to the AP score if rcpi is above rcpi_val - rcpi_val: threshold that indicates a good rcpi value (between 0 and 255) - low_rcpi: value that is added to the AP score if rcpi is under low_rcpi_val (use a negative value) - low_rcpi_val: threshold that indicates a bad rcpi value (between 0 and 255) - rsni: value that is added to the AP score if rsni is above rsni_val - rsni_val: threshold that indicates a good rsni value (between 0 and 255) - low_rsni: value that is added to the AP score if rsni is under low_rsni_val (use a negative value) - low_rsni_val: threshold that indicates a bad rsni value (between 0 and 255) I have to find out values for each parameter myself. So please take a look at the dawn-hearingmap and if you have a good setting, you can send it to me. --- src/include/datastorage.h | 8 ++++++++ src/storage/datastorage.c | 17 +++++++++++++++-- src/utils/dawn_uci.c | 8 ++++++++ src/utils/msghandler.c | 16 ++++++++++++++++ src/utils/ubus.c | 8 ++++++++ 5 files changed, 55 insertions(+), 2 deletions(-) diff --git a/src/include/datastorage.h b/src/include/datastorage.h index 043047f..3410f2a 100644 --- a/src/include/datastorage.h +++ b/src/include/datastorage.h @@ -52,11 +52,19 @@ struct probe_metric_s { int no_vht_support; // eval_probe_metric()() int rssi; // eval_probe_metric()() int low_rssi; // eval_probe_metric()() + int rcpi; // eval_probe_metric()() + int low_rcpi; // eval_probe_metric()() + int rsni; // eval_probe_metric()() + int low_rsni; // eval_probe_metric()() int freq; // eval_probe_metric()() int chan_util; // eval_probe_metric()() int max_chan_util; // eval_probe_metric()() int rssi_val; // eval_probe_metric()() int low_rssi_val; // eval_probe_metric()() + int rcpi_val; // eval_probe_metric()() + int low_rcpi_val; // eval_probe_metric()() + int rsni_val; // eval_probe_metric()() + int low_rsni_val; // eval_probe_metric()() int chan_util_val; // eval_probe_metric()() int max_chan_util_val; // eval_probe_metric()() int min_probe_count; diff --git a/src/storage/datastorage.c b/src/storage/datastorage.c index ae84588..d9fb9a3 100644 --- a/src/storage/datastorage.c +++ b/src/storage/datastorage.c @@ -426,8 +426,21 @@ int eval_probe_metric(struct probe_entry_s* probe_entry, ap* ap_entry) { // TODO: Should RCPI be used here as well? // TODO: Should this be more scaled? Should -63dB on current and -77dB on other both score 0 if low / high are -80db and -60dB? // TODO: That then lets device capabilites dominate score - making them more important than RSSI difference of 14dB. - score += (probe_entry->signal >= dawn_metric.rssi_val) ? dawn_metric.rssi : 0; - score += (probe_entry->signal <= dawn_metric.low_rssi_val) ? dawn_metric.low_rssi : 0; + if (probe_entry->rcpi != -1) // -1 currently magic number + { + score += (probe_entry->rcpi >= dawn_metric.rcpi_val) ? dawn_metric.rcpi : 0; + score += (probe_entry->rcpi <= dawn_metric.low_rcpi_val) ? dawn_metric.low_rcpi : 0; + } + else if(probe_entry->rsni != -1) + { + score += (probe_entry->rsni >= dawn_metric.rsni_val) ? dawn_metric.rsni : 0; + score += (probe_entry->rsni <= dawn_metric.low_rsni_val) ? dawn_metric.low_rsni : 0; + } + else //rssi is just fallback + { + score += (probe_entry->signal >= dawn_metric.rssi_val) ? dawn_metric.rssi : 0; + score += (probe_entry->signal <= dawn_metric.low_rssi_val) ? dawn_metric.low_rssi : 0; + } // TODO: This magic value never checked by caller. What does it achieve? if (score < 0) diff --git a/src/utils/dawn_uci.c b/src/utils/dawn_uci.c index ea65388..659cec6 100644 --- a/src/utils/dawn_uci.c +++ b/src/utils/dawn_uci.c @@ -93,15 +93,23 @@ struct probe_metric_s uci_get_dawn_metric() { ret.no_ht_support = uci_lookup_option_int(uci_ctx, s, "no_ht_support"); ret.no_vht_support = uci_lookup_option_int(uci_ctx, s, "no_vht_support"); ret.rssi = uci_lookup_option_int(uci_ctx, s, "rssi"); + ret.rcpi = uci_lookup_option_int(uci_ctx, s, "rcpi"); + ret.rsni = uci_lookup_option_int(uci_ctx, s, "rsni"); ret.freq = uci_lookup_option_int(uci_ctx, s, "freq"); ret.rssi_val = uci_lookup_option_int(uci_ctx, s, "rssi_val"); + ret.rcpi_val = uci_lookup_option_int(uci_ctx, s, "rcpi_val"); + ret.rsni_val = uci_lookup_option_int(uci_ctx, s, "rsni_val"); ret.chan_util = uci_lookup_option_int(uci_ctx, s, "chan_util"); ret.max_chan_util = uci_lookup_option_int(uci_ctx, s, "max_chan_util"); ret.chan_util_val = uci_lookup_option_int(uci_ctx, s, "chan_util_val"); ret.max_chan_util_val = uci_lookup_option_int(uci_ctx, s, "max_chan_util_val"); ret.min_probe_count = uci_lookup_option_int(uci_ctx, s, "min_probe_count"); ret.low_rssi = uci_lookup_option_int(uci_ctx, s, "low_rssi"); + ret.low_rcpi = uci_lookup_option_int(uci_ctx, s, "low_rcpi"); + ret.low_rsni = uci_lookup_option_int(uci_ctx, s, "low_rsni"); ret.low_rssi_val = uci_lookup_option_int(uci_ctx, s, "low_rssi_val"); + ret.low_rcpi_val = uci_lookup_option_int(uci_ctx, s, "low_rcpi_val"); + ret.low_rsni_val = uci_lookup_option_int(uci_ctx, s, "low_rsni_val"); ret.bandwidth_threshold = uci_lookup_option_int(uci_ctx, s, "bandwidth_threshold"); ret.use_station_count = uci_lookup_option_int(uci_ctx, s, "use_station_count"); ret.eval_probe_req = uci_lookup_option_int(uci_ctx, s, "eval_probe_req"); diff --git a/src/utils/msghandler.c b/src/utils/msghandler.c index 9315d47..f117b8c 100644 --- a/src/utils/msghandler.c +++ b/src/utils/msghandler.c @@ -579,11 +579,19 @@ enum { UCI_NO_VHT_SUPPORT, UCI_RSSI, UCI_LOW_RSSI, + UCI_RCPI, + UCI_LOW_RCPI, + UCI_RSNI, + UCI_LOW_RSNI, UCI_FREQ, UCI_CHAN_UTIL, UCI_MAX_CHAN_UTIL, UCI_RSSI_VAL, UCI_LOW_RSSI_VAL, + UCI_RCPI_VAL, + UCI_LOW_RCPI_VAL, + UCI_RSNI_VAL, + UCI_LOW_RSNI_VAL, UCI_CHAN_UTIL_VAL, UCI_MAX_CHAN_UTIL_VAL, UCI_MIN_PROBE_COUNT, @@ -632,11 +640,19 @@ static const struct blobmsg_policy uci_metric_policy[__UCI_METIC_MAX] = { [UCI_NO_VHT_SUPPORT] = {.name = "no_vht_support", .type = BLOBMSG_TYPE_INT32}, [UCI_RSSI] = {.name = "rssi", .type = BLOBMSG_TYPE_INT32}, [UCI_LOW_RSSI] = {.name = "low_rssi", .type = BLOBMSG_TYPE_INT32}, + [UCI_RCPI] = {.name = "rcpi", .type = BLOBMSG_TYPE_INT32}, + [UCI_LOW_RCPI] = {.name = "low_rcpi", .type = BLOBMSG_TYPE_INT32}, + [UCI_RSNI] = {.name = "rsni", .type = BLOBMSG_TYPE_INT32}, + [UCI_LOW_RSNI] = {.name = "low_rsni", .type = BLOBMSG_TYPE_INT32}, [UCI_FREQ] = {.name = "freq", .type = BLOBMSG_TYPE_INT32}, [UCI_CHAN_UTIL] = {.name = "chan_util", .type = BLOBMSG_TYPE_INT32}, [UCI_MAX_CHAN_UTIL] = {.name = "max_chan_util", .type = BLOBMSG_TYPE_INT32}, [UCI_RSSI_VAL] = {.name = "rssi_val", .type = BLOBMSG_TYPE_INT32}, [UCI_LOW_RSSI_VAL] = {.name = "low_rssi_val", .type = BLOBMSG_TYPE_INT32}, + [UCI_RCPI_VAL] = {.name = "rcpi_val", .type = BLOBMSG_TYPE_INT32}, + [UCI_LOW_RCPI_VAL] = {.name = "low_rcpi_val", .type = BLOBMSG_TYPE_INT32}, + [UCI_RSNI_VAL] = {.name = "rsni_val", .type = BLOBMSG_TYPE_INT32}, + [UCI_LOW_RSNI_VAL] = {.name = "low_rsni_val", .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_MIN_PROBE_COUNT] = {.name = "min_probe_count", .type = BLOBMSG_TYPE_INT32}, diff --git a/src/utils/ubus.c b/src/utils/ubus.c index 3f2b799..8deade9 100644 --- a/src/utils/ubus.c +++ b/src/utils/ubus.c @@ -1332,6 +1332,10 @@ int uci_send_via_network() blobmsg_add_u32(&b, "no_vht_support", dawn_metric.no_vht_support); blobmsg_add_u32(&b, "rssi", dawn_metric.rssi); blobmsg_add_u32(&b, "low_rssi", dawn_metric.low_rssi); + blobmsg_add_u32(&b, "rcpi", dawn_metric.rcpi); + blobmsg_add_u32(&b, "low_rcpi", dawn_metric.low_rcpi); + blobmsg_add_u32(&b, "rsni", dawn_metric.rsni); + blobmsg_add_u32(&b, "low_rsni", dawn_metric.low_rsni); blobmsg_add_u32(&b, "freq", dawn_metric.freq); blobmsg_add_u32(&b, "chan_util", dawn_metric.chan_util); @@ -1339,6 +1343,10 @@ int uci_send_via_network() blobmsg_add_u32(&b, "max_chan_util", dawn_metric.max_chan_util); blobmsg_add_u32(&b, "rssi_val", dawn_metric.rssi_val); blobmsg_add_u32(&b, "low_rssi_val", dawn_metric.low_rssi_val); + blobmsg_add_u32(&b, "rcpi_val", dawn_metric.rcpi_val); + blobmsg_add_u32(&b, "low_rcpi_val", dawn_metric.low_rcpi_val); + blobmsg_add_u32(&b, "rsni_val", dawn_metric.rsni_val); + blobmsg_add_u32(&b, "low_rsni_val", dawn_metric.low_rsni_val); blobmsg_add_u32(&b, "chan_util_val", dawn_metric.chan_util_val); blobmsg_add_u32(&b, "max_chan_util_val", dawn_metric.max_chan_util_val); blobmsg_add_u32(&b, "min_probe_count", dawn_metric.min_probe_count);