Hi,I use Thread X with RA6M3.FSP version 5.1
I want to send via tcp 119k byte using BSD wrapper, but:
If i try to send with a single call to send() function i get an error errno = 107 and the tcp socket disconnect.
bytes_to_send = 118784;
status = send(accepted_socket, ((const char*)p_SCmos), bytes_to_send, 0);
I thought it was a problem with the number of packet pool and their size but even setting the size to 1568 with 32 packets even trying to send only 15k bytes at a time I get an error.
The only wait to make it to go is to split with small send():
#define MAX_ONE_TIME_SEND_BYTES 1000
remaining_bytes = 118784
while(remaining_bytes > 0){
if(remaining_bytes > MAX_ONE_TIME_SEND_BYTES){
bytes_to_send = MAX_ONE_TIME_SEND_BYTES;
} else {
bytes_to_send = remaining_bytes;
}
status = send(accepted_socket, ((const char*)p_SCmos + (118784 - remaining_bytes)), bytes_to_send, 0);
if(status == -1){
SetLed(RED);
D(printf("Error sending body GetRawImage!\n"));
What is the connection with the BSD send() and packet pools? I thought that BSD send() took care of dividing my data to send it and not having to do it myself.The only limit i think may be space due to the number of packets * packet size, but even if i use 1568 * 32 = 50176 a send with only 15k at a time it should work but it doesn't.Can you explain to me why?
Hello sir,
Thanks for reaching out Renesas Engineering Community.
Could you please share the whole project to check also your configurations?
Best Regards,
IK
prova_bsd_eval.zipthank you
After checking your issue internally, let me point out two things:
1. In your code inside the init_tcp_socket(); you do not call the nx_ip_fragment_enable(); .
https://github.com/eclipse-threadx/rtos-docs/blob/main/rtos-docs/netx-duo/chapter3.md#ip-fragmentation
2. Also you would need a packet pool big enough to handle such kind of transmission. Please check this Forum thread.
https://community.renesas.com/mcu-mpu/embedded-system-platform/f/forum/9448/netx-duo-dhcp-and-bsd-sending-large-blocks-of-data
Hope it helps.
Hi,1)IP fragmentation in our case is irrelevant because we have a point-to-point connection,. Anyhow, with or without fragmentation the behavior is unpredictable.2)With our application we try to use g_packet_pool1 ( just to avoid confusion we reserved a proper packet pool for BSD communication ) configured with 16 packets of 1568.Next we define MAX_ONE_TIME_SEND_BITES = 20000 as a maximum block to send. With this configuration two sends are successful while the third fails with error 107.If you try to test this behaviour setting MAX_ONE_TIME_SEND_BITES to 15000 more sends are successful but sooner or later the error comes...With 16 packets of 1568 bytes we should be covered up to 25k so 15k shouldn't have any problems.Can you tell me the correlation between maximum send size and how large the pool needs to be? 1:1, 1:2 or how much? Is it possible to have a new example for eval where you use BSD with blocking tcp socket and do a send() with 120k of payload in one send()?I mean without the need to cut my payload in pieces and using a loop?Thanks
Any news?
Apologies for the delay, please let us investigate this more and come back to you.
Thank you!
Apologies for my delayed response.
After checking your issue also internally:
NetX BSD internally uses standard NetX API. Internally NetX BSD send will first call nx_packet_data_append to copy the message into a NetX packet, so if the message is larger than the size of a single packet, one or more packets will be allocated to satisfy the request. From the NetX DUO documentation for nx_packet_data_append ( github.com/.../chapter4.md ).
Check also the description here:
https://github.com/eclipse-threadx/rtos-docs/blob/main/rtos-docs/netx-duo/chapter4.md#description-66
So the packet pool should be large enough to hold the complete message that is passed to BSD send.
For example if we have a message with a total size 120KB and if we set the packet pool 16 packets (and the size of each packet is 1568 bytes), this is the place the send fails:
Timeout has been set to 2 sec. If we set the packet pool to 120 the send completes successfully.
Please find attached an example that runs on RA6M3, this requires a TCP server running on other machine to receive data sent from RA6M3.
FSP_5_3_0_EK_RA6M3_BSD_Socket_Large_Send.zip
Thank you. However, by placing 120 packages we will occupy 120k of RAM, and I don't want to allocate so much ram just for the packet pool...1)So if I have to send a lot of bytes of data I always have to cut my payload by myself, otherwise send can't handle it on its own, I thought it would at least send what it can instead of giving an error and blocking completely... 2)Another case: 32 packets of 1568 bytes (50176 bytes for the packet pool): sends of 40k do not always complete. If I set TCP Maximum TX Queue to 5 everything works(default is 20), is there an explanation?