lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] tcp_enqueue problem, using socket:


From: Piero 74
Subject: Re: [lwip-users] tcp_enqueue problem, using socket:
Date: Wed, 19 Mar 2008 14:36:34 +0100

Sorry Bill and J. , i didn't understand:

i saw a lwip 130rc1 bug????

as Bill said, using socket send function, i will see problem in tcp_write.... Now, with nagle disabled, i don't see the problem...

Do you think that tcp ip code needs a patch? I think (but it's only my opinion) that a middle ware like lwip, should never blocks application task. I prefer that it returns an error in some way and drops connection, destroys messages, coming back in stable situation. Application code have to handle error to be sure that all is working.

Bye,
Piero.

2008/3/19, Bill Auerbach <address@hidden>:
> If you are using the sockets interface, you don't have to worry about the
> calls to tcp_write. They are internal to the stack operation.


In any case, his problem will result by the socket interface calling it.


> Instead what seems to be happening is correct and expected behaviour when
> your remote end is not acking the data fast enough so it's buffering up
> locally waiting to be sent.


He's seeing what I was dealing with 2 weeks ago and I (respectfully) agree
that this is a problem that can (and should) be avoided.  The error is that
you can stay below tcp_sndbuf() amount of data for tcp_write (regardless of
who calls it) and exceed TCP_SND_QUEUELEN causing an error (and now, as
Piero adds, with Nagle enabled).  If you reach either tcp_sndbuf data or
TCP_SND_QUEUELEN segments, the system should block (with possibly tcp_sndbuf
should return 0 to indicate the connection really cannot accept any more
data).


> If you are trying to send data quickly from
> your application then this would be normal since you can usually send more
> data faster than it can be sent over the wire.


It's normal, but would be throttled by tcp_sndbuf indicating there is no
room, in which case tcp_sent would continue to ask for data as it can be
accepted.

The following might be a good idea, to be used before calling tcp_write:

#define tcp_accept_data(pcb) ((pcb)->snd_buf > 0 * (((pcb)->queuelen <
TCP_SND_QUEUELEN))

This gives you the amount of data the connection can accept which will be 0
if TCP_SND_QUEUELEN is reached.


> If data throughput is slow,
> then you may want to look at the wire to find out how quickly data is
> being acked to see if there's a problem at either end.
>
> So your application would be blocked sometimes. lwIP's sockets layer
> currently implements non-blocking behaviour with O_NONBLOCK for reads, but
> not for writes.


Doesn't it block when tcp_sndbuf is full?  If so, this error can occur
before that time.


Bill




_______________________________________________
lwip-users mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/lwip-users


reply via email to

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