-
Notifications
You must be signed in to change notification settings - Fork 286
/
ieee80211scan.bt
executable file
·55 lines (49 loc) · 1.26 KB
/
ieee80211scan.bt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/local/bin/bpftrace
/*
* ieee80211scan - Trace IEEE 802.11 WiFi scanning.
*
* See BPF Performance Tools, Chapter 10, for an explanation of this tool.
*
* Copyright (c) 2019 Brendan Gregg.
* Licensed under the Apache License, Version 2.0 (the "License").
* This was originally created for the BPF Performance Tools book
* published by Addison Wesley. ISBN-13: 9780136554820
* When copying or porting, include this comment.
*
* 23-Apr-2019 Brendan Gregg Created this.
*/
#include <net/mac80211.h>
BEGIN
{
printf("Tracing ieee80211 SSID scans. Hit Ctrl-C to end.\n");
// from include/uapi/linux/nl80211.h:
@band[0] = "2GHZ";
@band[1] = "5GHZ";
@band[2] = "60GHZ";
}
kprobe:ieee80211_request_scan
{
time("%H:%M:%S ");
printf("scan started (on-CPU PID %d, %s)\n", pid, comm);
@start = nsecs;
}
kretprobe:ieee80211_get_channel
/retval/
{
$ch = (struct ieee80211_channel *)retval;
$band = 0xff & *retval; // $ch->band; workaround for #776
time("%H:%M:%S ");
printf("scanning channel %s freq %d: beacon_found %d\n",
@band[$band], $ch->center_freq, $ch->beacon_found);
}
kprobe:ieee80211_scan_completed
/@start/
{
time("%H:%M:%S ");
printf("scan compeleted: %d ms\n", (nsecs - @start) / 1000000);
delete(@start);
}
END
{
clear(@start); clear(@band);
}