Q4-Send-probe-request
Topics in this section,
In this section, you are going to learn
How to send a probe-request every 30 seconds
# |
Version |
---|---|
Ubuntu |
Ubuntu 22.04 64 bit |
Linux Kernel |
6.9.2 |
Supplicant |
wpa_supplicant 2.10 |
Send a probe-request every 30 seconds
Add a configuration parameter called “periodic_probe=30” in supplicant conf file
If “periodic_probe=0”, then this feature is disabled
If “periodic_probe=5”, then probe is sent at every 5th second
Call flow for send a probe-request every 30 seconds
main ()
wpa_supplicant_add_iface ()
wpa_supplicant_init_iface ()
wpa_supplicant_driver_init ()
wpa_supplicant_req_scan ()
wpa_supplicant_scan ()
wpa_supplicant_trigger_scan ()
wpas_trigger_scan_cb ()
sta_send_probe ()
Download the below patch file
send_probe_req_every_30sec.patch
See the full content of patch file
diff -crB original/wpa_supplicant-2.10/src/utils/os.h changed/wpa_supplicant-2.10/src/utils/os.h
*** original/wpa_supplicant-2.10/src/utils/os.h 2022-01-17 02:21:29.000000000 +0530
--- changed/wpa_supplicant-2.10/src/utils/os.h 2024-07-26 17:25:21.376201368 +0530
***************
*** 42,47 ****
--- 42,48 ----
*/
int os_get_reltime(struct os_reltime *t);
+ void sta_get_curtime();
/* Helpers for handling struct os_time */
diff -crB original/wpa_supplicant-2.10/src/utils/os_unix.c changed/wpa_supplicant-2.10/src/utils/os_unix.c
*** original/wpa_supplicant-2.10/src/utils/os_unix.c 2022-01-17 02:21:29.000000000 +0530
--- changed/wpa_supplicant-2.10/src/utils/os_unix.c 2024-07-26 17:25:38.748201099 +0530
***************
*** 72,77 ****
--- 72,88 ----
return res;
}
+ void sta_get_curtime()
+ {
+ struct timeval tv;
+ struct timezone tz;
+ struct tm *today;
+
+ gettimeofday(&tv, &tz);
+
+ today = localtime(&tv.tv_sec);
+
+ }
int os_get_reltime(struct os_reltime *t)
{
diff -crB original/wpa_supplicant-2.10/wpa_supplicant/config_file.c changed/wpa_supplicant-2.10/wpa_supplicant/config_file.c
*** original/wpa_supplicant-2.10/wpa_supplicant/config_file.c 2022-01-17 02:21:29.000000000 +0530
--- changed/wpa_supplicant-2.10/wpa_supplicant/config_file.c 2024-07-26 17:29:50.744197189 +0530
***************
*** 329,335 ****
}
while (wpa_config_get_line(buf, sizeof(buf), f, &line, &pos)) {
! if (os_strcmp(pos, "network={") == 0) {
ssid = wpa_config_read_network(f, &line, id++);
if (ssid == NULL) {
wpa_printf(MSG_ERROR, "Line %d: failed to "
--- 329,338 ----
}
while (wpa_config_get_line(buf, sizeof(buf), f, &line, &pos)) {
! if (os_strncmp(pos, "periodic_probe=",15) == 0) {
! config->periodic_probe = atoi(pos+15);;
!
! } else if (os_strcmp(pos, "network={") == 0) {
ssid = wpa_config_read_network(f, &line, id++);
if (ssid == NULL) {
wpa_printf(MSG_ERROR, "Line %d: failed to "
diff -crB original/wpa_supplicant-2.10/wpa_supplicant/config.h changed/wpa_supplicant-2.10/wpa_supplicant/config.h
*** original/wpa_supplicant-2.10/wpa_supplicant/config.h 2022-01-17 02:21:29.000000000 +0530
--- changed/wpa_supplicant-2.10/wpa_supplicant/config.h 2024-07-26 17:25:45.576200993 +0530
***************
*** 1699,1704 ****
--- 1699,1705 ----
#endif /* CONFIG_TESTING_OPTIONS */
#endif /* CONFIG_PASN*/
+ int periodic_probe;
};
diff -crB original/wpa_supplicant-2.10/wpa_supplicant/scan.c changed/wpa_supplicant-2.10/wpa_supplicant/scan.c
*** original/wpa_supplicant-2.10/wpa_supplicant/scan.c 2022-01-17 02:21:29.000000000 +0530
--- changed/wpa_supplicant-2.10/wpa_supplicant/scan.c 2024-07-26 17:38:25.268189204 +0530
***************
*** 178,183 ****
--- 178,198 ----
wpa_supplicant_associate(wpa_s, NULL, ssid);
}
+ static int onetime_probe_entry = 0;
+ struct wpa_driver_scan_params *sta_params;
+ struct wpa_radio_work *devo_work;
+
+ static void sta_send_probe(void *eloop_ctx, void *timeout_ctx)
+ {
+ struct wpa_supplicant *wpa_s = eloop_ctx;
+ int sta_ret;
+ sta_params = &wpa_s->beacon_rep_data.scan_params;
+
+ sta_get_curtime();
+ eloop_register_timeout(wpa_s->conf->periodic_probe, 0, sta_send_probe, wpa_s, NULL);
+ wpa_supplicant_deauthenticate(wpa_s, WLAN_REASON_DEAUTH_LEAVING);
+ sta_ret = wpa_drv_scan(wpa_s, sta_params);
+ }
static void wpas_trigger_scan_cb(struct wpa_radio_work *work, int deinit)
{
***************
*** 216,222 ****
--- 231,246 ----
"Request driver to clear scan cache due to local BSS flush");
params->only_new_results = 1;
}
+
ret = wpa_drv_scan(wpa_s, params);
+
+ if (!onetime_probe_entry) {
+ onetime_probe_entry = 1;
+ sta_params = params;
+ devo_work = work->ctx;
+ eloop_register_timeout(wpa_s->conf->periodic_probe, 0, sta_send_probe, wpa_s, NULL);
+ }
+
/*
* Store the obtained vendor scan cookie (if any) in wpa_s context.
* The current design is to allow only one scan request on each
test:~$ pwd
/home/test
Make sure internet is available in laptop to download supplicant package
test:~$ sudo wget https://w1.fi/releases/wpa_supplicant-2.10.tar.gz
Create a directory
test:~$ mkdir supplicant
Change directory to supplicant
test:~$ cd supplicant
Note : Your present working directory should be supplicant
test:~$ pwd
/home/test/supplicant/
Extract wpa_supplicant
test:~$ sudo tar -xvf ~/wpa_supplicant-2.10.tar.gz
Run the below command to apply patch
test:~$ patch -p1 < send_probe_req_every_30sec.patch
patching file wpa_supplicant-2.10/src/utils/os.h
patching file wpa_supplicant-2.10/src/utils/os_unix.c
patching file wpa_supplicant-2.10/wpa_supplicant/config_file.c
patching file wpa_supplicant-2.10/wpa_supplicant/config.h
patching file wpa_supplicant-2.10/wpa_supplicant/scan.c
Change directory to wpa_supplicant
test:~$ cd wpa_supplicant-2.10/wpa_supplicant/
Check the current working directory using pwd command
Make sure your current working directory is wpa_supplicant
test:~$ pwd
/home/test/supplicant/wpa_supplicant-2.10/wpa_supplicant
Copy the contents of defconfig file to .config file
test:~$ sudo cp defconfig .config
Compile wpa_supplicant
test:~$ sudo make
Create run_supplicant.conf
test:~$ sudo vim ./run_supplicant.conf
ctrl_interface=/run/wpa_supplicant
update_config=1
periodic_probe=30
network={
ssid="test_open"
key_mgmt=NONE
}
Run wpa_supplicant
test:~$ sudo ./wpa_supplicant -Dnl80211 -i wlan1 -c ./run_supplicant.conf
Download file to check wireshark output
send_probe_req_every_30sec.pcapng
Check for probe-request packet
Apply display filter
wlan.addr == 02:00:00:00:01:00 && wlan.fc.type_subtype == 4

Observe the probe-request packets with 30 sec time interval
