diff options
Diffstat (limited to 'benchmark/benchmark_beacon.c')
-rw-r--r-- | benchmark/benchmark_beacon.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/benchmark/benchmark_beacon.c b/benchmark/benchmark_beacon.c new file mode 100644 index 0000000..d769be8 --- /dev/null +++ b/benchmark/benchmark_beacon.c | |||
@@ -0,0 +1,37 @@ | |||
1 | #include <libwifi.h> | ||
2 | |||
3 | #include <stdio.h> | ||
4 | #include <time.h> | ||
5 | |||
6 | // A simple 802.11 Beacon with an SSID and a Channel tag | ||
7 | #define BEACON_FRAME "\x80\x00\x00\x00\xff\xff\xff\xff" \ | ||
8 | "\xff\xff\x00\x20\x91\x11\x22\x33" \ | ||
9 | "\x00\x00\x00\x00\x00\x00\x70\x56" \ | ||
10 | "\xc6\x90\x20\xe7\x7b\x01\x00\x00" \ | ||
11 | "\x88\x00\x01\x00\x00\x0e\x6c\x69" \ | ||
12 | "\x62\x77\x69\x66\x69\x2d\x62\x65" \ | ||
13 | "\x61\x63\x6f\x6e\x03\x01\x0b" | ||
14 | |||
15 | int main(void) { | ||
16 | float times[12] = {0}; | ||
17 | |||
18 | for (int i = 0; i < 12; i++) { | ||
19 | float startTime = (float)clock() / CLOCKS_PER_SEC; | ||
20 | |||
21 | struct libwifi_frame frame; | ||
22 | struct libwifi_bss bss; | ||
23 | libwifi_get_wifi_frame(&frame, (const unsigned char *)BEACON_FRAME, 56, 0); | ||
24 | libwifi_parse_beacon(&bss, &frame); | ||
25 | |||
26 | float endTime = (float) clock() / CLOCKS_PER_SEC; | ||
27 | times[i] = (endTime - startTime); | ||
28 | |||
29 | libwifi_free_bss(&bss); | ||
30 | libwifi_free_wifi_frame(&frame); | ||
31 | } | ||
32 | |||
33 | for (int i = 0; i < 12; i++) { | ||
34 | printf("Run %d:\t%9.7f Seconds\n", i+1, times[i]); | ||
35 | } | ||
36 | } | ||
37 | |||