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,
140 vec_len (rx_buffer) - offset, 0 );
148 while (offset < vec_len (rx_buffer));
152 for (i = 0; i <
vec_len (rx_buffer); i++)
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");
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
#define clib_unix_error(format, args...)
static clib_error_t * tx_buffer(void *transport, mc_transport_type_t type, u32 buffer_index)
void test_bytes(echo_server_main_t *esm, int actual_transfer)
#define clib_warning(format, args...)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
#define clib_unix_warning(format, args...)
struct clib_bihash_value offset
template key/value backing page structure
int main(int argc, char *argv[])