omitted STREAM_BEGIN message from bytes calculation

This commit is contained in:
kaustubhprabhu 2009-07-13 18:44:18 +00:00
parent 48b0f1a334
commit fea54f51f7

View File

@ -93,7 +93,7 @@ void display_interval_list(struct iperf_stream_result *rp)
while(n) while(n)
{ {
printf("Interval = %d\tBytes transferred = %llu\n", n->interval_duration, n->bytes_transferred); printf("Interval = %f\tBytes transferred = %llu\n", n->interval_duration, n->bytes_transferred);
n = n->next; n = n->next;
} }
} }
@ -324,7 +324,7 @@ int iperf_udp_recv(struct iperf_stream *sp)
message = udp->state; message = udp->state;
} }
if(message != STREAM_END && (sp->stream_id == udp->stream_id)) if(message != STREAM_END && message != STREAM_BEGIN && (sp->stream_id == udp->stream_id))
{ {
sp->result->bytes_received+= result; sp->result->bytes_received+= result;
sp->packet_count++; sp->packet_count++;
@ -457,10 +457,10 @@ int iperf_udp_send(struct iperf_stream *sp)
case STREAM_BEGIN: case STREAM_BEGIN:
udp->state = STREAM_BEGIN; udp->state = STREAM_BEGIN;
udp->stream_id = (int)sp; udp->stream_id = (int)sp;
udp->packet_count = ++sp->packet_count; //udp->packet_count = ++sp->packet_count;
break; break;
case STREAM_END: case STREAM_END:
udp->state = STREAM_END; udp->state = STREAM_END;
udp->stream_id = (int) sp; udp->stream_id = (int) sp;
break; break;
@ -477,7 +477,7 @@ int iperf_udp_send(struct iperf_stream *sp)
default: default:
udp->state = 0; udp->state = 0;
udp->stream_id = (int)sp; udp->stream_id = (int)sp;
udp->packet_count = ++sp->packet_count; udp->packet_count = ++sp->packet_count;
break; break;
} }
@ -487,22 +487,18 @@ int iperf_udp_send(struct iperf_stream *sp)
sp->settings->state = STREAM_RUNNING; sp->settings->state = STREAM_RUNNING;
} }
if(gettimeofday(&before, 0) < 0) if(gettimeofday(&before, 0) < 0)
perror("gettimeofday"); perror("gettimeofday");
// TEST: lost packet // TEST: lost packet
//if(udp->packet_count == 4 || udp->packet_count == 5 || udp->packet_count == 6) ; //if(udp->packet_count == 4 || udp->packet_count == 5 || udp->packet_count == 6) ;
//else //else
result = send(sp->socket, buf, size, 0); result = send(sp->socket, buf, size, 0);
if(sp->settings->state != STREAM_END && sp->settings->state != RESULT_REQUEST) if(sp->settings->state == STREAM_RUNNING)
// printf("outgoing packet = %d AND SP = %d\n",sp->packet_count, sp->socket); //printf("State = %d Outgoing packet = %d AND SP = %d\n",sp->settings->state, sp->packet_count, sp->socket);
if(sp->settings->state != STREAM_END && sp->settings->state != RESULT_REQUEST) if(sp->settings->state == STREAM_RUNNING)
sp->result->bytes_sent+= result; sp->result->bytes_sent+= result;
if(gettimeofday(&after, 0) < 0) if(gettimeofday(&after, 0) < 0)
@ -663,7 +659,8 @@ void *iperf_stats_callback(struct iperf_test *test)
rp = sp->result; rp = sp->result;
if(!rp->interval_results) if(!rp->interval_results)
{ {
printf("1st time sp is %d \n", (int)sp);
if(test ->role == 'c') if(test ->role == 'c')
temp.bytes_transferred = rp->bytes_sent; temp.bytes_transferred = rp->bytes_sent;
else else
@ -679,6 +676,8 @@ void *iperf_stats_callback(struct iperf_test *test)
else else
{ {
printf("sp is %d \n", (int)sp);
ip = sp->result->interval_results; ip = sp->result->interval_results;
while(1) while(1)
{ {
@ -738,8 +737,7 @@ char *iperf_reporter_callback(struct iperf_test *test)
if(test->default_settings->state == TEST_RUNNING) if(test->default_settings->state == TEST_RUNNING)
{ {
while(sp) while(sp)
{ {
while(ip->next!= NULL) while(ip->next!= NULL)
{ {
ip_prev = ip; ip_prev = ip;
@ -749,31 +747,39 @@ char *iperf_reporter_callback(struct iperf_test *test)
bytes+= ip->bytes_transferred; bytes+= ip->bytes_transferred;
unit_snprintf(ubuf, UNIT_LEN, (double) (ip->bytes_transferred), test->unit_format); unit_snprintf(ubuf, UNIT_LEN, (double) (ip->bytes_transferred), test->unit_format);
test->stats_interval = test->stats_interval== 0 ? test->duration : test->stats_interval; test->stats_interval = test->stats_interval== 0 ? test->duration : test->stats_interval;
unit_snprintf(nbuf, UNIT_LEN, (double) (ip->bytes_transferred / test->stats_interval), test->unit_format);
sprintf(message,report_bw_header); sprintf(message,report_bw_header);
strcat(message_final, message); strcat(message_final, message);
if(test->streams->result->interval_results->next != NULL) if(test->streams->result->interval_results->next != NULL)
{
unit_snprintf(nbuf, UNIT_LEN, (double) (ip->bytes_transferred / (ip->interval_duration -ip_prev->interval_duration)),
test->unit_format);
sprintf(message, report_bw_format, sp->socket,ip_prev->interval_duration, ip->interval_duration, ubuf, nbuf); sprintf(message, report_bw_format, sp->socket,ip_prev->interval_duration, ip->interval_duration, ubuf, nbuf);
}
else else
{
unit_snprintf(nbuf, UNIT_LEN, (double) (ip->bytes_transferred /ip->interval_duration), test->unit_format);
sprintf(message, report_bw_format, sp->socket, 0.0, ip->interval_duration, ubuf, nbuf); sprintf(message, report_bw_format, sp->socket, 0.0, ip->interval_duration, ubuf, nbuf);
}
strcat(message_final, message);
strcat(message_final, message);
sp = sp->next; sp = sp->next;
} }
unit_snprintf(ubuf, UNIT_LEN, (double) ( bytes), test->unit_format); unit_snprintf(ubuf, UNIT_LEN, (double) ( bytes), test->unit_format);
unit_snprintf(nbuf, UNIT_LEN, (double) ( bytes / test->stats_interval), test->unit_format);
if(test->streams->result->interval_results->next != NULL) if(test->streams->result->interval_results->next != NULL)
{
unit_snprintf(nbuf, UNIT_LEN, (double) (ip->bytes_transferred / (ip->interval_duration -ip_prev->interval_duration)),
test->unit_format);
sprintf(message, report_sum_bw_format, ip_prev->interval_duration, ip->interval_duration, ubuf, nbuf); sprintf(message, report_sum_bw_format, ip_prev->interval_duration, ip->interval_duration, ubuf, nbuf);
}
else else
{
unit_snprintf(nbuf, UNIT_LEN, (double) (ip->bytes_transferred /ip->interval_duration), test->unit_format);
sprintf(message, report_sum_bw_format, 0.0, ip->interval_duration, ubuf, nbuf); sprintf(message, report_sum_bw_format, 0.0, ip->interval_duration, ubuf, nbuf);
}
strcat(message_final, message); strcat(message_final, message);
free(message); free(message);
@ -1015,8 +1021,7 @@ int iperf_udp_accept(struct iperf_test *test)
//setting noblock doesn't report back to client //setting noblock doesn't report back to client
//setnonblocking( sp->socket); //setnonblocking( sp->socket);
iperf_init_stream(sp, test); iperf_init_stream(sp, test);
sp->result->bytes_received+= sz;
iperf_add_stream(test, sp); iperf_add_stream(test, sp);
@ -1031,15 +1036,16 @@ int iperf_udp_accept(struct iperf_test *test)
connect_msg(sp); connect_msg(sp);
printf("1st UDP data packet for socket %d has arrived \n", sp->socket); printf("1st UDP data packet for socket %d has arrived \n", sp->socket);
sp->stream_id = udp->stream_id; sp->stream_id = udp->stream_id;
sp->result->bytes_received+= sz;
//OUT OF ORDER PACKETS //OUT OF ORDER PACKETS
if(udp->packet_count != sp->packet_count + 1) if(udp->packet_count != 0)
{ {
if( udp->packet_count < sp->packet_count + 1) if( udp->packet_count < sp->packet_count + 1)
sp->outoforder_packets++; sp->outoforder_packets++;
else else
sp->cnt_error += udp->packet_count - sp->packet_count - 1; sp->cnt_error += udp->packet_count - sp->packet_count;
} }
// store the latest packet id // store the latest packet id