Peter T. Breuer schrieb:
> In comp.os.linux.development.system Stephan Absmeier <m...@privacy.net> wrote:
>>Keith Wansbrough schrieb:
>>>"Peter T. Breuer" <p...@oboe.it.uc3m.es> writes:
>>>>Please perform the further experiments to confirm or deny. Detail your
>>>>measurement mode. To make valid measurements you will need to let the
>>>>NIC quiesce after each "packet". At least 1s delay.
>>I don't have root rights. How should I quiesce the card?
> Eh? Just sleep for a while. 1s between sends.
>>There is no packet delay module installed.
> Eh? How are you performing your measurements if you cannot control
> when your packet is sent? I presumed you were just doing a write to a
> socket, and timing how long it takes!
>>>Also, don't always start with the smaller files and work your way up
>>>to bigger ones - there are probably some startup costs associated with
>>>the first transfer. ARP comes to mind - are you sure that both hosts
>>>have the other's MAC addrs in their ARP caches before you start
>>>testing?
>>this time upside down. I started with 800000 Bytes going to
>>8000 Bytes:
> Useless, unless you tell us what your experimental procedure is!
>>Bytes fastest run average run slowest run
>>800000 0.068346 0.0688138 0.069734
>>500000 0.042749 0.046447 0.073162
>>400000 0.034251 0.0346192 0.035127
>>350000 0.030081 0.0334658 0.062391
>>300000 0.026015 0.0261624 0.026631
>>200000 0.017581 0.0177638 0.017923
>>100000 0.009186 0.0092719 0.009383
>> 80000 0.007103 0.0109007 0.0411
>> 50000 0.0048 0.0048566 0.005025
>> 40000 0.003765 0.0258131 0.040525
>> 35000 0.003641 0.0036926 0.003859
>> 30000 0.039624 0.039726 0.039826
>> 20000 0.038596 0.0392895 0.039463
>> 10240 0.037367 0.0401245 0.049999
>> 8000 0.03831 0.0386388 0.039061
>>nearly the same values as before but exactly the same picture.
> But we (I) asked for more details. What you show is not fine grained
> enough to give us an idea of what could be happening.
see the code at the end, should I repost my first post or
what are you interested in
>>It is done in a loop. There is a 1 second break between the
>>runs and a 5 second break between the different packets. The
> Runs? What is a "run"?
sending the data for one time
>>socket has benn closed after each run, cause of time measure
>>methods.
> Well, I would be happier if you did not close it, but it makes no
> difference at the packet level.
it's although to start again with slow start
> Now confirm that streaming continuously gives you the same speeds for
> all, and you have the answer. The NIC is waiting for more on
> the small stuff.
How big should this file be? 1MB, 10MB or more?
the version using gettimeofday, I deleteted all the
getRealTime stuff to reduce the length and tried to
translate it to english. Hopefully you see what I did.All
the tests were made with option 0 so far. the receiver puts
the data in a buffer and dump it so far.
Hope it's not too long to post.
Thanks
Stephan
#include "abs_net.h" //constants like TCP_SERVER_PORT, KB...
#include <unistd.h>
#include <sys/time.h>
#include <netinet/tcp.h>
#include <sstream>
#include <stdlib.h>
#include <iostream>
using namespace std;
class tcpSender
{
private:
int length;
char *line;
int mySocket, protokollAddr;
struct sockaddr_in serverAddr, clientAddr;
struct hostent *host;
int i,paketlength;
int window_size, mss, priority;
public:
tcpSender(const char *server,char *lineIn,int lengthIn)
{
length=lengthIn;
line=lineIn;
/* get server IP address (no check if input is IP
address or DNS name */
host = gethostbyname(server);
if(host==NULL)
{
cout<<"tcpSender: unknown host "<<server<<endl;
exit(1);
}
}
void init(int option)
{
serverAddr.sin_family = host->h_addrtype;
memcpy((char *)
&serverAddr.sin_addr.s_addr,host->h_addr_list[0],
host->h_length);
serverAddr.sin_port = htons(TCP_SERVER_PORT);
/* socket creation */
mySocket = socket(AF_INET,SOCK_STREAM,0);
if(mySocket<0)
{
cout<<"tcpSender: cannot open socket"<<endl;
exit(1);
}
/*wait for all data beiing send,need for time measure */
linger lingerwert;
lingerwert.l_onoff=1;
lingerwert.l_linger=32767;
setsockopt(mySocket,SOL_SOCKET,SO_LINGER,(char*)&lingerwert,sizeof(lingerwert));
/*
tcp optionen
8 buffer
4 priority
2 nagle off
1 mss
0 none
15 for all
*/
if (option>=8)
{
/* set SO_RCVBUF and SO_SNDBUF to 128*1024 Bytes */
window_size=KB*1024;
setsockopt(mySocket,SOL_SOCKET,SO_RCVBUF,(char*)&window_size,sizeof(window_size));
setsockopt(mySocket,SOL_SOCKET,SO_SNDBUF,(char*)&window_size,sizeof(window_size));
option -=8;
}
if (option >=4)
{
/* Priority of the Queue */
priority=PRIORITAET;
setsockopt(mySocket,SOL_SOCKET,SO_PRIORITY,(char*)&priority,sizeof(priority));
option -= 4;
}
if (option >= 2)
{
/* Nagle-Algorithm off */
setsockopt(mySocket, SOL_TCP,
TCP_NODELAY,(char*)true,sizeof(true));
option -=2;
}
if (option >= 1)
{
/* try an other mss */
mss=MSS;
setsockopt(mySocket, SOL_TCP,
TCP_MAXSEG,(char*)&mss,sizeof(mss));
option -= 1;
}
/* bind any port */
clientAddr.sin_family = AF_INET;
clientAddr.sin_addr.s_addr = htonl(INADDR_ANY);
clientAddr.sin_port = htons(0);
protokollAddr = bind(mySocket, (struct sockaddr *)
&clientAddr, sizeof(clientAddr));
if(protokollAddr<0)
{
cout<<"tcpSender: cannot bind TCP port
"<<clientAddr.sin_port<<endl;
exit(1);
}
/* connect to server */
protokollAddr = connect(mySocket, (struct sockaddr *)
&serverAddr, sizeof(serverAddr));
if(protokollAddr<0)
{
cout<<"tcpSender: cannot connect to Socket"<<endl;
exit(1);
}
}
void work()
{
protokollAddr = send(mySocket, line, length, 0);
if(protokollAddr<0)
{
cout<<"tcpSender: cannot send data"<<endl;
close(mySocket);
exit(1);
}
}
int end()
{
return close(mySocket);
}
};
int main(int argc, char *argv[])
{
int length, numberOfRuns,option, closeid;
timeval start, end;
/* check command line args */
if(argc!=4)
{
cout<<"usage: tcpSender <server> number_of_runs
option"<<endl;
cout<<"example: tcpSender blowfish 10 15"<<endl;
cout<<"options :"<<endl;
cout<<"8 sendingbuffer "<<KB<<"kb"<<endl;
cout<<"4 priority "<<PRIORITAET<<endl;
cout<<"2 Nagle algorithm off"<<endl;
cout<<"1 mss "<<MSS<<endl;
cout<<"0 default"<<endl;
exit(1);
}
numberOfRuns=atoi(argv[2]);
double before,after,duration[numberOfRuns],complete,min,max;
option=atoi(argv[3]);
char line[800000];
// fill the array with random chars
for (int aa=0;aa<800000;)
{
switch(rand() % 16)
{
case 0:
line[aa]='a';
break;
case 1:
line[aa]='b';
break;
case 2:
line[aa]='c';
break;
case 3:
line[aa]='d';
break;
case 4:
line[aa]='e';
break;
case 5:
line[aa]='f';
break;
case 6:
line[aa]='g';
break;
case 7:
line[aa]='h';
break;
case 8:
line[aa]='i';
break;
case 9:
line[aa]='j';
break;
case 10:
line[aa]='k';
break;
case 11:
line[aa]='l';
break;
case 12:
line[aa]='m';
break;
case 13:
line[aa]='n';
break;
case 14:
line[aa]='o';
break;
default:
line[aa]='p';
break;
}
aa++;
}
// try different length
for(int testrun=0;testrun<15;)
{
switch(testrun)
{
case 0:
length=800000;
break;
case 1:
length=500000;
break;
case 2:
length=400000;
break;
case 3:
length=350000;
break;
case 4:
length=300000;
break;
case 5:
length=200000;
break;
case 6:
length=100000;
break;
case 7:
length=80000;
break;
case 8:
length=50000;
break;
case 9:
length=40000;
break;
case 10:
length=35000;
break;
case 11:
length=30000;
break;
case 12:
length=20000;
break;
case 13:
length=10240;
break;
default:
length=8000;
break;
}
testrun++;
complete=min=max=0.0;
cout<<"option: "<<option<<" data size: "<<length<<endl;
cout<<endl;
//send data, measure time
for (int test=0;test<numberOfRuns;)
{
tcpSender testSender=tcpSender(argv[1],line,length);
testSender.init(option);
gettimeofday(&start,NULL);
testSender.work();
closeid=testSender.end();
gettimeofday(&end,NULL);
before=start.tv_sec+1.e-6*start.tv_usec;
after=end.tv_sec+1.e-6*end.tv_usec;
duration[test]=after-before;
cout<<"time for run "<<test<<" : "<<duration[test]<<"
sec"<<endl;
complete +=duration[test];
if (min==0)
min=duration[test];
else
if (duration[test]<min)
min=duration[test];
if (max<duration[test])
max=duration[test];
test++;
//break before next run, same length
sleep(1);
}
cout<<endl;
cout<<"average time: "<<complete/numberOfRuns<<" sec "<<endl;
cout<<"fastest run: "<<min<<" sec"<<endl;
cout<<"slowest run: "<<max<<" sec"<<endl;
cout<<endl;
cout<<endl;
//break before new length
sleep(5);
}
return 1;
}