From ae6c98a48da409d040604aeffb84a38155fb5bac Mon Sep 17 00:00:00 2001 From: Marc Date: Tue, 30 Nov 2021 22:39:26 +0000 Subject: Initial Commit Signed-off-by: Marc --- benchmark/Makefile | 9 +++++++++ benchmark/benchmark_beacon.c | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 benchmark/Makefile create mode 100644 benchmark/benchmark_beacon.c (limited to 'benchmark') diff --git a/benchmark/Makefile b/benchmark/Makefile new file mode 100644 index 0000000..6dd995d --- /dev/null +++ b/benchmark/Makefile @@ -0,0 +1,9 @@ +CC=clang +CFLAGS=-Wall -Werror -O3 -o benchmark_beacon +LDFLAGS=-lpcap -lwifi + +benchmark_beacon: benchmark_beacon.o + $(CC) $(CFLAGS) benchmark_beacon.c $(LDFLAGS) + +clean: + 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 @@ +#include + +#include +#include + +// A simple 802.11 Beacon with an SSID and a Channel tag +#define BEACON_FRAME "\x80\x00\x00\x00\xff\xff\xff\xff" \ + "\xff\xff\x00\x20\x91\x11\x22\x33" \ + "\x00\x00\x00\x00\x00\x00\x70\x56" \ + "\xc6\x90\x20\xe7\x7b\x01\x00\x00" \ + "\x88\x00\x01\x00\x00\x0e\x6c\x69" \ + "\x62\x77\x69\x66\x69\x2d\x62\x65" \ + "\x61\x63\x6f\x6e\x03\x01\x0b" + +int main(void) { + float times[12] = {0}; + + for (int i = 0; i < 12; i++) { + float startTime = (float)clock() / CLOCKS_PER_SEC; + + struct libwifi_frame frame; + struct libwifi_bss bss; + libwifi_get_wifi_frame(&frame, (const unsigned char *)BEACON_FRAME, 56, 0); + libwifi_parse_beacon(&bss, &frame); + + float endTime = (float) clock() / CLOCKS_PER_SEC; + times[i] = (endTime - startTime); + + libwifi_free_bss(&bss); + libwifi_free_wifi_frame(&frame); + } + + for (int i = 0; i < 12; i++) { + printf("Run %d:\t%9.7f Seconds\n", i+1, times[i]); + } +} + -- cgit 1.4.1