Question about luasocket-2.0-alpha and udp packet size.

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Question about luasocket-2.0-alpha and udp packet size.

Stewart
Title: Message
Hello Diego,
 
First let me say THANKS for your luasocket implementations over the years. They've been very useful to me.
 
Recently I began using luasocket-2.0-alpha to send/receive udp packets. I noticed in the documentation and code that you've set the max send/receive size to 576, but there's no real explanation as why.
 
Since I need to send/receive udp data ~1500 bytes, I just modified the UDP_DATAGRAMSIZE in udp.h to 1500 and everything seems to be okay.
 
Can you shed some illumination on why 576 was chosen as the buffer size and what I might break by changing it?
 
Thanks again!
 
-joe


- - - - - - - Appended by Scientific-Atlanta, Inc. - - - - - - -
This e-mail and any attachments may contain information which is confidential, proprietary, privileged or otherwise protected by law. The information is solely intended for the named addressee (or a person responsible for delivering it to the addressee). If you are not the intended recipient of this message, you are not authorized to read, print, retain, copy or disseminate this message or any part of it. If you have received this e-mail in error, please notify the sender immediately by return e-mail and delete it from your computer.
Reply | Threaded
Open this post in threaded view
|

Re: Question about luasocket-2.0-alpha and udp packet size.

Philipp Janda
Stewart, Joseph schröbte:
Hello Diego,
First let me say THANKS for your luasocket implementations over the years.
They've been very useful to me.
Recently I began using luasocket-2.0-alpha to send/receive udp packets. I
noticed in the documentation and code that you've set the max send/receive
size to 576, but there's no real explanation as why.
Since I need to send/receive udp data ~1500 bytes, I just modified the
UDP_DATAGRAMSIZE in udp.h to 1500 and everything seems to be okay.
Can you shed some illumination on why 576 was chosen as the buffer size and
what I might break by changing it?

>From http://www.faqs.org/rfcs/rfc791.html (IP Specification):
...
Total Length:  16 bits

    Total Length is the length of the datagram, measured in octets,
    including internet header and data.  This field allows the length of
    a datagram to be up to 65,535 octets.  Such long datagrams are
    impractical for most hosts and networks.  All hosts must be prepared
    to accept datagrams of up to 576 octets (whether they arrive whole
    or in fragments).  It is recommended that hosts only send datagrams
    larger than 576 octets if they have assurance that the destination
    is prepared to accept the larger datagrams.

    The number 576 is selected to allow a reasonable sized data block to
    be transmitted in addition to the required header information.  For
    example, this size allows a data block of 512 octets plus 64 header
    octets to fit in a datagram.  The maximal internet header is 60
    octets, and a typical internet header is 20 octets, allowing a
    margin for headers of higher level protocols.
...


And from http://www.thinkingsecure.com/docs/TCPIP-Illustrated-1/ip_inter.htm#3_2
...
Although it's possible to send a 65535-byte IP datagram, most link layers will fragment this. Furthermore, a host is not required to receive a datagram larger than 576 bytes. TCP divides the user's data into pieces, so this limit normally doesn't affect TCP. With UDP we'll encounter numerous applications in later chapters (RIP, TFTP, BOOTP, the DNS, and SNMP) that limit themselves to 512 bytes of user data, to stay below this 576-byte limit. Realistically, however, most implementations today (especially those that support the Network File System, NFS) allow for just over 8192-byte IP datagrams.
...

Thanks again! -joe


Philipp


Reply | Threaded
Open this post in threaded view
|

RE: Question about luasocket-2.0-alpha and udp packet size.

Stewart
In reply to this post by Stewart
Title: RE: Question about luasocket-2.0-alpha and udp packet size.

Thanks for the response. I understand the "safe" packet size restraint.

In my use of udp, I have other mechanisms to determine if the network/stack truncated my packets so I'm more interested if I'm gonna break some underlying assumption inside LuaSocket by changing the packetsize.

Hoping the answer is no... Then I'll take responsibility for the receiver.

Thanks again.

Lua ROCKS!

-joe

-----Original Message-----
From: Philipp Janda [[hidden email]]
Sent: Friday, February 06, 2004 10:53 AM
To: [hidden email]
Subject: Re: Question about luasocket-2.0-alpha and udp packet size.


Stewart, Joseph schröbte:
> Hello Diego,

> First let me say THANKS for your luasocket implementations over the years.
> They've been very useful to me.

> Recently I began using luasocket-2.0-alpha to send/receive udp packets. I
> noticed in the documentation and code that you've set the max send/receive
> size to 576, but there's no real explanation as why.

> Since I need to send/receive udp data ~1500 bytes, I just modified the
> UDP_DATAGRAMSIZE in udp.h to 1500 and everything seems to be okay.

> Can you shed some illumination on why 576 was chosen as the buffer size and
> what I might break by changing it?

 From http://www.faqs.org/rfcs/rfc791.html (IP Specification):
...
Total Length:  16 bits

     Total Length is the length of the datagram, measured in octets,
     including internet header and data.  This field allows the length of
     a datagram to be up to 65,535 octets.  Such long datagrams are
     impractical for most hosts and networks.  All hosts must be prepared
     to accept datagrams of up to 576 octets (whether they arrive whole
     or in fragments).  It is recommended that hosts only send datagrams
     larger than 576 octets if they have assurance that the destination
     is prepared to accept the larger datagrams.

     The number 576 is selected to allow a reasonable sized data block to
     be transmitted in addition to the required header information.  For
     example, this size allows a data block of 512 octets plus 64 header
     octets to fit in a datagram.  The maximal internet header is 60
     octets, and a typical internet header is 20 octets, allowing a
     margin for headers of higher level protocols.
