]> rtime.felk.cvut.cz Git - frescor/fwp.git/commitdiff
Resource manager gained parameters for setting wifi configuration
authorMichal Sojka <sojkam1@fel.cvut.cz>
Wed, 11 Nov 2009 13:28:15 +0000 (14:28 +0100)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Wed, 11 Nov 2009 13:31:36 +0000 (14:31 +0100)
... such as bitrate, modulatio used and whether short preamble is used.

fwp/mngr/fwp_admctrl.c
fwp/mngr/fwp_admctrl.h
fwp/mngr/fwp_mngr.c

index ee410b20bbbe57ff0f93da50e9fecc5f1e535857..ad5b5b73a0746f7ac0258dfd55fd23df5df4e38b 100644 (file)
@@ -151,10 +151,8 @@ int fwp_admctrl_utilization(struct fres_sa_scenario *scenario, void *priv,
                                 bool *schedulable)
 {
        int utilization = 0;
-
-       const int rate = 54*1000*1000;
-       const bool erp_ofdm = true;
-       const bool short_preamble = true;
+       struct frm_fwp_priv *pr = priv;
+       const int rate = pr->rate_mbps*1000*1000;
        struct fres_sa_contract *c;
        long int period_usec;
        fres_block_fwp_sched *fwp_sched;
@@ -188,22 +186,23 @@ int fwp_admctrl_utilization(struct fres_sa_scenario *scenario, void *priv,
                        LLC_HEADER_SIZE + MAC_FCS_SIZE;
 
                duration_usec = frame_duration(data_overhead + bytes%MTU, rate, 
-                                               erp_ofdm, short_preamble);
-               tmp_usec = frame_duration(data_overhead + MTU, rate, erp_ofdm, 
-                                               short_preamble);
+                                              pr->erp_ofdm, pr->short_preamble);
+               tmp_usec = frame_duration(data_overhead + MTU, rate,
+                                         pr->erp_ofdm, pr->short_preamble);
                duration_usec += tmp_usec*(fragments-1);
                /* Add average backoff - assume there is no collision */
                tmp_usec = ASLOTTIME_USEC*fragments*pisvejc[ac];
                duration_usec += (aifsn[ac] + cwmin[ac]/2)*tmp_usec;
                /* We use ACK and ignore burst */
-               tmp_usec = frame_duration(ACK_FRAME_SIZE, rate, erp_ofdm, 
-                                       short_preamble) + ASIFSTIME_USEC; 
+               tmp_usec = frame_duration(ACK_FRAME_SIZE, rate,
+                                         pr->erp_ofdm, pr->short_preamble)
+                       + ASIFSTIME_USEC; 
                duration_usec += fragments * tmp_usec; 
                //printf("duration: %ld ms\n", duration_usec/1000);
 
                /* TODO: If STA-to-STA, multiply it by two. Note that
                 * AP may use different values for backoff. */
-               //duration_usec *= 2; /* For demo, we have always STA-to-STA */
+               duration_usec *= 2; /* For demo, we have always STA-to-STA */
 
                if (c->contract == c->new) {
                        if (period_usec == 0) {
index ab91475bdec1d6b470dd4c1c6d11d2674dd1d241..336d65f338f3bcd6cabfabc11a5948c2bd168fb4 100644 (file)
 
 #include <frsh_distributed.h>
 
+struct frm_fwp_priv {
+       int rate_mbps;
+       bool erp_ofdm;
+       bool short_preamble;
+};
+
 int fwp_admctrl_utilization(struct fres_sa_scenario *scenario, void *priv,
                                 bool *schedulable);
 
index 080d1923257e070f3ff5f70f9f5062d289ea6c56..75baa517771adfcdaa7405d9d1befecc63b6614d 100644 (file)
@@ -84,17 +84,26 @@ int dummy_admission_test(struct fres_sa_scenario *scenario, void *priv,
 }
 #endif
 
+struct frm_fwp_priv priv = {
+       .rate_mbps = 1,
+       .erp_ofdm = false,
+       .short_preamble = false,
+};
+
 static const struct fres_res_manager frm = {
        .res_type = FRSH_RT_NETWORK,
        .res_id = FRSH_NETPF_FWP,
        //.admission_test = dummy_admission_test,
        .name = "WLAN",
        .admission_test = fwp_admctrl_utilization,
-       .priv = NULL
+       .priv = &priv,
 };
 
 static struct option long_opts[] = {
-    { "loglevel", 1, 0, 'l' },
+    { "loglevel",         required_argument, 0, 'l' },
+    { "bitrate",         required_argument, 0, 'b' },
+    { "ofdm",                    no_argument,       0, 'o' },
+    { "short-preamble",  no_argument,       0, 's' },
     { 0, 0, 0, 0}
 };
 
@@ -103,6 +112,9 @@ usage(void)
 {
        printf("usage: fwpmngr [ options ]\n");
        printf("  -l, --loglevel <number>|<domain>=<number>,...\n");
+       printf("  -b, --bitrate <mbits/s>\n");
+       printf("  -o, --ofdm\n");
+       printf("  -s, --short-preamble\n");
 }
 
 int main(int argc, char *argv[])
@@ -112,11 +124,20 @@ int main(int argc, char *argv[])
        forb_init_attr_t attr = { .orb_id = "org.frescor.frm.fwp" };
        int  opt;
 
-       while ((opt = getopt_long(argc, argv, "l:", &long_opts[0], NULL)) != EOF) {
+       while ((opt = getopt_long(argc, argv, "b:l:os", &long_opts[0], NULL)) != EOF) {
                switch (opt) {
                        case 'l':
                                ul_log_domain_arg2levels(optarg);
                                break;
+                       case 'b':
+                               priv.rate_mbps = atol(optarg);
+                               break;
+                       case 's':
+                               priv.short_preamble = true;
+                               break;
+                       case 'o':
+                               priv.erp_ofdm = true;
+                               break;
                        case 'h':
                        /*default:*/
                                usage();