Added working TCP_INFO code (only displays retransmits for now)
This commit is contained in:
parent
f970ce8ecd
commit
e170832926
@ -341,7 +341,11 @@ iperf_parse_arguments(struct iperf_test *test, int argc, char **argv)
|
|||||||
test->settings->unit_format = *optarg;
|
test->settings->unit_format = *optarg;
|
||||||
break;
|
break;
|
||||||
case 'T':
|
case 'T':
|
||||||
|
#if !defined(linux) && !defined(__FreeBSD__)
|
||||||
|
warning("TCP_INFO (-T) is not supported on your current platform");
|
||||||
|
#else
|
||||||
test->tcp_info = 1;
|
test->tcp_info = 1;
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
case '6':
|
case '6':
|
||||||
test->settings->domain = AF_INET6;
|
test->settings->domain = AF_INET6;
|
||||||
@ -918,7 +922,7 @@ parse_results(struct iperf_test *test, char *results)
|
|||||||
/*************************************************************/
|
/*************************************************************/
|
||||||
/**
|
/**
|
||||||
* add_to_interval_list -- adds new interval to the interval_list
|
* add_to_interval_list -- adds new interval to the interval_list
|
||||||
*
|
* XXX: Interval lists should use SLIST implementation fro queue
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -1180,7 +1184,7 @@ iperf_stats_callback(struct iperf_test * test)
|
|||||||
temp.interval_duration = timeval_diff(&temp.interval_start_time, &temp.interval_end_time);
|
temp.interval_duration = timeval_diff(&temp.interval_start_time, &temp.interval_end_time);
|
||||||
//temp.interval_duration = timeval_diff(&temp.interval_start_time, &temp.interval_end_time);
|
//temp.interval_duration = timeval_diff(&temp.interval_start_time, &temp.interval_end_time);
|
||||||
if (test->tcp_info)
|
if (test->tcp_info)
|
||||||
get_tcpinfo(test, &temp);
|
get_tcpinfo(sp, &temp);
|
||||||
add_to_interval_list(rp, &temp);
|
add_to_interval_list(rp, &temp);
|
||||||
rp->bytes_sent_this_interval = rp->bytes_received_this_interval = 0;
|
rp->bytes_sent_this_interval = rp->bytes_received_this_interval = 0;
|
||||||
|
|
||||||
@ -1231,12 +1235,10 @@ iperf_reporter_callback(struct iperf_test * test)
|
|||||||
start_time = timeval_diff(&sp->result->start_time,&ip->interval_start_time);
|
start_time = timeval_diff(&sp->result->start_time,&ip->interval_start_time);
|
||||||
end_time = timeval_diff(&sp->result->start_time,&ip->interval_end_time);
|
end_time = timeval_diff(&sp->result->start_time,&ip->interval_end_time);
|
||||||
printf(report_sum_bw_format, start_time, end_time, ubuf, nbuf);
|
printf(report_sum_bw_format, start_time, end_time, ubuf, nbuf);
|
||||||
|
|
||||||
#if defined(linux) || defined(__FreeBSD__) /* is it usful to figure out a way so sum * TCP_info acrross multiple streams? */
|
|
||||||
if (test->tcp_info)
|
|
||||||
print_tcpinfo(ip);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
if (test->tcp_info)
|
||||||
|
print_tcpinfo(test);
|
||||||
|
// print_tcpinfo(ip);
|
||||||
break;
|
break;
|
||||||
case DISPLAY_RESULTS:
|
case DISPLAY_RESULTS:
|
||||||
/* print final summary for all intervals */
|
/* print final summary for all intervals */
|
||||||
@ -1265,12 +1267,12 @@ iperf_reporter_callback(struct iperf_test * test)
|
|||||||
printf(" Sent\n");
|
printf(" Sent\n");
|
||||||
printf(report_bw_format, sp->socket, start_time, end_time, ubuf, nbuf);
|
printf(report_bw_format, sp->socket, start_time, end_time, ubuf, nbuf);
|
||||||
|
|
||||||
#if defined(linux) || defined(__FreeBSD__)
|
|
||||||
if (test->tcp_info) {
|
if (test->tcp_info) {
|
||||||
ip = sp->result->last_interval_results;
|
// ip = sp->result->last_interval_results;
|
||||||
print_tcpinfo(ip);
|
// print_tcpinfo(ip);
|
||||||
|
print_tcpinfo(test);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
} else {
|
} else {
|
||||||
printf(report_bw_jitter_loss_format, sp->socket, start_time,
|
printf(report_bw_jitter_loss_format, sp->socket, start_time,
|
||||||
end_time, ubuf, nbuf, sp->jitter * 1000, sp->cnt_error,
|
end_time, ubuf, nbuf, sp->jitter * 1000, sp->cnt_error,
|
||||||
@ -1345,10 +1347,11 @@ print_interval_results(struct iperf_test * test, struct iperf_stream * sp)
|
|||||||
|
|
||||||
printf(report_bw_format, sp->socket, st, et, ubuf, nbuf);
|
printf(report_bw_format, sp->socket, st, et, ubuf, nbuf);
|
||||||
|
|
||||||
#if defined(linux) || defined(__FreeBSD__)
|
/* doing aggregate TCP_INFO reporting for now...
|
||||||
if (test->tcp_info)
|
if (test->tcp_info)
|
||||||
print_tcpinfo(ir);
|
print_tcpinfo(ir);
|
||||||
#endif
|
*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
|
@ -89,8 +89,8 @@ int iperf_init_stream(struct iperf_stream *, struct iperf_test *);
|
|||||||
*/
|
*/
|
||||||
void iperf_free_stream(struct iperf_stream * sp);
|
void iperf_free_stream(struct iperf_stream * sp);
|
||||||
|
|
||||||
void get_tcpinfo(struct iperf_test *test, struct iperf_interval_results *rp);
|
void get_tcpinfo(struct iperf_stream *, struct iperf_interval_results *);
|
||||||
void print_tcpinfo(struct iperf_interval_results *);
|
void print_tcpinfo(struct iperf_test *);
|
||||||
void build_tcpinfo_message(struct iperf_interval_results *r, char *message);
|
void build_tcpinfo_message(struct iperf_interval_results *r, char *message);
|
||||||
|
|
||||||
void print_interval_results(struct iperf_test * test, struct iperf_stream *sp);
|
void print_interval_results(struct iperf_test * test, struct iperf_stream *sp);
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
* Brian Tierney, ESnet (bltierney@es.net)
|
* Brian Tierney, ESnet (bltierney@es.net)
|
||||||
*
|
*
|
||||||
* Note that this is only really useful on Linux.
|
* Note that this is only really useful on Linux.
|
||||||
|
* XXX: only standard on linux versions 2.4 and later
|
||||||
#
|
#
|
||||||
* FreeBSD has a limitted implementation that only includes the following:
|
* FreeBSD has a limitted implementation that only includes the following:
|
||||||
* tcpi_snd_ssthresh, tcpi_snd_cwnd, tcpi_rcv_space, tcpi_rtt
|
* tcpi_snd_ssthresh, tcpi_snd_cwnd, tcpi_rcv_space, tcpi_rtt
|
||||||
@ -16,7 +17,6 @@
|
|||||||
* I think MS Windows does support TCP_INFO, but iperf3 does not currently support Windows.
|
* I think MS Windows does support TCP_INFO, but iperf3 does not currently support Windows.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <sys/queue.h>
|
#include <sys/queue.h>
|
||||||
@ -31,39 +31,59 @@
|
|||||||
|
|
||||||
/*************************************************************/
|
/*************************************************************/
|
||||||
void
|
void
|
||||||
get_tcpinfo(struct iperf_test *test, struct iperf_interval_results *rp)
|
get_tcpinfo(struct iperf_stream *sp, struct iperf_interval_results *rp)
|
||||||
{
|
{
|
||||||
#if defined(linux) || defined(__FreeBSD__)
|
#if defined(linux) || defined(__FreeBSD__)
|
||||||
socklen_t tcp_info_length;
|
socklen_t tcp_info_length;
|
||||||
struct iperf_stream *sp = SLIST_FIRST(&test->streams);
|
// struct tcp_info tempinfo;
|
||||||
|
// struct iperf_stream *sp = SLIST_FIRST(&test->streams);
|
||||||
|
|
||||||
tcp_info_length = sizeof(struct tcp_info);
|
tcp_info_length = sizeof(struct tcp_info);
|
||||||
//printf("getting TCP_INFO for socket %d \n", sp->socket);
|
|
||||||
if (getsockopt(sp->socket, IPPROTO_TCP, TCP_INFO, (void *)&rp->tcpInfo, &tcp_info_length) < 0) {
|
if (getsockopt(sp->socket, IPPROTO_TCP, TCP_INFO, (void *)&rp->tcpInfo, &tcp_info_length) < 0) {
|
||||||
perror("getsockopt");
|
perror("getsockopt");
|
||||||
}
|
}
|
||||||
/* 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);
|
for (sp = SLIST_NEXT(sp, streams); sp != SLIST_END(&test->streams);
|
||||||
return;
|
sp = SLIST_NEXT(sp, streams)) {
|
||||||
#else
|
tcp_info_length = sizeof(struct tcp_info);
|
||||||
return;
|
if (getsockopt(sp->socket, IPPROTO_TCP, TCP_INFO, (void *) &tempinfo, &tcp_info_length) < 0) {
|
||||||
|
perror("getsockopt");
|
||||||
|
}
|
||||||
|
rp->tcpInfo.tcpi_retransmits += tempinfo.tcpi_retransmits;
|
||||||
|
}
|
||||||
|
*/
|
||||||
#endif
|
#endif
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*************************************************************/
|
/*************************************************************/
|
||||||
|
//print_tcpinfo(struct iperf_interval_results *r)
|
||||||
void
|
void
|
||||||
print_tcpinfo(struct iperf_interval_results *r)
|
print_tcpinfo(struct iperf_test *test)
|
||||||
{
|
{
|
||||||
|
long int retransmits = 0;
|
||||||
|
struct iperf_stream *sp;
|
||||||
#if defined(linux)
|
#if defined(linux)
|
||||||
|
SLIST_FOREACH(sp, &test->streams, streams) {
|
||||||
|
retransmits += sp->result->last_interval_results.tcpInfo.tcpi_retransmits;
|
||||||
|
}
|
||||||
|
printf("TCP Info\n");
|
||||||
|
printf(" Retransmits: %ld\n", retransmits);
|
||||||
|
|
||||||
|
/* old test print_tcpinfo code
|
||||||
printf(report_tcpInfo, r->tcpInfo.tcpi_snd_cwnd, r->tcpInfo.tcpi_snd_ssthresh,
|
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_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);
|
r->tcpInfo.tcpi_rtt, r->tcpInfo.tcpi_reordering);
|
||||||
|
*/
|
||||||
#endif
|
#endif
|
||||||
#if defined(__FreeBSD__)
|
#if defined(__FreeBSD__)
|
||||||
|
/*
|
||||||
printf(report_tcpInfo, r->tcpInfo.tcpi_snd_cwnd, r->tcpInfo.tcpi_rcv_space,
|
printf(report_tcpInfo, r->tcpInfo.tcpi_snd_cwnd, r->tcpInfo.tcpi_rcv_space,
|
||||||
r->tcpInfo.tcpi_snd_ssthresh, r->tcpInfo.tcpi_rtt);
|
r->tcpInfo.tcpi_snd_ssthresh, r->tcpInfo.tcpi_rtt);
|
||||||
|
*/
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,6 +102,5 @@ build_tcpinfo_message(struct iperf_interval_results *r, char *message)
|
|||||||
sprintf(message, report_tcpInfo, r->tcpInfo.tcpi_snd_cwnd,
|
sprintf(message, report_tcpInfo, r->tcpInfo.tcpi_snd_cwnd,
|
||||||
r->tcpInfo.tcpi_rcv_space, r->tcpInfo.tcpi_snd_ssthresh, r->tcpInfo.tcpi_rtt);
|
r->tcpInfo.tcpi_rcv_space, r->tcpInfo.tcpi_snd_ssthresh, r->tcpInfo.tcpi_rtt);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user