lwip-devel
[Top][All Lists]
Advanced

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

[lwip-devel] Re: [task #7040] Work on tcp_enqueue


From: Jakob Stoklund Olesen
Subject: [lwip-devel] Re: [task #7040] Work on tcp_enqueue
Date: Thu, 29 Jan 2009 21:33:06 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

"bill" <address@hidden> writes:
> Thank you!  Exactly right.  If I add the second if to my tcp_sent callback
> it works perfectly.  All packets are 1460 bytes with one trailing packet
> less than 1460.
>
>   if( tcp_sndbuf(pcb) >= dataLen )
>     len = dataLen;
>   else
>     len = tcp_sndbuf(pcb);
>   if( len > pcb->mss )
>     len -= len % pcb->mss;

If this works for you, it is an easy solution.

[...]

>>This means that every tcp_write() with more than mss bytes will always
>>start a new segment.
>
> Ok.  This makes sense.  Tcp_enqueue couldn't hang on to the last partial
> piece unless tcp_write had a flag to signal a flush or "end of contiguous
> data".  Someone like me using the example code above to call tcp_write in
> the tcp_sent callback knows when the end of the data has been reached
> because the sent callback has to determine that so implementing this flag in
> the application is trivial.

That is not quite how it works. Actually tcp_enqueue() doesn't transmit
any data right away. You should call tcp_output_nagle() after writing
continuous data. If you don't, nothing is transmitted until an ACK is
received or some timer goes off. This can make a big difference in
throughput.

I am not sure if it is legal to call tcp_output() from inside the
tcp_sent callback. It it is probably harmless, but will be called anyway
when your callback function returns.

> Maybe the second if above should be included in the tcp_sent examples with a
> comment // this test ensures full payloads will be transmitted.  Wouldn't
> the netconn API benefit from this addition?

I would prefer to fix tcp_enqueue() instead. The raw API is low-level,
but it doesn't have to be that low-level.

[...fix tcp_enqueue()...]

> I don't know the code that well to know where you mean - I'll look at it
> since I'm on the trail and it's trivial to test the change.  If we have a
> partial mss-worth of data at the end, if we leave it queued, will it get
> sent if there is no following tcp_write?

Yes, it will be sent the next time tcp_output_nagle() is called (or when
an ACK is received).

/stoklund





reply via email to

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