What are Metacard's UDP (datagram) Limits

Scott Raney raney at metacard.com
Tue Apr 30 00:41:01 EDT 2002


On Mon, 29 Apr 2002 spartics at aye.net (Sparticus Zarris) wrote:

> I'm trying to see what the limit is for UDP "packets" sent from
> Metacard using the form:

> open datagram socket to <socketID>
> write <myData> to socket <socketID>
> 
> Keep in mind this is for UDP packets (datagram).
> 
> I set up a sender and a listener using the MetaCard stack "chat.mc" as the
> shell.
> 
> Here's the problem.
> 
> I thought there would be a limit of some sort on the packet size -- probably
> associated with the size of Ethernet frames on my network, or a multiple of
> that size.

That, and whatever limits are imposed by the driver and even the hardware.

> I sent 32K of data, and got it out the other end, exactly.
> 
> I then assumed there was no problem, maybe there was NO limit.
> 
> Then I wrote a simple app that assumed there was NO limit.
> 
> My simple app wouldn't work.
> 
> My simple app was sending blocks of about 64K.
> 
> I re-tested using the "chat.mc" shell.
> 
> Turns out, I can send any amount of data, any kind of data, but no more than
> EXACTLY 65,507 bytes.
> 
> If I sent 65,508 bytes, NO PART OF THE DATA IS SENT.  NO ERROR IS REPORTED.
> 
> WHY, is this a MetaCard limit?  I'm sure Scott will explain this away as a
> feature, so it would be nice to understand the rationale, and if this is
> identical across all platforms
> 
> What kind of a limit is 65,507 bytes.  It is NOT a power of 2.  But is sure
> dang close.

It's the theoretical max size (64K) minus the IP header size.

> What does it mean.
> 
> Is it yet another flaw in MC.
> 
> Has anyone else ever run into this.  Is this a hard-and-fast limit across all
> platforms?

No, it varies.

> Is this this way because of some underlying API (like maybe a limit in
> BerkeleySockets, or some such API that Meta is using).

The UDP proptocol specification only guarantees up to a maximum size
of 576 bytes.  Try to send anything larger than that and it might work
on some systems but not others.

> Or maybe that he is setting a buffer size some place, and it should be set to
> another value??

In general it's not configurable, even at the OS level.  It's
certainly not configurable at the application level.

> I am using PowerPC Macintosh on OS 9.04, and 8.5.1  and MC 2.4.1
> 
> Why can't I find this documented anywhere?

Check the UDP protocol RFC (sorry, I don't know the number).

> Clues?

One big one is to not use UDP unless you've got a very specialized
application and you *really* know what you're doing.  Besides the size
limits, keep in mind that UDP is not reliable, which means you have to
write your app to keep track of dropped packets and ask for resends
(very complicated).  In the course of getting DNS MX record lookup
working, we've also recently discovered a significant limitation in
the datagram implementation in 2.4.2: you can't read from the same
socket you open for write.  This makes doing client-server stuff with
datagrams much more difficult than it should be, and makes it
impossible to use if the packets must pass through a firewall.  This
limitation will be eliminated in the next release, but even then UDP
will be something best left to cases where you must communicate with
existing servers that use this protocol (DNS lookups being the most
significant of these).
  Regards,
    Scott

********************************************************
Scott Raney  raney at metacard.com  http://www.metacard.com
MetaCard: You know, there's an easier way to do that...





More information about the metacard mailing list