esp32 wifi promiscuous mode, no control frame captured

lironghua
Posts: 4
Joined: Fri Dec 30, 2022 11:50 am

esp32 wifi promiscuous mode, no control frame captured

Postby lironghua » Fri Dec 30, 2022 12:57 pm

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?

lironghua
Posts: 4
Joined: Fri Dec 30, 2022 11:50 am

Re: esp32 wifi promiscuous mode, no control frame captured

Postby lironghua » Sun Jan 01, 2023 7:45 am

Ok, I solved it. It turns out that the ctrl frame filter needs to be set separately via "esp_wifi_set_promiscuous_ctrl_filter"

roger_
Posts: 1
Joined: Fri Feb 10, 2023 2:21 am

Re: esp32 wifi promiscuous mode, no control frame captured

Postby roger_ » Fri Feb 10, 2023 2:23 am

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!

lironghua
Posts: 4
Joined: Fri Dec 30, 2022 11:50 am

Re: esp32 wifi promiscuous mode, no control frame captured

Postby lironghua » Thu Nov 14, 2024 2:45 am

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);

Who is online

Users browsing this forum: Bing [Bot] and 87 guests