Because the configuration limit is also specified in the number of
pbufs. This allows people using it to have a much better estimate of
the amount of pbufs (and so memory) that can be used for the send queue,
which is important if you haven't got much memory (as per most lwIP
systems).
If we just counted segments, which can vary somewhat in size, you would
end up over-limiting the number of very small segments that can be
queued as your limit would have to be small enough to prevent lots of
large segments being queued as they would use up too much memory.
Perhaps counting the bytes would make most sense, but as our pbufs are
the resource it's trying to prevent being entirely consumed by the send
queue, I'm happy to leave it as it is.
Are you seeing a real problem, or just curious about why it's like that?
Kieran
_______________________________________________
lwip-users mailing list
lwip-...@nongnu.org
http://lists.nongnu.org/mailman/listinfo/lwip-users
That packets that you pass in to lwIP from the link layer should have no
direct effect on snd_queuelen, so how you construct them should be of no
consequence.
When an ACK is passed in from your link layer snd_queuelen is
decremented by the number of pbufs in ***the packet that is
acknowledged***, not the number of pbufs in the packet that you've just
passed in that does the acknowledging.
snd_queuelen was earlier (in tcp_out.c:tcp_enqueue()) incremented by the
number of pbufs in the same packet (when it was enqueued on the
unacknowledged or unsent list) so there is something really wrong if
you've ended up with snd_queuelen < the number of pbufs in one of the
packets in those queues. We should probably be asserting this in
tcp_in.c:tcp_receive().
For this to happen, my guess is your packet queues are getting
corrupted, most likely due to insufficient locking and protection of the
stack resulting in two threads accessing it at the same time.
Ahh, apologies for misunderstanding you. I think by using pbuf_queue()
you are essentially corrupting the internal state in lwIP. pbuf_queue()
modifies the next pointer in the pbuf, but this is already being used
(for the unsent/unacked lists) at the time you are modifying it. Our
pbuf queues/lists/chains only support the pbuf being in one
queue/list/chain at once, and by adding it to another you're breaking
that assumption.
To resolve it, one solution would be to create yourself a little link-
layer container structure for a pbuf:
struct link_pbuf {
struct link_pbuf *next;
struct pbuf *p;
}
Then you can use this next pointer to queue them up however you like
internally to the link layer without risk of corrupting the higher
layers.