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 */
83 #include <rx/rx_null.h>
84 #include <rx/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);
280 afs_int32 use_rx_readv = 0;
283 do_readbytes(struct rx_call *call, afs_int32 bytes)
285 struct iovec tiov[RX_MAXIOVECS];
296 if (size > RX_MAX_PACKET_DATA_SIZE)
297 size = RX_MAX_PACKET_DATA_SIZE;
298 code = rx_Readv(call, tiov, &tnio, RX_MAXIOVECS, size);
300 code = rx_Read(call, somebuf, size);
310 do_sendbytes(struct rx_call *call, afs_int32 bytes)
318 if (rx_Write(call, somebuf, size) != size)
327 rxperf_ExecuteRequest(struct rx_call *call)
336 afs_uint32 *readwrite;
340 DBFPRINT(("got a request\n"));
342 if (rx_Read32(call, &version) != 4) {
343 warn("rx_Read failed to read version");
347 if (htonl(RX_PERF_VERSION) != version) {
348 warnx("client has wrong version");
352 if (rx_Read32(call, &command) != 4) {
353 warnx("rx_Read failed to read command");
356 command = ntohl(command);
358 if (rx_Read32(call, &data) != 4) {
359 warnx("rx_Read failed to read size");
362 rxread_size = ntohl(data);
363 if (rxread_size > sizeof(somebuf)) {
364 warnx("rxread_size too large %d", rxread_size);
368 if (rx_Read32(call, &data) != 4) {
369 warnx("rx_Read failed to write size");
372 rxwrite_size = ntohl(data);
373 if (rxwrite_size > sizeof(somebuf)) {
374 warnx("rxwrite_size too large %d", rxwrite_size);
380 DBFPRINT(("got a send request\n"));
382 if (rx_Read32(call, &bytes) != 4) {
383 warnx("rx_Read failed to read bytes");
386 bytes = ntohl(bytes);
388 DBFPRINT(("reading(%d) ", bytes));
389 do_readbytes(call, bytes);
391 data = htonl(RXPERF_MAGIC_COOKIE);
392 if (rx_Write32(call, &data) != 4) {
393 warnx("rx_Write failed when sending back result");
396 DBFPRINT(("done\n"));
400 DBFPRINT(("got a rpc request, reading commands\n"));
402 if (rx_Read32(call, &recvb) != 4) {
403 warnx("rx_Read failed to read recvbytes");
406 recvb = ntohl(recvb);
407 if (rx_Read32(call, &sendb) != 4) {
408 warnx("rx_Read failed to read sendbytes");
411 sendb = ntohl(sendb);
413 DBFPRINT(("read(%d) ", recvb));
414 if (do_readbytes(call, recvb)) {
415 warnx("do_readbytes failed");
418 DBFPRINT(("send(%d) ", sendb));
419 if (do_sendbytes(call, sendb)) {
420 warnx("sendbytes failed");
424 DBFPRINT(("done\n"));
426 data = htonl(RXPERF_MAGIC_COOKIE);
427 if (rx_Write32(call, &data) != 4) {
428 warnx("rx_Write failed when sending back magic cookie");
434 if (rx_Read32(call, &data) != 4)
435 errx(1, "failed to read num from client");
438 readwrite = malloc(num * sizeof(afs_uint32));
439 if (readwrite == NULL)
442 if (rx_Read(call, (char*)readwrite, num * sizeof(afs_uint32)) !=
443 num * sizeof(afs_uint32))
444 errx(1, "failed to read recvlist from client");
446 for (i = 0; i < num; i++) {
447 if (readwrite[i] == 0) {
448 DBFPRINT(("readp %d", readwrite[i]));
452 bytes = ntohl(readwrite[i]) * sizeof(afs_uint32);
455 DBFPRINT(("read\n"));
456 do_readbytes(call, bytes);
458 do_sendbytes(call, bytes);
459 DBFPRINT(("send\n"));
465 DBFPRINT(("got a recv request\n"));
467 if (rx_Read32(call, &bytes) != 4) {
468 warnx("rx_Read failed to read bytes");
471 bytes = ntohl(bytes);
473 DBFPRINT(("sending(%d) ", bytes));
474 do_sendbytes(call, bytes);
476 data = htonl(RXPERF_MAGIC_COOKIE);
477 if (rx_Write32(call, &data) != 4) {
478 warnx("rx_Write failed when sending back result");
481 DBFPRINT(("done\n"));
485 warnx("client sent a unsupported command");
488 DBFPRINT(("done with command\n"));
498 do_server(short port, int nojumbo, int maxmtu, int maxwsize, int minpeertimeout,
499 int udpbufsz, int nostats, int hotthread,
500 int minprocs, int maxprocs)
502 struct rx_service *service;
503 struct rx_securityClass *secureobj;
508 if (afs_winsockInit() < 0) {
509 printf("Can't initialize winsock.\n");
515 rx_EnableHotThread();
520 rx_SetUdpBufSize(udpbufsz);
522 ret = rx_Init(htons(port));
524 errx(1, "rx_Init failed");
530 rx_SetMaxMTU(maxmtu);
533 rx_SetMaxReceiveWindow(maxwsize);
534 rx_SetMaxSendWindow(maxwsize);
538 rx_SetMinPeerTimeout(minpeertimeout);
541 get_sec(1, &secureobj, &secureindex);
544 rx_NewService(0, RX_SERVER_ID, "rxperf", &secureobj, secureindex,
545 rxperf_ExecuteRequest);
547 errx(1, "Cant create server");
549 rx_SetMinProcs(service, minprocs);
550 rx_SetMaxProcs(service, maxprocs);
552 rx_SetCheckReach(service, 1);
564 readfile(const char *filename, afs_uint32 ** readwrite, afs_uint32 * size)
573 *readwrite = malloc(sizeof(afs_uint32) * len);
574 buf = malloc(RXPERF_BUFSIZE);
576 if (*readwrite == NULL)
579 f = fopen(filename, "r");
583 while (fgets(buf, sizeof(buf), f) != NULL) {
586 *readwrite = realloc(*readwrite, len * sizeof(afs_uint32));
587 if (*readwrite == NULL)
592 data = htonl(strtol(buf, &ptr, 0));
593 if (ptr && ptr == buf)
594 errx(1, "can't resolve number of bytes to transfer");
599 (*readwrite)[num] = data;
612 struct rx_connection *conn;
622 client_thread( void *vparams)
624 struct client_data *params = (struct client_data *)vparams;
625 struct rx_call *call;
628 afs_uint32 *readwrite;
633 for (i = 0; i < params->times; i++) {
635 DBFPRINT(("starting command "));
637 call = rx_NewCall(params->conn);
639 errx(1, "rx_NewCall failed");
641 data = htonl(RX_PERF_VERSION);
642 if (rx_Write32(call, &data) != 4)
643 errx(1, "rx_Write failed to send version (err %d)", rx_Error(call));
645 data = htonl(params->command);
646 if (rx_Write32(call, &data) != 4)
647 errx(1, "rx_Write failed to send command (err %d)", rx_Error(call));
649 data = htonl(rxread_size);
650 if (rx_Write32(call, &data) != 4)
651 errx(1, "rx_Write failed to send read size (err %d)", rx_Error(call));
652 data = htonl(rxwrite_size);
653 if (rx_Write32(call, &data) != 4)
654 errx(1, "rx_Write failed to send write read (err %d)", rx_Error(call));
657 switch (params->command) {
659 DBFPRINT(("command "));
661 data = htonl(params->bytes);
662 if (rx_Write32(call, &data) != 4)
663 errx(1, "rx_Write failed to send size (err %d)", rx_Error(call));
665 DBFPRINT(("sending(%d) ", params->bytes));
666 if (do_readbytes(call, params->bytes))
667 errx(1, "sendbytes (err %d)", rx_Error(call));
669 if (rx_Read32(call, &data) != 4)
670 errx(1, "failed to read result from server (err %d)", rx_Error(call));
672 if (data != htonl(RXPERF_MAGIC_COOKIE))
673 warn("server send wrong magic cookie in responce");
675 DBFPRINT(("done\n"));
679 DBFPRINT(("command "));
681 data = htonl(params->bytes);
682 if (rx_Write32(call, &data) != 4)
683 errx(1, "rx_Write failed to send size (err %d)", rx_Error(call));
685 DBFPRINT(("sending(%d) ", params->bytes));
686 if (do_sendbytes(call, params->bytes))
687 errx(1, "sendbytes (err %d)", rx_Error(call));
689 if (rx_Read32(call, &data) != 4)
690 errx(1, "failed to read result from server (err %d)", rx_Error(call));
692 if (data != htonl(RXPERF_MAGIC_COOKIE))
693 warn("server send wrong magic cookie in responce");
695 DBFPRINT(("done\n"));
699 DBFPRINT(("commands "));
701 data = htonl(params->sendbytes);
702 if (rx_Write32(call, &data) != 4)
703 errx(1, "rx_Write failed to send command (err %d)", rx_Error(call));
705 data = htonl(params->readbytes);
706 if (rx_Write32(call, &data) != 4)
707 errx(1, "rx_Write failed to send command (err %d)", rx_Error(call));
709 DBFPRINT(("send(%d) ", params->sendbytes));
710 if (do_sendbytes(call, params->sendbytes))
711 errx(1, "sendbytes (err %d)", rx_Error(call));
713 DBFPRINT(("recv(%d) ", params->readbytes));
714 if (do_readbytes(call, params->readbytes))
715 errx(1, "sendbytes (err %d)", rx_Error(call));
717 if (rx_Read32(call, &data) != 4)
718 errx(1, "failed to read result from server (err %d)", rx_Error(call));
720 if (data != htonl(RXPERF_MAGIC_COOKIE))
721 warn("server send wrong magic cookie in responce");
723 DBFPRINT(("done\n"));
728 readfile(params->filename, &readwrite, &num);
731 if (rx_Write32(call, &data) != 4)
732 errx(1, "rx_Write failed to send size (err %d)", rx_Error(call));
734 if (rx_Write(call, (char *)readwrite, num * sizeof(afs_uint32))
735 != num * sizeof(afs_uint32))
736 errx(1, "rx_Write failed to send list (err %d)", rx_Error(call));
738 for (j = 0; j < num; j++) {
739 if (readwrite[j] == 0)
742 size = ntohl(readwrite[j]) * sizeof(afs_uint32);
745 if (do_readbytes(call, size))
746 errx(1, "sendbytes (err %d)", rx_Error(call));
747 DBFPRINT(("read\n"));
749 if (do_sendbytes(call, size))
750 errx(1, "sendbytes (err %d)", rx_Error(call));
751 DBFPRINT(("send\n"));
762 #ifdef AFS_PTHREAD_ENV
774 do_client(const char *server, short port, char *filename, afs_int32 command,
775 afs_int32 times, afs_int32 bytes, afs_int32 sendbytes, afs_int32 readbytes,
776 int dumpstats, int nojumbo, int maxmtu, int maxwsize, int minpeertimeout,
777 int udpbufsz, int nostats, int hotthread, int threads)
779 struct rx_connection *conn;
781 struct rx_securityClass *secureobj;
785 struct client_data *params;
787 #ifdef AFS_PTHREAD_ENV
789 pthread_t thread[MAX_THREADS];
790 pthread_attr_t tattr;
794 params = malloc(sizeof(struct client_data));
795 memset(params, 0, sizeof(struct client_data));
798 if (afs_winsockInit() < 0) {
799 printf("Can't initialize winsock.\n");
805 rx_EnableHotThread();
810 addr = str2addr(server);
812 rx_SetUdpBufSize(udpbufsz);
816 errx(1, "rx_Init failed");
822 rx_SetMaxMTU(maxmtu);
825 rx_SetMaxReceiveWindow(maxwsize);
826 rx_SetMaxSendWindow(maxwsize);
830 rx_SetMinPeerTimeout(minpeertimeout);
833 get_sec(0, &secureobj, &secureindex);
837 sprintf(stamp, "RPC: threads\t%d, times\t%d, write bytes\t%d, read bytes\t%d",
838 threads, times, sendbytes, readbytes);
841 sprintf(stamp, "RECV: threads\t%d, times\t%d, bytes\t%d",
842 threads, times, bytes);
845 sprintf(stamp, "SEND: threads\t%d, times\t%d, bytes\t%d",
846 threads, times, bytes);
849 sprintf(stamp, "FILE %s: threads\t%d, times\t%d, bytes\t%d",
850 filename, threads, times, bytes);
854 conn = rx_NewConnection(addr, htons(port), RX_SERVER_ID, secureobj, secureindex);
856 errx(1, "failed to contact server");
858 #ifdef AFS_PTHREAD_ENV
859 pthread_attr_init(&tattr);
860 pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_JOINABLE);
864 params->filename = filename;
865 params->command = command;
866 params->times = times;
867 params->bytes = bytes;
868 params->sendbytes = sendbytes;
869 params->readbytes = readbytes;
873 #ifdef AFS_PTHREAD_ENV
874 for ( i=0; i<threads; i++) {
875 pthread_create(&thread[i], &tattr, client_thread, params);
876 if ( (i + 1) % RX_MAXCALLS == 0 ) {
877 conn = rx_NewConnection(addr, htons(port), RX_SERVER_ID, secureobj, secureindex);
879 struct client_data *new_params = malloc(sizeof(struct client_data));
880 memcpy(new_params, params, sizeof(struct client_data));
881 new_params->conn = conn;
887 client_thread(params);
890 #ifdef AFS_PTHREAD_ENV
891 for ( i=0; i<threads; i++)
892 pthread_join(thread[i], &status);
895 end_and_print_timer(stamp);
896 DBFPRINT(("done for good\n"));
899 rx_PrintStats(stdout);
900 rx_PrintPeerStats(stdout, conn->peer);
904 #ifdef AFS_PTHREAD_ENV
905 pthread_attr_destroy(&tattr);
916 fprintf(stderr, "usage: %s client -c send -b <bytes>\n", __progname);
917 fprintf(stderr, "usage: %s client -c recv -b <bytes>\n", __progname);
919 "usage: %s client -c rpc -S <sendbytes> -R <recvbytes>\n",
921 fprintf(stderr, "usage: %s client -c file -f filename\n", __progname);
923 "%s: usage: common option to the client "
924 "-w <write-bytes> -r <read-bytes> -T times -p port -s server -D\n",
926 fprintf(stderr, "usage: %s server -p port\n", __progname);
934 * do argument processing and call networking functions
938 rxperf_server(int argc, char **argv)
940 short port = DEFAULT_PORT;
944 int udpbufsz = 64 * 1024;
949 int minpeertimeout = 0;
953 while ((ch = getopt(argc, argv, "r:d:p:P:w:W:HNjm:u:4:s:SV")) != -1) {
957 rx_debugFile = fopen(optarg, "w");
958 if (rx_debugFile == NULL)
959 err(1, "fopen %s", optarg);
961 errx(1, "compiled without RXDEBUG");
965 rxread_size = strtol(optarg, &ptr, 0);
966 if (ptr != 0 && ptr[0] != '\0')
967 errx(1, "can't resolve readsize");
968 if (rxread_size > sizeof(somebuf))
969 errx(1, "%d > sizeof(somebuf) (%d)", rxread_size,
973 minprocs = strtol(optarg, &ptr, 0);
974 if (ptr != 0 && ptr[0] != '\0')
975 errx(1, "can't resolve minprocs");
978 maxprocs = strtol(optarg, &ptr, 0);
979 if (ptr != 0 && ptr[0] != '\0')
980 errx(1, "can't resolve maxprocs");
983 minpeertimeout = strtol(optarg, &ptr, 0);
984 if (ptr != 0 && ptr[0] != '\0')
985 errx(1, "can't resolve min peer timeout");
988 port = (short) strtol(optarg, &ptr, 0);
989 if (ptr != 0 && ptr[0] != '\0')
990 errx(1, "can't resolve portname");
993 rxwrite_size = strtol(optarg, &ptr, 0);
994 if (ptr != 0 && ptr[0] != '\0')
995 errx(1, "can't resolve writesize");
996 if (rxwrite_size > sizeof(somebuf))
997 errx(1, "%d > sizeof(somebuf) (%d)", rxwrite_size,
1010 maxmtu = strtol(optarg, &ptr, 0);
1011 if (ptr && *ptr != '\0')
1012 errx(1, "can't resolve rx maxmtu to use");
1015 udpbufsz = strtol(optarg, &ptr, 0) * 1024;
1016 if (ptr && *ptr != '\0')
1017 errx(1, "can't resolve upd buffer size (Kbytes)");
1023 maxwsize = strtol(optarg, &ptr, 0);
1024 if (ptr && *ptr != '\0')
1025 errx(1, "can't resolve max send/recv window size (packets)");
1038 do_server(port, nojumbo, maxmtu, maxwsize, minpeertimeout, udpbufsz,
1039 nostats, hotthreads, minprocs, maxprocs);
1045 * do argument processing and call networking functions
1049 rxperf_client(int argc, char **argv)
1051 char *host = DEFAULT_HOST;
1052 int bytes = DEFAULT_BYTES;
1053 short port = DEFAULT_PORT;
1054 char *filename = NULL;
1065 int udpbufsz = 64 * 1024;
1067 int minpeertimeout = 0;
1071 cmd = RX_PERF_UNKNOWN;
1073 while ((ch = getopt(argc, argv, "T:S:R:b:c:d:p:P:r:s:w:W:f:HDNjm:u:4:t:V")) != -1) {
1076 bytes = strtol(optarg, &ptr, 0);
1077 if (ptr && *ptr != '\0')
1078 errx(1, "can't resolve number of bytes to transfer");
1081 if (strcasecmp(optarg, "send") == 0)
1083 else if (strcasecmp(optarg, "recv") == 0)
1085 else if (strcasecmp(optarg, "rpc") == 0)
1087 else if (strcasecmp(optarg, "file") == 0)
1090 errx(1, "unknown command %s", optarg);
1094 rx_debugFile = fopen(optarg, "w");
1095 if (rx_debugFile == NULL)
1096 err(1, "fopen %s", optarg);
1098 errx(1, "compiled without RXDEBUG");
1102 minpeertimeout = strtol(optarg, &ptr, 0);
1103 if (ptr != 0 && ptr[0] != '\0')
1104 errx(1, "can't resolve min peer timeout");
1107 port = (short) strtol(optarg, &ptr, 0);
1108 if (ptr != 0 && ptr[0] != '\0')
1109 errx(1, "can't resolve portname");
1112 rxread_size = strtol(optarg, &ptr, 0);
1113 if (ptr != 0 && ptr[0] != '\0')
1114 errx(1, "can't resolve readsize");
1115 if (rxread_size > sizeof(somebuf))
1116 errx(1, "%d > sizeof(somebuf) (%d)", rxread_size,
1120 host = strdup(optarg);
1128 rxwrite_size = strtol(optarg, &ptr, 0);
1129 if (ptr != 0 && ptr[0] != '\0')
1130 errx(1, "can't resolve writesize");
1131 if (rxwrite_size > sizeof(somebuf))
1132 errx(1, "%d > sizeof(somebuf) (%d)", rxwrite_size,
1136 maxwsize = strtol(optarg, &ptr, 0);
1137 if (ptr && *ptr != '\0')
1138 errx(1, "can't resolve max send/recv window size (packets)");
1141 times = strtol(optarg, &ptr, 0);
1142 if (ptr && *ptr != '\0')
1143 errx(1, "can't resolve number of times to execute rpc");
1146 sendbytes = strtol(optarg, &ptr, 0);
1147 if (ptr && *ptr != '\0')
1148 errx(1, "can't resolve number of bytes to send");
1151 readbytes = strtol(optarg, &ptr, 0);
1152 if (ptr && *ptr != '\0')
1153 errx(1, "can't resolve number of bytes to receive");
1156 #ifdef AFS_PTHREAD_ENV
1157 threads = strtol(optarg, &ptr, 0);
1158 if (ptr && *ptr != '\0')
1159 errx(1, "can't resolve number of threads to execute");
1160 if (threads > MAX_THREADS)
1161 errx(1, "too many threads");
1163 errx(1, "Not built for pthreads");
1182 maxmtu = strtol(optarg, &ptr, 0);
1183 if (ptr && *ptr != '\0')
1184 errx(1, "can't resolve rx maxmtu to use");
1187 udpbufsz = strtol(optarg, &ptr, 0) * 1024;
1188 if (ptr && *ptr != '\0')
1189 errx(1, "can't resolve upd buffer size (Kbytes)");
1199 if (nostats && dumpstats)
1200 errx(1, "cannot set both -N and -D");
1202 if (threads > 1 && cmd == RX_PERF_FILE)
1203 errx(1, "cannot use multiple threads with file command");
1208 if (cmd == RX_PERF_UNKNOWN)
1209 errx(1, "no command given to the client");
1211 do_client(host, port, filename, cmd, times, bytes, sendbytes,
1212 readbytes, dumpstats, nojumbo, maxmtu, maxwsize, minpeertimeout,
1213 udpbufsz, nostats, hotthreads, threads);
1219 * setup world and call cmd
1223 main(int argc, char **argv)
1225 #ifndef AFS_PTHREAD_ENV
1229 __progname = strrchr(argv[0], '/');
1230 if (__progname == 0)
1231 __progname = argv[0];
1233 #ifndef AFS_NT40_ENV
1234 signal(SIGUSR1, sigusr1);
1235 signal(SIGINT, sigint);
1238 #ifndef AFS_PTHREAD_ENV
1239 LWP_InitializeProcessSupport(LWP_NORMAL_PRIORITY, &pid);
1242 memset(somebuf, 0, sizeof(somebuf));
1244 if (argc >= 2 && strcmp(argv[1], "server") == 0)
1245 rxperf_server(argc - 1, argv + 1);
1246 else if (argc >= 2 && strcmp(argv[1], "client") == 0)
1247 rxperf_client(argc - 1, argv + 1);