Join Now
Quality Rating:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)
Expertise Level:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)

This page was last modified 14:18, 29 May 2008.

Set TCP Window Size

From Forum Nokia Wiki

Contents

What is a TCP Window ?

A TCP window is the amount of outstanding data (unacknowledged by the receiver) a sender can send on a particular connection before it gets an acknowledgment back from the receiver, that has received some of the data.

The primary reason for the TCP window is congestion control. The TCP window throttles down the transmission speed to a level where congestion and data loss do not occur.

Considering the importance of TCP Window, one should make sure that the two ends correctly negotiate the Window Size before making a connection. The main reason for establishing a Windows Size is that there are only 16 bits reserved for the window size in the TCP header, with a maximum window sizes of 64 KB.

To work around this limitation, the TCP window scale option was introduced. So, if a window size greater than 64 KB is to be established, it must be done at connection set-up time.

Setting the TCP Window Size

The following Open C code snippet shows how to set the TCP Window size on a client and a server.

int window_size = 128 * 1024;	/* 128 kilobytes */
sock = socket(AF_INET, SOCK_STREAM, 0);
 
/* Both the setsockopt() calls should be before the connect()/accept() */
setsockopt(sock, SOL_SOCKET, SO_SNDBUF,
	 (char *) &window_size, sizeof(window_size));
 
setsockopt(sock, SOL_SOCKET, SO_RCVBUF,
	 (char *) &window_size, sizeof(window_size));
	
#ifdef CLIENT_CODE
   connect(sock, (struct sockaddr *) &address, sizeof(address));
#endif
 
#ifdef SERVER_CODE
  listen(sock, 5);
 
  accept(sock, NULL, NULL);
#endif

The setsockopt() function provides an application program with the means to control socket behaviour. The required header file for this is sys/socket.h. In the above code, the setsockopt() calls must come before the connect() or accept() calls.


References


Links

Related Discussions
Thread Thread Starter Forum Replies Last Post
what is the maximum amount of stack size ? oncer General Symbian C++ 7 2007-02-02 15:57
CEikEdwin content display and style set mghost111 General Symbian C++ 2 2008-04-28 16:59
Increase receive-window in 7650 maghal Mobile Java General 1 2003-04-18 04:25
How to set size and position of camera??? hszr General Symbian C++ 4 2007-07-26 04:11
how do you scroll an image? Nokia_Archive General Symbian C++ 1 2002-05-29 19:58
 
Powered by MediaWiki
     
     RDF Facets:
     
     
     qfnZtypeQUqfnTypeZCommunityContentQ
     qfnZtypeQUqfnTypeZWebpageQ
     qfnZtypeQUqfnTypeZWikiContentQ
     qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX