Page 1 of 1

esp32 wifi promiscuous mode, no control frame captured

Posted: Fri Dec 30, 2022 12:57 pm
by lironghua
Hi, I'm doing a project to capture WiFi ACK frames under promiscuous mode. These are part of the initialization codes:
  1.     wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
  2.     ESP_ERROR_CHECK(esp_wifi_init(&cfg));
  3.  
  4.     ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA) );
  5.     ESP_ERROR_CHECK(esp_wifi_start());
  6.  
  7.     ESP_ERROR_CHECK(esp_wifi_set_promiscuous(true));
  8.     ESP_ERROR_CHECK(esp_wifi_set_promiscuous_rx_cb(&sniffer));
  9.     wifi_promiscuous_filter_t filter = {
  10.           .filter_mask = WIFI_PROMIS_CTRL_FILTER_MASK_ALL|WIFI_PROMIS_FILTER_MASK_DATA|WIFI_PROMIS_FILTER_MASK_CTRL;
  11.     };
  12.     ESP_ERROR_CHECK(esp_wifi_set_promiscuous_filter(&filter));
I've also tried other combinations of filters, but none of them can capture any control frame. Meanwhile, the Management frames and the Data frames can be captured successfully. Does anyone have some ideas?

Re: esp32 wifi promiscuous mode, no control frame captured

Posted: Sun Jan 01, 2023 7:45 am
by lironghua
Ok, I solved it. It turns out that the ctrl frame filter needs to be set separately via "esp_wifi_set_promiscuous_ctrl_filter"

Re: esp32 wifi promiscuous mode, no control frame captured

Posted: Fri Feb 10, 2023 2:23 am
by roger_
Can you please post a working filtering example? Is esp_wifi_set_promiscuous_filter() still needed, or just esp_wifi_set_promiscuous_ctrl_filter()?

Thanks!

Re: esp32 wifi promiscuous mode, no control frame captured

Posted: Thu Nov 14, 2024 2:45 am
by lironghua
Sorry for the late reply. Yes, both are needed. One is for enabling the capture of ctrl packets and the other is for specifying the packet type.
  1.     ESP_ERROR_CHECK(esp_wifi_set_promiscuous_rx_cb(&sniffer));
  2.     wifi_promiscuous_filter_t filter = {
  3.         .filter_mask = WIFI_PROMIS_FILTER_MASK_DATA|WIFI_PROMIS_FILTER_MASK_CTRL
  4.     };
  5.     ESP_ERROR_CHECK(esp_wifi_set_promiscuous_filter(&filter));
  6.     wifi_promiscuous_filter_t ctrl_filter = {
  7.         .filter_mask = WIFI_PROMIS_CTRL_FILTER_MASK_ACK
  8.     };
  9.     ESP_ERROR_CHECK(esp_wifi_set_promiscuous_ctrl_filter(&ctrl_filter));
  10.     esp_wifi_get_promiscuous_filter(&filter);