Determining the Total Network Buffer Space Available for TCP/UDP Sockets

Posted on 2010-11-24
Last Modified: 2012-05-10
I have a program that has multiple TCP and UDP socket connections.  In my program, I set the send and receive buffer size for the TCP sockets and the receive buffer size for the UDP sockets using setsockopt.  However, I was wondering the following::

* How can I determine how much total network buffer space is available at program startup, so that I can determine how to divide it up between my various sockets?  Right now, I use getsockopt to see what the send or receive buffer size is set for an individual socket, but it would be nice to see the total available before creating any sockets.

* Where is the network buffer space physically located?

I am programming in C/C++ using MS Visual C++ 2010 Express on a windows 7 machine.
Question by:jtrades
  • 3
  • 2
LVL 86

Accepted Solution

jkr earned 250 total points
ID: 34207666
Take a look at ("TCP Receive Window Size and Window Scaling" - that's for Server 2003, but should apply for W7 also):

The default receive window size that TCP advertises in Windows Server 2003 depends on the following, in order of precedence:

    *      The value for the SO_RCVBUF Windows Sockets option for the connection. This option specifies the total per-socket buffer space reserved for receive operations.
    *      The per-interface TcpWindowSize registry value.
    *      The GlobalMaxTcpWindowSize registry value.

The buffer space is physicall located in the RAM ;o) - no, seriously, I assume that the driver(s) maintain(s) it/them on a per-interface basis and map them into your process' address space as shared segments for performance reasons.

Author Comment

ID: 34219495
Thanks for the info.  However, do you know of any functions that I can call within my program to find the current total network buffer size (not just on a per socket basis)?  I want to be able to adjust the size depending on how many connections I create.  
LVL 86

Expert Comment

ID: 34220157
Well, as that article states, you can find them as

    *      The per-interface TcpWindowSize registry value.
    *      The GlobalMaxTcpWindowSize registry value.

So, you basically just have to read these registry values.
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why


Author Comment

ID: 34235160
Looks like these values don't exist every time.  In some articles, the admin/user may have to add these registry values to tweak their tcp performance.  Can you think of any other values that I can obtain within my program that are more consistent?

Author Comment

ID: 34235302
One more related question.  What is the max SO_RCVBUF/SO_SNDBUF that I can set?  From what I read, it seems to be 256K, but using setsockopt  I was able to maintain buffer sizes in the MB range.  Is this possible?
LVL 40

Expert Comment

ID: 34824148
This question has been classified as abandoned and is being closed as part of the Cleanup Program. See my comment at the end of the question for more details.

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question