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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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.
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

762 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