Greetings! I am using an ESP32-C3 with the attached short ESP32 Arduino program, which is a minimal repro of my application.
I expect that the program should send one packet every 50 ms. What I see, running Wireshark on a computer on the same Wi-Fi network, is that the traffic is "bursty".
Attached is a sample of the inter-packet delays, on a linear and a logarithmic scale.
* On the linear scale below, you can see that, on average, something happens every 200 ms to deliver a "burst" of packets.
* On the logarithmic scale below, you can see the actual distribution of the packets that arrive almost "simultaneously" with the previous ones.
Proper timing is important for my application. The receiving end is not an ESP32.
Is there an explanation for this? Is there something that can help?
Ihab Awad
Bursty UDP traffic from ESP32-C3
Bursty UDP traffic from ESP32-C3
- Attachments
-
- test_wifi_esp32.zip
- (2.34 KiB) Downloaded 186 times
Re: Bursty UDP traffic from ESP32-C3
Greetings again folks,
I have rewritten my example using ESP-IDF -- without Arduino -- and had the same results. Below is the logarithmic plot of inter-packet times. I have also attached a ZIP file of my code. The main section of code is also below.
This is a critical issue for my application. I am surprised this is the behavior.
Ihab
I have rewritten my example using ESP-IDF -- without Arduino -- and had the same results. Below is the logarithmic plot of inter-packet times. I have also attached a ZIP file of my code. The main section of code is also below.
This is a critical issue for my application. I am surprised this is the behavior.
Ihab
Code: Select all
struct addrinfo hints = {
.ai_flags = AI_PASSIVE,
.ai_socktype = SOCK_DGRAM,
};
struct addrinfo *res;
hints.ai_family = AF_INET; // For an IPv4 socket
err = getaddrinfo(EXAMPLE_MULTICAST_IPV4_ADDR,
NULL,
&hints,
&res);
if (err < 0) {
ESP_LOGE(TAG, "getaddrinfo() failed for IPV4 destination address. error: %d", err);
break;
}
if (res == 0) {
ESP_LOGE(TAG, "getaddrinfo() did not return any addresses");
break;
}
((struct sockaddr_in *)res->ai_addr)->sin_port = htons(UDP_PORT);
inet_ntoa_r(((struct sockaddr_in *)res->ai_addr)->sin_addr, addrbuf, sizeof(addrbuf)-1);
ESP_LOGI(TAG, "Sending to IPV4 multicast address %s:%d...", addrbuf, UDP_PORT);
err = sendto(sock, sendbuf, len, 0, res->ai_addr, res->ai_addrlen);
freeaddrinfo(res);
if (err < 0) {
ESP_LOGE(TAG, "IPV4 sendto failed. errno: %d", errno);
break;
}
vTaskDelay(50 / portTICK_PERIOD_MS);
- Attachments
-
- probe_idf.zip
- (29.42 KiB) Downloaded 264 times
-
- Posts: 9725
- Joined: Thu Nov 26, 2015 4:08 am
Re: Bursty UDP traffic from ESP32-C3
Have you disabled wifi power saving?
Code: Select all
esp_wifi_set_ps(WIFI_PS_NONE);
Re: Bursty UDP traffic from ESP32-C3
I just tried it --
The result is as below. No difference.
Ihab
Code: Select all
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_AP));
ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_AP, &wifi_config));
ESP_ERROR_CHECK(esp_wifi_start());
ESP_ERROR_CHECK(esp_wifi_set_ps(WIFI_PS_NONE));
Ihab
-
- Posts: 9725
- Joined: Thu Nov 26, 2015 4:08 am
Re: Bursty UDP traffic from ESP32-C3
Any chance that other traffic on the channel is interfering? WiFi is a shared medium, and when the airwaves are occupied transmitters tend to back off and resend later.
Re: Bursty UDP traffic from ESP32-C3
Well, I'm at home with my home Wi-Fi and perhaps other people's as well. Huh. Ok, let me see if I can get some time in the RF chamber at work and I'll report back.
Ihab
Ihab
Re: Bursty UDP traffic from ESP32-C3
I tried some more experiments and found that the behavior is to some extent dependent on the receiving Wi-Fi adapter. I tried receiving the UDP packets on my laptop using the built-in adapter versus a USB Wi-Fi dongle, and in some cases (though the results were inconsistent), I received properly spaced UDP packets.
I then returned to basics. I added to my actual Arduino code, and tried it out along with my Raspberry Pi CM4 receiving unit, for my actual application. This seemed to provide adequate response times.
As a result, I'm going to consider this issue solved for now, and see if I can address it systematically later. If it recurs, I will re-post here with what I have learned.
Thank you,
Ihab Awad
I then returned to basics. I added
Code: Select all
esp_wifi_set_ps(WIFI_PS_NONE)
As a result, I'm going to consider this issue solved for now, and see if I can address it systematically later. If it recurs, I will re-post here with what I have learned.
Thank you,
Ihab Awad
-
- Posts: 9725
- Joined: Thu Nov 26, 2015 4:08 am
Re: Bursty UDP traffic from ESP32-C3
Good to hear you put this to bed for now; thanks for keeping us updated!
Who is online
Users browsing this forum: Majestic-12 [Bot] and 62 guests