Maximum UDP datagram size under Windows XP

Felecha

Golden Member
Sep 24, 2000
1,434
0
0
I understand that the maximum datagram size for UDP can vary with the operating system. Anyone know the limit under Win XP?
 

cmetz

Platinum Member
Nov 13, 2001
2,296
0
0
Felecha, it can only vary if the OS doesn't implement the spec properly, and this would not be a minor oversight. The maximum datagram size for UDP is 65535-sizeof(previous headers), or typically 65507 bytes of UDP payload data when all is said and done. The IP minimum reassembly buffer size is 576, meaning that typically you have 548 bytes of UDP payload that a receiver is required to be able to receive and reassemble. All but the most constrained (embedded or ancient) systems have reassembly bufferring that can handle up to a full (64k-1) IP packet, and thus you can deliver up to 65507 UDP payload under normal conditions.

Put more simply, I think this is not going to vary with any real OS.
 

Felecha

Golden Member
Sep 24, 2000
1,434
0
0
OK, thanks. My coworker is doing a UDP thing and wanted to know the max, and told me he thought it was a generic thing but subject to possible OS specifics. In any case, it sounds ample.
 

Felecha

Golden Member
Sep 24, 2000
1,434
0
0
Coworker came back from lunch, and tweaked his question a bit. He's sending a message over to a process, and if his message is too big, it chokes with an error 10040, which we looked up and found in MSDN:

"WSAEMSGSIZE The message was too large to fit into the specified buffer and (for unreliable protocols only) any trailing portion of the message that did not fit into the buffer has been discarded. "

I take it the "unreliable protocols" means UDP

Any advice? That's what he meant by "what's the size he needs to work with". I thought he was asking what was the limit in general.

Is this internal buffer thing a limit we can increase somewhere, like a Registry setting?
 

Felecha

Golden Member
Sep 24, 2000
1,434
0
0
Found it. There was a buffer in the code that was the culprit. He reset that to larger and fixed the problem. Been a while since the code was written, and the error message sounded like a Windows error, not a code error.

Thanks

F
 

cmetz

Platinum Member
Nov 13, 2001
2,296
0
0
Felecha, recommend that your co-worker buy a copy of "Unix Network Programming, Vol. 1: The Sockets Networking API, Third Edition" (UNP/3E in the business). Winsock is originally based on sockets and a good sockets reference will help you with winsock, though it's important not to assume things are 1:1.