By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,490 Members | 1,283 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,490 IT Pros & Developers. It's quick & easy.

Maximum Datagram size for UDP Sockets

P: n/a
Hello,

Does anyone know how to get the maximum size of a datagram for a UDP Socket
created via .NET's System.Net.Sockets.Socket class?

Thanks!
Nov 17 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
UDP messages are called "datagrams" because they assume each
message will fit within a single packet for delivery. However, defining the
maximum size of a UDP datagram depends on lots of factors.

The length field of the UDP header allows up to 65535 bytes of data.
However, if you are sending your UDP packet across an Ethernet network, the
Ethernet MTU is 1500 bytes, limiting the maximum datagram size. Also, some
routers will attempt to fragment large UDP packets into 512 byte chunks.

So its more than .NET that determines "datagram" maximum size.
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Gregory Hassett" wrote:
Hello,

Does anyone know how to get the maximum size of a datagram for a UDP Socket
created via .NET's System.Net.Sockets.Socket class?

Thanks!

Nov 17 '05 #2

P: n/a
joe
"Gregory Hassett" <gh******@hotmail.com> writes:
Does anyone know how to get the maximum size of a datagram for a UDP
Socket created via .NET's System.Net.Sockets.Socket class?


A UDP datagram can't be more than 64K because the length is a 16 bit
integer (regardless of language or environment). I can't find .NET
documentation that states that so it might do something under the
covers to make you think it will send bigger datagrams, but I wouldn't
count on it.

Joe
--
Gort, klatu barada nikto
Nov 17 '05 #3

P: n/a
joe
"Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.com> writes:
UDP messages are called "datagrams" because they assume each message
will fit within a single packet for delivery. However, defining the
maximum size of a UDP datagram depends on lots of factors.

The length field of the UDP header allows up to 65535 bytes of data.
However, if you are sending your UDP packet across an Ethernet
network, the Ethernet MTU is 1500 bytes, limiting the maximum
datagram size. Also, some routers will attempt to fragment large UDP
packets into 512 byte chunks.


The MTU doesn't limit the maximum datagram size, the length field in
the IP header does. Fragmentation is performed routinely when the
datagram size exceeds the physical capacity of a network segment. I'm
not sure where the 512 byte chunks come from though, it depends on
what can be sent over the next link.

Joe
--
Gort, klatu barada nikto
Nov 17 '05 #4

P: n/a

"Gregory Hassett" <gh******@hotmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Hello,

Does anyone know how to get the maximum size of a datagram for a UDP
Socket
created via .NET's System.Net.Sockets.Socket class?

Thanks!


The maximum UDP Datagram size is determined by the underlying transport and
the subnet, .NET (or more exactly the Winsock library) has nothing to do
with this. The max. size can never exceed 64Kb, to get the max. size of the
outbound (send) message supported by the local transport provider (note
"local provider" here ! that means that the value returned is not
necessarily the message size that can be used end-to-end), you'll have to
call GetSockopt through PInvoke. Note that there is no way to get the
receive max. message size.

Willy.


Nov 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.