With TCP_MSS = 128 and you receive 536 byte segments from XP I would expect
the same number of pbufs to be used. They would simply be chained together.
Is suspect your problem may not be pbufs but some other issue/ resource.

Very small pbufs may cause some isses with TCP/IP processing, for example
lwip checks if the IP headers is fully contained in the first pbuf. IF it
is not then it drops the packet...but shouldn't crash! Even running out of
pbufs or heap shouldn't crash the system! lwip usually drops the packet,
prints a warning (if enabled to do so), logs and error (if stats is on) and
keeps going.

MEM_SIZE sets the Heap space used by lwip. This is only used when
the mem_malloc() function is called. Do Grep for it in your LWIP folder and
you will get an idea of what protocols call it.

If you don't already have it turned on I'd advice turning on lwip's Stats
(LWIP_STATS = 1). If you can set break points in your code you can examine
the global parameter 'lwip_stats' to see if any errors are logged for any
resources or if the MAX allocation was exceeded. This includes the Heap.
There are calls to special stats increment error functions
(???_STATS_INC(err) ) in the code you can use  as breakpoints if your code
crashes due to your error. Try a break point on a resource you suspect
might be the issue and re-create the problem. If break point not triggered,
it's not your problem, try another!

hope it helps.
Niall.


On 1 November 2013 09:38, ThomasJ <[email protected]> wrote:

> As I read the code the each pbuf size is defined by the PBUF_POOL_BUFSIZE.
> That is defined by the TCP_MSS + 40.
>
> So in the case using TCP_MSS of 128 it will be 168 for each PBUF's. ??
>
> In the case of WinXP i will receive a lot of 128 bytes segemnts eating a
> lot
> of pbuf's. Then the lwip runs out and crashes?
> In the case of Win7 I receive few 536 byte segment. Why does that not take
> as many pbuf as with winXP?
>
> I have increased the TCP_MSS and lowered the PBUF_POOL_SIZE and that seems
> to be good. Also for peformance. But I actually lowered the number of
> available PBUFs for the stack.
>
> The define for MEM_SIZE is increased. What is the define mem size actually
> used for?
>
>
>
> Niall Donovan wrote
> > One simple reason will be not enough pbufs allocated. Each received
> > segment
> > will take at lease one pbuf. Depending on the memory allocation scheme
> you
> > have used each pbuf might be a pre-allocated size (say 1518 + header). In
> > such a case each received segment in the win XP case will use a 1518 pbuf
> > to store a 128 byte segment...it's easy to run out! For Win 7 you are
> less
> > likely to run out since each segment is 536 so fewer pbufs are need to
> > save
> > the full payload.
> >
> > (at lease this is my understanding of how TCP works in lwip - someone
> > please correct me if I'm wrong!)
> >
> > You can have dynamic pbuf allocation - slow but possibly better use of
> > memory.
> > Pre-allocated fixed size pbufs pools - good performance but sizing pbufs
> > to
> > give optimal memory use is tricky.
> > custom pools i.e. varying size pre-allocated pbufs, picked based on best
> > fit.
> >
> > Which you select depends on your needs and sometimes the capability if
> the
> > device driver (if it uses DMA then dynamic pbuf allocation may not be
> > possible)
> >
> > Niall.
> >
> >
> >
> > On 1 November 2013 07:17, ThomasJ &lt;
>
> > tjo@
>
> > &gt; wrote:
> >
> >> Hi
> >>
> >> I see. Thanks for reply.
> >>
> >> But I also wonder, why the lwip crashes when the same amount of data
> >> comes
> >> in segments of 128 from WindowsXP. But do not crash when the same data
> >> comes
> >> from Win7 in 536 bytes chunks?
> >>
> >> There is enough memory to receive the data (it can be received when send
> >> from Win7).
> >>
> >> I have changed the MSS to 536 and increased the MEM_SIZE a bit. Seems to
> >> have helped.
> >>
> >> Thomas
> >>
> >>
> >>
> >> --
> >> View this message in context:
> >>
> http://lwip.100.n7.nabble.com/Works-with-Win7-not-Windows-XP-tp22003p22020.html
> >> Sent from the lwip-users mailing list archive at Nabble.com.
> >>
> >> _______________________________________________
> >> lwip-users mailing list
> >>
>
> > lwip-users@
>
> >> https://lists.nongnu.org/mailman/listinfo/lwip-users
> >>
> >
> > _______________________________________________
> > lwip-users mailing list
>
> > lwip-users@
>
> > https://lists.nongnu.org/mailman/listinfo/lwip-users
>
>
>
>
>
> --
> View this message in context:
> http://lwip.100.n7.nabble.com/Works-with-Win7-not-Windows-XP-tp22003p22022.html
> Sent from the lwip-users mailing list archive at Nabble.com.
>
> _______________________________________________
> lwip-users mailing list
> [email protected]
> https://lists.nongnu.org/mailman/listinfo/lwip-users
>
_______________________________________________
lwip-users mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/lwip-users

Reply via email to