diff options
author | Marc <foxtrot@malloc.me> | 2021-11-30 22:39:26 +0000 |
---|---|---|
committer | Marc <foxtrot@malloc.me> | 2021-12-01 16:54:44 +0000 |
commit | ae6c98a48da409d040604aeffb84a38155fb5bac (patch) | |
tree | c27a8e28972209581ce3fba2130bf0c2b4f9c9c0 /benchmark | |
download | libwifi-ae6c98a48da409d040604aeffb84a38155fb5bac.tar.gz libwifi-ae6c98a48da409d040604aeffb84a38155fb5bac.tar.bz2 libwifi-ae6c98a48da409d040604aeffb84a38155fb5bac.zip |
Initial Commit
Signed-off-by: Marc <foxtrot@malloc.me>
Diffstat (limited to 'benchmark')
-rw-r--r-- | benchmark/Makefile | 9 | ||||
-rw-r--r-- | benchmark/benchmark_beacon.c | 37 |
2 files changed, 46 insertions, 0 deletions
diff --git a/benchmark/Makefile b/benchmark/Makefile new file mode 100644 index 0000000..6dd995d --- /dev/null +++ b/benchmark/Makefile | |||
@@ -0,0 +1,9 @@ | |||
1 | CC=clang | ||
2 | CFLAGS=-Wall -Werror -O3 -o benchmark_beacon | ||
3 | LDFLAGS=-lpcap -lwifi | ||
4 | |||
5 | benchmark_beacon: benchmark_beacon.o | ||
6 | $(CC) $(CFLAGS) benchmark_beacon.c $(LDFLAGS) | ||
7 | |||
8 | clean: | ||
9 | rm benchmark_beacon *.o | ||
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 | |||