1/*
2        Copyright (C) 1993-2004 Hewlett-Packard Company
3*/
4
5 /* This file contains the test-specific definitions for netperf's BSD */
6 /* sockets tests */
7
8/* well boys and girls, seems that while AF_INET is "2" and AF_UNSPEC
9   is "0" the world over, AF_INET6 is different values depending on
10   the platform... grrr.  On HP-UX 11i it is "22" and on Linux 2.6 it
11   is "10" sooooo... we have to define our own space for netperf to
12   enable us to pass values around from machine to machine. raj
13   2005-02-08 */
14#define NF_UNSPEC 0
15#define NF_INET   4
16#define NF_INET6  6
17
18struct	tcp_stream_request_struct {
19  int	send_buf_size;
20  int	recv_buf_size;	/* how big does the client want it - the */
21			/* receive socket buffer that is */
22  int	receive_size;   /* how many bytes do we want to receive at one */
23			/* time? */
24  int	recv_alignment; /* what is the alignment of the receive */
25			/* buffer? */
26  int	recv_offset;    /* and at what offset from that alignment? */
27  int	no_delay;       /* do we disable the nagle algorithm for send */
28			/* coalescing? */
29  int	measure_cpu;	/* does the client want server cpu utilization */
30			/* measured? */
31  float	cpu_rate;	/* do we know how fast the cpu is already? */
32  int	test_length;	/* how long is the test?		*/
33  int	so_rcvavoid;    /* do we want the remote to avoid copies on */
34			/* receives? */
35  int	so_sndavoid;    /* do we want the remote to avoid send copies? */
36  int   dirty_count;    /* how many integers in the receive buffer */
37			/* should be made dirty before calling recv? */
38  int   clean_count;    /* how many integers should be read from the */
39			/* recv buffer before calling recv? */
40  int   port;           /* the port to which the recv side should bind
41			   to allow netperf to run through those evil
42			   firewall things */
43  int   ipfamily;       /* the address family of ipaddress */
44};
45
46struct	tcp_stream_response_struct {
47  int	recv_buf_size;	/* how big does the client want it	*/
48  int	receive_size;
49  int	no_delay;
50  int	measure_cpu;	/* does the client want server cpu	*/
51  int	test_length;	/* how long is the test?		*/
52  int	send_buf_size;
53  int	data_port_number;	/* connect to me here	*/
54  float	cpu_rate;		/* could we measure	*/
55  int	so_rcvavoid;	/* could the remote avoid receive copies? */
56  int	so_sndavoid;	/* could the remote avoid send copies? */
57};
58
59struct tcp_stream_results_struct {
60  double         bytes_received;
61  unsigned int	 recv_calls;
62  float	         elapsed_time;	/* how long the test ran */
63  float	         cpu_util;	/* -1 if not measured */
64  float	         serv_dem;	/* -1 if not measured */
65  int            cpu_method;    /* how was cpu util measured? */
66  int            num_cpus;      /* how many CPUs had the remote? */
67};
68
69struct	tcp_maerts_request_struct {
70  int	send_buf_size;
71  int	recv_buf_size;	/* how big does the client want it - the */
72			/* receive socket buffer that is */
73  int	send_size;      /* how many bytes do we want netserver to send
74			   at one time? */
75  int	send_alignment; /* what is the alignment of the send */
76			/* buffer? */
77  int	send_offset;    /* and at what offset from that alignment? */
78  int	no_delay;       /* do we disable the nagle algorithm for send */
79			/* coalescing? */
80  int	measure_cpu;	/* does the client want server cpu utilization */
81			/* measured? */
82  float	cpu_rate;	/* do we know how fast the cpu is already? */
83  int	test_length;	/* how long is the test?		*/
84  int	so_rcvavoid;    /* do we want the remote to avoid copies on */
85			/* receives? */
86  int	so_sndavoid;    /* do we want the remote to avoid send copies? */
87  int   dirty_count;    /* how many integers in the send buffer */
88			/* should be made dirty before calling recv? */
89  int   clean_count;    /* how many integers should be read from the */
90			/* recv buffer before calling recv? */
91  int   port;           /* the port to which the recv side should bind
92			   to allow netperf to run through those evil
93			   firewall things */
94  int   ipfamily;
95};
96
97struct	tcp_maerts_response_struct {
98  int	recv_buf_size;	/* how big does the client want it	*/
99  int	send_size;
100  int	no_delay;
101  int	measure_cpu;	/* does the client want server cpu	*/
102  int	test_length;	/* how long is the test?		*/
103  int	send_buf_size;
104  int	data_port_number;	/* connect to me here	*/
105  float	cpu_rate;		/* could we measure	*/
106  int	so_rcvavoid;	/* could the remote avoid receive copies? */
107  int	so_sndavoid;	/* could the remote avoid send copies? */
108};
109
110struct tcp_maerts_results_struct {
111  double         bytes_sent;
112  unsigned int	 send_calls;
113  float	         elapsed_time;	/* how long the test ran */
114  float	         cpu_util;	/* -1 if not measured */
115  float	         serv_dem;	/* -1 if not measured */
116  int            cpu_method;    /* how was cpu util measured? */
117  int            num_cpus;      /* how many CPUs had the remote? */
118};
119
120struct	tcp_rr_request_struct {
121  int	recv_buf_size;	/* how big does the client want it	*/
122  int	send_buf_size;
123  int	recv_alignment;
124  int	recv_offset;
125  int	send_alignment;
126  int	send_offset;
127  int	request_size;
128  int	response_size;
129  int	no_delay;
130  int	measure_cpu;	/* does the client want server cpu	*/
131  float	cpu_rate;	/* do we know how fast the cpu is?	*/
132  int	test_length;	/* how long is the test?		*/
133  int	so_rcvavoid;    /* do we want the remote to avoid receive */
134			/* copies? */
135  int	so_sndavoid;    /* do we want the remote to avoid send copies? */
136  int   port;           /* the port to which the recv side should bind
137			   to allow netperf to run through those evil
138			   firewall things */
139  int   ipfamily;
140};
141
142struct	tcp_rr_response_struct {
143  int	recv_buf_size;	/* how big does the client want it	*/
144  int	no_delay;
145  int	measure_cpu;	/* does the client want server cpu	*/
146  int	test_length;	/* how long is the test?		*/
147  int	send_buf_size;
148  int	data_port_number;	/* connect to me here	*/
149  float	cpu_rate;		/* could we measure	*/
150  int	so_rcvavoid;	/* could the remote avoid receive copies? */
151  int	so_sndavoid;	/* could the remote avoid send copies? */
152};
153
154struct tcp_rr_results_struct {
155  unsigned int  bytes_received;	/* ignored initially */
156  unsigned int	recv_calls;	/* ignored initially */
157  unsigned int	trans_received;	/* not ignored  */
158  float	        elapsed_time;	/* how long the test ran */
159  float	        cpu_util;	/* -1 if not measured */
160  float	        serv_dem;	/* -1 if not measured */
161  int           cpu_method;    /* how was cpu util measured? */
162  int           num_cpus;      /* how many CPUs had the remote? */
163};
164
165struct	tcp_conn_rr_request_struct {
166  int	recv_buf_size;	/* how big does the client want it	*/
167  int	send_buf_size;
168  int	recv_alignment;
169  int	recv_offset;
170  int	send_alignment;
171  int	send_offset;
172  int	request_size;
173  int	response_size;
174  int	no_delay;
175  int	measure_cpu;	/* does the client want server cpu	*/
176  float	cpu_rate;	/* do we know how fast the cpu is?	*/
177  int	test_length;	/* how long is the test?		*/
178  int	so_rcvavoid;    /* do we want the remote to avoid receive */
179			/* copies? */
180  int	so_sndavoid;    /* do we want the remote to avoid send copies? */
181  int   port;           /* the port to which the recv side should bind
182			   to allow netperf to run through those evil
183			   firewall things */
184  int   ipfamily;
185};
186
187
188struct	tcp_conn_rr_response_struct {
189  int	recv_buf_size;	/* how big does the client want it	*/
190  int	no_delay;
191  int	measure_cpu;	/* does the client want server cpu	*/
192  int	test_length;	/* how long is the test?		*/
193  int	send_buf_size;
194  int	data_port_number;	/* connect to me here	*/
195  float	cpu_rate;		/* could we measure	*/
196  int	so_rcvavoid;	/* could the remote avoid receive copies? */
197  int	so_sndavoid;	/* could the remote avoid send copies? */
198};
199
200struct tcp_conn_rr_results_struct {
201  unsigned int	bytes_received;	/* ignored initially */
202  unsigned int	recv_calls;	/* ignored initially */
203  unsigned int	trans_received;	/* not ignored  */
204  float	        elapsed_time;	/* how long the test ran */
205  float	        cpu_util;	/* -1 if not measured */
206  float	        serv_dem;	/* -1 if not measured */
207  int           cpu_method;    /* how was cpu util measured? */
208  int           num_cpus;      /* how many CPUs had the remote? */
209};
210
211struct	tcp_tran_rr_request_struct {
212  int	recv_buf_size;	/* how big does the client want it	*/
213  int	send_buf_size;
214  int	recv_alignment;
215  int	recv_offset;
216  int	send_alignment;
217  int	send_offset;
218  int	request_size;
219  int	response_size;
220  int	no_delay;
221  int	measure_cpu;	/* does the client want server cpu	*/
222  float	cpu_rate;	/* do we know how fast the cpu is?	*/
223  int	test_length;	/* how long is the test?		*/
224  int	so_rcvavoid;    /* do we want the remote to avoid receive */
225			/* copies? */
226  int	so_sndavoid;    /* do we want the remote to avoid send copies? */
227  int   port;           /* the port to which the recv side should bind
228			   to allow netperf to run through those evil
229			   firewall things */
230  int   ipfamily;
231};
232
233
234struct	tcp_tran_rr_response_struct {
235  int	recv_buf_size;	/* how big does the client want it	*/
236  int	no_delay;
237  int	measure_cpu;	/* does the client want server cpu	*/
238  int	test_length;	/* how long is the test?		*/
239  int	send_buf_size;
240  int	data_port_number;	/* connect to me here	*/
241  float	cpu_rate;		/* could we measure	*/
242  int	so_rcvavoid;	/* could the remote avoid receive copies? */
243  int	so_sndavoid;	/* could the remote avoid send copies? */
244};
245
246struct tcp_tran_rr_results_struct {
247  unsigned int	bytes_received;	/* ignored initially */
248  unsigned int	recv_calls;	/* ignored initially */
249  unsigned int	trans_received;	/* not ignored  */
250  float	        elapsed_time;	/* how long the test ran */
251  float	        cpu_util;	/* -1 if not measured */
252  float	        serv_dem;	/* -1 if not measured */
253  int           cpu_method;    /* how was cpu util measured? */
254  int           num_cpus;      /* how many CPUs had the remote? */
255
256};
257
258struct	udp_stream_request_struct {
259  int	recv_buf_size;
260  int	message_size;
261  int   recv_connected;
262  int	recv_alignment;
263  int	recv_offset;
264  int	checksum_off;
265  int	measure_cpu;
266  float	cpu_rate;
267  int	test_length;
268  int	so_rcvavoid;    /* do we want the remote to avoid receive */
269			/* copies? */
270  int	so_sndavoid;    /* do we want the remote to avoid send copies? */
271  int   port;           /* the port to which the recv side should bind
272			   to allow netperf to run through those evil
273			   firewall things */
274  int   ipfamily;
275
276};
277
278struct	udp_stream_response_struct {
279  int	recv_buf_size;
280  int	send_buf_size;
281  int	measure_cpu;
282  int	test_length;
283  int	data_port_number;
284  float	cpu_rate;
285  int	so_rcvavoid;	/* could the remote avoid receive copies? */
286  int	so_sndavoid;	/* could the remote avoid send copies? */
287};
288
289struct	udp_stream_results_struct {
290  unsigned int	messages_recvd;
291  unsigned int	bytes_received;
292  float	        elapsed_time;
293  float	        cpu_util;
294  int           cpu_method;    /* how was cpu util measured? */
295  int           num_cpus;      /* how many CPUs had the remote? */
296};
297
298
299struct	udp_rr_request_struct {
300  int	recv_buf_size;	/* how big does the client want it	*/
301  int	send_buf_size;
302  int	recv_alignment;
303  int	recv_offset;
304  int	send_alignment;
305  int	send_offset;
306  int	request_size;
307  int	response_size;
308  int	no_delay;
309  int	measure_cpu;	/* does the client want server cpu	*/
310  float	cpu_rate;	/* do we know how fast the cpu is?	*/
311  int	test_length;	/* how long is the test?		*/
312  int	so_rcvavoid;    /* do we want the remote to avoid receive */
313			/* copies? */
314  int	so_sndavoid;    /* do we want the remote to avoid send copies? */
315  int   port;           /* the port to which the recv side should bind
316			   to allow netperf to run through those evil
317			   firewall things */
318  int   ipfamily;
319};
320
321struct	udp_rr_response_struct {
322  int	recv_buf_size;	/* how big does the client want it	*/
323  int	no_delay;
324  int	measure_cpu;	/* does the client want server cpu	*/
325  int	test_length;	/* how long is the test?		*/
326  int	send_buf_size;
327  int	data_port_number;	/* connect to me here	*/
328  float	cpu_rate;		/* could we measure	*/
329  int	so_rcvavoid;	/* could the remote avoid receive copies? */
330  int	so_sndavoid;	/* could the remote avoid send copies? */
331};
332
333struct udp_rr_results_struct {
334  unsigned int	bytes_received;	/* ignored initially */
335  unsigned int	recv_calls;	/* ignored initially */
336  unsigned int	trans_received;	/* not ignored  */
337  float	        elapsed_time;	/* how long the test ran */
338  float	        cpu_util;	/* -1 if not measured */
339  float	        serv_dem;	/* -1 if not measured */
340  int           cpu_method;    /* how was cpu util measured? */
341  int           num_cpus;      /* how many CPUs had the remote? */
342};
343
344struct	tcp_cc_request_struct {
345  int	recv_buf_size;	/* how big does the client want it	*/
346  int	send_buf_size;
347  int	recv_alignment;
348  int	recv_offset;
349  int	send_alignment;
350  int	send_offset;
351  int	request_size;
352  int	response_size;
353  int	no_delay;
354  int	measure_cpu;	/* does the client want server cpu	*/
355  float	cpu_rate;	/* do we know how fast the cpu is?	*/
356  int	test_length;	/* how long is the test?		*/
357  int	so_rcvavoid;    /* do we want the remote to avoid receive */
358			/* copies? */
359  int	so_sndavoid;    /* do we want the remote to avoid send copies? */
360  int   port;           /* the port to which the recv side should bind
361			   to allow netperf to run through those evil
362			   firewall things */
363  int   ipfamily;
364};
365
366
367struct	tcp_cc_response_struct {
368  int	recv_buf_size;	/* how big does the client want it	*/
369  int	no_delay;
370  int	measure_cpu;	/* does the client want server cpu	*/
371  int	test_length;	/* how long is the test?		*/
372  int	send_buf_size;
373  int	data_port_number;	/* connect to me here	*/
374  float	cpu_rate;		/* could we measure	*/
375  int	so_rcvavoid;	/* could the remote avoid receive copies? */
376  int	so_sndavoid;	/* could the remote avoid send copies? */
377};
378
379struct tcp_cc_results_struct {
380  unsigned int	bytes_received;	/* ignored initially */
381  unsigned int	recv_calls;	/* ignored initially */
382  unsigned int	trans_received;	/* not ignored  */
383  float	        elapsed_time;	/* how long the test ran */
384  float	        cpu_util;	/* -1 if not measured */
385  float	        serv_dem;	/* -1 if not measured */
386  int           cpu_method;    /* how was cpu util measured? */
387  int           num_cpus;      /* how many CPUs had the remote? */
388};
389
390extern int   rss_size_req,     /* requested remote socket send buffer size */
391	     rsr_size_req,     /* requested remote socket recv buffer size */
392	     rss_size,         /* remote socket send buffer size       */
393	     rsr_size,         /* remote socket recv buffer size       */
394	     lss_size_req,     /* requested local socket send buffer size */
395	     lsr_size_req,     /* requested local socket recv buffer size */
396	     lss_size,         /* local  socket send buffer size       */
397	     lsr_size,         /* local  socket recv buffer size       */
398	     req_size,         /* request size                         */
399	     rsp_size,         /* response size                        */
400	     send_size,        /* how big are individual sends         */
401	     recv_size,        /* how big are individual receives      */
402	     loc_nodelay,          /* don't/do use NODELAY locally         */
403	     rem_nodelay,          /* don't/do use NODELAY remotely        */
404	     loc_sndavoid,         /* avoid send copies locally            */
405	     loc_rcvavoid,         /* avoid recv copies locally            */
406	     rem_sndavoid,         /* avoid send copies remotely           */
407	     rem_rcvavoid;         /* avoid recv_copies remotely           */
408
409
410extern void scan_sockets_args(int argc, char *argv[]);
411extern struct addrinfo *complete_addrinfo(char *controlhost,
412				   char *data_address,
413				   char *port,
414				   int family,
415				   int type,
416				   int protocol,
417				   int flags);
418extern void complete_addrinfos(struct addrinfo **remote,
419			       struct addrinfo **local,
420			       char remote_host[],
421			       int type,
422			       int protocol,
423			       int flags);
424extern int af_to_nf(int af);
425extern int nf_to_af(int nf);
426extern void print_top_test_header(char test_name[],
427				  struct addrinfo *source,
428				  struct addrinfo *destination);
429extern void set_port_number(struct addrinfo *res,
430			    unsigned short port);
431extern void set_hostname_and_port(char *hostname,
432				  char *portstr,
433				  int family,
434				  int port);
435extern void send_tcp_stream(char remote_host[]);
436extern void send_tcp_maerts(char remote_host[]);
437extern void send_tcp_rr(char remote_host[]);
438extern void send_tcp_conn_rr(char remote_host[]);
439extern void send_tcp_cc(char remote_host[]);
440extern void send_udp_stream(char remote_host[]);
441extern void send_udp_rr(char remote_host[]);
442
443extern void recv_tcp_stream();
444extern void recv_tcp_maerts();
445extern void recv_tcp_rr();
446extern void recv_tcp_conn_rr();
447extern void recv_tcp_cc();
448extern void recv_udp_stream();
449extern void recv_udp_rr();
450
451extern void loc_cpu_rate();
452extern void rem_cpu_rate();
453
454#ifdef HAVE_ICSC_EXS
455extern void send_exs_tcp_stream(char remotehost[]);
456#endif /* HAVE_ICSC_EXS */
457
458#ifdef HAVE_SENDFILE
459extern void sendfile_tcp_stream(char remotehost[]);
460#endif /* HAVE_SENDFILE */
461
462#if !defined(HAVE_STRUCT_SOCKADDR_STORAGE) && !defined(sockaddr_storage)
463#define sockaddr_storage sockaddr_in
464#endif
465
466#ifdef DO_NBRR
467extern void send_tcp_nbrr(char remote_host[]);
468
469extern void recv_tcp_nbrr();
470#endif
471
472