Solved

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

Posted on 2010-11-24
7
1,025 Views
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.
0
Comment
Question by:jtrades
  • 3
  • 2
7 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 250 total points
ID: 34207666
Take a look at http://msdn.microsoft.com/en-us/library/ms819736.aspx ("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.
0
 

Author Comment

by:jtrades
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.  
0
 
LVL 86

Expert Comment

by:jkr
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.
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:jtrades
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?
0
 

Author Comment

by:jtrades
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?
0
 
LVL 40

Expert Comment

by:evilrix
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.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

757 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now