17 #include <sys/types.h>
18 #include <sys/socket.h>
19 #include <netinet/in.h>
25 main (
int argc,
char *argv[])
27 int sockfd, portno, n;
28 struct sockaddr_in serv_addr;
29 struct hostent *server;
32 long bytes = 1 << 20, to_send;
34 struct timeval start,
end;
39 portno = atoi (argv[2]);
40 server = gethostbyname (argv[1]);
52 bytes = ((long) atoi (argv[0])) << 20;
58 no_echo = atoi (argv[0]);
72 server = gethostbyname (
"6.0.1.1" );
81 sockfd = socket (AF_INET, SOCK_STREAM, 0);
88 bzero ((
char *) &serv_addr,
sizeof (serv_addr));
89 serv_addr.sin_family = AF_INET;
90 bcopy ((
char *) server->h_addr,
91 (
char *) &serv_addr.sin_addr.s_addr, server->h_length);
92 serv_addr.sin_port = htons (portno);
93 if (connect (sockfd, (
const void *) &serv_addr,
sizeof (serv_addr)) < 0)
115 gettimeofday (&start, NULL);
139 n = recv (sockfd, rx_buffer +
offset,
164 gettimeofday (&
end, NULL);
166 deltat = (
end.tv_sec - start.tv_sec);
167 deltat += (
end.tv_usec - start.tv_usec) / 1000000.0;
169 clib_warning (
"%.4f Gbit/second %s", (((
f64) to_send * 8.0) / deltat / 1e9),
170 no_echo ?
"half" :
"full");