lwip-users
[Top][All Lists]
Advanced

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

[lwip-users] lwIP nagle algorithm and delayed ACK


From: Joy Kitikonti
Subject: [lwip-users] lwIP nagle algorithm and delayed ACK
Date: Tue, 12 Nov 2013 17:15:20 +0000 (GMT)


Hello,

I would like to test the TCP transfer speed between a device running lwIP 1.4.1 using Raw API (192.168.0.100) and my laptop (192.168.0.1).
I have 2 questions:
1/ The first part of the trace is testing transmission from PC=>lwIP. Performance is okay but AFAIK the stack should only acknowledge each second received packet (this is known as delayed ACK, to save some bandwidth for faster transfer), but this is not what happens in the trace here, so why? What should I do to only ACK the 2nd packet? Could this be related to my recv callback function?

static err_t test_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err)
{
    /* Handle data/connection error. */
    if (p == NULL) {
        test_close(pcb, test);
        return ERR_OK;
    }
    else if (err != ERR_OK) {
        if (p != NULL) {
            pbuf_free(p);
        }
        return err;
    }
    /* Read received data. */
    else {
        /* Acknowledge received data. */
        tcp_recved(pcb, p->tot_len);

        pbuf_free(p);
        return ERR_OK;
    }
}

2a/ The second part of the trace is testing transmission from lwIP=>PC (at the end of capture). Performance is bad because there are delays in ACKs from PC. Note that I disabled the naggle algorithm. The code repeatedly calls (in the sent callback):

tcp_write(pcb, buffer, 2900, 0);

2900 is inferior to the send buffer size which is 2*MSS (2*1500).
The delay always happen when pushing the last data of the send buffer (size 1494) with the PSH flag is set. Why do I see this delay? I thought the PSH flag would force the PC stack to pass the data to the application layer and therefore immediately generates the ACK...

2b/ If I write 3000 bytes of data instead of 2900 in the tcp_write call, the delay does not show up and performance is really much better. But still, I would expect to see:
{2 MSS sized TCP segment} {ACK} {2 MSS sized TCP segment} {ACK} etc... but this is not the case, each packet gets ACKed by PC stack (windows XP), is this normal?

I have attached my lwipopts.h file and the zip file contains the wireshark packet capture.

Thanks for your help,

--
Joy

Attachment: log.pcapng.zip
Description: Zip compressed data

Attachment: lwipopts.h
Description: Binary data


reply via email to

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