AnsweredAssumed Answered

MQX httpsrv - large cgi stream - retransmissons

Question asked by m.bach on Aug 25, 2014
Latest reply on Aug 29, 2014 by Karel Mozny

Hi there,


I'm quite new to MQX, just starting to port some projects to MQX. I need to create an application which is generating 'big' files as dynamically generated CGI data, so I started to figure out what the MQX http server is capable of.


First question: is it allowed to have a resource like this, which is 'just' doing multiple subsequent calls to HTTPSRV_cgi_write() ?

My first impression: it works. (spot on).

My second impression: it's slow. After a few packets, I see many TCP re-transmission on a very regular basis.


You find attached a wireshark trace of the complete TCP stream.

It's not always exactly the same packet no, though the re-transmissions are kicking in at approx the same stream-position, maybe one or two packets more or less.


Here is the code I added to cgi.c, starting at the MQX demo http server project:


const HTTPSRV_CGI_LINK_STRUCT cgi_lnk_tbl[] = {

    { "bigdata",        cgi_big_data,  1500},

    { 0, 0 }    // DO NOT REMOVE - last item - end of table



static _mqx_int cgi_big_data(HTTPSRV_CGI_REQ_STRUCT* param)



    if (param->request_method != HTTPSRV_REQ_GET)





    response.ses_handle = param->ses_handle;

    response.content_type = HTTPSRV_CONTENT_TYPE_PLAIN;

    response.status_code = 200;

    response.content_length = 0; // @TODO this prevents keep-alive


    int i;

    char str[32]; = str;

    for (i = 0; i < 60000; i++)


        response.data_length = snprintf(str, 32, "%ld\n", i);



    return (1); // ?




Does anyone can tell me if it's OK to generate large CGI streams that way?

Does anyone know what might be the reason for the many re-transmissions?


Here is my example wget call to get the file:


  $ wget ""  -O /tmp/bla

  --2014-08-25 13:41:36--

  Connecting to connected.

  HTTP request sent, awaiting response... 200 OK

  Length: unspecified [text/plain]

  Saving to: ‘/tmp/bla’

      [                                       <=>        ] 348.890     26,9KB/s   in 13s   

  2014-08-25 13:41:49 (26,3 KB/s) - ‘/tmp/bla’ saved [348890]



best regards, and many thank in advance,


Original Attachment has been moved to: