public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] max IP packet size = 9216 B. Why?
@ 2007-06-12 21:58 Jürgen Lambrecht
  2007-06-12 22:12 ` Andrew Lunn
       [not found] ` <058cebc1-1c19-438d-b5de-2c8015835c36@googlegroups.com>
  0 siblings, 2 replies; 8+ messages in thread
From: Jürgen Lambrecht @ 2007-06-12 21:58 UTC (permalink / raw)
  To: eCos Discussion; +Cc: Jürgen Lambrecht

Hello,

I found out that the maximum IP packet size = 9216 B (0x2400).
I implemented an echo program, both udp and tcp.
My ecos applic can receive more that 9216B, but not send back more than 
that.

Has anybody a clue how to solve this?
I need to support the maximum IP packet size of 65535 B (IP_MAXPACKET).
I don't know if this is a bug in ecos, or a (hidden?) limitation of an 
embedded OS.

Thanks,
Juergen Lambrecht

P.S.:
I'm busy tracing this back in the source
This comes from the socket that is allocated statically in 
/io/fileio/.../fd.cxx and socket is part of a cyg_file (cyg_file is 
defined by file in file.h). In cyg_file there is a member f_data, which 
is the socket.
I'm continuing my search in the code at this point....

-- 
Jürgen Lambrecht
R&D Engineer
Televic Transport Systems
http://www.televic.com
Televic NV / SA (main office)  	
Leo Bekaertlaan 1
B-8870 Izegem
Tel: +32 (0)51 303045
Fax: +32 (0)51 310670


-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [ECOS] max IP packet size = 9216 B. Why?
  2007-06-12 21:58 [ECOS] max IP packet size = 9216 B. Why? Jürgen Lambrecht
@ 2007-06-12 22:12 ` Andrew Lunn
  2007-06-12 22:46   ` Jürgen Lambrecht
       [not found] ` <058cebc1-1c19-438d-b5de-2c8015835c36@googlegroups.com>
  1 sibling, 1 reply; 8+ messages in thread
From: Andrew Lunn @ 2007-06-12 22:12 UTC (permalink / raw)
  To: J?rgen Lambrecht; +Cc: eCos Discussion, J?rgen Lambrecht

On Tue, Jun 12, 2007 at 05:49:30PM +0200, J?rgen Lambrecht wrote:
> Hello,
> 
> I found out that the maximum IP packet size = 9216 B (0x2400).
> I implemented an echo program, both udp and tcp.
> My ecos applic can receive more that 9216B, but not send back more than 
> that.
> 
> Has anybody a clue how to solve this?
> I need to support the maximum IP packet size of 65535 B (IP_MAXPACKET).

Interesting. What network technology do you have underneath
this. Something reliable i presume since even small packet error rates
are going to cause big delay and inefficiencies with retries.

> I don't know if this is a bug in ecos, or a (hidden?) limitation of an 
> embedded OS.

I don't know of anybody else using nearly jumbo packets. So you might
be running into bugs, or configuration tweaks might be needed.

> I'm busy tracing this back in the source
> This comes from the socket that is allocated statically in 
> /io/fileio/.../fd.cxx and socket is part of a cyg_file (cyg_file is 
> defined by file in file.h). In cyg_file there is a member f_data, which 
> is the socket.
> I'm continuing my search in the code at this point....

Do you get a crash, or does write/sendto return an error code?

   Andrew

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [ECOS] max IP packet size = 9216 B. Why?
  2007-06-12 22:12 ` Andrew Lunn
@ 2007-06-12 22:46   ` Jürgen Lambrecht
  2007-06-12 23:03     ` Andrew Lunn
  0 siblings, 1 reply; 8+ messages in thread
From: Jürgen Lambrecht @ 2007-06-12 22:46 UTC (permalink / raw)
  To: Andrew Lunn, ecos-discuss

