Re: UDP max packet size
Re: UDP max packet size
- Subject: Re: UDP max packet size
- From: Marshall Eubanks <email@hidden>
- Date: Tue, 16 Nov 2010 10:45:37 -0500
On Nov 16, 2010, at 4:22 AM, Quinn The Eskimo! wrote:
>
> On 15 Nov 2010, at 19:16, Jonathon Kuo wrote:
>
>> I have a dedicated ad hoc network between two OSX devices, and I use UDP packets between them to transfer status messages, and this all works fine. The standard "max" size of a UPD packet is generally taken to be 512 bytes over the internet, but does this hold strictly true between two end points on a dedicated (local) network? Just wondering about the OSX UDP implementation, if it allows a SO_MAX_MSG_SIZE up to 64k bytes like Windows does?
>
> You're mixing up the UDP maximum packet size with the UDP maximum packet size without fragmentation. The former is just under 64 KB (the IP max packet size minus the IP and UDP header overhead). The latter is determined by the link layers between you and your peer. The historical 512 byte limit is probably too low these days (smells like LocalTalk to me). Virtually all commonly-used link layers support a maximum packet size of 1500 bytes, or just under that (curse you PPPoE and your 1492 byte MTU!). So I'd expect that you could double your maximum UDP size to 1024 without running into major problems, even on the wider Internet. However, given that you have a dedicated network, you should be able to set your packet size based on knowledge of that network. If it's a standard Wi-Fi network, it uses 1500 byte Ethernet packets, from which you can subtract the IP and UDP header sizes to get your maximum UDP packet size.
Getting dropped packets due to fragmentation is an excellent way to have weird hard to diagnose errors, so attention must be paid.
512 bytes is long obsolete minimum MTU (note that IPv6's minimum is 1280). It's simply irrelevant for you.
Now-a-days, the MTU set by Ethernet - use 1492 to be compliant with 802.3. Then you have to be careful - if you set this in software,
do they include the headers, or not ? And, for UDP, do they include the UDP header in addition to the IP header ? I see
little consistency here - I would suggest you use (for IPv4!)
IP - 20 bytes (no options!)
UDP - 8 bytes
So 1492 - 28 = 1464 at most.
I tend to use 1450 just as an easy to remember safe number. See page 16 of http://tools.ietf.org/html/rfc1191 for more.
Regards
Marshall
>
> S+E
> --
> Quinn "The Eskimo!" <http://www.apple.com/developer/>
> Apple Developer Relations, Developer Technical Support, Core OS/Hardware
>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Macnetworkprog mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden