Unable to send an UDP packet less than 18 bytes

Hi experts,

I try to send a packet with some infos.
My problem is that te packet is always padded with zero if the length of the data is less than 18 bytes.

The problem is that the device does not recognize the data if it does not meet exactly what the device expects (so I cannot add some extra characters to pad the data).

Any ideas ?

// Code

udpMulti.beginPacketMulticast(multicast, multiPort, WiFi.localIP());
char packet = "toto";
udpMulti.write(packet);
udpMulti.endPacket();

U 192.168.0.100:49508 -> 220.0.0.50:5678 #364
74 6f 74 6f 00 ef ef fe 00 00 00 00 00 00 00 00 toto............
00 00 ..

The minimum Ethernet packet is 64 bytes, so I guess the slightly extended UDP header is 46 bytes (28 would the minimum size), 18 bytes must be padded to be sent by Ethernet.

I'm sure your device will accept such packets if it's connected to Ethernet too. :slight_smile:

Hi,

thank you very much.

I am testing in real time with two other softs : Packet Sender and a Python script. Both of them are OK excepted the arduino code above. The only difference is the padded packet by the Arduino. Is it because the UDP library is derived from the TCP one ?

Packet sender is also padding the packet. So I don’t understant why I don’t receive the packets from the device.

Regards,

OK, thank you pylon for challenging my statements.

I had to start a udp listener before sending the multicast packet.

It works now by adding

udp.begin(5555);

Thank you very much !