]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
hostapd: Add average channel utilization in STATUS
authorBhagavathi Perumal S <bperumal@qti.qualcomm.com>
Mon, 4 Dec 2017 09:23:33 +0000 (14:53 +0530)
committerJouni Malinen <j@w1.fi>
Mon, 11 Dec 2017 22:48:27 +0000 (00:48 +0200)
This allows external programs to get the average channel utilization.
The average channel utilization is calculated and reported through
STATUS command. Users need to configure chan_util_avg_period and
bss_load_update_period in hostapd config to get the average channel
utilization.

Signed-off-by: Bhagavathi Perumal S <bperumal@qti.qualcomm.com>
hostapd/config_file.c
hostapd/hostapd.conf
src/ap/ap_config.h
src/ap/bss_load.c
src/ap/ctrl_iface_ap.c
src/ap/hostapd.h

index f1e84b7c9bcdd33490ce0ff8bacb57f157f65a67..289180428b1e2ddf5dccad3734d3023be09ab5f8 100644 (file)
@@ -2863,6 +2863,16 @@ static int hostapd_config_fill(struct hostapd_config *conf,
                        return 1;
                }
                bss->bss_load_update_period = val;
+       } else if (os_strcmp(buf, "chan_util_avg_period") == 0) {
+               int val = atoi(pos);
+
+               if (val < 0) {
+                       wpa_printf(MSG_ERROR,
+                                  "Line %d: invalid chan_util_avg_period",
+                                  line);
+                       return 1;
+               }
+               bss->chan_util_avg_period = val;
        } else if (os_strcmp(buf, "rts_threshold") == 0) {
                conf->rts_threshold = atoi(pos);
                if (conf->rts_threshold < -1 || conf->rts_threshold > 65535) {
index 140c8d6ff41bcf07a7055f109e708ab41931b013..0d49fd744851a72918ad9871cea972f2edc1632e 100644 (file)
@@ -511,6 +511,12 @@ wmm_ac_vo_acm=0
 # Beacon and Probe Response frames.
 #bss_load_update_period=50
 
+# Channel utilization averaging period (in BUs)
+# This field is used to enable and configure channel utilization average
+# calculation with bss_load_update_period. This should be in multiples of
+# bss_load_update_period for more accurate calculation.
+#chan_util_avg_period=600
+
 # Fixed BSS Load value for testing purposes
 # This field can be used to configure hostapd to add a fixed BSS Load element
 # into Beacon and Probe Response frames for testing purposes. The format is
index fa99d37500394d55cf2f930cb4c84cf36674c868..dc0686e69214af3c6ede8a7ef6cba74dd850f30a 100644 (file)
@@ -249,6 +249,7 @@ struct hostapd_bss_config {
 
        int dtim_period;
        unsigned int bss_load_update_period;
+       unsigned int chan_util_avg_period;
 
        int ieee802_1x; /* use IEEE 802.1X */
        int eapol_version;
index ef2d36be3853c0880af5e2af1a7f7af763b714a0..725d3cd3469bad25285a40002ef69307e24129f0 100644 (file)
@@ -44,6 +44,7 @@ static void update_channel_utilization(void *eloop_data, void *user_data)
        struct hostapd_data *hapd = eloop_data;
        unsigned int sec, usec;
        int err;
+       struct hostapd_iface *iface = hapd->iface;
 
        if (!(hapd->beacon_set_done && hapd->started))
                return;
@@ -59,6 +60,21 @@ static void update_channel_utilization(void *eloop_data, void *user_data)
        if (get_bss_load_update_timeout(hapd, &sec, &usec) < 0)
                return;
 
+       if (hapd->conf->chan_util_avg_period) {
+               iface->chan_util_samples_sum += iface->channel_utilization;
+               iface->chan_util_num_sample_periods +=
+                       hapd->conf->bss_load_update_period;
+               if (iface->chan_util_num_sample_periods >=
+                   hapd->conf->chan_util_avg_period) {
+                       iface->chan_util_average =
+                               iface->chan_util_samples_sum /
+                               (iface->chan_util_num_sample_periods /
+                                hapd->conf->bss_load_update_period);
+                       iface->chan_util_samples_sum = 0;
+                       iface->chan_util_num_sample_periods = 0;
+               }
+       }
+
        eloop_register_timeout(sec, usec, update_channel_utilization, hapd,
                               NULL);
 }
index 74d3a2577587f246644d743f557b208f49c1c38a..883b005b27c5c789a9c1cd72f6c7670d8ac9f64f 100644 (file)
@@ -795,6 +795,15 @@ int hostapd_ctrl_iface_status(struct hostapd_data *hapd, char *buf,
                len += ret;
        }
 
+       if (hapd->conf->chan_util_avg_period) {
+               ret = os_snprintf(buf + len, buflen - len,
+                                 "chan_util_avg=%u\n",
+                                 iface->chan_util_average);
+               if (os_snprintf_error(buflen - len, ret))
+                       return len;
+               len += ret;
+       }
+
        return len;
 }
 
index 2c095dcfaf2b58efa1da7fa5f065304cc4b7fe44..0e35ee80a5169490889962195cc7eec8f72462d9 100644 (file)
@@ -497,6 +497,10 @@ struct hostapd_iface {
        u64 last_channel_time_busy;
        u8 channel_utilization;
 
+       unsigned int chan_util_samples_sum;
+       unsigned int chan_util_num_sample_periods;
+       unsigned int chan_util_average;
+
        /* eCSA IE will be added only if operating class is specified */
        u8 cs_oper_class;