Andrew Lunn wrote:
> On Tue, Jun 12, 2007 at 05:49:30PM +0200, J?rgen Lambrecht wrote:
>   
>> Hello,
>>
>> I found out that the maximum IP packet size = 9216 B (0x2400).
>> I implemented an echo program, both udp and tcp.
>> My ecos applic can receive more that 9216B, but not send back more than 
>> that.
>>
>> Has anybody a clue how to solve this?
>> I need to support the maximum IP packet size of 65535 B (IP_MAXPACKET).
>>     
>
> Interesting. What network technology do you have underneath
> this. Something reliable i presume since even small packet error rates
> are going to cause big delay and inefficiencies with retries.
>   
Don't tell me! Our customer is very stubborn.. Because the maximum size 
of an IP packet is 64KB, their suppliers (us) _must_ support it. We must 
support IP.
>   
>> I don't know if this is a bug in ecos, or a (hidden?) limitation of an 
>> embedded OS.
>>     
>
> I don't know of anybody else using nearly jumbo packets. So you might
> be running into bugs, or configuration tweaks might be needed.
>   
It has nothing to do with Ethernet Jumbo frames. We use the standart 
Ethernet MTU 1518B. The IP layer is responsible of fragmenting the IP 
packets to fit the MAC's layer MTU.
>   
>> I'm busy tracing this back in the source
>> This comes from the socket that is allocated statically in 
>> /io/fileio/.../fd.cxx and socket is part of a cyg_file (cyg_file is 
>> defined by file in file.h). In cyg_file there is a member f_data, which 
>> is the socket.
>> I'm continuing my search in the code at this point....
>>     
>
> Do you get a crash, or does write/sendto return an error code?
>   
sendto returns the error code 322 or EMSGSIZE "Message too long".
I forgot to tell that's because the high water level of the send socket 
(o->so_snd.sb_hiwat) is 9216 B (=0x2400) (in file 
bsd_tcpip/current/src/sys/kern/uipc_socket.c:523).

I will try to increase the socket's high water level (after I have found 
where it is set ;-).

Kind regards,
Juergen
>    Andrew
>
>
>   



-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [ECOS] max IP packet size = 9216 B. Why?
  2007-06-12 22:46   ` Jürgen Lambrecht
@ 2007-06-12 23:03     ` Andrew Lunn
  2007-06-13 14:24       ` Jürgen Lambrecht
  0 siblings, 1 reply; 8+ messages in thread
From: Andrew Lunn @ 2007-06-12 23:03 UTC (permalink / raw)
  To: Juergen Lambrecht; +Cc: Andrew Lunn, ecos-discuss

> sendto returns the error code 322 or EMSGSIZE "Message too long".
> I forgot to tell that's because the high water level of the send socket 
> (o->so_snd.sb_hiwat) is 9216 B (=0x2400) (in file 
> bsd_tcpip/current/src/sys/kern/uipc_socket.c:523).
> 
> I will try to increase the socket's high water level (after I have found 
> where it is set ;-).

I think you can set it with setsockopt(). The option names are
SO_SNDBUF & SO_RCVBUF. However, there might be a system check to
ensure they are not too large.

       Andrew

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [ECOS] max IP packet size = 9216 B. Why?
  2007-06-12 23:03     ` Andrew Lunn
@ 2007-06-13 14:24       ` Jürgen Lambrecht
  2007-06-13 15:44         ` Andrew Lunn
  0 siblings, 1 reply; 8+ messages in thread
From: Jürgen Lambrecht @ 2007-06-13 14:24 UTC (permalink / raw)
  To: Andrew Lunn; +Cc: Juergen Lambrecht, ecos-discuss

Thanks Andrew! This solves it.
So the maximum supported IP packet size for an UDP socket is a configuration option. But you must be a TCP/IP networking expert to know about the option..

For anybody's information: to send/receive maximum sized UDP packets you have to setsockopt() SO_SNDBUF & SO_RCVBUF.
The maximum IP packet size is 65535 B, so the maximum UDP payload is 65507 B.
So it has no use to set SO_SNDBUF (for an UDP socket) higher than that value (65507 B).
Mark that SO_RCVBUF must be set to 65539 B to be able to receive the 65535 B IP packets (using UDP)!

For the ping test, ecos is configured OK for 65535 B IP-ping packets

