PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Noms de domaine > comp.protocols.tcp-ip > Problem with winsock2 to setup a constant bit rate, please
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
comp.protocols.tcp-ip TCP and IP network protocols.

Problem with winsock2 to setup a constant bit rate, please

Réponse
 
LinkBack Outils de la discussion
Vieux 19/10/2006, 05h43   #1
charlie
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Problem with winsock2 to setup a constant bit rate, please

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

  Réponse avec citation
Vieux 19/10/2006, 09h17   #2
robertwessel2@yahoo.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Problem with winsock2 to setup a constant bit rate, please


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.

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 09h37.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,10703 seconds with 10 queries