This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC3220SF-LAUNCHXL: Fragmentation in HTTP Message Transfer from Server(CC3220SF) To client (Any other Device)

Part Number: CC3220SF-LAUNCHXL
Other Parts Discussed in Thread: CC3220SF

Hi,

I am trying to send the http message from CC3220SF Http Server to a Laptop based http client where CC3220SF also working as access point. I have to send huge data (approx 10kB) in response for each http request. I tried sending 2kB with 4 fragments of each size 500B (total 2kB) which is working fine and the code is as below - 

int32_t dataGetCallback(uint8_t requestIdx, uint8_t *argcCallback, uint8_t **argvCallback, SlNetAppRequest_t *netAppRequest)
{
    uint8_t *pPayload;
    uint16_t metadataLen, sendDatalen;



    char sendDataStr1[500] = "1Machine learning (ML) is a field of inquiry devoted to understanding and building methods that 'learn', that is, methods that leverage data to improve performance on some set of tasks. It is seen as a part of artificial intelligence. Machine learning algorithms build a model based on sample data, known as training data, in order to make predictions or decisions without being explicitly programmed to do so1.";
    char sendDataStr2[500] = "2Machine learning (ML) is a field of inquiry devoted to understanding and building methods that 'learn', that is, methods that leverage data to improve performance on some set of tasks. It is seen as a part of artificial intelligence. Machine learning algorithms build a model based on sample data, known as training data, in order to make predictions or decisions without being explicitly programmed to do so2.";
    char sendDataStr3[500] = "3Machine learning (ML) is a field of inquiry devoted to understanding and building methods that 'learn', that is, methods that leverage data to improve performance on some set of tasks. It is seen as a part of artificial intelligence. Machine learning algorithms build a model based on sample data, known as training data, in order to make predictions or decisions without being explicitly programmed to do so3.";
    char sendDataStr4[500] = "4Machine learning (ML) is a field of inquiry devoted to understanding and building methods that 'learn', that is, methods that leverage data to improve performance on some set of tasks. It is seen as a part of artificial intelligence. Machine learning algorithms build a model based on sample data, known as training data, in order to make predictions or decisions without being explicitly programmed to do so4.";
    char sendDataStr5[500] = "4Machine learning (ML) is a field of inquiry devoted to understanding and building methods that 'learn', that is, methods that leverage data to improve performance on some set of tasks. It is seen as a part of artificial intelligence. Machine learning algorithms build a model based on sample data, known as training data, in order to make predictions or decisions without being explicitly programmed to do so5.";

    pPayload = gPayloadBuffer;



    sl_Memcpy (pPayload, sendDataStr1, sizeof(sendDataStr1));
    pPayload += sizeof(sendDataStr1);

    /* NULL terminate the payload */
    *(pPayload) = '\0';

    sendDatalen = sizeof(sendDataStr1) + sizeof(sendDataStr2) + sizeof(sendDataStr3)+ sizeof(sendDataStr4); //+sizeof(sendDataStr5);

    metadataLen = prepareGetMetadata(0, sendDatalen, HttpContentTypeList_TextPlain);

    pthread_mutex_lock(&spiMutex);

    sl_NetAppSend (netAppRequest->Handle, metadataLen, gMetadataBuffer, (SL_NETAPP_REQUEST_RESPONSE_FLAGS_CONTINUATION | SL_NETAPP_REQUEST_RESPONSE_FLAGS_METADATA));
    sl_NetAppSend (netAppRequest->Handle,sizeof(sendDataStr1), gPayloadBuffer, SL_NETAPP_REQUEST_RESPONSE_FLAGS_CONTINUATION); /* mark as last segment */


    pPayload = gPayloadBuffer;
    sl_Memcpy (pPayload, sendDataStr2, sizeof(sendDataStr2));
    pPayload += sizeof(sendDataStr2);

    /* NULL terminate the payload */
    *(pPayload) = '\0';

    sl_NetAppSend (netAppRequest->Handle,sizeof(sendDataStr3), gPayloadBuffer, SL_NETAPP_REQUEST_RESPONSE_FLAGS_CONTINUATION); /* mark as last segment */

    pPayload = gPayloadBuffer;
    sl_Memcpy (pPayload, sendDataStr3, sizeof(sendDataStr3));
    pPayload += sizeof(sendDataStr3);

    /* NULL terminate the payload */
    *(pPayload) = '\0';

   sl_NetAppSend (netAppRequest->Handle,sizeof(sendDataStr3), gPayloadBuffer, SL_NETAPP_REQUEST_RESPONSE_FLAGS_CONTINUATION); /* mark as last segment */

    pPayload = gPayloadBuffer;
    sl_Memcpy (pPayload, sendDataStr4, sizeof(sendDataStr4));
    pPayload += sizeof(sendDataStr4);

    /* NULL terminate the payload */
    *(pPayload) = '\0';

    sl_NetAppSend (netAppRequest->Handle,sizeof(sendDataStr4), gPayloadBuffer, 0); /* mark as last segment */

    pthread_mutex_unlock(&spiMutex);

    return 0;
}

