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 #include <sys/types.h>
55 #include <sys/socket.h>
58 #include <netinet/in.h>
59 #include <arpa/inet.h>
78 #include <err.h> /* not stricly right, but if we have a errx() there
79 * is hopefully a err.h */
84 #include "rx_globals.h"
86 #ifdef AFS_PTHREAD_ENV
88 #define MAX_THREADS 128
91 static const char *__progname;
95 warnx(const char *fmt, ...)
100 fprintf(stderr, "%s: ", __progname);
101 vfprintf(stderr, fmt, args);
102 fprintf(stderr, "\n");
105 #endif /* !HAVE_WARNX */
109 errx(int eval, const char *fmt, ...)
114 fprintf(stderr, "%s: ", __progname);
115 vfprintf(stderr, fmt, args);
116 fprintf(stderr, "\n");
121 #endif /* !HAVE_ERRX */
125 warn(const char *fmt, ...)
131 fprintf(stderr, "%s: ", __progname);
132 vfprintf(stderr, fmt, args);
134 errstr = strerror(errno);
136 fprintf(stderr, ": %s\n", errstr ? errstr : "unknown error");
139 #endif /* !HAVE_WARN */
143 err(int eval, const char *fmt, ...)
149 fprintf(stderr, "%s: ", __progname);
150 vfprintf(stderr, fmt, args);
152 errstr = strerror(errno);
154 fprintf(stderr, ": %s\n", errstr ? errstr : "unknown error");
159 #endif /* !HAVE_ERR */
161 #define DEFAULT_PORT 7009 /* To match tcpdump */
162 #define DEFAULT_HOST "127.0.0.1"
163 #define DEFAULT_BYTES 1024 * 1024
164 #define RXPERF_BUFSIZE 512 * 1024
166 enum { RX_PERF_VERSION = 3 };
167 enum { RX_SERVER_ID = 147 };
168 enum { RX_PERF_UNKNOWN = -1,
175 enum { RXPERF_MAGIC_COOKIE = 0x4711 };
182 #define DBFPRINT(x) do { printf x ; } while(0)
190 exit(2); /* XXX profiler */
197 exit(2); /* XXX profiler */
204 static struct timeval timer_start;
205 static struct timeval timer_stop;
206 static int timer_check = 0;
212 gettimeofday(&timer_start, NULL);
220 end_and_print_timer(char *str)
222 long long start_l, stop_l;
225 assert(timer_check == 0);
226 gettimeofday(&timer_stop, NULL);
227 start_l = timer_start.tv_sec * 1000000 + timer_start.tv_usec;
228 stop_l = timer_stop.tv_sec * 1000000 + timer_stop.tv_usec;
229 printf("%s:\t%8llu msec\n", str, (stop_l - start_l) / 1000);
237 str2addr(const char *s)
239 struct in_addr server;
243 #define INADDR_NONE 0xffffffff
245 if (inet_addr(s) != INADDR_NONE)
247 h = gethostbyname(s);
249 memcpy(&server, h->h_addr_list[0], sizeof(server));
250 return server.s_addr;
261 get_sec(int serverp, struct rx_securityClass **sec, int *secureindex)
264 *sec = rxnull_NewServerSecurityObject();
267 *sec = rxnull_NewClientSecurityObject();
273 * process the "RPC" and return the results
276 char somebuf[RXPERF_BUFSIZE];
278 afs_int32 rxwrite_size = sizeof(somebuf);
279 afs_int32 rxread_size = sizeof(somebuf);
282 readbytes(struct rx_call *call, afs_int32 bytes)
290 if (rx_Read(call, somebuf, size) != size)
298 sendbytes(struct rx_call *call, afs_int32 bytes)
306 if (rx_Write(call, somebuf, size) != size)
315 rxperf_ExecuteRequest(struct rx_call *call)
324 afs_uint32 *readwrite;
328 DBFPRINT(("got a request\n"));
330 if (rx_Read32(call, &version) != 4) {
331 warn("rx_Read failed to read version");
335 if (htonl(RX_PERF_VERSION) != version) {
336 warnx("client has wrong version");
340 if (rx_Read32(call, &command) != 4) {
341 warnx("rx_Read failed to read command");
344 command = ntohl(command);
346 if (rx_Read32(call, &data) != 4) {
347 warnx("rx_Read failed to read size");
350 rxread_size = ntohl(data);
351 if (rxread_size > sizeof(somebuf)) {
352 warnx("rxread_size too large %d", rxread_size);
356 if (rx_Read32(call, &data) != 4) {
357 warnx("rx_Read failed to write size");
360 rxwrite_size = ntohl(data);
361 if (rxwrite_size > sizeof(somebuf)) {
362 warnx("rxwrite_size too large %d", rxwrite_size);
368 DBFPRINT(("got a send request\n"));
370 if (rx_Read32(call, &bytes) != 4) {
371 warnx("rx_Read failed to read bytes");
374 bytes = ntohl(bytes);
376 DBFPRINT(("reading(%d) ", bytes));
377 readbytes(call, bytes);
379 data = htonl(RXPERF_MAGIC_COOKIE);
380 if (rx_Write32(call, &data) != 4) {
381 warnx("rx_Write failed when sending back result");
384 DBFPRINT(("done\n"));
388 DBFPRINT(("got a rpc request, reading commands\n"));
390 if (rx_Read32(call, &recvb) != 4) {
391 warnx("rx_Read failed to read recvbytes");
394 recvb = ntohl(recvb);
395 if (rx_Read32(call, &sendb) != 4) {
396 warnx("rx_Read failed to read sendbytes");
399 sendb = ntohl(sendb);
401 DBFPRINT(("read(%d) ", recvb));
402 if (readbytes(call, recvb)) {
403 warnx("readbytes failed");
406 DBFPRINT(("send(%d) ", sendb));
407 if (sendbytes(call, sendb)) {
408 warnx("sendbytes failed");
412 DBFPRINT(("done\n"));
414 data = htonl(RXPERF_MAGIC_COOKIE);
415 if (rx_Write32(call, &data) != 4) {
416 warnx("rx_Write failed when sending back magic cookie");
422 if (rx_Read32(call, &data) != 4)
423 errx(1, "failed to read num from client");
426 readwrite = malloc(num * sizeof(afs_uint32));
427 if (readwrite == NULL)
430 if (rx_Read(call, (char*)readwrite, num * sizeof(afs_uint32)) !=
431 num * sizeof(afs_uint32))
432 errx(1, "failed to read recvlist from client");
434 for (i = 0; i < num; i++) {
435 if (readwrite[i] == 0) {
436 DBFPRINT(("readp %d", readwrite[i]));
440 bytes = ntohl(readwrite[i]) * sizeof(afs_uint32);
443 DBFPRINT(("read\n"));
444 readbytes(call, bytes);
446 sendbytes(call, bytes);
447 DBFPRINT(("send\n"));
453 DBFPRINT(("got a recv request\n"));
455 if (rx_Read32(call, &bytes) != 4) {
456 warnx("rx_Read failed to read bytes");
459 bytes = ntohl(bytes);
461 DBFPRINT(("sending(%d) ", bytes));
462 sendbytes(call, bytes);
464 data = htonl(RXPERF_MAGIC_COOKIE);
465 if (rx_Write32(call, &data) != 4) {
466 warnx("rx_Write failed when sending back result");
469 DBFPRINT(("done\n"));
473 warnx("client sent a unsupported command");
476 DBFPRINT(("done with command\n"));
486 do_server(short port, int nojumbo, int maxmtu, int maxwsize, int minpeertimeout,
487 int udpbufsz, int nostats, int hotthread,
488 int minprocs, int maxprocs)
490 struct rx_service *service;
491 struct rx_securityClass *secureobj;
496 if (afs_winsockInit() < 0) {
497 printf("Can't initialize winsock.\n");
503 rx_EnableHotThread();
508 ret = rx_Init(htons(port));
510 errx(1, "rx_Init failed");
516 rx_SetMaxMTU(maxmtu);
519 rx_SetMaxReceiveWindow(maxwsize);
520 rx_SetMaxSendWindow(maxwsize);
524 rx_SetMinPeerTimeout(minpeertimeout);
526 rx_SetUdpBufSize(udpbufsz);
528 get_sec(1, &secureobj, &secureindex);
531 rx_NewService(0, RX_SERVER_ID, "rxperf", &secureobj, secureindex,
532 rxperf_ExecuteRequest);
534 errx(1, "Cant create server");
536 rx_SetMinProcs(service, minprocs);
537 rx_SetMaxProcs(service, maxprocs);
539 rx_SetCheckReach(service, 1);
551 readfile(const char *filename, afs_uint32 ** readwrite, afs_uint32 * size)
558 char buf[RXPERF_BUFSIZE];
560 *readwrite = malloc(sizeof(afs_uint32) * len);
562 if (*readwrite == NULL)
565 f = fopen(filename, "r");
569 while (fgets(buf, sizeof(buf), f) != NULL) {
572 *readwrite = realloc(*readwrite, len * sizeof(afs_uint32));
573 if (*readwrite == NULL)
578 data = htonl(strtol(buf, &ptr, 0));
579 if (ptr && ptr == buf)
580 errx(1, "can't resolve number of bytes to transfer");
585 (*readwrite)[num] = data;
597 struct rx_connection *conn;
607 client_thread( void *vparams)
609 struct client_data *params = (struct client_data *)vparams;
610 struct rx_call *call;
613 afs_uint32 *readwrite;
618 for (i = 0; i < params->times; i++) {
620 DBFPRINT(("starting command "));
622 call = rx_NewCall(params->conn);
624 errx(1, "rx_NewCall failed");
626 data = htonl(RX_PERF_VERSION);
627 if (rx_Write32(call, &data) != 4)
628 errx(1, "rx_Write failed to send version (err %d)", rx_Error(call));
630 data = htonl(params->command);
631 if (rx_Write32(call, &data) != 4)
632 errx(1, "rx_Write failed to send command (err %d)", rx_Error(call));
634 data = htonl(rxread_size);
635 if (rx_Write32(call, &data) != 4)
636 errx(1, "rx_Write failed to send read size (err %d)", rx_Error(call));
637 data = htonl(rxwrite_size);
638 if (rx_Write32(call, &data) != 4)
639 errx(1, "rx_Write failed to send write read (err %d)", rx_Error(call));
642 switch (params->command) {
644 DBFPRINT(("command "));
646 data = htonl(params->bytes);
647 if (rx_Write32(call, &data) != 4)
648 errx(1, "rx_Write failed to send size (err %d)", rx_Error(call));
650 DBFPRINT(("sending(%d) ", params->bytes));
651 if (readbytes(call, params->bytes))
652 errx(1, "sendbytes (err %d)", rx_Error(call));
654 if (rx_Read32(call, &data) != 4)
655 errx(1, "failed to read result from server (err %d)", rx_Error(call));
657 if (data != htonl(RXPERF_MAGIC_COOKIE))
658 warn("server send wrong magic cookie in responce");
660 DBFPRINT(("done\n"));
664 DBFPRINT(("command "));
666 data = htonl(params->bytes);
667 if (rx_Write32(call, &data) != 4)
668 errx(1, "rx_Write failed to send size (err %d)", rx_Error(call));
670 DBFPRINT(("sending(%d) ", params->bytes));
671 if (sendbytes(call, params->bytes))
672 errx(1, "sendbytes (err %d)", rx_Error(call));
674 if (rx_Read32(call, &data) != 4)
675 errx(1, "failed to read result from server (err %d)", rx_Error(call));
677 if (data != htonl(RXPERF_MAGIC_COOKIE))
678 warn("server send wrong magic cookie in responce");
680 DBFPRINT(("done\n"));
684 DBFPRINT(("commands "));
686 data = htonl(params->sendtimes);
687 if (rx_Write32(call, &data) != 4)
688 errx(1, "rx_Write failed to send command (err %d)", rx_Error(call));
690 data = htonl(params->recvtimes);
691 if (rx_Write32(call, &data) != 4)
692 errx(1, "rx_Write failed to send command (err %d)", rx_Error(call));
694 DBFPRINT(("send(%d) ", params->sendtimes));
695 if (sendbytes(call, params->sendtimes))
696 errx(1, "sendbytes (err %d)", rx_Error(call));
698 DBFPRINT(("recv(%d) ", params->recvtimes));
699 if (readbytes(call, params->recvtimes))
700 errx(1, "sendbytes (err %d)", rx_Error(call));
702 if (rx_Read32(call, &data) != 4)
703 errx(1, "failed to read result from server (err %d)", rx_Error(call));
705 if (data != htonl(RXPERF_MAGIC_COOKIE))
706 warn("server send wrong magic cookie in responce");
708 DBFPRINT(("done\n"));
713 readfile(params->filename, &readwrite, &num);
716 if (rx_Write32(call, &data) != 4)
717 errx(1, "rx_Write failed to send size (err %d)", rx_Error(call));
719 if (rx_Write(call, (char *)readwrite, num * sizeof(afs_uint32))
720 != num * sizeof(afs_uint32))
721 errx(1, "rx_Write failed to send list (err %d)", rx_Error(call));
723 for (j = 0; j < num; j++) {
724 if (readwrite[j] == 0)
727 size = ntohl(readwrite[j]) * sizeof(afs_uint32);
730 if (readbytes(call, size))
731 errx(1, "sendbytes (err %d)", rx_Error(call));
732 DBFPRINT(("read\n"));
734 if (sendbytes(call, size))
735 errx(1, "sendbytes (err %d)", rx_Error(call));
736 DBFPRINT(("send\n"));
747 #ifdef AFS_PTHREAD_ENV
759 do_client(const char *server, short port, char *filename, afs_int32 command,
760 afs_int32 times, afs_int32 bytes, afs_int32 sendtimes, afs_int32 recvtimes,
761 int dumpstats, int nojumbo, int maxmtu, int maxwsize, int minpeertimeout,
762 int udpbufsz, int nostats, int hotthread, int threads)
764 struct rx_connection *conn;
766 struct rx_securityClass *secureobj;
770 struct client_data params;
772 #ifdef AFS_PTHREAD_ENV
774 pthread_t thread[MAX_THREADS];
775 pthread_attr_t tattr;
780 if (afs_winsockInit() < 0) {
781 printf("Can't initialize winsock.\n");
787 rx_EnableHotThread();
792 addr = str2addr(server);
796 errx(1, "rx_Init failed");
802 rx_SetMaxMTU(maxmtu);
805 rx_SetMaxReceiveWindow(maxwsize);
806 rx_SetMaxSendWindow(maxwsize);
810 rx_SetMinPeerTimeout(minpeertimeout);
812 rx_SetUdpBufSize(udpbufsz);
814 get_sec(0, &secureobj, &secureindex);
816 conn = rx_NewConnection(addr, htons(port), RX_SERVER_ID, secureobj, secureindex);
818 errx(1, "failed to contact server");
820 #ifdef AFS_PTHREAD_ENV
821 pthread_attr_init(&tattr);
822 pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_JOINABLE);
826 params.filename = filename;
827 params.command = command;
828 params.times = times;
829 params.bytes = bytes;
830 params.sendtimes = sendtimes;
831 params.recvtimes = recvtimes;
835 sprintf(stamp, "RPC: threads\t%d, times\t%d, writes\t%d, reads\t%d",
836 threads, times, sendtimes, recvtimes);
839 sprintf(stamp, "RECV: threads\t%d, times\t%d, bytes\t%d",
840 threads, times, bytes);
843 sprintf(stamp, "SEND: threads\t%d, times\t%d, bytes\t%d",
844 threads, times, bytes);
847 sprintf(stamp, "FILE %s: threads\t%d, times\t%d, bytes\t%d",
848 filename, threads, times, bytes);
854 #ifdef AFS_PTHREAD_ENV
855 for ( i=0; i<threads; i++)
856 pthread_create(&thread[i], &tattr, client_thread, ¶ms);
858 client_thread(¶ms);
861 #ifdef AFS_PTHREAD_ENV
862 for ( i=0; i<threads; i++)
863 pthread_join(thread[i], &status);
866 end_and_print_timer(stamp);
867 DBFPRINT(("done for good\n"));
870 rx_PrintStats(stdout);
871 rx_PrintPeerStats(stdout, conn->peer);
875 #ifdef AFS_PTHREAD_ENV
876 pthread_attr_destroy(&tattr);
885 fprintf(stderr, "usage: %s client -c send -b <bytes>\n", __progname);
886 fprintf(stderr, "usage: %s client -c recv -b <bytes>\n", __progname);
888 "usage: %s client -c rpc -S <sendbytes> -R <recvbytes>\n",
890 fprintf(stderr, "usage: %s client -c file -f filename\n", __progname);
892 "%s: usage: common option to the client "
893 "-w <write-bytes> -r <read-bytes> -T times -p port -s server -D\n",
895 fprintf(stderr, "usage: %s server -p port\n", __progname);
903 * do argument processing and call networking functions
907 rxperf_server(int argc, char **argv)
909 short port = DEFAULT_PORT;
913 int udpbufsz = 64 * 1024;
918 int minpeertimeout = 0;
922 while ((ch = getopt(argc, argv, "r:d:p:P:w:W:HNjm:u:4:s:S")) != -1) {
926 rx_debugFile = fopen(optarg, "w");
927 if (rx_debugFile == NULL)
928 err(1, "fopen %s", optarg);
930 errx(1, "compiled without RXDEBUG");
934 rxread_size = strtol(optarg, &ptr, 0);
935 if (ptr != 0 && ptr[0] != '\0')
936 errx(1, "can't resolve readsize");
937 if (rxread_size > sizeof(somebuf))
938 errx(1, "%d > sizeof(somebuf) (%d)", rxread_size,
942 minprocs = strtol(optarg, &ptr, 0);
943 if (ptr != 0 && ptr[0] != '\0')
944 errx(1, "can't resolve minprocs");
947 maxprocs = strtol(optarg, &ptr, 0);
948 if (ptr != 0 && ptr[0] != '\0')
949 errx(1, "can't resolve maxprocs");
952 minpeertimeout = strtol(optarg, &ptr, 0);
953 if (ptr != 0 && ptr[0] != '\0')
954 errx(1, "can't resolve min peer timeout");
957 port = (short) strtol(optarg, &ptr, 0);
958 if (ptr != 0 && ptr[0] != '\0')
959 errx(1, "can't resolve portname");
962 rxwrite_size = strtol(optarg, &ptr, 0);
963 if (ptr != 0 && ptr[0] != '\0')
964 errx(1, "can't resolve writesize");
965 if (rxwrite_size > sizeof(somebuf))
966 errx(1, "%d > sizeof(somebuf) (%d)", rxwrite_size,
979 maxmtu = strtol(optarg, &ptr, 0);
980 if (ptr && *ptr != '\0')
981 errx(1, "can't resolve rx maxmtu to use");
984 udpbufsz = strtol(optarg, &ptr, 0) * 1024;
985 if (ptr && *ptr != '\0')
986 errx(1, "can't resolve upd buffer size (Kbytes)");
989 maxwsize = strtol(optarg, &ptr, 0);
990 if (ptr && *ptr != '\0')
991 errx(1, "can't resolve max send/recv window size (packets)");
1004 do_server(port, nojumbo, maxmtu, maxwsize, minpeertimeout, udpbufsz,
1005 nostats, hotthreads, minprocs, maxprocs);
1011 * do argument processing and call networking functions
1015 rxperf_client(int argc, char **argv)
1017 char *host = DEFAULT_HOST;
1018 int bytes = DEFAULT_BYTES;
1019 short port = DEFAULT_PORT;
1020 char *filename = NULL;
1031 int udpbufsz = 64 * 1024;
1033 int minpeertimeout = 0;
1037 cmd = RX_PERF_UNKNOWN;
1039 while ((ch = getopt(argc, argv, "T:S:R:b:c:d:p:P:r:s:w:W:f:HDNjm:u:4:t:")) != -1) {
1042 bytes = strtol(optarg, &ptr, 0);
1043 if (ptr && *ptr != '\0')
1044 errx(1, "can't resolve number of bytes to transfer");
1047 if (strcasecmp(optarg, "send") == 0)
1049 else if (strcasecmp(optarg, "recv") == 0)
1051 else if (strcasecmp(optarg, "rpc") == 0)
1053 else if (strcasecmp(optarg, "file") == 0)
1056 errx(1, "unknown command %s", optarg);
1060 rx_debugFile = fopen(optarg, "w");
1061 if (rx_debugFile == NULL)
1062 err(1, "fopen %s", optarg);
1064 errx(1, "compiled without RXDEBUG");
1068 minpeertimeout = strtol(optarg, &ptr, 0);
1069 if (ptr != 0 && ptr[0] != '\0')
1070 errx(1, "can't resolve min peer timeout");
1073 port = (short) strtol(optarg, &ptr, 0);
1074 if (ptr != 0 && ptr[0] != '\0')
1075 errx(1, "can't resolve portname");
1078 rxread_size = strtol(optarg, &ptr, 0);
1079 if (ptr != 0 && ptr[0] != '\0')
1080 errx(1, "can't resolve readsize");
1081 if (rxread_size > sizeof(somebuf))
1082 errx(1, "%d > sizeof(somebuf) (%d)", rxread_size,
1086 host = strdup(optarg);
1091 rxwrite_size = strtol(optarg, &ptr, 0);
1092 if (ptr != 0 && ptr[0] != '\0')
1093 errx(1, "can't resolve writesize");
1094 if (rxwrite_size > sizeof(somebuf))
1095 errx(1, "%d > sizeof(somebuf) (%d)", rxwrite_size,
1099 maxwsize = strtol(optarg, &ptr, 0);
1100 if (ptr && *ptr != '\0')
1101 errx(1, "can't resolve max send/recv window size (packets)");
1104 times = strtol(optarg, &ptr, 0);
1105 if (ptr && *ptr != '\0')
1106 errx(1, "can't resolve number of times to execute rpc");
1109 sendtimes = strtol(optarg, &ptr, 0);
1110 if (ptr && *ptr != '\0')
1111 errx(1, "can't resolve number of bytes to send");
1114 recvtimes = strtol(optarg, &ptr, 0);
1115 if (ptr && *ptr != '\0')
1116 errx(1, "can't resolve number of bytes to receive");
1119 #ifdef AFS_PTHREAD_ENV
1120 threads = strtol(optarg, &ptr, 0);
1121 if (ptr && *ptr != '\0')
1122 errx(1, "can't resolve number of threads to execute");
1123 if (threads > MAX_THREADS)
1124 errx(1, "too many threads");
1126 errx(1, "Not built for pthreads");
1145 maxmtu = strtol(optarg, &ptr, 0);
1146 if (ptr && *ptr != '\0')
1147 errx(1, "can't resolve rx maxmtu to use");
1150 udpbufsz = strtol(optarg, &ptr, 0) * 1024;
1151 if (ptr && *ptr != '\0')
1152 errx(1, "can't resolve upd buffer size (Kbytes)");
1162 if (nostats && dumpstats)
1163 errx(1, "cannot set both -N and -D");
1165 if (threads > 1 && cmd == RX_PERF_FILE)
1166 errx(1, "cannot use multiple threads with file command");
1171 if (cmd == RX_PERF_UNKNOWN)
1172 errx(1, "no command given to the client");
1174 do_client(host, port, filename, cmd, times, bytes, sendtimes,
1175 recvtimes, dumpstats, nojumbo, maxmtu, maxwsize, minpeertimeout,
1176 udpbufsz, nostats, hotthreads, threads);
1182 * setup world and call cmd
1186 main(int argc, char **argv)
1188 #ifndef AFS_PTHREAD_ENV
1192 __progname = strrchr(argv[0], '/');
1193 if (__progname == 0)
1194 __progname = argv[0];
1196 #ifndef AFS_NT40_ENV
1197 signal(SIGUSR1, sigusr1);
1198 signal(SIGINT, sigint);
1201 #ifndef AFS_PTHREAD_ENV
1202 LWP_InitializeProcessSupport(LWP_NORMAL_PRIORITY, &pid);
1205 memset(somebuf, 0, sizeof(somebuf));
1207 if (argc >= 2 && strcmp(argv[1], "server") == 0)
1208 rxperf_server(argc - 1, argv + 1);
1209 else if (argc >= 2 && strcmp(argv[1], "client") == 0)
1210 rxperf_client(argc - 1, argv + 1);