...


And from
http://www.thinkingsecure.com/docs/TCPIP-Illustrated-1/ip_inter.htm#3_2
...
Although it's possible to send a 65535-byte IP datagram, most link
layers will fragment this. Furthermore, a host is not required to
receive a datagram larger than 576 bytes. TCP divides the user's data
into pieces, so this limit normally doesn't affect TCP. With UDP we'll
encounter numerous applications in later chapters (RIP, TFTP, BOOTP, the
DNS, and SNMP) that limit themselves to 512 bytes of user data, to stay
below this 576-byte limit. Realistically, however, most implementations
today (especially those that support the Network File System, NFS) allow
for just over 8192-byte IP datagrams.
...


> Thanks again!

> -joe
>

Philipp



- - - - - - - Appended by Scientific-Atlanta, Inc. - - - - - - -
This e-mail and any attachments may contain information which is confidential, proprietary, privileged or otherwise protected by law. The information is solely intended for the named addressee (or a person responsible for delivering it to the addressee). If you are not the intended recipient of this message, you are not authorized to read, print, retain, copy or disseminate this message or any part of it. If you have received this e-mail in error, please notify the sender immediately by return e-mail and delete it from your computer.
Reply | Threaded
Open this post in threaded view
|

RE: Question about luasocket-2.0-alpha and udp packet size.

Diego Nehab-3
Hi,

> In my use of udp, I have other mechanisms to determine if the network/stack
> truncated my packets so I'm more interested if I'm gonna break some
> underlying assumption inside LuaSocket by changing the packetsize.
>
> Hoping the answer is no... Then I'll take responsibility for the receiver.

Doesn't break anything to change the define, although I have never
tried it. However, it is so uncommon (and unsafe) that you actually need
to send a bigger packet that I don't think I will make this a run-time
option. :o/

[]s,
Diego.

Reply | Threaded
Open this post in threaded view
|

RE: Question about luasocket-2.0-alpha and udp packet size.

Rob Kendrick
On Fri, 2004-02-06 at 17:03, Diego Nehab wrote:

> Doesn't break anything to change the define, although I have never
> tried it. However, it is so uncommon (and unsafe) that you actually need
> to send a bigger packet that I don't think I will make this a run-time
> option. :o/

Talking about luasocket, I've not looked in a while, but does it support
Unix Domain Sockets?

-- 
Rob Kendrick, Pepperfish Ltd.         +44 (0)845 226 4146  www.pepperfish.net
PGP signed or encrypted mail welcome                         Key ID: 3651D17A


Reply | Threaded
Open this post in threaded view
|

RE: Question about luasocket-2.0-alpha and udp packet size.

Stewart
In reply to this post by Stewart
Title: RE: Question about luasocket-2.0-alpha and udp packet size.

I've tried it with a buffer size of 1500 bytes. It works between linux machines just fine.

Why does this buffer need to be declared statically anyway? The sendto/receivefrom calls have size parameters, and the underlying socket calls return the amount they received/sent from/to the network stack?

It seems to me that the application should be responsible for making the "safe/unsafe" determination anyway.

Either way, I can make it do what I need to, so thanks for your hard work and the clarification!

-joe

-----Original Message-----
From: Diego Nehab [[hidden email]]
Sent: Friday, February 06, 2004 12:04 PM
To: Lua list
Subject: RE: Question about luasocket-2.0-alpha and udp packet size.


Hi,

> In my use of udp, I have other mechanisms to determine if the network/stack
> truncated my packets so I'm more interested if I'm gonna break some
> underlying assumption inside LuaSocket by changing the packetsize.
>
> Hoping the answer is no... Then I'll take responsibility for the receiver.

Doesn't break anything to change the define, although I have never
tried it. However, it is so uncommon (and unsafe) that you actually need
to send a bigger packet that I don't think I will make this a run-time
option. :o/

[]s,
Diego.



- - - - - - - Appended by Scientific-Atlanta, Inc. - - - - - - -
This e-mail and any attachments may contain information which is confidential, proprietary, privileged or otherwise protected by law. The information is solely intended for the named addressee (or a person responsible for delivering it to the addressee). If you are not the intended recipient of this message, you are not authorized to read, print, retain, copy or disseminate this message or any part of it. If you have received this e-mail in error, please notify the sender immediately by return e-mail and delete it from your computer.
Reply | Threaded
Open this post in threaded view
|

RE: Question about luasocket-2.0-alpha and udp packet size.

Diego Nehab-3
Hi,

> Why does this buffer need to be declared statically anyway? The
> sendto/receivefrom calls have size parameters, and the underlying socket
> calls return the amount they received/sent from/to the network stack?

For performance, and because UDP isn't like TCP. If you call recv but
doesn't provide a large enough buffer, that extra data is gone, forever.
The next function call will get the next packet. There might be some way
to find out the size of the message before calling recv, but I just
didn't think it was worth it. I have to agree with you that I should
raise the packet size to the maximum IP packet size and let the users
decide what is safe and what isn't. I might do just that.

[]s,
Diego.

Reply | Threaded
Open this post in threaded view
|

RE: Question about luasocket-2.0-alpha and udp packet size.

Diego Nehab-3
In reply to this post by Stewart
Hi,

> Talking about luasocket, I've not looked in a while, but does it support
> Unix Domain Sockets?

It's in my TODO List.

[]s,
Diego.