The response is as below - 

But when I try sending more fragments or/and four fragments with larger size it stuck is the request only and then show 404 error as shown below - 

int32_t dataGetCallback(uint8_t requestIdx, uint8_t *argcCallback, uint8_t **argvCallback, SlNetAppRequest_t *netAppRequest)
{
    uint8_t *pPayload;
    uint16_t metadataLen, sendDatalen;



    char sendDataStr1[500] = "1Machine learning (ML) is a field of inquiry devoted to understanding and building methods that 'learn', that is, methods that leverage data to improve performance on some set of tasks. It is seen as a part of artificial intelligence. Machine learning algorithms build a model based on sample data, known as training data, in order to make predictions or decisions without being explicitly programmed to do so1.";
    char sendDataStr2[500] = "2Machine learning (ML) is a field of inquiry devoted to understanding and building methods that 'learn', that is, methods that leverage data to improve performance on some set of tasks. It is seen as a part of artificial intelligence. Machine learning algorithms build a model based on sample data, known as training data, in order to make predictions or decisions without being explicitly programmed to do so2.";
    char sendDataStr3[500] = "3Machine learning (ML) is a field of inquiry devoted to understanding and building methods that 'learn', that is, methods that leverage data to improve performance on some set of tasks. It is seen as a part of artificial intelligence. Machine learning algorithms build a model based on sample data, known as training data, in order to make predictions or decisions without being explicitly programmed to do so3.";
    char sendDataStr4[500] = "4Machine learning (ML) is a field of inquiry devoted to understanding and building methods that 'learn', that is, methods that leverage data to improve performance on some set of tasks. It is seen as a part of artificial intelligence. Machine learning algorithms build a model based on sample data, known as training data, in order to make predictions or decisions without being explicitly programmed to do so4.";
    char sendDataStr5[500] = "4Machine learning (ML) is a field of inquiry devoted to understanding and building methods that 'learn', that is, methods that leverage data to improve performance on some set of tasks. It is seen as a part of artificial intelligence. Machine learning algorithms build a model based on sample data, known as training data, in order to make predictions or decisions without being explicitly programmed to do so5.";

    pPayload = gPayloadBuffer;



    sl_Memcpy (pPayload, sendDataStr1, sizeof(sendDataStr1));
    pPayload += sizeof(sendDataStr1);

//    /* NULL terminate the payload */
    *(pPayload) = '\0';

    sendDatalen = sizeof(sendDataStr1) + sizeof(sendDataStr2) + sizeof(sendDataStr3)+ sizeof(sendDataStr4)+sizeof(sendDataStr5);

    metadataLen = prepareGetMetadata(0, sendDatalen, HttpContentTypeList_TextPlain);

    pthread_mutex_lock(&spiMutex);

    sl_NetAppSend (netAppRequest->Handle, metadataLen, gMetadataBuffer, (SL_NETAPP_REQUEST_RESPONSE_FLAGS_CONTINUATION | SL_NETAPP_REQUEST_RESPONSE_FLAGS_METADATA));
    sl_NetAppSend (netAppRequest->Handle,sizeof(sendDataStr1), gPayloadBuffer, SL_NETAPP_REQUEST_RESPONSE_FLAGS_CONTINUATION); /* mark as last segment */


    pPayload = gPayloadBuffer;
    sl_Memcpy (pPayload, sendDataStr2, sizeof(sendDataStr2));
    pPayload += sizeof(sendDataStr2);

//    /* NULL terminate the payload */
    *(pPayload) = '\0';

    sl_NetAppSend (netAppRequest->Handle,sizeof(sendDataStr3), gPayloadBuffer, SL_NETAPP_REQUEST_RESPONSE_FLAGS_CONTINUATION); /* mark as last segment */

    pPayload = gPayloadBuffer;
    sl_Memcpy (pPayload, sendDataStr3, sizeof(sendDataStr3));
    pPayload += sizeof(sendDataStr3);

//    /* NULL terminate the payload */
    *(pPayload) = '\0';

   sl_NetAppSend (netAppRequest->Handle,sizeof(sendDataStr3), gPayloadBuffer, SL_NETAPP_REQUEST_RESPONSE_FLAGS_CONTINUATION); /* mark as last segment */

    pPayload = gPayloadBuffer;
    sl_Memcpy (pPayload, sendDataStr4, sizeof(sendDataStr4));
    pPayload += sizeof(sendDataStr4);

////    /* NULL terminate the payload */
    *(pPayload) = '\0';

    sl_NetAppSend (netAppRequest->Handle,sizeof(sendDataStr4), gPayloadBuffer, SL_NETAPP_REQUEST_RESPONSE_FLAGS_CONTINUATION); /* mark as last segment */

     pPayload = gPayloadBuffer;
     sl_Memcpy (pPayload, sendDataStr5, sizeof(sendDataStr5));
     pPayload += sizeof(sendDataStr5);

 ////    /* NULL terminate the payload */
     *(pPayload) = '\0';

    sl_NetAppSend (netAppRequest->Handle,sizeof(sendDataStr5), gPayloadBuffer, 0); /* mark as last segment */

    pthread_mutex_unlock(&spiMutex);

    return 0;
}

