Re: UDP max packet size
Re: UDP max packet size
- Subject: Re: UDP max packet size
- From: Jonathon Kuo <email@hidden>
- Date: Tue, 16 Nov 2010 09:06:08 -0800
On Nov 16, 2010, at 7:45 AM, Marshall Eubanks wrote:
>
> 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.
Thanks everyone. I guess the fragmentation issue kills it for me. So, would the following be possible?
I connect from one iPhone to another using Bonjour over a UDP socket. The receiving iPhone then uses the originator ethernet address in sockaddr.sin_addr and opens up a TCP/IP connection back to the originator.
1. I'm guessing I can't reuse the original UDP socket, but need to create an entirely new socket/connection.
2. What port do I use to communicate back? The originator will have a thread waiting on INADDR_ANY, but what port do I use? How does one open a port on an iPhone?
3. Will this even work???
Thanks!
_______________________________________________
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