From c387a59f33197406113a69743a7f9374d12d1cd9 Mon Sep 17 00:00:00 2001 From: PolynomialDivision Date: Mon, 18 Sep 2017 20:51:19 +0200 Subject: [PATCH] Try to fix metric --- files/dawn.config | 3 ++- src/include/datastorage.h | 2 ++ src/storage/datastorage.c | 8 ++------ src/utils/dawn_uci.c | 20 +++++++++++++++++++- 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/files/dawn.config b/files/dawn.config index f0f4864..f83c9c7 100644 --- a/files/dawn.config +++ b/files/dawn.config @@ -18,4 +18,5 @@ config settings metric option rssi '10' option freq '50' option chan_util '0' - + option max_chan_util '100' + option min_rssi '-60' \ No newline at end of file diff --git a/src/include/datastorage.h b/src/include/datastorage.h index a4f576d..ebd623a 100644 --- a/src/include/datastorage.h +++ b/src/include/datastorage.h @@ -23,6 +23,8 @@ struct probe_metric_s { int rssi; int freq; int chan_util; + int max_chan_util; + int min_rssi; }; #define SORT_NUM 5 diff --git a/src/storage/datastorage.c b/src/storage/datastorage.c index e599c11..e8b1fd0 100644 --- a/src/storage/datastorage.c +++ b/src/storage/datastorage.c @@ -48,16 +48,12 @@ int eval_probe_metric(struct probe_entry_s probe_entry) { score += !probe_entry.ht_support && !ap_entry.ht ? dawn_metric.no_ht_support : 0; score += probe_entry.vht_support ? dawn_metric.vht_support : 0; score += !probe_entry.vht_support && !ap_entry.vht ? dawn_metric.no_vht_support : 0; + score += ap_entry.channel_utilization <= dawn_metric.max_chan_util ? dawn_metric.chan_util : 0; } - //score += probe_entry.ht_support ? dawn_metric.ht_support : 0; - //score += !probe_entry.ht_support && !ap_entry.ht ? dawn_metric.n_ht_support : 0; - //score += probe_entry.vht_support ? dawn_metric.vht_support : 0; - score += (probe_entry.freq > 5000) ? dawn_metric.freq : 0; - score += (probe_entry.signal > -60) ? dawn_metric.rssi : 0; + score += (probe_entry.signal >= dawn_metric.min_rssi) ? dawn_metric.rssi : 0; - // TODO: Add minimal rssi threshold printf("SCORE: %d\n", score); print_probe_entry(probe_entry); diff --git a/src/utils/dawn_uci.c b/src/utils/dawn_uci.c index 277a862..03288b1 100644 --- a/src/utils/dawn_uci.c +++ b/src/utils/dawn_uci.c @@ -54,7 +54,7 @@ struct probe_metric_s uci_get_dawn_metric() if(ptr.o->type == UCI_TYPE_STRING) ret.no_vht_support = atoi(ptr.o->v.string); - char tmp_rssi[] = "dawn.metric.freq"; + char tmp_rssi[] = "dawn.metric.rssi"; if (uci_lookup_ptr (c, &ptr, tmp_rssi, 1) != UCI_OK) { uci_perror(c, "uci_get_daw_metric Error"); return ret; @@ -78,6 +78,24 @@ struct probe_metric_s uci_get_dawn_metric() if(ptr.o->type == UCI_TYPE_STRING) ret.chan_util = atoi(ptr.o->v.string); + char tmp_min_rssi[] = "dawn.metric.min_rssi"; + if (uci_lookup_ptr (c, &ptr, tmp_min_rssi, 1) != UCI_OK) { + uci_perror(c, "uci_get_daw_metric Error"); + return ret; + } + if(ptr.o->type == UCI_TYPE_STRING) + ret.min_rssi = atoi(ptr.o->v.string); + + char tmp_max_chan_util[] = "dawn.metric.max_chan_util"; + if (uci_lookup_ptr (c, &ptr, tmp_max_chan_util, 1) != UCI_OK) { + uci_perror(c, "uci_get_daw_metric Error"); + return ret; + } + if(ptr.o->type == UCI_TYPE_STRING) + ret.max_chan_util = atoi(ptr.o->v.string); + + printf("Loaded metric: %d, %d\n", ret.min_rssi, ret.max_chan_util); + uci_free_context (c); return ret;