mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-08-01 11:26:52 +03:00
benchmarks: fix some bugs
This commit is contained in:
@ -155,7 +155,7 @@ int benchmarks_raw_up (ssh_session session, struct argument_s *args,
|
|||||||
if(args->verbose>0)
|
if(args->verbose>0)
|
||||||
fprintf(stdout,"Finished upload, now waiting the ack\n");
|
fprintf(stdout,"Finished upload, now waiting the ack\n");
|
||||||
|
|
||||||
if((err=ssh_channel_read(channel,buffer,sizeof(buffer)-1,0))==SSH_ERROR)
|
if((err=ssh_channel_read(channel,buffer,5,0))==SSH_ERROR)
|
||||||
goto error;
|
goto error;
|
||||||
buffer[err]=0;
|
buffer[err]=0;
|
||||||
if(!strstr(buffer,"done")){
|
if(!strstr(buffer,"done")){
|
||||||
|
@ -178,6 +178,15 @@ static struct argp_option options[] = {
|
|||||||
.doc = "[async SFTP] number of concurrent requests",
|
.doc = "[async SFTP] number of concurrent requests",
|
||||||
.group = 0
|
.group = 0
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
.name = "cipher",
|
||||||
|
.key = 'C',
|
||||||
|
.arg = "cipher",
|
||||||
|
.flags = 0,
|
||||||
|
.doc = "Cryptographic cipher to be used",
|
||||||
|
.group = 0
|
||||||
|
},
|
||||||
|
|
||||||
{NULL, 0, NULL, 0, NULL, 0}
|
{NULL, 0, NULL, 0, NULL, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -214,6 +223,9 @@ static error_t parse_opt (int key, char *arg, struct argp_state *state) {
|
|||||||
case 'c':
|
case 'c':
|
||||||
arguments->chunksize = atoi(arg);
|
arguments->chunksize = atoi(arg);
|
||||||
break;
|
break;
|
||||||
|
case 'C':
|
||||||
|
arguments->cipher = arg;
|
||||||
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
if(arguments->nhosts >= MAX_HOSTS_CONNECT){
|
if(arguments->nhosts >= MAX_HOSTS_CONNECT){
|
||||||
fprintf(stderr, "Too much hosts\n");
|
fprintf(stderr, "Too much hosts\n");
|
||||||
@ -249,7 +261,8 @@ static void cmdline_parse(int argc, char **argv, struct argument_s *arguments) {
|
|||||||
#else /* HAVE_ARGP_H */
|
#else /* HAVE_ARGP_H */
|
||||||
(void) argc;
|
(void) argc;
|
||||||
(void) argv;
|
(void) argv;
|
||||||
(void) arguments;
|
arguments->hosts[0]="localhost";
|
||||||
|
arguments->nhosts=1;
|
||||||
#endif /* HAVE_ARGP_H */
|
#endif /* HAVE_ARGP_H */
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -260,13 +273,19 @@ static void arguments_init(struct argument_s *arguments){
|
|||||||
arguments->datasize = 10;
|
arguments->datasize = 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssh_session connect_host(const char *host, int verbose){
|
static ssh_session connect_host(const char *host, int verbose, char *cipher){
|
||||||
ssh_session session=ssh_new();
|
ssh_session session=ssh_new();
|
||||||
if(session==NULL)
|
if(session==NULL)
|
||||||
goto error;
|
goto error;
|
||||||
if(ssh_options_set(session,SSH_OPTIONS_HOST, host)<0)
|
if(ssh_options_set(session,SSH_OPTIONS_HOST, host)<0)
|
||||||
goto error;
|
goto error;
|
||||||
ssh_options_set(session, SSH_OPTIONS_LOG_VERBOSITY, &verbose);
|
ssh_options_set(session, SSH_OPTIONS_LOG_VERBOSITY, &verbose);
|
||||||
|
if(cipher != NULL){
|
||||||
|
if (ssh_options_set(session, SSH_OPTIONS_CIPHERS_C_S, cipher) ||
|
||||||
|
ssh_options_set(session, SSH_OPTIONS_CIPHERS_S_C, cipher)){
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
}
|
||||||
if(ssh_connect(session)==SSH_ERROR)
|
if(ssh_connect(session)==SSH_ERROR)
|
||||||
goto error;
|
goto error;
|
||||||
if(ssh_userauth_autopubkey(session,NULL) != SSH_AUTH_SUCCESS)
|
if(ssh_userauth_autopubkey(session,NULL) != SSH_AUTH_SUCCESS)
|
||||||
@ -311,7 +330,7 @@ static void do_benchmarks(ssh_session session, struct argument_s *arguments,
|
|||||||
}
|
}
|
||||||
err=benchmarks_ssh_latency(session, &ssh_rtt);
|
err=benchmarks_ssh_latency(session, &ssh_rtt);
|
||||||
if(err==0){
|
if(err==0){
|
||||||
fprintf(stdout, "SSH RTT : %f ms\n",ssh_rtt);
|
fprintf(stdout, "SSH RTT : %f ms. Theoretical max BW (win=128K) : %s\n",ssh_rtt,network_speed(128000.0/(ssh_rtt / 1000.0)));
|
||||||
}
|
}
|
||||||
for (i=0 ; i<BENCHMARK_NUMBER ; ++i){
|
for (i=0 ; i<BENCHMARK_NUMBER ; ++i){
|
||||||
b = &benchmarks[i];
|
b = &benchmarks[i];
|
||||||
@ -343,7 +362,7 @@ int main(int argc, char **argv){
|
|||||||
}
|
}
|
||||||
arguments.ntests=BENCHMARK_NUMBER;
|
arguments.ntests=BENCHMARK_NUMBER;
|
||||||
}
|
}
|
||||||
buffer=malloc(arguments.chunksize);
|
buffer=malloc(arguments.chunksize > 1024 ? arguments.chunksize : 1024);
|
||||||
if(buffer == NULL){
|
if(buffer == NULL){
|
||||||
fprintf(stderr,"Allocation of chunk buffer failed\n");
|
fprintf(stderr,"Allocation of chunk buffer failed\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
@ -364,7 +383,7 @@ int main(int argc, char **argv){
|
|||||||
for(i=0; i<arguments.nhosts;++i){
|
for(i=0; i<arguments.nhosts;++i){
|
||||||
if(arguments.verbose > 0)
|
if(arguments.verbose > 0)
|
||||||
fprintf(stdout,"Connecting to \"%s\"...\n",arguments.hosts[i]);
|
fprintf(stdout,"Connecting to \"%s\"...\n",arguments.hosts[i]);
|
||||||
session=connect_host(arguments.hosts[i], arguments.verbose);
|
session=connect_host(arguments.hosts[i], arguments.verbose, arguments.cipher);
|
||||||
if(session != NULL && arguments.verbose > 0)
|
if(session != NULL && arguments.verbose > 0)
|
||||||
fprintf(stdout,"Success\n");
|
fprintf(stdout,"Success\n");
|
||||||
if(session == NULL){
|
if(session == NULL){
|
||||||
|
@ -48,6 +48,7 @@ struct argument_s {
|
|||||||
unsigned int datasize;
|
unsigned int datasize;
|
||||||
unsigned int chunksize;
|
unsigned int chunksize;
|
||||||
int concurrent_requests;
|
int concurrent_requests;
|
||||||
|
char *cipher;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern char *buffer;
|
extern char *buffer;
|
||||||
|
Reference in New Issue
Block a user