So,
I have updated reception code (from the contrib examples httpd_raw) and still
the behaviour is the same (code at bottom).
I did a quick and ugly test by calling tcp_ack_now and tcp_output at the end of
the function and then the behaviour dramatically improved as ACKs are being
sent back and there is no RST from server (as expected).
I might also add that each http request I am sending is a blocking call (and
awaits a response) with timeout at application level. So practically I am only
handling one full transaction at a time. The transactions are deterministic and
small in size.
So this for me boils down to TCP_WND setting. The http requests I'm sending is
roughly at 200 bytes and reception is in equal side so they are fairly small.
Is there a guidance on how to set LWIPOPTS variables regarding TCP for this
kind of behaviour? Right now my settings are:
LWIPOPTS.H
#define TCP_MSS 1460
/**
* TCP_WND: The size of a TCP window. This must be at least
* (2 * TCP_MSS) for things to work well
*/
#define TCP_WND (2 * TCP_MSS)
/**
* TCP_SND_BUF: TCP sender buffer space (bytes).
* To achieve good performance, this should be at least 2 * TCP_MSS.
*/
#define TCP_SND_BUF (2 * TCP_MSS)
Reception Code:
err_t tcp_tx_resp_cb(void *arg, struct tcp_pcb *tpcb, struct pbuf *p, err_t err)
{
eth_ctx_t* ctx = (eth_ctx_t*)arg;
uint8_t* data;
if ((err != ERR_OK) || (p == NULL)) {
DBG_W(EINVAL, "Ignoring response err '%d'.", err);
/* error or closed by other side? */
if (p != NULL) {
/* Inform TCP that we have taken the data. */
tcp_recved(tpcb, p->tot_len);
pbuf_free(p);
}
tcp_close(tpcb);
return ERR_OK;
}
if (p->len != p->tot_len) {
DBG_E(ECOMM, "Received message is incomplete %d<%d.", p->len,
p->tot_len);
}
/* Acknowledge that we have received the packet */
tcp_recved(pcb_tcp, p->tot_len);
if (ctx->recv_buf == NULL){
DBG_W(EINVAL, "Cannot transfer received buffer. No buffer given.");
return ERR_OK;
}
/*** Parse data ***/
if(p != NULL) {
pbuf_free(p);
}
return ERR_OK;
}
_______________________________________________
lwip-users mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/lwip-users