#1641515 RTT time displayed

MAINT_6_0
Stephane Bortzmeyer 17 years ago
parent b0e30c76e6
commit 6628af477e

@ -215,6 +215,33 @@ AC_ARG_ENABLE(ttcp,
TTCP=1
fi)
AC_MSG_CHECKING([TCP info from socket])
AC_TRY_COMPILE(
[#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/tcp.h>
],
[int foobar = SOL_TCP;],
[AC_DEFINE(TCP_INFO,,[TCP info from socket])
ac_have_tcp_info="yes"],
ac_have_tcp_info=no)
AC_MSG_RESULT($ac_have_tcp_info)
AC_ARG_ENABLE(tcp_info,
[ --enable-tcp-info TCP info from socket],
[if test "$enableval" = "yes"; then
if test $ac_have_tcp_info = "yes"; then
AC_DEFINE(TCP_INFO,,[TCP info from socket])
TCP_INFO=1
else
AC_MSG_WARN([No TCP info support on this system, request ignored])
fi
fi],
dnl Default: enable it if supported
if test $ac_have_tcp_info = "yes"; then
AC_DEFINE(TCP_INFO,,[TCP info])
TCP_INFO=1
fi)
dnl Type Of Service
AC_MSG_CHECKING([Type Of Service])
AC_TRY_COMPILE(

@ -143,6 +143,10 @@ main(argc, argv)
int priority_requested = 0;
int tos;
int tos_requested = 0;
#ifdef TCP_INFO
struct tcp_info tcpinfo;
socklen_t socket_length = sizeof(tcpinfo);
#endif
char *p;
echoping_options global_options;
@ -617,13 +621,13 @@ main(argc, argv)
strcpy(port_name, "80");
} else
if (strcmp
(port_name, DEFAULT_HTTPS_TCP_PORT)
== 0) {
(port_name,
DEFAULT_HTTPS_TCP_PORT) == 0) {
strcpy(port_name, "443");
} else
if (strcmp
(port_name, DEFAULT_ICP_UDP_PORT)
== 0) {
(port_name,
DEFAULT_ICP_UDP_PORT) == 0) {
strcpy(port_name, "3130");
}
}
@ -947,8 +951,7 @@ main(argc, argv)
if (tcp) {
(void) gettimeofday(&connectedtv,
(struct timezone
*)
NULL);
*) NULL);
temp = connectedtv;
tvsub(&temp, &conntv);
if (verbose) {
@ -1338,6 +1341,17 @@ main(argc, argv)
}
} /* That's all, folks */
alarm(0);
#ifdef TCP_INFO
/* Thanks to Perry Lorier <perry@coders.net> for the tip */
if (tcp && verbose) {
if (getsockopt
(sockfd, SOL_TCP, TCP_INFO, &tcpinfo, &socket_length)
!= -1) {
printf("Estimated TCP RTT: %.04f seconds\n",
tcpinfo.tcpi_rtt / 1000000.0);
}
}
#endif
if (http) {
#ifdef OPENSSL
if (ssl)

@ -24,6 +24,7 @@
#include <sys/types.h>
#include <netdb.h>
#include <sys/socket.h>
#include <netinet/tcp.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdarg.h>

Loading…
Cancel
Save