UDP packets greater than 510 bytes clipped
UDP packets greater than 510 bytes clipped
- Subject: UDP packets greater than 510 bytes clipped
- From: Heath Raftery <email@hidden>
- Date: Tue, 21 Jun 2005 19:02:00 +1000
G'day list,
I've been playing with UDP transmission in my Cocoa app for a few
days. My intention is to have UDP provide fast, unreliable, raw data
transfer to back up the current TCP messaging framework I have
working. At first sendto() returned EMSGSIZE's, so I now check
getsockopt(SO_SNDBUF) first and limit outgoing packets to that size.
I no longer get EMSGSIZE, and packet sniffing seems to show the
correct thing happening. That is, the entire packet is sent out, but
in IP fragments of about 1500 bytes. However the receiving host does
not get all the data.
From what I've read, IP should fragment the packets to the MTU of
the medium, and reassemble them at the other end. But the reassembly
doesn't appear to be happening! In fact, on the receiving side I only
get about 510 bytes of each packet, which destroys the data. On the
advice I read in a few different places, I limited the packet size to
548 bytes, since apparently that guarantees I wont get segmentation.
That didn't help - I still only received about 510 bytes.
In desperation I limited the packet size to 400 bytes, and everything
seems to work well - except that I'm sending out a lot of packets of
course!
The network architecture I was playing with was:
client <-> airport <-> server <-> localhost <-> client
SO_SNDBUF = 9216
SO_RCVBUF = 42080
I'm using the socket, bind and sendto calls to establish and send UDP
data, and NSFileHandle's readInBackgroundAndNotify to read. Would I
be right in discovering readToEndOfFileInBackgroundAndNotify does not
apply to UDP?
Can anyone suggest why I can't get more than about 510 bytes through
via UDP? Does anyone have any relevant resources to suggest to learn
more about UDP on OS X using Cocoa? I've read a bit of general UDP
information (such as <http://www.kmutt.ac.th/knowledge/programming/c/
unix_socket/faq/unix-socket-faq-5.html>) but haven't found much at
all that deals with Cocoa or OS X in particular.
Heath
_______________________________________________
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