The response of the client in Postman is shown below (same response occurred in html page) --

When the next request is placed then it shows 404 error after 30 s - 

Can anyone help, whats wrong going here?

Thanks & Regards,

Kuldeep

  • Hi,

    We are not aware of such an issue.

    can you quickly do a test that instead divides it even more, i.e. 8 buffers of 250 each.

    I want to see if it still fails after 4 buffers or whether it is size related.

    Regards,

    Shlomi

  • Hi Shlomi,

    Thank you for your response

    I tried sending 8 buffers with size of 250 bytes and its working. Its clearly a size issue but why size issue is there even the max fragment size is 1364.

    And I think this is not the fragment size. its the total size for which I am facing the issue. 

    Also when i increase the request frequency then also I face this issue. A timeout occurs at client for the 1st request itself if the size is high and followup requests have 404 "Page not found" issue.

    Can you please check above code once if I am doing something wrong?

    Thanks & Regards,

    Kuldeep

  • Hi Shlomi,

    I further tried to change the code and investigate the issue and the CC3220SF is getting stuck in metadata netappsend itself as shown below -

    This doesn't draw any conclusion for me. Can you let me know if the defining the string and its uses are as needed?

    or possible can you share the code for the callback which have fragmentation and large size data ( more the 4096 or so).

    It will be great help.

    Thanks & Regards,

    Kuldeep

  • well, I don't have a working example to share at the moment.

    When you say it crashes on sending the metadata, can you verify all the parameters make sense (metadata and senddata lengths for example).

    also, where inside this function it fails? can you step in carefully and let me know? I want to verify whether the command goes to the chip or remains in the host.

    Shlomi

  • Hi Shlomi,

    Thank you for the response.

    As I see the metadata (datalen etc.) are correct  as shown below - 

    The metadata have no difference with 4 fragments and 8 fragments except datalen.

    1. with 8 fragments - 

    2. With 4 Fragments

    I am not able to find the exact location where the code is triggering infinite spin but sometimes i can see that hw_int is getting triggers while i have the debugging point in spiwrite or read function as shown below.

    1. 

    2.

    If possible can you create a fragmentation code with large data size and share, that will be great help.

    Thanks & Regards,

    Kuldeep

  • Hi,

    I will do my best and let you know.

    Shlomi

  • Hi,

    I managed to use the OOB example which implements similar HTTP GET requests as you are using (and I believe you used it as a reference since the code is similar) and I haven't seen any issues. Actually, just to make sure I even increased it to 8 buffers of 500 bytes each and still I am able to get all buffers concatenated on my browser.

    I suspect you may have a SW issue, e.g. stack overflow that may cause the system to stuck.

    Just for the test, can you place the large buffers outside the function as global variables so it doesn't get consumed from the stack memory?

    Regards,

    Shlomi

  • Dear Shlomi,

    Thanks for your response. You are correct. The issue is due to stack overflow itself. I was able to resolve the issue by using a global buffer. I got that after some iterations that I am doing wrong there.

    Thank you for your help.

    Regards,

    Kuldeep