cmv has asked for the wisdom of the Perl Monks concerning the following question:

I'm using POE::Wheel::UDP to receive UDP messages from a source. Some of the incoming UDP messages are larger than 1500 bytes. The documentation for this module states:

Currently a maximum of 1500 will be read, and datagrams which are larger will be truncated.

Checking the source confirms this:

while( my $addr = recv( $socket, my $input = "", 1500, MSG_DONTWAIT ) +) {
Is there a good reason for this limit, or is it just the preference of the author? Would it be reasonable to change this to 65535? Something else? User settable? What would be the best solution to recommend to the author?

Thanks

-Craig

Replies are listed 'Best First'.
Re: 1500 Byte UDP Limit in POE::Wheel::UDP?
by Fletch (Bishop) on Jul 28, 2008 at 19:04 UTC

    That size is based upon the fact that most ethernet networks have an MTU size of around the same number (the MTU being the largest number of bytes that can be transmitted in a single ethernet frame (after adding ethernet headers and the like) without fragmentation; any thing bigger will wind up being split at the IP layer into multiple packets). Since UDP is usually used in an attempt to get the most performance out of the network you want to avoid extra overhead (such as fragmenting and re-assembling) if at all possible (I also see mentions of some OSen not allowing packets larger than a certain size so there could be platform issues involved as well).

    Probably the best route would be to submit a patch which provides a user-configurable parameter (RecvSize maybe) which defaults to the current 1500 value.

    The cake is a lie.
    The cake is a lie.
    The cake is a lie.

Re: 1500 Byte UDP Limit in POE::Wheel::UDP?
by Perlbotics (Archbishop) on Jul 28, 2008 at 18:56 UTC
    One reason that comes to my mind is, that an UDP packet of size less than 1500 byte fits well into a single Ethernet frame (MTU usually 1500 byte) without IP fragmentation.Usually, UDP based protocols are suited for fast (unreliable) exchange of small information chunks (e.g. Radius, DNS, etc.). You can benefit from UDP in contrast to TCP because you dont need to execute the threeway handshake in advance. In case, you need to transfer only small datagrams that's faster with UDP. However, higher protocol layers may need to implement retransmission schemes and the like to ensure a better level of reliability. So I guess, the reason is avoidance of fragmentation. Hope that helps.
    Update: If you can, do not use PDU-sizes bigger than 1500 bytes.
Re: 1500 Byte UDP Limit in POE::Wheel::UDP?
by rcaputo (Chaplain) on Jul 28, 2008 at 19:04 UTC
Re: 1500 Byte UDP Limit in POE::Wheel::UDP?
by Anonymous Monk on Jul 28, 2008 at 20:43 UTC
    Long ago I had less clue than I do now about all this networking wizardry. I thought I was protecting the user. You're right, just set it to something higher. I wrote a ticket for this: http://rt.cpan.org/Ticket/Display.html?id=38003 I suggest just making the line be 64k or something for yourself, and in a version soon it'll be configurable and bigger by default. --hachi
Re: 1500 Byte UDP Limit in POE::Wheel::UDP?
by Bloodnok (Vicar) on Jul 29, 2008 at 14:57 UTC
    Hi,

    You don't identify the OS, but on Solaris, the typical/default MTU size is 1502 bytes (as you may or may not already know:-) for efficiency reasons as suggested elsewhere in response to your OP.

    HTH ,

    At last, a user level that overstates my experience :-))