mirror of
https://github.com/berlin-open-wireless-lab/DAWN.git
synced 2025-03-09 15:40:12 +00:00
average channel utilization
This commit is contained in:
parent
c32351f0e5
commit
dc15ba9fa1
5 changed files with 38 additions and 4 deletions
|
@ -23,6 +23,7 @@ config times
|
|||
option remove_ap '460'
|
||||
option update_hostapd '10'
|
||||
option update_tcp_con '10'
|
||||
option update_chan_util '5'
|
||||
|
||||
config metric
|
||||
option ht_support '10'
|
||||
|
@ -49,3 +50,4 @@ config metric
|
|||
option deny_assoc_reason '17' # assoc rejected can't handle new station
|
||||
option use_driver_recog '1'
|
||||
option min_number_to_kick '3'
|
||||
option chan_util_avg_period '3'
|
||||
|
|
|
@ -60,6 +60,7 @@ struct probe_metric_s {
|
|||
int deny_assoc_reason;
|
||||
int use_driver_recog;
|
||||
int min_kick_count;
|
||||
int chan_util_avg_period;
|
||||
};
|
||||
|
||||
struct time_config_s {
|
||||
|
@ -70,6 +71,7 @@ struct time_config_s {
|
|||
time_t update_hostapd;
|
||||
time_t update_tcp_con;
|
||||
time_t denied_req_threshold;
|
||||
time_t update_chan_util;
|
||||
};
|
||||
|
||||
struct network_config_s {
|
||||
|
|
|
@ -296,8 +296,11 @@ int get_channel_utilization(const char *ifname, uint64_t *last_channel_time, uin
|
|||
printf("last_channel_time_busy: %llu\n", *last_channel_time_busy);
|
||||
|
||||
printf("GOT SURVEY INFO!\n");
|
||||
return (int)(dividend * 255 / divisor);
|
||||
int ret = 0;
|
||||
if(divisor)
|
||||
ret = (int)(dividend * 255 / divisor);
|
||||
iwinfo_finish();
|
||||
return ret;
|
||||
}
|
||||
|
||||
int support_ht(const char *ifname) {
|
||||
|
|
|
@ -32,6 +32,7 @@ struct time_config_s uci_get_time_config() {
|
|||
ret.remove_ap = uci_lookup_option_int(uci_ctx, s, "remove_ap");
|
||||
ret.update_tcp_con = uci_lookup_option_int(uci_ctx, s, "update_tcp_con");
|
||||
ret.denied_req_threshold = uci_lookup_option_int(uci_ctx, s, "denied_req_threshold");
|
||||
ret.update_chan_util = uci_lookup_option_int(uci_ctx, s, "update_chan_util");
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
@ -72,6 +73,7 @@ struct probe_metric_s uci_get_dawn_metric() {
|
|||
ret.max_station_diff = uci_lookup_option_int(uci_ctx, s, "max_station_diff");
|
||||
ret.use_driver_recog = uci_lookup_option_int(uci_ctx, s, "use_driver_recog");
|
||||
ret.min_kick_count = uci_lookup_option_int(uci_ctx, s, "min_number_to_kick");
|
||||
ret.chan_util_avg_period = uci_lookup_option_int(uci_ctx, s, "chan_util_avg_period");
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,6 +37,8 @@ void update_clients(struct uloop_timeout *t);
|
|||
|
||||
void update_tcp_connections(struct uloop_timeout *t);
|
||||
|
||||
void update_channel_utilization(struct uloop_timeout *t);
|
||||
|
||||
struct uloop_timeout client_timer = {
|
||||
.cb = update_clients
|
||||
};
|
||||
|
@ -46,6 +48,9 @@ struct uloop_timeout hostapd_timer = {
|
|||
struct uloop_timeout umdns_timer = {
|
||||
.cb = update_tcp_connections
|
||||
};
|
||||
struct uloop_timeout channel_utilization_timer = {
|
||||
.cb = update_channel_utilization
|
||||
};
|
||||
|
||||
#define MAX_HOSTAPD_SOCKETS 10
|
||||
#define MAX_INTERFACE_NAME 64
|
||||
|
@ -60,6 +65,9 @@ struct hostapd_sock_entry{
|
|||
uint8_t vht;
|
||||
uint64_t last_channel_time;
|
||||
uint64_t last_channel_time_busy;
|
||||
int chan_util_samples_sum;
|
||||
int chan_util_num_sample_periods;
|
||||
int chan_util_average;
|
||||
struct ubus_subscriber subscriber;
|
||||
};
|
||||
|
||||
|
@ -787,6 +795,8 @@ int dawn_init_ubus(const char *ubus_socket, const char *hostapd_dir) {
|
|||
// get clients
|
||||
uloop_timeout_add(&client_timer);
|
||||
|
||||
uloop_timeout_add(&channel_utilization_timer);
|
||||
|
||||
ubus_call_umdns();
|
||||
|
||||
ubus_add_oject();
|
||||
|
@ -983,9 +993,8 @@ static void ubus_get_clients_cb(struct ubus_request *req, int type, struct blob_
|
|||
blobmsg_add_u8(&b_domain, "ht_supported", entry->ht);
|
||||
blobmsg_add_u8(&b_domain, "vht_supported", entry->vht);
|
||||
|
||||
int channel_util = get_channel_utilization(entry->iface_name, &entry->last_channel_time, &entry->last_channel_time_busy);
|
||||
blobmsg_add_u32(&b_domain, "channel_utilization", channel_util);
|
||||
printf("CHANNEL UTILIZATION!!!: %d\n", channel_util);
|
||||
//int channel_util = get_channel_utilization(entry->iface_name, &entry->last_channel_time, &entry->last_channel_time_busy);
|
||||
blobmsg_add_u32(&b_domain, "channel_utilization", entry->chan_util_average);
|
||||
|
||||
char* collision_string = blobmsg_format_json(b_domain.head, 1);
|
||||
printf("COLLISION STRING: %s\n", collision_string);
|
||||
|
@ -1013,6 +1022,22 @@ void update_clients(struct uloop_timeout *t) {
|
|||
uloop_timeout_set(&client_timer, timeout_config.update_client * 1000);
|
||||
}
|
||||
|
||||
void update_channel_utilization(struct uloop_timeout *t) {
|
||||
for (int i = 0; i <= hostapd_sock_last; i++) {
|
||||
|
||||
hostapd_sock_arr[i]->chan_util_samples_sum += get_channel_utilization(hostapd_sock_arr[i]->iface_name, &hostapd_sock_arr[i]->last_channel_time, &hostapd_sock_arr[i]->last_channel_time_busy);
|
||||
hostapd_sock_arr[i]->chan_util_num_sample_periods++;
|
||||
|
||||
if(hostapd_sock_arr[i]->chan_util_num_sample_periods > dawn_metric.chan_util_avg_period)
|
||||
{
|
||||
hostapd_sock_arr[i]->chan_util_average = hostapd_sock_arr[i]->chan_util_samples_sum / hostapd_sock_arr[i]->chan_util_num_sample_periods;
|
||||
hostapd_sock_arr[i]->chan_util_samples_sum = 0;
|
||||
hostapd_sock_arr[i]->chan_util_num_sample_periods = 0;
|
||||
}
|
||||
}
|
||||
uloop_timeout_set(&channel_utilization_timer, timeout_config.update_chan_util * 1000);
|
||||
}
|
||||
|
||||
void update_tcp_connections(struct uloop_timeout *t) {
|
||||
ubus_call_umdns();
|
||||
uloop_timeout_set(&umdns_timer, timeout_config.update_tcp_con * 1000);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue