How to handle insufficient "available_space" in "wiced_packet_create_tcp"?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Hi All,

I am trying to send a rather large packet over TCP in AP mode. The packet varies anywhere between 1400 to 1800 bytes. When I give this length to "wiced_packet_create_tcp", it sometimes returns the "available_space" parameter with a value smaller than my packet size.

What does this mean? Does it mean I have to split up my packet or is it dependent on any other memory?

Has my application occupied so much memory that the TCP stack is unable to find any more memory?

I am using WICED 3.3.1 with (FreeRTOS + LwIP) on an MXCHIP EMW3162 module with STM32 and BCM43362A2.

Sample Code: (Function from my end responsible for sending packets).

    if ((result = wiced_packet_create_tcp( socket, strlen (response), &tx_packet, (uint8_t**) &tx_data, &available_data_length )) != WICED_SUCCESS )
    {
        MYLOG("TCP packet creation failed, %d", result);
        return WICED_ERROR;
    }
    if (available_data_length >= strlen(response)) {
        MYLOG (" Not enough memory available for sending data ");
        return WICED_ERROR;
    }

Thanks in advance for the help.

Best Regards,

Avinash

Message was edited by: Avinash Kumar The title could have been better framed.

0 Likes
4 Replies
Anonymous
Not applicable

That platform has only 128k or sram 


So it is possible that there isn't enough packet memory available at that moment


You can profile your memory usage using mallinfo 

0 Likes

nsankar wrote:

That platform has only 128k or sram

So it is possible that there isn't enough packet memory available at that moment

Hi nsankar​,

In this case wiced_packet_create_tcp() returns success.

The question is what is the graceful way to handle the case "available_space"

is small than the packet size to send?

0 Likes
Anonymous
Not applicable

You need to break up the packet in application space rather than in the TCP stack in this case. And send via multiple TCP packets

0 Likes
AxLi_1746341
Level 7
Level 7
10 comments on KBA 5 comments on KBA First comment on KBA

avinashckumar.switch wrote:

Hi All,

I am trying to send a rather large packet over TCP in AP mode. The packet varies anywhere between 1400 to 1800 bytes. When I give this length to "wiced_packet_create_tcp", it sometimes returns the "available_space" parameter with a value smaller than my packet size.

What does this mean? Does it mean I have to split up my packet or is it dependent on any other memory?

Has my application occupied so much memory that the TCP stack is unable to find any more memory?

Hi avinashckumar.switch​,

I think you can take a look at the implementation of wiced_tcp_send_buffer() to see how it handles this case.

Or just switch to use wiced_tcp_send_buffer() instead of wiced_packet_create_tcp().

Regards,

Axel

0 Likes