|
|
|
|
||||||
| comp.protocols.tcp-ip TCP and IP network protocols. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Hi,
I am trying to figure out how to set up a constant bit rate (about 100 Mbits/s) of network traffic under Windows XP with winsock2 functions. I have a simple client/server application running on 2 computers, both running windows XP, on Intel motherboard DP965LTCK with core 2 duo processor, and Intel 82566DC gigabit network adapter. Both client and server are running a simple while loop, to send and receive data via TCP/IP, to set up a constant rate of network traffic: /////////////////////////////////////////////////////////////// // CLIENT test constant bit rate = 100 Mbits/s int port = 33333; int sleepTime = 10; // sleep for 10 ms between each send int blockSize = 31250; // send 31250 float (= 1 Mbits) each call float *bufferToSend = new float[blockSize]; memset(bufferToSend,0,sizeof(float) * blockSize); .......................................... int bytesSent = 0; while(1) { bytesSent = send(client, (char *)bufferToSend, blockSize * sizeof(float), 0); Sleep(sleepTime); } /////////////////////////////////////////////////////////////// // SERVER test constant bit rate = 100 Mbits/s int blockSize = 3*31250; // can receive 3 * 31250 float each call float * bufferToRcv = new float[blockSize]; memset(bufferToRcv,0,sizeof(float) * blockSize); .................................................. .. int bytesRecv = 0; while(1) { bytesRecv = recv(client, (char *)bufferToRcv, blockSize*sizeof(float), 0); } According to Windows Task Manager, the applications only require about 2% of the CPU and 10% of the network bandwidth (which is well 100Mbits/s). The problem is that even if the bit rate is well constant most of the time, big gaps appear in the traffic intermittently. It seems that the client just stops sending packets for a few 10th of seconds (or the server stops receiving?) every 15-20 minutes maybe. I tried with blocking and non-blocking TCP sockets, I tried to connect the computers with a crossover cable, with a gigabit switch, I also tried to run this application on different computers with different network adapters and each time I found the same kind of gaps, more or less frequently. What's wrong? Thanks a lot for any , best regards, Charles |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
charlie wrote: > Hi, > > I am trying to figure out how to set up a constant bit rate (about 100 > Mbits/s) of network traffic under Windows XP with winsock2 functions. > I have a simple client/server application running on 2 computers, both > running windows XP, on Intel motherboard DP965LTCK with core 2 duo > processor, and Intel 82566DC gigabit network adapter. Both client and > server are running a simple while loop, to send and receive data via > TCP/IP, to set up a constant rate of network traffic: > > /////////////////////////////////////////////////////////////// > // CLIENT test constant bit rate = 100 Mbits/s > int port = 33333; > int sleepTime = 10; // sleep for 10 ms between each send > int blockSize = 31250; // send 31250 float (= 1 Mbits) each call > float *bufferToSend = new float[blockSize]; > memset(bufferToSend,0,sizeof(float) * blockSize); > > ......................................... > > int bytesSent = 0; > while(1) > { > bytesSent = send(client, (char *)bufferToSend, blockSize * > sizeof(float), 0); > Sleep(sleepTime); > } > > /////////////////////////////////////////////////////////////// > // SERVER test constant bit rate = 100 Mbits/s > int blockSize = 3*31250; // can receive 3 * 31250 float each call > float * bufferToRcv = new float[blockSize]; > memset(bufferToRcv,0,sizeof(float) * blockSize); > > .................................................. . > > int bytesRecv = 0; > while(1) > { > bytesRecv = recv(client, (char *)bufferToRcv, blockSize*sizeof(float), > 0); > } > > According to Windows Task Manager, the applications only require about > 2% of the CPU and 10% of the network bandwidth (which is well > 100Mbits/s). The problem is that even if the bit rate is well constant > most of the time, big gaps appear in the traffic intermittently. It > seems that the client just stops sending packets for a few 10th of > seconds (or the server stops receiving?) every 15-20 minutes maybe. I > tried with blocking and non-blocking TCP sockets, I tried to connect > the computers with a crossover cable, with a gigabit switch, I also > tried to run this application on different computers with different > network adapters and each time I found the same kind of gaps, more or > less frequently. What's wrong? TCP does not guarantee transfer rates or regularity thereof, the Windows TCP stack does not either, and Sleep() makes very few guarantees about how long your application will be suspended. First, Sleep(10) may well suspend you application for far longer than 10ms. Or the OS might, just on its whim. Second, the send will block until the ~125KB of data is sent. If there is any delay in sending it, for example, a lost packet, some whim of either side's TCP/IP stack, a delay in the receiving application, whatever, you may further throw your timing off. You may want to attach a sniffer, or run a packet monitor to detect TCP retransmissions. Most of the time CBR applications use UDP, and deal with lost packets. You simply can't get true CBR out of TCP. But if you want to transmit at about 100Mb/s, at least averaged over some extended period of time, you'll need to track your actual performance, and tweak your send loop as appropriate. IOW, keep sending without sleeping to make up for any lost time. Always assuming, of course, that there are no other bottlenecks actually preventing you from achieving the desired data rate. In any event, the real question is what are you trying to accomplish? You're almost certainly on the wrong path. |
|
![]() |
| Outils de la discussion | |
|
|