some fixes/cleanup for Linux

This commit is contained in:
Brian Tierney 2009-11-13 19:20:52 +00:00
parent 7d8b10f945
commit 70866d6dc0
5 changed files with 32 additions and 19 deletions

View File

@ -4,7 +4,8 @@ LDFLAGS=
UNAME=$(shell uname)
ifeq ($(UNAME), Linux)
LDFLAGS=$(LDFLAGS) -luuid
LDFLAGS= -luuid
#LDFLAGS=$(LDFLAGS) -luuid
endif
all: iperf

View File

@ -32,7 +32,8 @@ struct iperf_stream_result
iperf_size_t bytes_sent;
struct timeval start_time;
struct timeval end_time;
struct iperf_interval_results *interval_results;
struct iperf_interval_results *interval_results; /* head of list */
struct iperf_interval_results *last_interval_results; /* end of list */
void *data;
};
@ -185,8 +186,9 @@ enum
/* constants for command line arg sanity checks
*/
#define MAX_TCP_BUFFER 128 * 1024 * 1024
#define MAX_BLOCKSIZE 1024 * 1024
#define MB 1024 * 1024
#define MAX_TCP_BUFFER 128 * MB
#define MAX_BLOCKSIZE MB
#define MAX_INTERVAL 60
#define MAX_TIME 3600
#define MAX_MSS 9 * 1024

View File

@ -187,7 +187,7 @@ display_interval_list(struct iperf_stream_result * rp, int tflag)
while (n)
{
printf("Interval = %f\tBytes transferred = %llu\n", n->interval_duration, n->bytes_transferred);
printf("Interval = %f\tMBytes transferred = %u\n", n->interval_duration, (uint) (n->bytes_transferred / MB));
if (tflag)
print_tcpinfo(n);
n = n->next;
@ -280,9 +280,9 @@ Display(struct iperf_test * test)
if (n)
{
if (test->role == 'c')
printf("position-%d\tsp=%d\tsocket=%d\tbytes sent=%llu\n", count++, (int) n, n->socket, n->result->bytes_sent);
printf("position-%d\tsp=%d\tsocket=%d\tMbytes sent=%u\n", count++, (int) n, n->socket, (uint) (n->result->bytes_sent / MB));
else
printf("position-%d\tsp=%d\tsocket=%d\tbytes received=%llu\n", count++, (int) n, n->socket, n->result->bytes_received);
printf("position-%d\tsp=%d\tsocket=%d\tMbytes received=%u\n", count++, (int) n, n->socket, (uint) (n->result->bytes_received / MB));
if (n->next == NULL)
{
@ -485,6 +485,8 @@ iperf_stats_callback(struct iperf_test * test)
temp.interval_duration = timeval_diff(&sp->result->start_time, &temp.interval_time);
gettimeofday(&sp->result->end_time, NULL);
if (test->tcp_info)
get_tcpinfo(test, &temp);
add_to_interval_list(rp, &temp);
} else
{
@ -507,10 +509,10 @@ iperf_stats_callback(struct iperf_test * test)
temp.interval_duration = timeval_diff(&sp->result->start_time, &temp.interval_time);
gettimeofday(&sp->result->end_time, NULL);
if (test->tcp_info)
get_tcpinfo(test, &temp);
add_to_interval_list(rp, &temp);
}
if (test->tcp_info)
get_tcpinfo(test, &temp);
/* for debugging */
/* display_interval_list(rp, test->tcp_info); */
@ -577,7 +579,6 @@ iperf_reporter_callback(struct iperf_test * test)
test->default_settings->unit_format);
sprintf(message, report_bw_format, sp->socket, ip_prev->interval_duration, ip->interval_duration, ubuf, nbuf);
} else
{
if (first_stream) /* only print header for 1st stream */
@ -623,11 +624,14 @@ iperf_reporter_callback(struct iperf_test * test)
sprintf(message, report_sum_bw_format, 0.0, ip->interval_duration, ubuf, nbuf);
}
safe_strcat(message_final, message);
#ifdef NOT_DONE /* is it usful to figure out a way so sum TCP_info acrross multiple streams? */
if (test->tcp_info)
{
build_tcpinfo_message(ip, message);
safe_strcat(message_final, message);
}
#endif
}
} else
{
@ -666,6 +670,12 @@ iperf_reporter_callback(struct iperf_test * test)
{
sprintf(message, report_bw_format, sp->socket, start_time, end_time, ubuf, nbuf);
safe_strcat(message_final, message);
if (test->tcp_info)
{
printf("Final TCP_INFO results: \n");
build_tcpinfo_message(ip, message);
safe_strcat(message_final, message);
}
} else
{ /* UDP mode */
sprintf(message, report_bw_jitter_loss_format, sp->socket, start_time,
@ -680,9 +690,7 @@ iperf_reporter_callback(struct iperf_test * test)
if (sp->outoforder_packets > 0)
printf(report_sum_outoforder, start_time, end_time, sp->cnt_error);
}
/*
* XXX: we need to do something with any TCP_INFO results here
*/
sp = sp->next;
}
} /* while (sp) */

View File

@ -231,7 +231,7 @@ const char reportCSV_peer[] =
#if defined(linux)
const char report_tcpInfo[] =
"event=TCP_Info CWND=%u RCV_WIND=%u SND_SSTHRESH=%u UNACKED=%u SACK=%u LOST=%u RETRANS=%u FACK=%u RTT=%u REORDERING=%u";
"event=TCP_Info CWND=%u SND_SSTHRESH=%u RCV_SSTHRESH=%u UNACKED=%u SACK=%u LOST=%u RETRANS=%u FACK=%u RTT=%u REORDERING=%u";
#endif
#if defined(__FreeBSD__)
const char report_tcpInfo[] =

View File

@ -43,7 +43,7 @@ get_tcpinfo(struct iperf_test *test, struct iperf_interval_results *rp)
if (getsockopt(sp->socket, IPPROTO_TCP, TCP_INFO, (void *)&tcpInfo, &tcp_info_length) < 0) {
perror("getsockopt");
}
memcpy(&rp->tcpInfo, &tcpInfo, sizeof(tcpInfo));
memcpy(&(rp->tcpInfo), &tcpInfo, sizeof(tcpInfo));
/* for debugging
printf(" got TCP_INFO: %d, %d, %d, %d\n", rp->tcpInfo.tcpi_snd_cwnd,
rp->tcpInfo.tcpi_snd_ssthresh, rp->tcpInfo.tcpi_rcv_space, rp->tcpInfo.tcpi_rtt);
@ -60,8 +60,9 @@ print_tcpinfo(struct iperf_interval_results *r)
{
#if defined(linux)
printf(report_tcpInfo, r->tcpInfo.tcpi_snd_cwnd, r->tcpInfo.tcpi_snd_ssthresh,
r->tcpInfo.tcpi_rcv_ssthresh, r->tcpInfo.tcpi_unacked, r->tcpInfo.tcpi_sacked,
r->tcpInfo.tcpi_lost, r->tcpInfo.tcpi_retrans, r->tcpInfo.tcpi_fackets, tcpi_reordering);
r->tcpInfo.tcpi_rcv_ssthresh, r->tcpInfo.tcpi_unacked, r->tcpInfo.tcpi_sacked,
r->tcpInfo.tcpi_lost, r->tcpInfo.tcpi_retrans, r->tcpInfo.tcpi_fackets,
r->tcpInfo.tcpi_rtt, r->tcpInfo.tcpi_reordering);
#endif
#if defined(__FreeBSD__)
printf(report_tcpInfo, r->tcpInfo.tcpi_snd_cwnd, r->tcpInfo.tcpi_rcv_space,
@ -77,11 +78,12 @@ build_tcpinfo_message(struct iperf_interval_results *r, char *message)
#if defined(linux)
sprintf(message, report_tcpInfo, r->tcpInfo.tcpi_snd_cwnd, r->tcpInfo.tcpi_snd_ssthresh,
r->tcpInfo.tcpi_rcv_ssthresh, r->tcpInfo.tcpi_unacked, r->tcpInfo.tcpi_sacked,
r->tcpInfo.tcpi_lost, r->tcpInfo.tcpi_retrans, r->tcpInfo.tcpi_fackets);
r->tcpInfo.tcpi_lost, r->tcpInfo.tcpi_retrans, r->tcpInfo.tcpi_fackets,
r->tcpInfo.tcpi_rtt, r->tcpInfo.tcpi_reordering);
#endif
#if defined(__FreeBSD__)
sprintf(message, report_tcpInfo, r->tcpInfo.tcpi_snd_cwnd,
r->tcpInfo.tcpi_snd_ssthresh, r->tcpInfo.tcpi_rcv_space, r->tcpInfo.tcpi_rtt);
r->tcpInfo.tcpi_rcv_space, r->tcpInfo.tcpi_snd_ssthresh, r->tcpInfo.tcpi_rtt);
#endif
}