2 * Copyright (c) 2000 - 2001 Kungliga Tekniska Högskolan
3 * (Royal Institute of Technology, Stockholm, Sweden).
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution
16 * at such time that OpenAFS documentation is written.
18 * 3. Neither the name of the Institute nor the names of its contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 #include <afsconfig.h>
38 nn * We are using getopt since we want it to be possible to link to
42 #include <afsconfig.h>
43 #include <afs/param.h>
46 #ifdef HAVE_SYS_FILE_H
53 #include <rx/rx_null.h>
54 #include <rx/rx_globals.h>
55 #include <rx/rx_packet.h>
57 #ifdef AFS_PTHREAD_ENV
59 #define MAX_THREADS 128
62 #define DEFAULT_PORT 7009 /* To match tcpdump */
63 #define DEFAULT_HOST "127.0.0.1"
64 #define DEFAULT_BYTES 1024 * 1024
65 #define RXPERF_BUFSIZE 512 * 1024
67 enum { RX_PERF_VERSION
= 3 };
68 enum { RX_SERVER_ID
= 147 };
69 enum { RX_PERF_UNKNOWN
= -1,
76 enum { RXPERF_MAGIC_COOKIE
= 0x4711 };
83 #define DBFPRINT(x) do { printf x ; } while(0)
91 exit(2); /* XXX profiler */
98 exit(2); /* XXX profiler */
105 static struct timeval timer_start
;
106 static struct timeval timer_stop
;
107 static int timer_check
= 0;
113 gettimeofday(&timer_start
, NULL
);
121 end_and_print_timer(char *str
, long long bytes
)
123 long long start_l
, stop_l
;
127 assert(timer_check
== 0);
128 gettimeofday(&timer_stop
, NULL
);
129 start_l
= timer_start
.tv_sec
* 1000000 + timer_start
.tv_usec
;
130 stop_l
= timer_stop
.tv_sec
* 1000000 + timer_stop
.tv_usec
;
131 printf("%s:\t%8llu msec", str
, (stop_l
- start_l
) / 1000);
133 kbps
= bytes
* 8000.0 / (stop_l
- start_l
);
134 if (kbps
> 1000000.0)
135 printf("\t[%.4g Gbit/s]\n", kbps
/1000000.0);
136 else if (kbps
> 1000.0)
137 printf("\t[%.4g Mbit/s]\n", kbps
/1000.0);
139 printf("\t[%.4g kbit/s]\n", kbps
);
147 str2addr(const char *s
)
149 struct in_addr server
;
153 #define INADDR_NONE 0xffffffff
155 if (inet_addr(s
) != INADDR_NONE
)
157 h
= gethostbyname(s
);
159 memcpy(&server
, h
->h_addr_list
[0], sizeof(server
));
160 return server
.s_addr
;
171 get_sec(int serverp
, struct rx_securityClass
**sec
, int *secureindex
)
174 *sec
= rxnull_NewServerSecurityObject();
177 *sec
= rxnull_NewClientSecurityObject();
183 * process the "RPC" and return the results
186 char somebuf
[RXPERF_BUFSIZE
];
188 afs_int32 rxwrite_size
= sizeof(somebuf
);
189 afs_int32 rxread_size
= sizeof(somebuf
);
190 afs_int32 use_rx_readv
= 0;
193 do_readbytes(struct rx_call
*call
, afs_int32 bytes
)
195 struct iovec tiov
[RX_MAXIOVECS
];
206 if (size
> RX_MAX_PACKET_DATA_SIZE
)
207 size
= RX_MAX_PACKET_DATA_SIZE
;
208 code
= rx_Readv(call
, tiov
, &tnio
, RX_MAXIOVECS
, size
);
210 code
= rx_Read(call
, somebuf
, size
);
220 do_sendbytes(struct rx_call
*call
, afs_int32 bytes
)
228 if (rx_Write(call
, somebuf
, size
) != size
)
237 rxperf_ExecuteRequest(struct rx_call
*call
)
246 afs_uint32
*readwrite
;
250 DBFPRINT(("got a request\n"));
252 if (rx_Read32(call
, &version
) != 4) {
253 warn("rx_Read failed to read version");
257 if (htonl(RX_PERF_VERSION
) != version
) {
258 warnx("client has wrong version");
262 if (rx_Read32(call
, &command
) != 4) {
263 warnx("rx_Read failed to read command");
266 command
= ntohl(command
);
268 if (rx_Read32(call
, &data
) != 4) {
269 warnx("rx_Read failed to read size");
272 rxread_size
= ntohl(data
);
273 if (rxread_size
> sizeof(somebuf
)) {
274 warnx("rxread_size too large %d", rxread_size
);
278 if (rx_Read32(call
, &data
) != 4) {
279 warnx("rx_Read failed to write size");
282 rxwrite_size
= ntohl(data
);
283 if (rxwrite_size
> sizeof(somebuf
)) {
284 warnx("rxwrite_size too large %d", rxwrite_size
);
290 DBFPRINT(("got a send request\n"));
292 if (rx_Read32(call
, &bytes
) != 4) {
293 warnx("rx_Read failed to read bytes");
296 bytes
= ntohl(bytes
);
298 DBFPRINT(("reading(%d) ", bytes
));
299 do_readbytes(call
, bytes
);
301 data
= htonl(RXPERF_MAGIC_COOKIE
);
302 if (rx_Write32(call
, &data
) != 4) {
303 warnx("rx_Write failed when sending back result");
306 DBFPRINT(("done\n"));
310 DBFPRINT(("got a rpc request, reading commands\n"));
312 if (rx_Read32(call
, &recvb
) != 4) {
313 warnx("rx_Read failed to read recvbytes");
316 recvb
= ntohl(recvb
);
317 if (rx_Read32(call
, &sendb
) != 4) {
318 warnx("rx_Read failed to read sendbytes");
321 sendb
= ntohl(sendb
);
323 DBFPRINT(("read(%d) ", recvb
));
324 if (do_readbytes(call
, recvb
)) {
325 warnx("do_readbytes failed");
328 DBFPRINT(("send(%d) ", sendb
));
329 if (do_sendbytes(call
, sendb
)) {
330 warnx("sendbytes failed");
334 DBFPRINT(("done\n"));
336 data
= htonl(RXPERF_MAGIC_COOKIE
);
337 if (rx_Write32(call
, &data
) != 4) {
338 warnx("rx_Write failed when sending back magic cookie");
344 if (rx_Read32(call
, &data
) != 4)
345 errx(1, "failed to read num from client");
348 readwrite
= malloc(num
* sizeof(afs_uint32
));
349 if (readwrite
== NULL
)
352 if (rx_Read(call
, (char*)readwrite
, num
* sizeof(afs_uint32
)) !=
353 num
* sizeof(afs_uint32
))
354 errx(1, "failed to read recvlist from client");
356 for (i
= 0; i
< num
; i
++) {
357 if (readwrite
[i
] == 0) {
358 DBFPRINT(("readp %d", readwrite
[i
]));
362 bytes
= ntohl(readwrite
[i
]) * sizeof(afs_uint32
);
365 DBFPRINT(("read\n"));
366 do_readbytes(call
, bytes
);
368 do_sendbytes(call
, bytes
);
369 DBFPRINT(("send\n"));
375 DBFPRINT(("got a recv request\n"));
377 if (rx_Read32(call
, &bytes
) != 4) {
378 warnx("rx_Read failed to read bytes");
381 bytes
= ntohl(bytes
);
383 DBFPRINT(("sending(%d) ", bytes
));
384 do_sendbytes(call
, bytes
);
386 data
= htonl(RXPERF_MAGIC_COOKIE
);
387 if (rx_Write32(call
, &data
) != 4) {
388 warnx("rx_Write failed when sending back result");
391 DBFPRINT(("done\n"));
395 warnx("client sent a unsupported command");
398 DBFPRINT(("done with command\n"));
408 do_server(short port
, int nojumbo
, int maxmtu
, int maxwsize
, int minpeertimeout
,
409 int udpbufsz
, int nostats
, int hotthread
,
410 int minprocs
, int maxprocs
)
412 struct rx_service
*service
;
413 struct rx_securityClass
*secureobj
;
418 if (afs_winsockInit() < 0) {
419 printf("Can't initialize winsock.\n");
425 rx_EnableHotThread();
430 rx_SetUdpBufSize(udpbufsz
);
432 ret
= rx_Init(htons(port
));
434 errx(1, "rx_Init failed");
440 rx_SetMaxMTU(maxmtu
);
443 rx_SetMaxReceiveWindow(maxwsize
);
444 rx_SetMaxSendWindow(maxwsize
);
448 rx_SetMinPeerTimeout(minpeertimeout
);
451 get_sec(1, &secureobj
, &secureindex
);
454 rx_NewService(0, RX_SERVER_ID
, "rxperf", &secureobj
, secureindex
,
455 rxperf_ExecuteRequest
);
457 errx(1, "Cant create server");
459 rx_SetMinProcs(service
, minprocs
);
460 rx_SetMaxProcs(service
, maxprocs
);
462 rx_SetCheckReach(service
, 1);
474 readfile(const char *filename
, afs_uint32
** readwrite
, afs_uint32
* size
)
483 *readwrite
= malloc(sizeof(afs_uint32
) * len
);
484 buf
= malloc(RXPERF_BUFSIZE
);
486 if (*readwrite
== NULL
)
489 f
= fopen(filename
, "r");
493 while (fgets(buf
, sizeof(buf
), f
) != NULL
) {
496 *readwrite
= realloc(*readwrite
, len
* sizeof(afs_uint32
));
497 if (*readwrite
== NULL
)
502 data
= htonl(strtol(buf
, &ptr
, 0));
503 if (ptr
&& ptr
== buf
)
504 errx(1, "can't resolve number of bytes to transfer");
509 (*readwrite
)[num
] = data
;
522 struct rx_connection
*conn
;
532 client_thread( void *vparams
)
534 struct client_data
*params
= (struct client_data
*)vparams
;
535 struct rx_call
*call
;
538 afs_uint32
*readwrite
;
543 for (i
= 0; i
< params
->times
; i
++) {
545 DBFPRINT(("starting command "));
547 call
= rx_NewCall(params
->conn
);
549 errx(1, "rx_NewCall failed");
551 data
= htonl(RX_PERF_VERSION
);
552 if (rx_Write32(call
, &data
) != 4)
553 errx(1, "rx_Write failed to send version (err %d)", rx_Error(call
));
555 data
= htonl(params
->command
);
556 if (rx_Write32(call
, &data
) != 4)
557 errx(1, "rx_Write failed to send command (err %d)", rx_Error(call
));
559 data
= htonl(rxread_size
);
560 if (rx_Write32(call
, &data
) != 4)
561 errx(1, "rx_Write failed to send read size (err %d)", rx_Error(call
));
562 data
= htonl(rxwrite_size
);
563 if (rx_Write32(call
, &data
) != 4)
564 errx(1, "rx_Write failed to send write read (err %d)", rx_Error(call
));
567 switch (params
->command
) {
569 DBFPRINT(("command "));
571 data
= htonl(params
->bytes
);
572 if (rx_Write32(call
, &data
) != 4)
573 errx(1, "rx_Write failed to send size (err %d)", rx_Error(call
));
575 DBFPRINT(("sending(%d) ", params
->bytes
));
576 if (do_readbytes(call
, params
->bytes
))
577 errx(1, "sendbytes (err %d)", rx_Error(call
));
579 if (rx_Read32(call
, &data
) != 4)
580 errx(1, "failed to read result from server (err %d)", rx_Error(call
));
582 if (data
!= htonl(RXPERF_MAGIC_COOKIE
))
583 warn("server send wrong magic cookie in responce");
585 DBFPRINT(("done\n"));
589 DBFPRINT(("command "));
591 data
= htonl(params
->bytes
);
592 if (rx_Write32(call
, &data
) != 4)
593 errx(1, "rx_Write failed to send size (err %d)", rx_Error(call
));
595 DBFPRINT(("sending(%d) ", params
->bytes
));
596 if (do_sendbytes(call
, params
->bytes
))
597 errx(1, "sendbytes (err %d)", rx_Error(call
));
599 if (rx_Read32(call
, &data
) != 4)
600 errx(1, "failed to read result from server (err %d)", rx_Error(call
));
602 if (data
!= htonl(RXPERF_MAGIC_COOKIE
))
603 warn("server send wrong magic cookie in responce");
605 DBFPRINT(("done\n"));
609 DBFPRINT(("commands "));
611 data
= htonl(params
->sendbytes
);
612 if (rx_Write32(call
, &data
) != 4)
613 errx(1, "rx_Write failed to send command (err %d)", rx_Error(call
));
615 data
= htonl(params
->readbytes
);
616 if (rx_Write32(call
, &data
) != 4)
617 errx(1, "rx_Write failed to send command (err %d)", rx_Error(call
));
619 DBFPRINT(("send(%d) ", params
->sendbytes
));
620 if (do_sendbytes(call
, params
->sendbytes
))
621 errx(1, "sendbytes (err %d)", rx_Error(call
));
623 DBFPRINT(("recv(%d) ", params
->readbytes
));
624 if (do_readbytes(call
, params
->readbytes
))
625 errx(1, "sendbytes (err %d)", rx_Error(call
));
627 if (rx_Read32(call
, &data
) != 4)
628 errx(1, "failed to read result from server (err %d)", rx_Error(call
));
630 if (data
!= htonl(RXPERF_MAGIC_COOKIE
))
631 warn("server send wrong magic cookie in responce");
633 DBFPRINT(("done\n"));
638 readfile(params
->filename
, &readwrite
, &num
);
641 if (rx_Write32(call
, &data
) != 4)
642 errx(1, "rx_Write failed to send size (err %d)", rx_Error(call
));
644 if (rx_Write(call
, (char *)readwrite
, num
* sizeof(afs_uint32
))
645 != num
* sizeof(afs_uint32
))
646 errx(1, "rx_Write failed to send list (err %d)", rx_Error(call
));
648 for (j
= 0; j
< num
; j
++) {
649 if (readwrite
[j
] == 0)
652 size
= ntohl(readwrite
[j
]) * sizeof(afs_uint32
);
655 if (do_readbytes(call
, size
))
656 errx(1, "sendbytes (err %d)", rx_Error(call
));
657 DBFPRINT(("read\n"));
659 if (do_sendbytes(call
, size
))
660 errx(1, "sendbytes (err %d)", rx_Error(call
));
661 DBFPRINT(("send\n"));
672 #ifdef AFS_PTHREAD_ENV
684 do_client(const char *server
, short port
, char *filename
, afs_int32 command
,
685 afs_int32 times
, afs_int32 bytes
, afs_int32 sendbytes
, afs_int32 readbytes
,
686 int dumpstats
, int nojumbo
, int maxmtu
, int maxwsize
, int minpeertimeout
,
687 int udpbufsz
, int nostats
, int hotthread
, int threads
)
689 struct rx_connection
*conn
;
691 struct rx_securityClass
*secureobj
;
695 struct client_data
*params
;
697 #ifdef AFS_PTHREAD_ENV
699 pthread_t thread
[MAX_THREADS
];
700 pthread_attr_t tattr
;
704 params
= calloc(1, sizeof(struct client_data
));
707 if (afs_winsockInit() < 0) {
708 printf("Can't initialize winsock.\n");
714 rx_EnableHotThread();
719 addr
= str2addr(server
);
721 rx_SetUdpBufSize(udpbufsz
);
725 errx(1, "rx_Init failed");
731 rx_SetMaxMTU(maxmtu
);
734 rx_SetMaxReceiveWindow(maxwsize
);
735 rx_SetMaxSendWindow(maxwsize
);
739 rx_SetMinPeerTimeout(minpeertimeout
);
742 get_sec(0, &secureobj
, &secureindex
);
746 sprintf(stamp
, "RPC: threads\t%d, times\t%d, write bytes\t%d, read bytes\t%d",
747 threads
, times
, sendbytes
, readbytes
);
750 sprintf(stamp
, "RECV: threads\t%d, times\t%d, bytes\t%d",
751 threads
, times
, bytes
);
754 sprintf(stamp
, "SEND: threads\t%d, times\t%d, bytes\t%d",
755 threads
, times
, bytes
);
758 sprintf(stamp
, "FILE %s: threads\t%d, times\t%d, bytes\t%d",
759 filename
, threads
, times
, bytes
);
763 conn
= rx_NewConnection(addr
, htons(port
), RX_SERVER_ID
, secureobj
, secureindex
);
765 errx(1, "failed to contact server");
767 #ifdef AFS_PTHREAD_ENV
768 pthread_attr_init(&tattr
);
769 pthread_attr_setdetachstate(&tattr
, PTHREAD_CREATE_JOINABLE
);
773 params
->filename
= filename
;
774 params
->command
= command
;
775 params
->times
= times
;
776 params
->bytes
= bytes
;
777 params
->sendbytes
= sendbytes
;
778 params
->readbytes
= readbytes
;
782 #ifdef AFS_PTHREAD_ENV
783 for ( i
=0; i
<threads
; i
++) {
784 pthread_create(&thread
[i
], &tattr
, client_thread
, params
);
785 if ( (i
+ 1) % RX_MAXCALLS
== 0 ) {
786 conn
= rx_NewConnection(addr
, htons(port
), RX_SERVER_ID
, secureobj
, secureindex
);
788 struct client_data
*new_params
= malloc(sizeof(struct client_data
));
789 memcpy(new_params
, params
, sizeof(struct client_data
));
790 new_params
->conn
= conn
;
796 client_thread(params
);
799 #ifdef AFS_PTHREAD_ENV
800 for ( i
=0; i
<threads
; i
++)
801 pthread_join(thread
[i
], &status
);
806 end_and_print_timer(stamp
, (long long)threads
*times
*(sendbytes
+readbytes
));
811 end_and_print_timer(stamp
, (long long)threads
*times
*bytes
);
815 DBFPRINT(("done for good\n"));
818 rx_PrintStats(stdout
);
819 rx_PrintPeerStats(stdout
, rx_PeerOf(conn
));
823 #ifdef AFS_PTHREAD_ENV
824 pthread_attr_destroy(&tattr
);
835 fprintf(stderr
, "usage: %s client -c send -b <bytes>\n", getprogname());
836 fprintf(stderr
, "usage: %s client -c recv -b <bytes>\n", getprogname());
838 "usage: %s client -c rpc -S <sendbytes> -R <recvbytes>\n",
840 fprintf(stderr
, "usage: %s client -c file -f filename\n", getprogname());
842 "%s: usage: common option to the client "
843 "-w <write-bytes> -r <read-bytes> -T times -p port -s server -D\n",
845 fprintf(stderr
, "usage: %s server -p port\n", getprogname());
853 * do argument processing and call networking functions
857 rxperf_server(int argc
, char **argv
)
859 short port
= DEFAULT_PORT
;
863 int udpbufsz
= 64 * 1024;
868 int minpeertimeout
= 0;
872 while ((ch
= getopt(argc
, argv
, "r:d:p:P:w:W:HNjm:u:4:s:S:V")) != -1) {
876 rx_debugFile
= fopen(optarg
, "w");
877 if (rx_debugFile
== NULL
)
878 err(1, "fopen %s", optarg
);
880 errx(1, "compiled without RXDEBUG");
884 rxread_size
= strtol(optarg
, &ptr
, 0);
885 if (ptr
!= 0 && ptr
[0] != '\0')
886 errx(1, "can't resolve readsize");
887 if (rxread_size
> sizeof(somebuf
))
888 errx(1, "%d > sizeof(somebuf) (%"AFS_SIZET_FMT
")", rxread_size
,
892 minprocs
= strtol(optarg
, &ptr
, 0);
893 if (ptr
!= 0 && ptr
[0] != '\0')
894 errx(1, "can't resolve minprocs");
897 maxprocs
= strtol(optarg
, &ptr
, 0);
898 if (ptr
!= 0 && ptr
[0] != '\0')
899 errx(1, "can't resolve maxprocs");
902 minpeertimeout
= strtol(optarg
, &ptr
, 0);
903 if (ptr
!= 0 && ptr
[0] != '\0')
904 errx(1, "can't resolve min peer timeout");
907 port
= (short) strtol(optarg
, &ptr
, 0);
908 if (ptr
!= 0 && ptr
[0] != '\0')
909 errx(1, "can't resolve portname");
912 rxwrite_size
= strtol(optarg
, &ptr
, 0);
913 if (ptr
!= 0 && ptr
[0] != '\0')
914 errx(1, "can't resolve writesize");
915 if (rxwrite_size
> sizeof(somebuf
))
916 errx(1, "%d > sizeof(somebuf) (%"AFS_SIZET_FMT
")", rxwrite_size
,
929 maxmtu
= strtol(optarg
, &ptr
, 0);
930 if (ptr
&& *ptr
!= '\0')
931 errx(1, "can't resolve rx maxmtu to use");
934 udpbufsz
= strtol(optarg
, &ptr
, 0) * 1024;
935 if (ptr
&& *ptr
!= '\0')
936 errx(1, "can't resolve upd buffer size (Kbytes)");
942 maxwsize
= strtol(optarg
, &ptr
, 0);
943 if (ptr
&& *ptr
!= '\0')
944 errx(1, "can't resolve max send/recv window size (packets)");
957 do_server(port
, nojumbo
, maxmtu
, maxwsize
, minpeertimeout
, udpbufsz
,
958 nostats
, hotthreads
, minprocs
, maxprocs
);
964 * do argument processing and call networking functions
968 rxperf_client(int argc
, char **argv
)
970 char *host
= DEFAULT_HOST
;
971 int bytes
= DEFAULT_BYTES
;
972 short port
= DEFAULT_PORT
;
973 char *filename
= NULL
;
984 int udpbufsz
= 64 * 1024;
986 int minpeertimeout
= 0;
990 cmd
= RX_PERF_UNKNOWN
;
992 while ((ch
= getopt(argc
, argv
, "T:S:R:b:c:d:p:P:r:s:w:W:f:HDNjm:u:4:t:V")) != -1) {
995 bytes
= strtol(optarg
, &ptr
, 0);
996 if (ptr
&& *ptr
!= '\0')
997 errx(1, "can't resolve number of bytes to transfer");
1000 if (strcasecmp(optarg
, "send") == 0)
1002 else if (strcasecmp(optarg
, "recv") == 0)
1004 else if (strcasecmp(optarg
, "rpc") == 0)
1006 else if (strcasecmp(optarg
, "file") == 0)
1009 errx(1, "unknown command %s", optarg
);
1013 rx_debugFile
= fopen(optarg
, "w");
1014 if (rx_debugFile
== NULL
)
1015 err(1, "fopen %s", optarg
);
1017 errx(1, "compiled without RXDEBUG");
1021 minpeertimeout
= strtol(optarg
, &ptr
, 0);
1022 if (ptr
!= 0 && ptr
[0] != '\0')
1023 errx(1, "can't resolve min peer timeout");
1026 port
= (short) strtol(optarg
, &ptr
, 0);
1027 if (ptr
!= 0 && ptr
[0] != '\0')
1028 errx(1, "can't resolve portname");
1031 rxread_size
= strtol(optarg
, &ptr
, 0);
1032 if (ptr
!= 0 && ptr
[0] != '\0')
1033 errx(1, "can't resolve readsize");
1034 if (rxread_size
> sizeof(somebuf
))
1035 errx(1, "%d > sizeof(somebuf) (%"AFS_SIZET_FMT
")", rxread_size
,
1039 host
= strdup(optarg
);
1047 rxwrite_size
= strtol(optarg
, &ptr
, 0);
1048 if (ptr
!= 0 && ptr
[0] != '\0')
1049 errx(1, "can't resolve writesize");
1050 if (rxwrite_size
> sizeof(somebuf
))
1051 errx(1, "%d > sizeof(somebuf) (%"AFS_SIZET_FMT
")", rxwrite_size
,
1055 maxwsize
= strtol(optarg
, &ptr
, 0);
1056 if (ptr
&& *ptr
!= '\0')
1057 errx(1, "can't resolve max send/recv window size (packets)");
1060 times
= strtol(optarg
, &ptr
, 0);
1061 if (ptr
&& *ptr
!= '\0')
1062 errx(1, "can't resolve number of times to execute rpc");
1065 sendbytes
= strtol(optarg
, &ptr
, 0);
1066 if (ptr
&& *ptr
!= '\0')
1067 errx(1, "can't resolve number of bytes to send");
1070 readbytes
= strtol(optarg
, &ptr
, 0);
1071 if (ptr
&& *ptr
!= '\0')
1072 errx(1, "can't resolve number of bytes to receive");
1075 #ifdef AFS_PTHREAD_ENV
1076 threads
= strtol(optarg
, &ptr
, 0);
1077 if (ptr
&& *ptr
!= '\0')
1078 errx(1, "can't resolve number of threads to execute");
1079 if (threads
> MAX_THREADS
)
1080 errx(1, "too many threads");
1082 errx(1, "Not built for pthreads");
1101 maxmtu
= strtol(optarg
, &ptr
, 0);
1102 if (ptr
&& *ptr
!= '\0')
1103 errx(1, "can't resolve rx maxmtu to use");
1106 udpbufsz
= strtol(optarg
, &ptr
, 0) * 1024;
1107 if (ptr
&& *ptr
!= '\0')
1108 errx(1, "can't resolve upd buffer size (Kbytes)");
1118 if (nostats
&& dumpstats
)
1119 errx(1, "cannot set both -N and -D");
1121 if (threads
> 1 && cmd
== RX_PERF_FILE
)
1122 errx(1, "cannot use multiple threads with file command");
1127 if (cmd
== RX_PERF_UNKNOWN
)
1128 errx(1, "no command given to the client");
1130 do_client(host
, port
, filename
, cmd
, times
, bytes
, sendbytes
,
1131 readbytes
, dumpstats
, nojumbo
, maxmtu
, maxwsize
, minpeertimeout
,
1132 udpbufsz
, nostats
, hotthreads
, threads
);
1138 * setup world and call cmd
1142 main(int argc
, char **argv
)
1144 #ifndef AFS_PTHREAD_ENV
1148 setprogname(argv
[0]);
1150 #ifndef AFS_NT40_ENV
1151 signal(SIGUSR1
, sigusr1
);
1152 signal(SIGINT
, sigint
);
1155 #ifndef AFS_PTHREAD_ENV
1156 LWP_InitializeProcessSupport(LWP_NORMAL_PRIORITY
, &pid
);
1159 memset(somebuf
, 0, sizeof(somebuf
));
1161 if (argc
>= 2 && strcmp(argv
[1], "server") == 0)
1162 rxperf_server(argc
- 1, argv
+ 1);
1163 else if (argc
>= 2 && strcmp(argv
[1], "client") == 0)
1164 rxperf_client(argc
- 1, argv
+ 1);