lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-users] Httpd server in contrib


From: Louis Wells
Subject: [lwip-users] Httpd server in contrib
Date: Thu, 14 Feb 2013 08:32:59 -0800

Hello,

I have recently been working a good amount with the httpd server supplied in contrib. 

I am working on improving the SSI implementation to easily be able to include other shtml files, such as headers and footers, instead of simply inserting a string generated by some function.

An issue that I have noticed however is that this webserver is incredibly slow in situations with high latency. I initially thought it might be an issue with tcp in lwip, but discovered it is in the way the server is written.

In http_send_data we have this little chunk of code:

if (tcp_sndbuf(pcb) < hs->left) {
      len = tcp_sndbuf(pcb);
    } else {
      len = (u16_t)hs->left;
      LWIP_ASSERT("hs->left did not fit into u16_t!", (len == hs->left));
    }
    mss = tcp_mss(pcb);
    if(len > (2 * mss)) {
      len = 2 * mss;
    }

    err = http_write(pcb, hs->file, &len, HTTP_IS_DATA_VOLATILE(hs));

The way this is written, the server will only send 2  * mss worth of data, and then wait for tcp to call the httpd_sent callback upon receiving an ack for the data sent. 

I was able to speed it up a bit by changing it to send 8 * mss instead of 2, but even this is not optimal because we still have to wait for the ack before sending more data. This setup is kind of counter intuitive based on how tcp sliding window is supposed to work, and I am going to try and find a way to get the webserver to stream data out more efficiently.

If anyone has any input of a good way to do this, I'd love to hear it, and I will be sure to send out an updated version of httpd when I find a way to speed it up.

Thanks 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]