1
1

minor changes and packet payloads changed

Этот коммит содержится в:
kaustubhprabhu 2009-07-08 22:57:43 +00:00
родитель 6b65cf6e25
Коммит 71a7ccf6d3

Просмотреть файл

@ -43,6 +43,27 @@ static struct option longopts[] =
}; };
void setnonblocking(int sock)
{
int opts;
/*
opts = fcntl(sock,F_GETFL);
if (opts < 0) {
perror("fcntl(F_GETFL)");
exit(EXIT_FAILURE);
}
*/
opts = (opts | O_NONBLOCK);
if (fcntl(sock,F_SETFL,opts) < 0)
{
perror("fcntl(F_SETFL)");
exit(EXIT_FAILURE);
}
return;
}
void add_interval_list(struct iperf_stream_result *rp, struct iperf_interval_results temp) void add_interval_list(struct iperf_stream_result *rp, struct iperf_interval_results temp)
{ {
struct iperf_interval_results *n; struct iperf_interval_results *n;
@ -80,7 +101,7 @@ void display_interval_list(struct iperf_stream_result *rp)
void send_result_to_client(struct iperf_stream *sp) void send_result_to_client(struct iperf_stream *sp)
{ {
int result; int result;
int size = sp->settings->blksize; int size = strlen((char *)sp->data) + 1;
printf("BLKSIZE = %d \n", size); printf("BLKSIZE = %d \n", size);
@ -170,7 +191,7 @@ int set_socket_options(struct iperf_stream *sp, struct iperf_test *tp)
} }
} }
#ifdef TCP_MAXSEG
//-M //-M
if(tp->default_settings->mss > 0) if(tp->default_settings->mss > 0)
{ {
@ -197,6 +218,7 @@ int set_socket_options(struct iperf_stream *sp, struct iperf_test *tp)
return -1; return -1;
} }
} }
#endif
return 0; return 0;
} }
@ -327,23 +349,30 @@ int iperf_tcp_send(struct iperf_stream *sp)
{ {
case STREAM_BEGIN: case STREAM_BEGIN:
buf[0]= STREAM_BEGIN; buf[0]= STREAM_BEGIN;
for(i=1; i < size; i++)
buf[i] = i % 37;
break; break;
case STREAM_END: case STREAM_END:
buf[0]= STREAM_END; buf[0]= STREAM_END;
break; break;
case RESULT_REQUEST: case RESULT_REQUEST:
buf[0]= RESULT_REQUEST; buf[0]= RESULT_REQUEST;
break; break;
case ALL_STREAMS_END: case ALL_STREAMS_END:
buf[0]= ALL_STREAMS_END; buf[0]= ALL_STREAMS_END;
break; break;
default: default:
buf[0]= 0; buf[0]= 0;
for(i=1; i < size; i++)
buf[i] = i % 37;
break; break;
} }
for(i=1; i < size; i++)
buf[i] = i % 37;
//applicable for 1st packet sent //applicable for 1st packet sent
if(sp->settings->state == STREAM_BEGIN) if(sp->settings->state == STREAM_BEGIN)
@ -384,22 +413,28 @@ int iperf_udp_send(struct iperf_stream *sp)
{ {
case STREAM_BEGIN: case STREAM_BEGIN:
buf[0]= STREAM_BEGIN; buf[0]= STREAM_BEGIN;
for(i=1; i < size; i++)
buf[i] = i % 37;
break; break;
case STREAM_END: case STREAM_END:
buf[0]= STREAM_END; buf[0]= STREAM_END;
break; break;
case RESULT_REQUEST: case RESULT_REQUEST:
buf[0]= RESULT_REQUEST; buf[0]= RESULT_REQUEST;
break; break;
case ALL_STREAMS_END: case ALL_STREAMS_END:
buf[0]= ALL_STREAMS_END; buf[0]= ALL_STREAMS_END;
break;
default: default:
buf[0]= 0; buf[0]= 0;
break;
}
for(i=1; i < size; i++) for(i=1; i < size; i++)
buf[i] = i % 37; buf[i] = i % 37;
break;
}
// applicable for 1st packet sent // applicable for 1st packet sent
if(sp->settings->state == STREAM_BEGIN) if(sp->settings->state == STREAM_BEGIN)
@ -433,8 +468,6 @@ int iperf_udp_send(struct iperf_stream *sp)
free(buf); free(buf);
} // timer_expired_micro } // timer_expired_micro
return result; return result;
} }
@ -540,7 +573,6 @@ void iperf_init_test(struct iperf_test *test)
perror("unable to set window"); perror("unable to set window");
} }
//setting noblock causes error in byte count -kprabhu
//setnonblocking(s); //setnonblocking(s);
sp = test->new_stream(test); sp = test->new_stream(test);
@ -629,7 +661,6 @@ char *iperf_reporter_callback(struct iperf_test *test)
double start_time, end_time; double start_time, end_time;
// need to reassign this // need to reassign this
char *message = (char *) malloc(500); char *message = (char *) malloc(500);
// used to determine the length of reporter buffer // used to determine the length of reporter buffer
while(sp) while(sp)
{ {
@ -637,12 +668,12 @@ char *iperf_reporter_callback(struct iperf_test *test)
sp = sp->next; sp = sp->next;
} }
sp = test->streams; char *message_final = (char *) malloc((count+1) * (strlen(report_bw_jitter_loss_header) + strlen(report_bw_jitter_loss_format) + strlen(report_sum_bw_jitter_loss_format)));
char *message_final = (char *) malloc((count+1) * (strlen(report_bw_jitter_loss_header) + strlen(report_bw_jitter_loss_format) + strlen(report_sum_bw_jitter_loss_format)) );
struct iperf_interval_results *ip = test->streams->result->interval_results; struct iperf_interval_results *ip = test->streams->result->interval_results;
sp = test->streams;
if(test->default_settings->state == TEST_RUNNING) if(test->default_settings->state == TEST_RUNNING)
{ {
while(sp) while(sp)
@ -761,7 +792,7 @@ char *iperf_reporter_callback(struct iperf_test *test)
// -m option // -m option
if((test->print_mss != 0) && (test->role == 'c')) if((test->print_mss != 0) && (test->role == 'c'))
{ {
sprintf(message,"the TCP maximum segment size mss = %d \n", getsock_tcp_mss(sp->socket)); sprintf(message,"\nThe TCP maximum segment size mss = %d \n", getsock_tcp_mss(sp->socket));
strcat(message_final, message); strcat(message_final, message);
} }
@ -891,6 +922,9 @@ int iperf_udp_accept(struct iperf_test *test)
sp = test->new_stream(test); sp = test->new_stream(test);
sp->socket = test->listener_sock_udp; sp->socket = test->listener_sock_udp;
//setting noblock doesn't report back to client
//setnonblocking( sp->socket);
iperf_init_stream(sp, test); iperf_init_stream(sp, test);
sp->result->bytes_received+= sz; sp->result->bytes_received+= sz;
iperf_add_stream(test, sp); iperf_add_stream(test, sp);
@ -928,6 +962,8 @@ int iperf_tcp_accept(struct iperf_test *test)
else else
{ {
sp = test->new_stream(test); sp = test->new_stream(test);
//setting noblock doesn't report back to client
//setnonblocking(peersock); //setnonblocking(peersock);
FD_SET(peersock, &test->read_set); FD_SET(peersock, &test->read_set);
@ -1355,7 +1391,8 @@ main(int argc, char **argv)
test->default_settings->rate = unit_atof(optarg); test->default_settings->rate = unit_atof(optarg);
break; break;
case 'l': case 'l':
test->default_settings->blksize = atol(optarg); test->default_settings->blksize = unit_atoi(optarg);
printf("%lld is the blksize\n", unit_atoi(optarg));
break; break;
case 'w': case 'w':
test->default_settings->socket_bufsize = unit_atof(optarg); test->default_settings->socket_bufsize = unit_atof(optarg);
@ -1371,6 +1408,7 @@ main(int argc, char **argv)
break; break;
case 'M': case 'M':
test->default_settings->mss = atoi(optarg); test->default_settings->mss = atoi(optarg);
break;
case 'f': case 'f':
test->unit_format = *optarg; test->unit_format = *optarg;
printf("%c is format \n", test->unit_format); printf("%c is format \n", test->unit_format);