mirror of
https://github.com/berlin-open-wireless-lab/DAWN.git
synced 2025-03-09 15:40:12 +00:00
add channel util
This commit is contained in:
parent
db5a9c88b2
commit
0dc0e951af
3 changed files with 23 additions and 15 deletions
|
@ -59,6 +59,6 @@ int get_bssid(const char *ifname, uint8_t *bssid_addr);
|
|||
|
||||
int get_ssid(const char *ifname, char *ssid);
|
||||
|
||||
int get_channel_utilization(const char *ifname);
|
||||
int get_channel_utilization(const char *ifname, uint64_t *last_channel_time, uint64_t *last_channel_time_busy);
|
||||
|
||||
#endif //DAWN_RSSI_H
|
||||
|
|
|
@ -21,9 +21,6 @@ int get_bandwidth(const char *ifname, uint8_t *client_addr, float *rx_rate, floa
|
|||
|
||||
#define IWINFO_ESSID_MAX_SIZE 32
|
||||
|
||||
uint64_t last_channel_time = 0;
|
||||
uint64_t last_channel_time_busy = 0;
|
||||
|
||||
int compare_essid_iwinfo(__uint8_t *bssid_addr, __uint8_t *bssid_addr_to_compare) {
|
||||
const struct iwinfo_ops *iw;
|
||||
|
||||
|
@ -278,19 +275,27 @@ int get_ssid(const char *ifname, char* ssid) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int get_channel_utilization(const char *ifname) {
|
||||
int get_channel_utilization(const char *ifname, uint64_t *last_channel_time, uint64_t *last_channel_time_busy) {
|
||||
printf("GETTING UTILKIATUION FOR : %s\n", ifname);
|
||||
|
||||
const struct iwinfo_ops *iw;
|
||||
struct iwinfo_survey_entry survey_entry;
|
||||
|
||||
iw = iwinfo_backend(ifname);
|
||||
if (iw->survey(ifname, &survey_entry))
|
||||
{
|
||||
uint64_t dividend = survey_entry.channel_time_busy - last_channel_time_busy;
|
||||
uint64_t divisor = survey_entry.channel_time - last_channel_time;
|
||||
last_channel_time = survey_entry.channel_time;
|
||||
last_channel_time_busy = survey_entry.channel_time_busy;
|
||||
printf("GOT SURVEY INFO!\n");
|
||||
return (dividend * 255 / divisor);
|
||||
}
|
||||
return 0;
|
||||
return 0;
|
||||
|
||||
uint64_t dividend = survey_entry.channel_time_busy - *last_channel_time_busy;
|
||||
uint64_t divisor = survey_entry.channel_time - *last_channel_time;
|
||||
*last_channel_time = survey_entry.channel_time;
|
||||
*last_channel_time_busy = survey_entry.channel_time_busy;
|
||||
printf("dvidend: %llu\n", dividend);
|
||||
printf("divisior: %llu\n", divisor);
|
||||
|
||||
printf("last_channel_time: %llu\n", *last_channel_time);
|
||||
printf("last_channel_time_busy: %llu\n", *last_channel_time_busy);
|
||||
|
||||
printf("GOT SURVEY INFO!\n");
|
||||
return (int)(dividend * 255 / divisor);
|
||||
iwinfo_finish();
|
||||
}
|
|
@ -58,6 +58,8 @@ struct hostapd_sock_entry{
|
|||
char ssid[SSID_MAX_LEN];
|
||||
uint8_t ht;
|
||||
uint8_t vht;
|
||||
uint64_t last_channel_time;
|
||||
uint64_t last_channel_time_busy;
|
||||
struct ubus_subscriber subscriber;
|
||||
};
|
||||
|
||||
|
@ -977,7 +979,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);
|
||||
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);
|
||||
|
||||
char* collision_string = blobmsg_format_json(b_domain.head, 1);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue