]> rtime.felk.cvut.cz Git - frescor/fwp.git/commitdiff
Added utilization based admission test and a testing application.
authorMichal Sojka <sojkam1@fel.cvut.cz>
Tue, 29 Jan 2008 22:43:04 +0000 (23:43 +0100)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Tue, 29 Jan 2008 22:43:04 +0000 (23:43 +0100)
The testing application compares results of utilization test with real
measured values.

fwp/fwp_manager/Makefile.omk
fwp/fwp_manager/admtest_utilization.c [new file with mode: 0644]
fwp/fwp_manager/tests/BE_packet_size_graph [new file with mode: 0644]
fwp/fwp_manager/tests/Makefile [new file with mode: 0644]
fwp/fwp_manager/tests/Makefile.omk [new file with mode: 0644]
fwp/fwp_manager/tests/VI_packet_size_graph [new file with mode: 0644]
fwp/fwp_manager/tests/VO_packet_size_graph [new file with mode: 0644]
fwp/fwp_manager/tests/adm_utilization.c [new file with mode: 0644]
fwp/fwp_manager/tests/plot_sat [new file with mode: 0644]

index bdea5333d8c01bde66ce55791ae2481bd3b17317..da84978f2766388a4734714a39d8d16f12940da5 100644 (file)
@@ -2,6 +2,9 @@ bin_PROGRAMS = fwpmngr
 
 CFLAGS = -Wall -D_REENTRANT -g
 fwpmngr_SOURCES+= fwpmngr.c
-fwpmngr_SOURCES+= admtest_stupid.c
+#fwpmngr_SOURCES+= admtest_stupid.c
+fwpmngr_SOURCES+= admtest_utilization.c
 
 lib_LOADLIBES+= fwp pthread rt
+
+SUBDIRS=tests
\ No newline at end of file
diff --git a/fwp/fwp_manager/admtest_utilization.c b/fwp/fwp_manager/admtest_utilization.c
new file mode 100644 (file)
index 0000000..08c94cd
--- /dev/null
@@ -0,0 +1,71 @@
+#include "admtest.h"
+#include <fwp_util.h>
+#include <stdint.h>
+#include <fwp_ac.h>
+#include <fwp_conf.h>
+
+/* TODO: Find out the real value and determine what influences it (MTU
+ *      of the interface minus header sizes?).  */
+#define MTU 1472
+#define UDP_HEADER_SIZE 8
+#define IP_HEADER_SIZE 20
+#define LLC_HEADER_SIZE 2      /* ??? */
+#define MAC_HEADER_SIZE 26     /* With QoS field added */
+#define MAC_FCS_SIZE 4
+
+#define RTS_FRAME_SIZE 20
+#define CTS_FRAME_SIZE 14
+#define ACK_FRAME_SIZE 14
+
+#define BITRATE_BPS (1000*1000)
+#define ASLOTTIME_USEC 20      /* 802.11g-2003 p. 46 */
+#define ASIFSTIME_USEC 10
+#define ADIFSTIME_USEC (ASIFSTIME_USEC + 2*ASLOTTIME_USEC)
+#define AAIFSTIME_USEC(n) (ASIFSTIME_USEC + (n)*ASLOTTIME_USEC)
+
+#define TXTIME_USEC(bytes) ((int64_t)(bytes) * 8 * SEC_TO_USEC / BITRATE_BPS)
+
+
+/* Default values from 802.11e */
+int aifsn[FWP_AC_NUM] = { 2, 2, 3, 7 };
+int cwmin[FWP_AC_NUM] = { 3, 7, 15, 15 };
+
+/* Experimental konstants - weight of backoff */
+int pisvejc[FWP_AC_NUM] = { 10, 7, 4, 2 };
+
+
+int fwp_adm_test(struct fwp_ctable *ct)
+{
+       int i;
+       int utilization = 0;
+       
+       for (i = 0; i < ct->nr_contract; i++) {
+               int bytes, duration_usec, fragments;
+               struct fwp_contract *contract = &ct->entry[i].contract;
+               int ac = FWP_AC_VO; /* FIXME: assign to AC before this
+                                    * loop based on deadlines */
+               ac = contract->ac_id;
+
+               /* Calculate protocol overhead */
+
+               bytes = contract->budget;
+               fragments = 1 + bytes / MTU;
+
+               bytes += (UDP_HEADER_SIZE + IP_HEADER_SIZE +
+                         LLC_HEADER_SIZE + MAC_FCS_SIZE + MAC_FCS_SIZE) * fragments;
+               duration_usec = TXTIME_USEC(bytes);
+               /* Add average backoff - assume there is no collision */
+               duration_usec += (aifsn[ac] + cwmin[ac]/2)*ASLOTTIME_USEC*fragments*pisvejc[ac];
+               /* We use ACK and ignore burst */
+               duration_usec += (ASIFSTIME_USEC + TXTIME_USEC(ACK_FRAME_SIZE)) * fragments;
+               /* TODO: If STA-to-STA, multiply it by two. Note that
+                * AP may use different values for backoff. */
+               if (contract->period_usec == 0) return FWP_CNT_REJECTED;
+               utilization += (long long)(duration_usec * 10000) / contract->period_usec;
+       }
+       if (utilization >= 10000 * 95/100) {
+               return FWP_CNT_REJECTED;
+       } else {
+               return FWP_CNT_NEGOTIATED;      
+       }
+}
diff --git a/fwp/fwp_manager/tests/BE_packet_size_graph b/fwp/fwp_manager/tests/BE_packet_size_graph
new file mode 100644 (file)
index 0000000..0d81a2f
--- /dev/null
@@ -0,0 +1,62 @@
+12 17.5 17.5
+20 28.1 28.1
+30 40.2 40.2
+40 50.4 50.4
+50 60.0 60.0
+60 69.1 69.1
+70 77.2 77.2
+80 83.1 83.1
+90 89.8 89.8
+100 94.8 94.8
+110 102 102
+120 107 107
+130 111 111
+140 116 116
+150 119 119
+160 125 125
+170 126 126
+180 131 131
+190 132 132
+200 136 136
+250 151 151
+300 161 161
+350 168 168
+400 174 174
+450 179 179
+500 186 186
+550 187 187
+600 192 192
+650 194 194
+700 199 199
+750 200 200
+800 203 203
+850 204 204
+900 204 204
+950 205 205
+1000 208 208
+1050 207 207
+1100 210 210
+1150 210 210
+1200 212 212
+1250 214 214
+1300 212 212
+1350 217 217
+1400 215 215
+1450 217 217
+1460 212 212
+1470 217 217
+1480 199 199
+1490 200 200
+1500 199 199
+1510 199 199
+1520 198 198
+1550 200 200
+1600 201 201
+1650 204 204
+1700 205 205
+1750 207 207
+1800 207 207
+1850 206 206
+1900 209 209
+1950 211 211
+2000 210 210
diff --git a/fwp/fwp_manager/tests/Makefile b/fwp/fwp_manager/tests/Makefile
new file mode 100644 (file)
index 0000000..b22a357
--- /dev/null
@@ -0,0 +1,14 @@
+# Generic directory or leaf node makefile for OCERA make framework
+
+ifndef MAKERULES_DIR
+MAKERULES_DIR := $(shell ( old_pwd="" ;  while [ ! -e Makefile.rules ] ; do if [ "$$old_pwd" = `pwd`  ] ; then exit 1 ; else old_pwd=`pwd` ; cd -L .. 2>/dev/null ; fi ; done ; pwd ) )
+endif
+
+ifeq ($(MAKERULES_DIR),)
+all : default
+.DEFAULT::
+       @echo -e "\nThe Makefile.rules has not been found in this or partent directory\n"
+else
+include $(MAKERULES_DIR)/Makefile.rules
+endif
+
diff --git a/fwp/fwp_manager/tests/Makefile.omk b/fwp/fwp_manager/tests/Makefile.omk
new file mode 100644 (file)
index 0000000..7c51521
--- /dev/null
@@ -0,0 +1,6 @@
+test_PROGRAMS = adm_utilization
+
+adm_utilization_SOURCES = adm_utilization.c ../admtest_utilization.c
+adm_utilization_LIBS = fwp
+
+CFLAGS=-Wall -O0 -g
diff --git a/fwp/fwp_manager/tests/VI_packet_size_graph b/fwp/fwp_manager/tests/VI_packet_size_graph
new file mode 100644 (file)
index 0000000..724dc98
--- /dev/null
@@ -0,0 +1,62 @@
+12 64.6 0.511
+20 45.6 2.04
+30 64.1 2.56
+40 80.5 1.66
+50 94.8 3.45
+60 98.0 28.1
+70 98.4 53.1
+80 98.9 73.9
+90 98.4 89.1
+100 98.9 102
+110 98.9 108
+120 98.8 119
+130 98.7 128
+140 98.9 130
+150 99.7 137
+160 99.4 141
+170 100 145
+180 98.1 153
+190 101 151
+200 99.6 152
+250 99.5 165
+300 100 176
+350 98.7 180
+400 99.8 187
+450 100 189
+500 100 191
+550 98.9 194
+600 100 193
+650 100 198
+700 99.8 199
+750 100 199
+800 99.9 200
+850 98.6 205
+900 99.1 207
+950 99.3 204
+1000 99.8 203
+1050 102 198
+1100 100 204
+1150 98.6 207
+1200 102 204
+1250 99.4 206
+1300 97.8 208
+1350 99.0 207
+1400 97.4 209
+1450 99.7 208
+1460 98.7 210
+1470 100 208
+1480 99.5 198
+1490 100 197
+1500 101 198
+1510 100 201
+1520 100 198
+1550 99.7 198
+1600 103 195
+1650 98.4 203
+1700 99.2 200
+1750 101 201
+1800 101 200
+1850 100 203
+1900 101 199
+1950 99.5 201
+2000 99.8 208
diff --git a/fwp/fwp_manager/tests/VO_packet_size_graph b/fwp/fwp_manager/tests/VO_packet_size_graph
new file mode 100644 (file)
index 0000000..e6b362d
--- /dev/null
@@ -0,0 +1,62 @@
+12 70.5 0.64
+20 63.1 2.81
+30 87.3 2.56
+40 98.2 0.896
+50 98.3 2.56
+60 98.5 27.9
+70 98.3 53.0
+80 99.4 71.0
+90 98.6 87.6
+100 99.6 97.1
+110 98.8 110
+120 99.2 118
+130 99.0 125
+140 99.1 134
+150 99.3 135
+160 99.7 141
+170 99.1 144
+180 99.0 150
+190 100 154
+200 100 154
+250 99.4 164
+300 99.4 178
+350 99.1 183
+400 99.3 187
+450 99.5 190
+500 100 193
+550 99.2 193
+600 99.5 194
+650 99.2 195
+700 100 198
+750 100 197
+800 99.8 199
+850 99.3 201
+900 100 204
+950 100 202
+1000 99.8 204
+1050 100 204
+1100 100 205
+1150 99.0 206
+1200 100 207
+1250 99.3 207
+1300 97.9 208
+1350 100 206
+1400 96.3 211
+1450 99.6 205
+1460 98.3 206
+1470 97.4 212
+1480 98.8 199
+1490 99.9 195
+1500 101 197
+1510 100 197
+1520 96.7 203
+1550 100 198
+1600 100 200
+1650 99.3 200
+1700 101 200
+1750 97.8 202
+1800 99.0 203
+1850 96.8 205
+1900 98.4 205
+1950 102 203
+2000 99.5 203
diff --git a/fwp/fwp_manager/tests/adm_utilization.c b/fwp/fwp_manager/tests/adm_utilization.c
new file mode 100644 (file)
index 0000000..4689c2f
--- /dev/null
@@ -0,0 +1,84 @@
+/**
+ * @file   adm_utilization.c
+ * @author Michal Sojka <sojkam1@fel.cvut.cz>
+ * 
+ * @brief  Test for utilization based admition control.
+ *
+ * This test tries to simulate results of the following test whose
+ * results are available at:
+ * http://rtime.felk.cvut.cz/frescor/images/b/bb/Packet_sizes_sat_comp.pdf
+ * (http://rtime.felk.cvut.cz/frescor/index.php/Experiments#Experiments_2008.2F01)
+ *
+ * Brief description of the test: Measuring of saturation bandwidth of
+ * AC_BE with respect to the size of packets in AC_VO, AC_VI and AC_BE
+ * itself. In this test we have generated the following streams AC_VO:
+ * 100 kbps, AC_VI: 100 kbps and AC_BE: 500 kbps (saturation). The
+ * streams, where the packet size was not changed was formed by
+ * packets of 800 bytes (UDP). The real bandwidth of AC_BE was
+ * measured.
+ */
+
+#include "../admtest.h"
+#include <fwp_ctable.h>
+#include <fwp_ac.h>
+#include <string.h>
+#include <fwp_util.h>
+
+void insert_contract(struct fwp_ctable *ctable, enum ac_id_t ac, int bandwidth_bps, int packet_size)
+{
+       struct fwp_ctable_entry entry;
+       int period_usec;
+
+       if (bandwidth_bps == 0) return;
+       
+       period_usec = SEC_TO_USEC*packet_size*8/bandwidth_bps;
+
+       memset(&entry, 0, sizeof(entry));
+       entry.contract.budget = packet_size;
+       entry.contract.period_usec = period_usec;
+       entry.contract.ac_id = ac;
+
+       fwp_ctable_put(ctable, &entry);
+}
+
+int main()
+{
+       int ac, size;
+       struct fwp_ctable ctable;
+
+       for (ac=FWP_AC_VO; ac <= FWP_AC_BE; ac++) {
+               for (size=10; size < 2000; size+=10) {
+                       /* Find maximum BE badwidth by binary
+                        * chopping. */
+                       int min=0, max=300000, bw;
+                       int packet_size[] = {[FWP_AC_VO] = (ac == FWP_AC_VO) ? size : 800,
+                                            [FWP_AC_VI] = (ac == FWP_AC_VI) ? size : 800,
+                                            [FWP_AC_BE] = (ac == FWP_AC_BE) ? size : 800};
+                       enum contract_status_t cs;
+                       bw=(max+min+1)/2;
+                       while (min < max) {
+                               fwp_ctable_init(&ctable);
+
+                               /* Two equal contracts, one for each direction */
+                               insert_contract(&ctable, FWP_AC_VO, 100*Kbit, packet_size[FWP_AC_VO]);
+                               insert_contract(&ctable, FWP_AC_VO, 100*Kbit, packet_size[FWP_AC_VO]);
+
+                               insert_contract(&ctable, FWP_AC_VI, 100*Kbit, packet_size[FWP_AC_VI]);
+                               insert_contract(&ctable, FWP_AC_VI, 100*Kbit, packet_size[FWP_AC_VI]);
+                               
+                               insert_contract(&ctable, FWP_AC_BE, bw, packet_size[FWP_AC_BE]);
+                               insert_contract(&ctable, FWP_AC_BE, bw, packet_size[FWP_AC_BE]);
+                               cs = fwp_adm_test(&ctable);
+                               if (cs == FWP_CNT_REJECTED) {
+                                       max = bw-1;
+                               } else {
+                                       min = bw;
+                               }
+                               bw=(max+min+1)/2;
+                       }
+                       printf("%d %f\n", size, bw/1000.0);
+               }
+               printf("\n\n");
+       }
+       return 0;
+}
diff --git a/fwp/fwp_manager/tests/plot_sat b/fwp/fwp_manager/tests/plot_sat
new file mode 100644 (file)
index 0000000..8fc5d34
--- /dev/null
@@ -0,0 +1,22 @@
+# Usage: adm_utilization > data; gnuplot plot_sat
+
+set terminal postscript eps color
+set output "admutil_comp.eps"
+
+set style line 1 lt 1 lc rgb "red"
+set style line 2 lt 1 lc rgb "green"
+set style line 3 lt 1 lc rgb "blue"
+
+set style data lines
+set grid
+set key right bottom nobox
+set title "Comparsion of utilization based test and reality"
+set xlabel "Packet sizes [bytes]"
+set ylabel "AC_BE bandwidth [kbps]"
+
+plot  "data" index 0 with lines lt 1 lw 3 lc rgb "red"   title "utilization test: AC_VO changed",\
+      "data" index 1 with lines lt 1 lw 3 lc rgb "green" title "utilization test: AC_VI changed",\
+      "data" index 2 with lines lt 1 lw 3 lc rgb "blue"  title "utilization test: AC_BE changed",\
+      "VO_packet_size_graph" using 1:3 with lines lw 3 lt 2 lc rgb "red"   title "reality: AC_VO changed",\
+      "VI_packet_size_graph" using 1:3 with lines lw 3 lt 2 lc rgb "green" title "reality: AC_VI changed",\
+      "BE_packet_size_graph" using 1:3 with lines lw 3 lt 2 lc rgb "blue"  title "reality: AC_BE changed"