I'm having a weird issue with UDP performance.
What I'm doing is broadcasting an UDP packet (roughly 50 bytes) from ESP8266, then the receiving computer sends back an acknowledgment back (which is exact same packet plus one extra byte) and the entire operation takes whooping 100+ milliseconds. I find it really weird, because by main loop on ESP side is under 1ms, the server application sends ACK back in less than half ms, and the average ping from server machine to the ESP is 2ms.
Anyone knows what can cause behavior like that?
sending like that:
void sendUDP( IPAddress ip, int port, char msg[]){
WiFiUDP UdpSend;
UdpSend.beginPacket( ip, port );
UdpSend.printf("%s", "+=+=");
UdpSend.printf("%s", msg);
UdpSend.printf("%s", "*=*=");
UdpSend.endPacket();
}and receiving like that (in the loop, of course):
int packetSize = UdpIn.parsePacket();
if (packetSize) {
int len = UdpIn.read( incomingPacket, 255 );
if ( len > 0 ){
incomingPacket[len] = 0;
}
packetPayload = String(incomingPacket);
}everything using standard WiFiUdp.h so nothing fancy
----edit----
I just tried sending the packet to a specific machine instead of using multicast address and it seems to be more than 10 times faster this way. Why would multicast be so much slower?.....