I still have to test TCP, but TCP should adapt its buffers automatically.

Andrew Lunn wrote:
>>sendto returns the error code 322 or EMSGSIZE "Message too long".
>>I forgot to tell that's because the high water level of the send socket 
>>(o->so_snd.sb_hiwat) is 9216 B (=0x2400) (in file 
>>bsd_tcpip/current/src/sys/kern/uipc_socket.c:523).
>>
>>I will try to increase the socket's high water level (after I have found 
>>where it is set ;-).
The high water level is set in bsd_tcpip/current/src/sys/netinet/udp_usrreq.c line 769.
Changing it here solves my problem.
> 
> 
> I think you can set it with setsockopt(). The option names are
Indeed! But I though you would then change so->so_snd.sb_mbmax in stead of so->so_snd.sb_hiwat.
With those options, I indeed changed the high water level. So the ecos patch above is wrong.

> SO_SNDBUF & SO_RCVBUF. However, there might be a system check to
> ensure they are not too large.
How can you know wat the allowed maximum is? I guess that is the value of so->so_snd.sb_mbmax that was set default to 73728 (as I saw with the debugger).
That maximum is probably related to the options CYGPKG_NET_MEM_USAGE, ...
You can of course check the return value of setsockopt().

Thank you again,
Juergen
> 
>        Andrew
> 

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [ECOS] max IP packet size = 9216 B. Why?
  2007-06-13 14:24       ` Jürgen Lambrecht
@ 2007-06-13 15:44         ` Andrew Lunn
  0 siblings, 0 replies; 8+ messages in thread
From: Andrew Lunn @ 2007-06-13 15:44 UTC (permalink / raw)
  To: J?rgen Lambrecht; +Cc: Andrew Lunn, Juergen Lambrecht, ecos-discuss

On Wed, Jun 13, 2007 at 03:21:23PM +0200, J?rgen Lambrecht wrote:
> Thanks Andrew! This solves it.
> So the maximum supported IP packet size for an UDP socket is a 
> configuration option. But you must be a TCP/IP networking expert to know 
> about the option..

Not really, see man 7 socket. It is also in Steven's book.

> >SO_SNDBUF & SO_RCVBUF. However, there might be a system check to
> >ensure they are not too large.

> How can you know wat the allowed maximum is? I guess that is the value of 
> so->so_snd.sb_mbmax that was set default to 73728 (as I saw with the 
> debugger).

The check is:

 if ((u_quad_t)cc > (u_quad_t)sb_max * MCLBYTES / (MSIZE + MCLBYTES))
                return (0);

sb_max has the value SB_MAX, which is (256*1024)
MCLBYTES is (1 << MCLSHIFT)
MCLSHIFT is 11
MSIZE is 128

So that boils down to

