Hey everybody,
I'm writing up a little UDP chat client just to get my feet wet in winsock. I've read that when you transmit packets across the net, they can be split up along the way if the packet is too large. I was wondering if there is a guaranteed size that will not be split (and hence, arrive in one piece)

Any input is appreciated
--Chorus
Posted on 2002-08-18 09:40:35 by chorus
AFAIK UDP packets dont get split. Can someone verify this?
Posted on 2002-08-18 10:39:11 by bazik
I don't think the routers distinguish between UDP and TCP/IP packets. I think they just go by size.
Unless, UDP packets are split by the OS before being sent out *shrugs*.
--Chorus
Posted on 2002-08-18 10:53:17 by chorus
Packets will always be split by the OS, to meet the MTU of the network interface card. It's hard guaranteeign your data streams will never be split, as there's a LOT of different routing hardware on the internet, and a lot of different MTUs. Ethernet, ATM, whatever.

I wouldn't worry too much about this; while UDP is "unreliable" (packets might get lost, and appear in another sequence than what you sent them in), you should always get one entire UDP datagram when you get something... ie, you' wont get "a half packet" (it will simply be dropped instead).
Posted on 2002-08-18 11:01:08 by f0dder
The half a packet thing worried me (thanks for clarifying), but also I was wondering about overhead. Ex, I don't wanna be sending 10 50 byte packets when I could send 1 500 byte packet. This would make the difference between me sending out messages to clients immediately or saving up a few until I meet the "right" size.

As an aside, I checked out getsockopt with SO_MAX_MSG_SIZE which reports the max packet size supported by the SOCK_DGRAM protocol. It told me 65527. Somehow, sending 64kb UDP packets doesn't sound like a good idea to me...

Thanks for the info guys,

--Chorus
Posted on 2002-08-18 11:13:24 by chorus
Why not use TCP? :)
Posted on 2002-08-18 11:19:58 by f0dder

Somehow, sending 64kb UDP packets doesn't sound like a good idea to me...


The small file transfer application I developed for my Company sends 100MB packets :)
That's why I guess there is no *real* limit with UDP :grin:
Posted on 2002-08-18 11:46:32 by bazik
Test this
ping -f -l www.av.com

and ping will tell you when the packets gets fragmented.
Posted on 2002-08-18 11:50:54 by ante
>Why not use TCP?

Two reasons:

1) UDP is incredibly easy to implement -- right now I'm learning so I thought I'll do some stuff in UDP before I start looking at full TCP/IP (the connectionless aspect is kinda nice)
2) UDP seems to be the way to go for fast, small transfers. A friend of mine wants to get a multiplayer game together, so ultimately, this is where the work will end up. The chat program is just to get the basics of setting up a little server and having a bunch of people connect and exchange info.

bazik: 100MB UDP sends... that's... interesting...
Do you just set up a send loop to fire a bunch of chunks of the file off? You couldn't send that all in one go can you? You would have to read 100MB into memory... or I guess you could file map it...
I think I'll be mostly dealing with sends in the range of 10-100 bytes (small text messages, and for the game, positional updates, etc)

Thanks again guys


--Chorus
Posted on 2002-08-18 12:11:33 by chorus
ante I get 1472 bytes at most without fragmentation

Thanks

--Chorus
Posted on 2002-08-18 12:15:11 by chorus