lwIP port to Genode - lwip_recv()
Stefan Kalkowski
stefan.kalkowski at ...1...
Wed Dec 7 11:10:33 CET 2011
Hello Amadeo,
On 07.12.2011 03:20, Amadeo Casas Cuadrado wrote:
> Hello,
>
> Question about the lwIP port to Genode. Is it possible to receive a
> large amount of data with lwip_recv()? A quick test shows me the maximum
> amount of data that is received is 1460 bytes (properly matching TCP_MSS
> in lwipopts.h). What if I am expecting a larger amount of data? Do I
> need to perform the defragmentation explicitly in my program?
Yes you're right. In general, when using LwIP receive operations it's
impossible to be blocked until the whole provided buffer is filled. You
can find a related section in the LwIP documentation:
http://lwip.wikia.com/wiki/Receiving_data_with_LWIP
"... LWIP may choose to return a fewer number of bytes for a variety of
reasons. This is true even if you do a blocking receive operation. There
is no option to make lwip_recv() block until a certain minimum number of
bytes have been received. ..."
In fact, the Genode-specific part of the LwIP stack mainly is the
ethernet-driver implementation. This driver executes a designated
receiver-thread, which blocks on Genode's NIC-session interface.
Whenever, a new packet from the NIC is on-line, this thread puts it into
the higher layers of LwIP which is platform-independent code. The driver
can't accumulate packets, as it has no knowledge how much data the
application is going to receive. It would block an application endlessly
in the worst case. The only layer, where this accumulation can be done
is the socket-layer, or the application itself.
But, this policy isn't particular to the LwIP stack. The glibc of my
Linux system works similar. It doesn't block until all data is received.
An excerpt from the man page:
"... The receive calls normally return any data available, up to the
requested amount, rather than waiting for receipt of the full amount
requested. ..."
Nevertheless, if for some reason you definitely need this hard-blocking
behaviour, you can wrap the 'lwip_' socket functions, and implement an
adequate loop in the 'recv()' wrapper. You can have a look at our
libc-lwip plugin in 'libports/src/lib/libc_lwip/plugin.cc'. Here we
already wrapped LwIP's socket-layer to integrate LwIP' functionality
conveniently in our libc. You can simply extend the recv() function in
there.
>
> My apologies beforehand for posting to this list if this is a limitation
> of lwIP stack, and not of its port to Genode.
No matter.
Regards
Stefan
>
> Thanks,
> Amadeo
>
> ------------------------------------------------------------------------------
> Cloud Services Checklist: Pricing and Packaging Optimization
> This white paper is intended to serve as a reference, checklist and point of
> discussion for anyone considering optimizing the pricing and packaging model
> of a cloud services business. Read Now!
> http://www.accelacomm.com/jaw/sfnl/114/51491232/
> _______________________________________________
> Genode-main mailing list
> Genode-main at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/genode-main
>
--
Stefan Kalkowski
Genode Labs
http://www.genode-labs.com/ · http://genode.org/
Genode Labs GmbH · Amtsgericht Dresden · HRB 28424 · Sitz Dresden
Geschäftsführer: Dr.-Ing. Norman Feske, Christian Helmuth
More information about the users
mailing list