469,276 Members | 1,922 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,276 developers. It's quick & easy.

Maximum Datagram size for UDP Sockets

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
4 31471
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
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
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

"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.

Similar topics

reply views Thread by Jonathan Ellis | last post: by
2 posts views Thread by Kums | last post: by
6 posts views Thread by Iain King | last post: by
6 posts views Thread by 7stud | last post: by
8 posts views Thread by babakandme | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.