Because of this, we have set the default transmit and receive buffers to ~1460 bytes. This keeps sockets' RAM usage down to as little as ~3KB each while still permitting full usage of standard-size TCP messages.
But of course the Internet has latency. When you request a web page, it can take around 100ms (estimated average) for each TCP message to arrive. Each message is then ACK'd which can take another 100ms to cross back over the Internet. That can limit Internet-based TCP throughput to about 7300 bytes per second (1460 bytes times five "DATA+ACK round-trips" per second).
For most NETMF applications this is a good default. For others you'll want faster throughput. And for some tight-memory applications you may even want to reduce the buffer size (to the minimum of 536 bytes as recommended/required by the TCP/IP spec).
Here is how you change the size of your receive and send buffers:
// example: set "socket"'s receive buffer size to "rxBufferSize" bytes in length socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveBuffer, rxBufferSize); // example: set "socket"'s send buffer size to "txBufferSize" bytes in length socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendBuffer, txBufferSize);Of course there are other throughput limitations on the Internet. Most notably, a web server's send buffer size (or other connection management algorithms) will limit the amount of data it can send to your Netduino before requiring an ACK.
In my experience, 8KB is a good receive buffer size for across-the-board performance:
// performance-optimized buffer size (for web requests) socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveBuffer, 8192);And if you're running a mini web server, 8KB is a good transmit buffer size. But remember that this is per-socket, so if you serve multiple clients this could eat up memory quickly:
// performance-optimized buffer size (for mini web servers) socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendBuffer, 8192);Chris