working on fixing TCP_INFO, in progress
Этот коммит содержится в:
родитель
5ed85b8fa1
Коммит
01a5081d51
@ -15,6 +15,9 @@ iperf: $(OBJS)
|
||||
profile: iperf
|
||||
$(CC) -pg -o iperf-profile $(OBJS)
|
||||
|
||||
dist:
|
||||
tar cvfz iperf3.0-alpha.tar.gz *.c *.h *.txt Makefile AUTHORS
|
||||
|
||||
test: t_timer t_units t_uuid
|
||||
./t_timer
|
||||
./t_units
|
||||
|
@ -3,8 +3,9 @@ This is iperf3, a tool for measuring Internet bandwidth performance.
|
||||
|
||||
iperf3 should work on Linux, FreeBSD, and Mac OSX
|
||||
|
||||
Prerequists:
|
||||
libuuidgen
|
||||
Prerequisites:
|
||||
libuuid: this is not installed by default for Debian/Ubuntu Systems
|
||||
to install: apt-get install uuid-dev
|
||||
|
||||
To build, just type 'make' (or 'gmake' on FreeBSD)
|
||||
|
||||
|
@ -571,6 +571,7 @@ iperf_reporter_callback(struct iperf_test * test)
|
||||
if (test->tcp_info)
|
||||
{
|
||||
printf("Final TCP_INFO results: \n");
|
||||
ip = sp->result->last_interval_results;
|
||||
build_tcpinfo_message(ip, message);
|
||||
safe_strcat(message_final, message);
|
||||
}
|
||||
@ -578,7 +579,8 @@ iperf_reporter_callback(struct iperf_test * test)
|
||||
} else
|
||||
{ /* UDP mode */
|
||||
sprintf(message, report_bw_jitter_loss_format, sp->socket, start_time,
|
||||
end_time, ubuf, nbuf, sp->jitter * 1000, sp->cnt_error, sp->packet_count, (double) (100.0 * sp->cnt_error / sp->packet_count));
|
||||
end_time, ubuf, nbuf, sp->jitter * 1000, sp->cnt_error,
|
||||
sp->packet_count, (double) (100.0 * sp->cnt_error / sp->packet_count));
|
||||
safe_strcat(message_final, message);
|
||||
|
||||
if (test->role == 'c')
|
||||
|
19
src/locale.c
19
src/locale.c
@ -68,26 +68,27 @@ Usage: iperf [-s|-c host] [options]\n\
|
||||
iperf [-h|--help] [-v|--version]\n\
|
||||
\n\
|
||||
Client/Server:\n\
|
||||
-f, --format [kmKM] format to report: Kbits, Mbits, KBytes, MBytes\n\
|
||||
-f, --format [kmgKMG] format to report: Kbits, Mbits, KBytes, MBytes\n\
|
||||
-i, --interval # seconds between periodic bandwidth reports\n\
|
||||
-l, --len #[KM] length of buffer to read or write (default 8 KB)\n\
|
||||
-l, --len #[KMG] length of buffer to read or write (default 8 KB)\n\
|
||||
-m, --print_mss print TCP maximum segment size (MTU - TCP/IP header)\n\
|
||||
-p, --port # server port to listen on/connect to\n\
|
||||
-u, --udp use UDP rather than TCP\n\
|
||||
-w, --window #[KM] TCP window size (socket buffer size)\n\
|
||||
-w, --window #[KMG] TCP window size (socket buffer size)\n\
|
||||
-M, --mss # set TCP maximum segment size (MTU - 40 bytes)\n\
|
||||
-N, --nodelay set TCP no delay, disabling Nagle's Algorithm\n\
|
||||
-T, --tcpinfo Output detailed TCP info\n\
|
||||
-v, --version print version information and quit\n\
|
||||
-V, --verbose more verbose output \n\
|
||||
-d, --debug debug mode \n\
|
||||
Server specific:\n\
|
||||
-s, --server run in server mode\n\
|
||||
-U, --single_udp run in single threaded UDP mode\n\
|
||||
-D, --daemon run the server as a daemon\n"
|
||||
-s, --server run in server mode"
|
||||
;
|
||||
|
||||
#ifdef NOT_YET_SUPPORTED /* still working on these */
|
||||
-S, --tos N set IP 'Type of Service' bit \n\
|
||||
-Z, --linux-congestion <algo> set TCP congestion control algorithm (Linux only)\n\
|
||||
-D, --daemon run the server as a daemon\n"
|
||||
-6, --IPv6Version Set the domain to IPv6\n\
|
||||
|
||||
#endif
|
||||
@ -105,10 +106,10 @@ Server specific:\n\
|
||||
const char usage_long2[] = "\
|
||||
\n\
|
||||
Client specific:\n\
|
||||
-b, --bandwidth #[KM] for UDP, bandwidth to send at in bits/sec\n\
|
||||
-b, --bandwidth #[KMG] for UDP, bandwidth to send at in bits/sec\n\
|
||||
(default 1 Mbit/sec, implies -u)\n\
|
||||
-c, --client <host> run in client mode, connecting to <host>\n\
|
||||
-n, --num #[KM] number of bytes to transmit (instead of -t)\n\
|
||||
-n, --num #[KMG] number of bytes to transmit (instead of -t)\n\
|
||||
-t, --time # time in seconds to transmit for (default 10 secs)\n\
|
||||
-P, --parallel # number of parallel client threads to run\n\
|
||||
-T, --tcpinfo Output detailed TCP info (Linux and FreeBSD only)\n\
|
||||
@ -116,7 +117,7 @@ Client specific:\n\
|
||||
Miscellaneous:\n\
|
||||
-h, --help print this message and quit\n\
|
||||
\n\
|
||||
[KM] Indicates options that support a K or M suffix for kilo- or mega-\n\
|
||||
[KMG] Indicates options that support a K,M, or G suffix for kilo-, mega-, or giga- \n\
|
||||
\n\
|
||||
Report bugs to <iperf-users@lists.sourceforge.net>\n";
|
||||
|
||||
|
12
src/main.c
12
src/main.c
@ -50,6 +50,8 @@ static struct option longopts[] =
|
||||
{"Print-mss", no_argument, NULL, 'm'},
|
||||
{"Set-mss", required_argument, NULL, 'M'},
|
||||
{"version", no_argument, NULL, 'v'},
|
||||
{"verbose", no_argument, NULL, 'V'},
|
||||
{"debug", no_argument, NULL, 'd'},
|
||||
{"help", no_argument, NULL, 'h'},
|
||||
#ifdef ADD_WHEN_SUPPORTED
|
||||
{"tos", required_argument, NULL, 'S'},
|
||||
@ -104,7 +106,7 @@ main(int argc, char **argv)
|
||||
test = iperf_new_test();
|
||||
iperf_defaults(test); /* sets defaults */
|
||||
|
||||
while ((ch = getopt_long(argc, argv, "c:p:st:uP:b:l:w:i:n:mNTvhM:f:", longopts, NULL)) != -1)
|
||||
while ((ch = getopt_long(argc, argv, "c:p:st:uP:b:l:w:i:n:mNTvhVdM:f:", longopts, NULL)) != -1)
|
||||
{
|
||||
switch (ch)
|
||||
{
|
||||
@ -126,7 +128,7 @@ main(int argc, char **argv)
|
||||
test->duration = atoi(optarg);
|
||||
if (test->duration > MAX_TIME)
|
||||
{
|
||||
fprintf(stderr, "\n Error: test duration too long. Maximum value = %d \n\n", MAX_TIME);
|
||||
fprintf(stderr, "\n Error: test duration too long. Maximum value = %d \n\n", (int)MAX_TIME);
|
||||
fprintf(stderr, usage_long1);
|
||||
fprintf(stderr, usage_long2);
|
||||
exit(1);
|
||||
@ -209,6 +211,12 @@ main(int argc, char **argv)
|
||||
case 'T':
|
||||
test->tcp_info = 1;
|
||||
break;
|
||||
case 'V':
|
||||
test->verbose = 1;
|
||||
break;
|
||||
case 'd':
|
||||
test->debug = 1;
|
||||
break;
|
||||
case 'v': // print version and exit
|
||||
fprintf( stderr, version );
|
||||
exit(1);
|
||||
|
@ -256,7 +256,7 @@ set_tcp_options(int sock, int no_delay, int mss)
|
||||
int
|
||||
setnonblocking(int sock)
|
||||
{
|
||||
int opts;
|
||||
int opts = 0;
|
||||
|
||||
opts = (opts | O_NONBLOCK);
|
||||
if (fcntl(sock, F_SETFL, opts) < 0)
|
||||
|
@ -34,20 +34,16 @@ get_tcpinfo(struct iperf_test *test, struct iperf_interval_results *rp)
|
||||
{
|
||||
#if defined(linux) || defined(__FreeBSD__)
|
||||
socklen_t tcp_info_length;
|
||||
struct tcp_info tcpInfo;
|
||||
struct iperf_stream *sp = test->streams;
|
||||
|
||||
tcp_info_length = sizeof(tcpInfo);
|
||||
memset((char *)&tcpInfo, 0, tcp_info_length);
|
||||
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 *)&tcpInfo, &tcp_info_length) < 0) {
|
||||
if (getsockopt(sp->socket, IPPROTO_TCP, TCP_INFO, (void *)&rp->tcpInfo, &tcp_info_length) < 0) {
|
||||
perror("getsockopt");
|
||||
}
|
||||
memcpy(&(rp->tcpInfo), &tcpInfo, sizeof(tcpInfo));
|
||||
/* for debugging
|
||||
/* 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);
|
||||
*/
|
||||
return;
|
||||
#else
|
||||
return;
|
||||
@ -75,6 +71,7 @@ print_tcpinfo(struct iperf_interval_results *r)
|
||||
void
|
||||
build_tcpinfo_message(struct iperf_interval_results *r, char *message)
|
||||
{
|
||||
printf("in build_tcpinfo_message \n");
|
||||
#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,
|
||||
@ -87,3 +84,4 @@ build_tcpinfo_message(struct iperf_interval_results *r, char *message)
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user