UDP dropping frames

CollinK
Posts: 18
Joined: Mon Apr 16, 2018 11:38 pm

UDP dropping frames

Postby CollinK » Mon Apr 16, 2018 11:48 pm

I'm using the current master version of Arduino-ESP32. UPD performance seems to just plain be garbage. Oh, I can send rapidly if I want to but randomly it'll quit sending traffic. If I set to send a packet every 500ms it'll still drop randomly and sometimes not transmit anything for 2-8 seconds. If I set to 100ms it'll send great sometimes and have multi-second drops other times. Below is a very simple sketch that still seems to have this problem. I'm confirming this problem by using wireshark on my PC. I'm rather doubting that the problem is my PC dropping traffic, it seems more likely that the ESP32 isn't sending it properly. You can see in the below sketch that it is outputting
a star every time it sends. I can see weird pauses sometimes in the output of stars which probably correspond to the dropping of UDP frames. But, why?! That sketch does nothing but send UPD frames and wait around in between times. There's nothing running to bog it down.

This is all with a WROOM-32 module. I suspect that the PCB antenna might be garbage but this module is running on a board right next to the PC and the signal strength seems decent enough. Has anyone gotten UDP packets to reliably send from the ESP32? Yes, I know UDP is not reliable but it should be sending more than 75% of the packets. It ought to get to at least 95% of the packets delivered in this case, and probably closer to 99 - 99.9%. Instead I really am getting only like 75% or less through whether I send at 500ms or 100ms. I shudder to even attempt 10ms.

Code: Select all

#include <WiFi.h>

byte i = 0;

byte serialBuffer[2048];
int serialBufferLength = 0;
uint32_t lastFlushMicros = 0;

WiFiUDP wifiUDPServer;
IPAddress broadcastAddr(192,168,4,255);

void setup()
{
    Serial.begin(115200);

    WiFi.mode(WIFI_AP);
    WiFi.softAP("ESP32DUE", "1234PASSWORD");

    Serial.print("Wifi setup as SSID ");
    Serial.println("ESP32DUE");
    Serial.print("IP address: ");
    Serial.println(WiFi.softAPIP());
    Serial.print("Done with init\n");
}

void loop()
{
    serialBufferLength = 400;
    delay(100);
    //If the max time has passed or the buffer is almost filled then send a frame out
    //if ((micros() - lastFlushMicros > 100000) ) {
        Serial.write('*');
        wifiUDPServer.begin(17222);
        wifiUDPServer.beginPacket(broadcastAddr, 17222);
        wifiUDPServer.write(serialBuffer, serialBufferLength);
        wifiUDPServer.endPacket();
        wifiUDPServer.stop();
        //lastFlushMicros = micros();
    //}
}

plajjd
Posts: 54
Joined: Thu Jul 05, 2018 11:47 pm

Re: UDP dropping frames

Postby plajjd » Wed Sep 19, 2018 11:06 pm

Has anyone else had an issue like this? I am using ESP-NOW on Adafruit Feather Huzzah32 boards . (ESP32) I am doing a simple broadcast esp_now_send() to 2 receivers about a meter away. I get the send callback for every transmit, but not every packet is received by the other 2 devices. I am questioning if it is even being sent. (I lose around 3% of the packets)

I would like to send small packets of data (20 bytes) continually - every 10 ms or so. But I can't get reliable reception even at 50 or 100ms intervals.

Thanks!

Eyer1951
Posts: 3
Joined: Sat Jul 06, 2019 4:08 pm

Re: UDP dropping frames

Postby Eyer1951 » Mon Sep 16, 2019 8:56 pm

I experience a similar problem: sending a UDP packet with 164 data bytes every 20 msec. The loop calls

Code: Select all

			udp.beginPacket(broadcastIp, udpPort);
				udp.write(buffer, sizeof(buffer));
				udp.endPacket();
every 20 msec, but randomly about one packet in 10 is apparently not transmitted. The worse problem: the spacing between packets should be 20 msec, but often instead there are a bunch of packets at 2 msec spacing followed by a ~170 msec gap.

This behavior is not consistent: sometimes I see the expected 20 msec spacing, then after a while it switches to the bunched output. Here is a Wireshark capture showing timing between displayed packets.
Screen Shot 2019-09-16 at 1.45.53 PM.png
Screen Shot 2019-09-16 at 1.45.53 PM.png (163.63 KiB) Viewed 5672 times
One of the missing packets is between 209 and 210 (data has a timestamp, so this is obvious).

What's going on here? Is there any remedy? I'm using ESP IDF 1.0.3-rc1 on an ESP32 WROOM32 dev board:
arduino15\packages\esp32\hardware\esp32\1.0.3-rc1\cores\esp32\libb64

Who is online

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