(256*1024) * (1 << 11) / (128 + (1<<11)
262144 * 2048 / (2176)
246723

However, there might be another check somewhere else....

As you said, setsockopt should return an error, so you could binary
chop.

        Andrew

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [ECOS] max IP packet size = 9216 B. Why?
       [not found] ` <058cebc1-1c19-438d-b5de-2c8015835c36@googlegroups.com>
@ 2017-06-20 10:29   ` Jürgen Lambrecht
  2017-06-23 10:32     ` Jürgen Lambrecht
  0 siblings, 1 reply; 8+ messages in thread
From: Jürgen Lambrecht @ 2017-06-20 10:29 UTC (permalink / raw)
  To: lawshere, osdeve.mirror.rtos.ecos-discuss; +Cc: ecos-discuss, jurgen.lambrecht

Hi,

It is a implicit limitation of eCos: to limit the amount of RAM needed, 
the maximum IP packet size is 9kB.
This is hardcoded in the eCos code, so I changed it there.
I don't remember where, but when I find it, I will mail you again.

Kind regards,
Jürgen

On 05/04/2017 02:55 AM, lawshere@gmail.com wrote:
> is there any patch for it,
> no matter how i set SNDBUF, the problem is still,
> it seems the maximum accessable size for one udp packet is the same as 
> MTU.
>
> 在 2007年6月12日星期二 UTC+8下午11:49:30,Jürgen Lambrecht写道:
>
>     Hello,
>
>     I found out that the maximum IP packet size = 9216 B (0x2400).
>     I implemented an echo program, both udp and tcp.
>     My ecos applic can receive more that 9216B, but not send back more
>     than
>     that.
>
>     Has anybody a clue how to solve this?
>     I need to support the maximum IP packet size of 65535 B
>     (IP_MAXPACKET).
>     I don't know if this is a bug in ecos, or a (hidden?) limitation
>     of an
>     embedded OS.
>
>     Thanks,
>     Juergen Lambrecht
>
>     P.S.:
>     I'm busy tracing this back in the source
>     This comes from the socket that is allocated statically in
>     /io/fileio/.../fd.cxx and socket is part of a cyg_file (cyg_file is
>     defined by file in file.h). In cyg_file there is a member f_data,
>     which
>     is the socket.
>     I'm continuing my search in the code at this point....
>
>     -- 
>     Jürgen Lambrecht
>     R&D Engineer
>     Televic Transport Systems
>     http://www.televic.com
>     Televic NV / SA (main office)
>     Leo Bekaertlaan 1
>     B-8870 Izegem
>     Tel: +32 (0)51 303045
>     Fax: +32 (0)51 310670
>
>
>     -- 
>     Before posting, please read the FAQ:
>     http://ecos.sourceware.org/fom/ecos
>     <http://ecos.sourceware.org/fom/ecos>
>     and search the list archive:
>     http://ecos.sourceware.org/ml/ecos-discuss
>     <http://ecos.sourceware.org/ml/ecos-discuss>
>


-- 
Jürgen Lambrecht
R&D Associate
Mobile: +32 499 644 531
Twitter: JGRLambrecht
Tel: +32 (0)51 303045    Fax: +32 (0)51 310670
http://www.televic-rail.com
https://www.facebook.com/TelevicRail
Televic Rail NV - Leo Bekaertlaan 1 - 8870 Izegem - Belgium
Company number 0825.539.581 - RPR Kortrijk

This electronic transmission is intended exclusively for the person or entity
to whom it is addressed and may contain confidential and/or privileged
material. Any disclosure, copying, distribution or other action based upon the
information by persons or entities other than the intended recipient is
prohibited. All e-mail correspondence from Televic Rail NV is only intended for
information purposes and can not result in contractual obligations. Commitments
under Televic Rail NV can only occur through regular exchange of letters,
signed by authorized persons in accordance with publication in the Belgian
Official Gazette.


-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [ECOS] max IP packet size = 9216 B. Why?
  2017-06-20 10:29   ` Jürgen Lambrecht
@ 2017-06-23 10:32     ` Jürgen Lambrecht
  0 siblings, 0 replies; 8+ messages in thread
From: Jürgen Lambrecht @ 2017-06-23 10:32 UTC (permalink / raw)
  To: lawshere, osdeve.mirror.rtos.ecos-discuss; +Cc: ecos-discuss

On 06/20/2017 12:29 PM, Jürgen Lambrecht wrote:
> Hi,
>
> It is a implicit limitation of eCos: to limit the amount of RAM 
> needed, the maximum IP packet size is 9kB.
> This is hardcoded in the eCos code, so I changed it there.
> I don't remember where, but when I find it, I will mail you again.
I found it back, and it is not hard-coded.
There is a default set in 
ecos/packages/net/bsd_tcpip/current/src/sys/netinet/udp_usrreq.c.

But you can overwrite it on the socket:

   udpEchoSocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
   sendBuf = 65507; //The maximum IP packet has 64KB or 65535 B. The 
maximum UDP
                    //payload is (- 20B IP  header and 8B UDP header) 65507.
   if (setsockopt(udpEchoSocket, SOL_SOCKET, SO_SNDBUF, &sendBuf, 
sizeof(sendBuf))) {
     debug_printf("<ERR> setsockopt SO_SNDBUF\n");
   }
   sendBuf = 65539; //The maximum IP packet has 64KB or 65535 B. The 
maximum UDP
   if (setsockopt(udpEchoSocket, SOL_SOCKET, SO_RCVBUF, &sendBuf, 
sizeof(sendBuf))) {
     debug_printf("<ERR> setsockopt SO_RCVBUF\n");
   }


I tried both ways (first change eCos sources, then use the ioctl calls), 
and both worked for me: I could send/receive up to 64kB IP (UDP and TCP) 
packets.

Kind regards,
Jürgen
>
> Kind regards,
> Jürgen
>
> On 05/04/2017 02:55 AM, lawshere@gmail.com wrote:
>> is there any patch for it,
>> no matter how i set SNDBUF, the problem is still,
>> it seems the maximum accessable size for one udp packet is the same 
>> as MTU.
>>
>> 在 2007年6月12日星期二 UTC+8下午11:49:30,Jürgen Lambrecht写道:
>>
>>     Hello,
>>
>>     I found out that the maximum IP packet size = 9216 B (0x2400).
>>     I implemented an echo program, both udp and tcp.
>>     My ecos applic can receive more that 9216B, but not send back more
>>     than
>>     that.
>>
>>     Has anybody a clue how to solve this?
>>     I need to support the maximum IP packet size of 65535 B
>>     (IP_MAXPACKET).
>>     I don't know if this is a bug in ecos, or a (hidden?) limitation
>>     of an
>>     embedded OS.
>>
>>     Thanks,
>>     Juergen Lambrecht
>>
>>     P.S.:
>>     I'm busy tracing this back in the source
>>     This comes from the socket that is allocated statically in
>>     /io/fileio/.../fd.cxx and socket is part of a cyg_file (cyg_file is
>>     defined by file in file.h). In cyg_file there is a member f_data,
>>     which
>>     is the socket.
>>     I'm continuing my search in the code at this point....
>>
>>     --     Jürgen Lambrecht
>>     R&D Engineer
>>     Televic Transport Systems
>> http://www.televic.com
>>     Televic NV / SA (main office)
>>     Leo Bekaertlaan 1
>>     B-8870 Izegem
>>     Tel: +32 (0)51 303045
>>     Fax: +32 (0)51 310670
>>
>>
>>     --     Before posting, please read the FAQ:
>> http://ecos.sourceware.org/fom/ecos
>> <http://ecos.sourceware.org/fom/ecos>
>>     and search the list archive:
>> http://ecos.sourceware.org/ml/ecos-discuss
>> <http://ecos.sourceware.org/ml/ecos-discuss>
>>
>
>


-- 
Jürgen Lambrecht
R&D Associate
Mobile: +32 499 644 531
Twitter: JGRLambrecht
Tel: +32 (0)51 303045    Fax: +32 (0)51 310670
http://www.televic-rail.com
https://www.facebook.com/TelevicRail
Televic Rail NV - Leo Bekaertlaan 1 - 8870 Izegem - Belgium
Company number 0825.539.581 - RPR Kortrijk

This electronic transmission is intended exclusively for the person or entity
to whom it is addressed and may contain confidential and/or privileged
material. Any disclosure, copying, distribution or other action based upon the
information by persons or entities other than the intended recipient is
prohibited. All e-mail correspondence from Televic Rail NV is only intended for
information purposes and can not result in contractual obligations. Commitments
under Televic Rail NV can only occur through regular exchange of letters,
signed by authorized persons in accordance with publication in the Belgian
Official Gazette.


-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2017-06-23 10:32 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-06-12 21:58 [ECOS] max IP packet size = 9216 B. Why? Jürgen Lambrecht
2007-06-12 22:12 ` Andrew Lunn
2007-06-12 22:46   ` Jürgen Lambrecht
2007-06-12 23:03     ` Andrew Lunn
2007-06-13 14:24       ` Jürgen Lambrecht
2007-06-13 15:44         ` Andrew Lunn
     [not found] ` <058cebc1-1c19-438d-b5de-2c8015835c36@googlegroups.com>
2017-06-20 10:29   ` Jürgen Lambrecht
2017-06-23 10:32     ` Jürgen Lambrecht

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).