[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Question about luasocket-2.0-alpha and udp packet size.
- From: Philipp Janda <siffiejoe@...>
- Date: Fri, 06 Feb 2004 16:53:12 +0100
Stewart, Joseph schröbte:
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.
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.