Design Considerations for a Network Performance Test
Other versions of this page are also available for the following:
8/28/2008
Prior to optimizing a network driver, identify the performance improvements you are seeking. For example, your current hardware and driver might perform at a rate that is lower than expected. The first step in addressing a performance issue is to design a network performance test for your driver and hardware.
You must specifically design a network performance test. It is not sufficient to use an application that employs networking functionality and additional technology to test network performance. For example, Microsoft® Internet Explorer uses networking functionality to download content for Web pages, but also uses graphics capabilities to generate and display Web pages. If you use any technologies other than networking functionality, your test results will not necessarily indicate the maximum performance for a specified set of hardware.
A typical design of a network performance test consists of a client desktop computer and a server. Both the client desktop computer and the server repeatedly call the send, recv and recvfrom Winsock functions to send or receive data over TCP\IP or User Datagram Protocol (UDP). The following code example shows the main loop of a TCP or UDP networking performance test.
//Set up connection SOCKET sd.
DWORD dwBytesSent = 0;
DWORD dwTime = GetTickCount();
while(dwBytesSent < dwTotalBytesReq){
int nRet = send(sd, buf, dwBufSize- cwBytesSent, 0)
if(nRet == SOCKET_ERROR || nRet == 0){
//Handle error or TCP closed connection.
break;
}
dwBytesSent += nRet;
}
//Close connection.
_tprintf(TEXT("Sent %ld bytes in %ld ms; throughput: %f Mbps\n"),
dwBytesSent,
dwTime,
(float)dwBytesSent * 8. / (float)dwTime / 1000.);
The connection setup and shutdown times, along with all other operations except the sending of data, are excluded from the block where the send or receive throughput is measured. In addition, there are no calls to the select or setsockopt (Windows Sockets) functions from within the main send loop. Avoid excess function calls. These can have a negative impact on performance.
For a Windows Embedded CE-based device with x-86, Microsoft recommends that you design your performance test so that it is compatible with both Windows Embedded CE and a Windows-based desktop OS. This design helps you compare results when you use the same hardware on different OSs.
Once you have designed your network performance test, you can implement your test. For more information, see Implementing a Network Performance Test.