Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Time fix for packet, and filter addition #21

Open
henriberisha opened this issue Mar 12, 2024 · 0 comments
Open

Time fix for packet, and filter addition #21

henriberisha opened this issue Mar 12, 2024 · 0 comments

Comments

@henriberisha
Copy link

henriberisha commented Mar 12, 2024

Stefan, thank you for this library.

Below are two code changes that i made to improve the results of all examples that you provide.

  1. Fix time issue when writing or sending a packet. Change the following lines:
    uint32_t timestamp = now(); //current timestamp
    uint32_t microseconds = (unsigned int)(micros() - millis() * 1000); //micro seconds offset (0 - 999)

into

uint32_t timestamp = now(); // current timestamp
uint32_t microseconds = (unsigned int)(micros() % 1000000U);

This will fix the relative time between packets, see below results:

relative_time_bad_offset

relative_time_fixed_offset

  1. Can add filter to capture management and data packets:
PCAP pcap = PCAP();
int ch = CHANNEL;
unsigned long lastChannelChange = 0;

const wifi_promiscuous_filter_t filter_data_mgmt = {
    .filter_mask = WIFI_PROMIS_FILTER_MASK_DATA | WIFI_PROMIS_FILTER_MASK_MGMT}; // this filter either DATA or MGMT frames```

```/* setup wifi */
nvs_flash_init();  
tcpip_adapter_init();  
ESP_ERROR_CHECK(esp_event_loop_init(event_handler, NULL));  
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();  
ESP_ERROR_CHECK(esp_wifi_init(&cfg));  
ESP_ERROR_CHECK(esp_wifi_set_storage(WIFI_STORAGE_RAM)); ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_NULL));  
ESP_ERROR_CHECK(esp_wifi_start());  
esp_wifi_set_promiscuous_filter(&filter_data_mgmt); // the filter is used here  
esp_wifi_set_promiscuous(true);  
esp_wifi_set_promiscuous_rx_cb(sniffer);  
wifi_second_chan_t secondCh = (wifi_second_chan_t)NULL;  
esp_wifi_set_channel(ch, secondCh);```


 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant