RA6M2 FreeRTOS+TCP large UDP messages.

FSP: 4.3

OS: FreeRTOS

Module: FreeRTOS+TCP

MCU: R7FA6M2AD3CFB

IDE: VS Code

I have set up UDP comms and this works on its own. I can send and receive messages that are smaller than ~1.5kB. However, larger messages do not trigger FreeRTOS_recvfrom, or the lower layers as far as I've been able to dig. I've tried upping the size of g_ether0_ether_buffer0-7 and increasing ether_buffer_size to match but that doesn't seem to help. I also tried increasing ipconfigUDP_MAX_RX_PACKETS incase the packet was being split somewhere, this doesn't help either. Please help in increasing the max receivable message size.

  • Hello,

    Thanks for reaching our Renesas Engineering Community!

    Could you please send us more details about the configurations you made in your project? Also have you tried to increase the size of RX buffer for TCP sockets in properties of FreeRTOS+TCP stack?

    Thank you!

    Best Regards,

    IK

  • Hi,

    I'm not sure which configurations are required but these are some below, also yes I have tried increasing those buffer sizes to 5200 with no success. According to packet sender, the size of the message being set is ~4.5k. I also have MQTT set up, not sure if that is relevant. Please let me know what additional info is required.


  • Hello again,

    Yes I can see. Please could you send me the hole configuration.xml file of your project? You also mentioned something about setting MQTT what settings have you done? 

    Thank you!

    Best Regards,

    IK

  • 8508.configuration.xml

    Please find the config attached. Hopefully this covers what you want to know about the mqtt, please let me know if there's something else I can provide on this. Also note that I am compiling via a vscode project, though the initial setup/generation was done on e2studio, also note that the vscode project was updated to use FSP 4.3

  • So I've done some testing and the max incoming message side on UDP seems to be 1472. Which is suspiciously equal to ipMAX_UDP_PAYLOAD_LENGTH, but this seems to only be used in the FreeRTOS_sendto function. There seem to be similar limitations in usGenerateProtocolChecksum and xCheckSizeFields but these don't get hit. It seems I'm limited to 1472 which is the NETWORK_MTU - Header(28 bytes).

  • Hello Vernon,

    Thanks for your response and the information you shared with us.

    Yes it seems that this is the typical allowed size by most ethernet networks. As you can see bellow:

    The typical size of the payload reaches 1472 bytes.

    Thank you!

    Best Regards,

    IK

  • Hi,

    This should only be the case for the lower layer though shouldn't it? Why can I make a 6k buffer for receiving data if it is limited by the NETWORK_MTU? Also, I tried switching to TCP, and I am able to receive the message on that (though it is split into 1x 1.5k message and 1x 3k message). Though the fact that I can receive a 3k message on tcp, which uses the same FreeRTOS_recv function as UDP, means that the FreeRTOS+TCP stack can handle receiving messages larger than the NETWORK_MTU, which makes sense. I don't know if UDP's implementation is different at a lower level somehow, the max size of the datagram should be ~65k so I assume that it shouldn't be though I have little experience on the matter, but please confirm if the implementation on the RA platform (or if this is the case in FreeRTOS+TCP) in general cannot receive messages >  NETWORK_MTU.

  • UDP is frame based, you can't send anything larger than a single IP frame. You can build your own fragmentation protocol on top - that's one of the things TCP does for you. Also see this: https://stackoverflow.com/questions/1098897/what-is-the-largest-safe-udp-packet-size-on-the-internet

  • Thank you for that clarification. The issue I'm having, is that if the UDP message is larger than 1472 bytes,  I receive nothing at all from FreeRTOS_recv, and as far as I can trace down before the breakpoints becomes problematic, I cannot find the condition that is discarding the message. The TCP message I receive is fragmented so I'd have to implement my own reconstruction in the application layer either way it seems. I am not experienced with with intricacies of UDP in this aspect so thank you for the insight, but should the UDP message be rejected outright like this?

  • FreeRTOS+TCP does not support UDP fragmentation. The max message size is one network frame.