lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] Optimizing TCP writes


From: Jonathan Larmour
Subject: Re: [lwip-users] Optimizing TCP writes
Date: Thu, 06 Mar 2008 13:58:57 +0000
User-agent: Thunderbird 1.5.0.12 (X11/20070530)

Bill Auerbach wrote:
> Thanks Jonathan,
> 
> I see that it outputs a segment in tcp_output, but I'm not calling
> tcp_output.  I'm calling tcp_write multiple times.  I do see it append a
> segment in tcp_enqueue.  Shouldn't tcp_output pass a linked pbuf chain with
> enough data up to the MSS?  If I call tcp_write 10 times with 10 "Hello
> World"s, I would think one Ethernet frame would be sent with a call to
> ip_output with one pbuf pointer with 11 payloads (the header and 10 data
> payloads).

Yes that's what should happen. The bit of magic that does this is nearish
the bottom of tcp_enqueue in tcp_out.c:

  /* If there is room in the last pbuf on the unsent queue,
  chain the first pbuf on the queue together with that. */
  if (useg != NULL &&
    TCP_TCPLEN(useg) != 0 &&
    !(TCPH_FLAGS(useg->tcphdr) & (TCP_SYN | TCP_FIN)) &&
    !(flags & (TCP_SYN | TCP_FIN)) &&
    /* fit within max seg size */
    useg->len + queue->len <= pcb->mss) {
    /* Remove TCP header from first segment of our to-be-queued list */
    if(pbuf_header(queue->p, -TCP_HLEN)) {
      /* Can we cope with this failing?  Just assert for now */
      LWIP_ASSERT("pbuf_header failed\n", 0);
      TCP_STATS_INC(tcp.err);
      goto memerr;
    }
    pbuf_cat(useg->p, queue->p);
    useg->len += queue->len;
    useg->next = queue->next;
[snip]

I can only assume that your subsequent tcp_writes are not matching the 'if'
condition. Maybe you could debug it (or add a little print statement) to
find out why. It is possible there may be a bug around.

Jifl
-- 
eCosCentric Limited      http://www.eCosCentric.com/     The eCos experts
 **  Visit us at ESC Silicon Valley <http://www.embedded.com/esc/sv>  **
 **  April 15-17 2008, Booth 3012, San Jose McEnery Convention Center **
Barnwell House, Barnwell Drive, Cambridge, UK.       Tel: +44 1223 245571
Registered in England and Wales: Reg No 4422071.
------["Si fractum non sit, noli id reficere"]------       Opinions==mine




reply via email to

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