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>
47 #include <sys/types.h>
56 #include <sys/socket.h>
59 #include <netinet/in.h>
60 #include <arpa/inet.h>
79 #include <err.h> /* not stricly right, but if we have a errx() there
80 * is hopefully a err.h */
83 #include <rx/rx_null.h>
84 #include <rx/rx_globals.h>
85 #include <rx/rx_packet.h>
87 #ifdef AFS_PTHREAD_ENV
89 #define MAX_THREADS 128
92 static const char *__progname;
96 warnx(const char *fmt, ...)
101 fprintf(stderr, "%s: ", __progname);
102 vfprintf(stderr, fmt, args);
103 fprintf(stderr, "\n");
106 #endif /* !HAVE_WARNX */
110 errx(int eval, const char *fmt, ...)
115 fprintf(stderr, "%s: ", __progname);
116 vfprintf(stderr, fmt, args);
117 fprintf(stderr, "\n");
122 #endif /* !HAVE_ERRX */
126 warn(const char *fmt, ...)
132 fprintf(stderr, "%s: ", __progname);
133 vfprintf(stderr, fmt, args);
135 errstr = strerror(errno);
137 fprintf(stderr, ": %s\n", errstr ? errstr : "unknown error");
140 #endif /* !HAVE_WARN */
144 err(int eval, const char *fmt, ...)
150 fprintf(stderr, "%s: ", __progname);
151 vfprintf(stderr, fmt, args);
153 errstr = strerror(errno);
155 fprintf(stderr, ": %s\n", errstr ? errstr : "unknown error");
160 #endif /* !HAVE_ERR */
162 #define DEFAULT_PORT 7009 /* To match tcpdump */
163 #define DEFAULT_HOST "127.0.0.1"
164 #define DEFAULT_BYTES 1024 * 1024
165 #define RXPERF_BUFSIZE 512 * 1024
167 enum { RX_PERF_VERSION = 3 };
168 enum { RX_SERVER_ID = 147 };
169 enum { RX_PERF_UNKNOWN = -1,
176 enum { RXPERF_MAGIC_COOKIE = 0x4711 };
183 #define DBFPRINT(x) do { printf x ; } while(0)
191 exit(2); /* XXX profiler */
198 exit(2); /* XXX profiler */
205 static struct timeval timer_start;
206 static struct timeval timer_stop;
207 static int timer_check = 0;
213 gettimeofday(&timer_start, NULL);
221 end_and_print_timer(char *str)
223 long long start_l, stop_l;
226 assert(timer_check == 0);
227 gettimeofday(&timer_stop, NULL);
228 start_l = timer_start.tv_sec * 1000000 + timer_start.tv_usec;
229 stop_l = timer_stop.tv_sec * 1000000 + timer_stop.tv_usec;
230 printf("%s:\t%8llu msec\n", str, (stop_l - start_l) / 1000);
238 str2addr(const char *s)
240 struct in_addr server;
244 #define INADDR_NONE 0xffffffff
246 if (inet_addr(s) != INADDR_NONE)
248 h = gethostbyname(s);
250 memcpy(&server, h->h_addr_list[0], sizeof(server));
251 return server.s_addr;
262 get_sec(int serverp, struct rx_securityClass **sec, int *secureindex)
265 *sec = rxnull_NewServerSecurityObject();
268 *sec = rxnull_NewClientSecurityObject();
274 * process the "RPC" and return the results
277 char somebuf[RXPERF_BUFSIZE];
279 afs_int32 rxwrite_size = sizeof(somebuf);
280 afs_int32 rxread_size = sizeof(somebuf);
281 afs_int32 use_rx_readv = 0;
284 do_readbytes(struct rx_call *call, afs_int32 bytes)
286 struct iovec tiov[RX_MAXIOVECS];
297 if (size > RX_MAX_PACKET_DATA_SIZE)
298 size = RX_MAX_PACKET_DATA_SIZE;
299 code = rx_Readv(call, tiov, &tnio, RX_MAXIOVECS, size);
301 code = rx_Read(call, somebuf, size);
311 do_sendbytes(struct rx_call *call, afs_int32 bytes)
319 if (rx_Write(call, somebuf, size) != size)
328 rxperf_ExecuteRequest(struct rx_call *call)
337 afs_uint32 *readwrite;
341 DBFPRINT(("got a request\n"));
343 if (rx_Read32(call, &version) != 4) {
344 warn("rx_Read failed to read version");
348 if (htonl(RX_PERF_VERSION) != version) {
349 warnx("client has wrong version");
353 if (rx_Read32(call, &command) != 4) {
354 warnx("rx_Read failed to read command");
357 command = ntohl(command);
359 if (rx_Read32(call, &data) != 4) {
360 warnx("rx_Read failed to read size");
363 rxread_size = ntohl(data);
364 if (rxread_size > sizeof(somebuf)) {
365 warnx("rxread_size too large %d", rxread_size);
369 if (rx_Read32(call, &data) != 4) {
370 warnx("rx_Read failed to write size");
373 rxwrite_size = ntohl(data);
374 if (rxwrite_size > sizeof(somebuf)) {
375 warnx("rxwrite_size too large %d", rxwrite_size);
381 DBFPRINT(("got a send request\n"));
383 if (rx_Read32(call, &bytes) != 4) {
384 warnx("rx_Read failed to read bytes");
387 bytes = ntohl(bytes);
389 DBFPRINT(("reading(%d) ", bytes));
390 do_readbytes(call, bytes);
392 data = htonl(RXPERF_MAGIC_COOKIE);
393 if (rx_Write32(call, &data) != 4) {
394 warnx("rx_Write failed when sending back result");
397 DBFPRINT(("done\n"));
401 DBFPRINT(("got a rpc request, reading commands\n"));
403 if (rx_Read32(call, &recvb) != 4) {
404 warnx("rx_Read failed to read recvbytes");
407 recvb = ntohl(recvb);
408 if (rx_Read32(call, &sendb) != 4) {
409 warnx("rx_Read failed to read sendbytes");
412 sendb = ntohl(sendb);
414 DBFPRINT(("read(%d) ", recvb));
415 if (do_readbytes(call, recvb)) {
416 warnx("do_readbytes failed");
419 DBFPRINT(("send(%d) ", sendb));
420 if (do_sendbytes(call, sendb)) {
421 warnx("sendbytes failed");
425 DBFPRINT(("done\n"));
427 data = htonl(RXPERF_MAGIC_COOKIE);
428 if (rx_Write32(call, &data) != 4) {
429 warnx("rx_Write failed when sending back magic cookie");
435 if (rx_Read32(call, &data) != 4)
436 errx(1, "failed to read num from client");
439 readwrite = malloc(num * sizeof(afs_uint32));
440 if (readwrite == NULL)
443 if (rx_Read(call, (char*)readwrite, num * sizeof(afs_uint32)) !=
444 num * sizeof(afs_uint32))
445 errx(1, "failed to read recvlist from client");
447 for (i = 0; i < num; i++) {
448 if (readwrite[i] == 0) {
449 DBFPRINT(("readp %d", readwrite[i]));
453 bytes = ntohl(readwrite[i]) * sizeof(afs_uint32);
456 DBFPRINT(("read\n"));
457 do_readbytes(call, bytes);
459 do_sendbytes(call, bytes);
460 DBFPRINT(("send\n"));
466 DBFPRINT(("got a recv request\n"));
468 if (rx_Read32(call, &bytes) != 4) {
469 warnx("rx_Read failed to read bytes");
472 bytes = ntohl(bytes);
474 DBFPRINT(("sending(%d) ", bytes));
475 do_sendbytes(call, bytes);
477 data = htonl(RXPERF_MAGIC_COOKIE);
478 if (rx_Write32(call, &data) != 4) {
479 warnx("rx_Write failed when sending back result");
482 DBFPRINT(("done\n"));
486 warnx("client sent a unsupported command");
489 DBFPRINT(("done with command\n"));
499 do_server(short port, int nojumbo, int maxmtu, int maxwsize, int minpeertimeout,
500 int udpbufsz, int nostats, int hotthread,
501 int minprocs, int maxprocs)
503 struct rx_service *service;
504 struct rx_securityClass *secureobj;
509 if (afs_winsockInit() < 0) {
510 printf("Can't initialize winsock.\n");
516 rx_EnableHotThread();
521 rx_SetUdpBufSize(udpbufsz);
523 ret = rx_Init(htons(port));
525 errx(1, "rx_Init failed");
531 rx_SetMaxMTU(maxmtu);
534 rx_SetMaxReceiveWindow(maxwsize);
535 rx_SetMaxSendWindow(maxwsize);
539 rx_SetMinPeerTimeout(minpeertimeout);
542 get_sec(1, &secureobj, &secureindex);
545 rx_NewService(0, RX_SERVER_ID, "rxperf", &secureobj, secureindex,
546 rxperf_ExecuteRequest);
548 errx(1, "Cant create server");
550 rx_SetMinProcs(service, minprocs);
551 rx_SetMaxProcs(service, maxprocs);
553 rx_SetCheckReach(service, 1);
565 readfile(const char *filename, afs_uint32 ** readwrite, afs_uint32 * size)
574 *readwrite = malloc(sizeof(afs_uint32) * len);
575 buf = malloc(RXPERF_BUFSIZE);
577 if (*readwrite == NULL)
580 f = fopen(filename, "r");
584 while (fgets(buf, sizeof(buf), f) != NULL) {
587 *readwrite = realloc(*readwrite, len * sizeof(afs_uint32));
588 if (*readwrite == NULL)
593 data = htonl(strtol(buf, &ptr, 0));
594 if (ptr && ptr == buf)
595 errx(1, "can't resolve number of bytes to transfer");
600 (*readwrite)[num] = data;
613 struct rx_connection *conn;
623 client_thread( void *vparams)
625 struct client_data *params = (struct client_data *)vparams;
626 struct rx_call *call;
629 afs_uint32 *readwrite;
634 for (i = 0; i < params->times; i++) {
636 DBFPRINT(("starting command "));
638 call = rx_NewCall(params->conn);
640 errx(1, "rx_NewCall failed");
642 data = htonl(RX_PERF_VERSION);
643 if (rx_Write32(call, &data) != 4)
644 errx(1, "rx_Write failed to send version (err %d)", rx_Error(call));
646 data = htonl(params->command);
647 if (rx_Write32(call, &data) != 4)
648 errx(1, "rx_Write failed to send command (err %d)", rx_Error(call));
650 data = htonl(rxread_size);
651 if (rx_Write32(call, &data) != 4)
652 errx(1, "rx_Write failed to send read size (err %d)", rx_Error(call));
653 data = htonl(rxwrite_size);
654 if (rx_Write32(call, &data) != 4)
655 errx(1, "rx_Write failed to send write read (err %d)", rx_Error(call));
658 switch (params->command) {
660 DBFPRINT(("command "));
662 data = htonl(params->bytes);
663 if (rx_Write32(call, &data) != 4)
664 errx(1, "rx_Write failed to send size (err %d)", rx_Error(call));
666 DBFPRINT(("sending(%d) ", params->bytes));
667 if (do_readbytes(call, params->bytes))
668 errx(1, "sendbytes (err %d)", rx_Error(call));
670 if (rx_Read32(call, &data) != 4)
671 errx(1, "failed to read result from server (err %d)", rx_Error(call));
673 if (data != htonl(RXPERF_MAGIC_COOKIE))
674 warn("server send wrong magic cookie in responce");
676 DBFPRINT(("done\n"));
680 DBFPRINT(("command "));
682 data = htonl(params->bytes);
683 if (rx_Write32(call, &data) != 4)
684 errx(1, "rx_Write failed to send size (err %d)", rx_Error(call));
686 DBFPRINT(("sending(%d) ", params->bytes));
687 if (do_sendbytes(call, params->bytes))
688 errx(1, "sendbytes (err %d)", rx_Error(call));
690 if (rx_Read32(call, &data) != 4)
691 errx(1, "failed to read result from server (err %d)", rx_Error(call));
693 if (data != htonl(RXPERF_MAGIC_COOKIE))
694 warn("server send wrong magic cookie in responce");
696 DBFPRINT(("done\n"));
700 DBFPRINT(("commands "));
702 data = htonl(params->sendbytes);
703 if (rx_Write32(call, &data) != 4)
704 errx(1, "rx_Write failed to send command (err %d)", rx_Error(call));
706 data = htonl(params->readbytes);
707 if (rx_Write32(call, &data) != 4)
708 errx(1, "rx_Write failed to send command (err %d)", rx_Error(call));
710 DBFPRINT(("send(%d) ", params->sendbytes));
711 if (do_sendbytes(call, params->sendbytes))
712 errx(1, "sendbytes (err %d)", rx_Error(call));
714 DBFPRINT(("recv(%d) ", params->readbytes));
715 if (do_readbytes(call, params->readbytes))
716 errx(1, "sendbytes (err %d)", rx_Error(call));
718 if (rx_Read32(call, &data) != 4)
719 errx(1, "failed to read result from server (err %d)", rx_Error(call));
721 if (data != htonl(RXPERF_MAGIC_COOKIE))
722 warn("server send wrong magic cookie in responce");
724 DBFPRINT(("done\n"));
729 readfile(params->filename, &readwrite, &num);
732 if (rx_Write32(call, &data) != 4)
733 errx(1, "rx_Write failed to send size (err %d)", rx_Error(call));
735 if (rx_Write(call, (char *)readwrite, num * sizeof(afs_uint32))
736 != num * sizeof(afs_uint32))
737 errx(1, "rx_Write failed to send list (err %d)", rx_Error(call));
739 for (j = 0; j < num; j++) {
740 if (readwrite[j] == 0)
743 size = ntohl(readwrite[j]) * sizeof(afs_uint32);
746 if (do_readbytes(call, size))
747 errx(1, "sendbytes (err %d)", rx_Error(call));
748 DBFPRINT(("read\n"));
750 if (do_sendbytes(call, size))
751 errx(1, "sendbytes (err %d)", rx_Error(call));
752 DBFPRINT(("send\n"));
763 #ifdef AFS_PTHREAD_ENV
775 do_client(const char *server, short port, char *filename, afs_int32 command,
776 afs_int32 times, afs_int32 bytes, afs_int32 sendbytes, afs_int32 readbytes,
777 int dumpstats, int nojumbo, int maxmtu, int maxwsize, int minpeertimeout,
778 int udpbufsz, int nostats, int hotthread, int threads)
780 struct rx_connection *conn;
782 struct rx_securityClass *secureobj;
786 struct client_data *params;
788 #ifdef AFS_PTHREAD_ENV
790 pthread_t thread[MAX_THREADS];
791 pthread_attr_t tattr;
795 params = malloc(sizeof(struct client_data));
796 memset(params, 0, sizeof(struct client_data));
799 if (afs_winsockInit() < 0) {
800 printf("Can't initialize winsock.\n");
806 rx_EnableHotThread();
811 addr = str2addr(server);
813 rx_SetUdpBufSize(udpbufsz);
817 errx(1, "rx_Init failed");
823 rx_SetMaxMTU(maxmtu);
826 rx_SetMaxReceiveWindow(maxwsize);
827 rx_SetMaxSendWindow(maxwsize);
831 rx_SetMinPeerTimeout(minpeertimeout);
834 get_sec(0, &secureobj, &secureindex);
838 sprintf(stamp, "RPC: threads\t%d, times\t%d, write bytes\t%d, read bytes\t%d",
839 threads, times, sendbytes, readbytes);
842 sprintf(stamp, "RECV: threads\t%d, times\t%d, bytes\t%d",
843 threads, times, bytes);
846 sprintf(stamp, "SEND: threads\t%d, times\t%d, bytes\t%d",
847 threads, times, bytes);
850 sprintf(stamp, "FILE %s: threads\t%d, times\t%d, bytes\t%d",
851 filename, threads, times, bytes);
855 conn = rx_NewConnection(addr, htons(port), RX_SERVER_ID, secureobj, secureindex);
857 errx(1, "failed to contact server");
859 #ifdef AFS_PTHREAD_ENV
860 pthread_attr_init(&tattr);
861 pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_JOINABLE);
865 params->filename = filename;
866 params->command = command;
867 params->times = times;
868 params->bytes = bytes;
869 params->sendbytes = sendbytes;
870 params->readbytes = readbytes;
874 #ifdef AFS_PTHREAD_ENV
875 for ( i=0; i<threads; i++) {
876 pthread_create(&thread[i], &tattr, client_thread, params);
877 if ( (i + 1) % RX_MAXCALLS == 0 ) {
878 conn = rx_NewConnection(addr, htons(port), RX_SERVER_ID, secureobj, secureindex);
880 struct client_data *new_params = malloc(sizeof(struct client_data));
881 memcpy(new_params, params, sizeof(struct client_data));
882 new_params->conn = conn;
888 client_thread(params);
891 #ifdef AFS_PTHREAD_ENV
892 for ( i=0; i<threads; i++)
893 pthread_join(thread[i], &status);
896 end_and_print_timer(stamp);
897 DBFPRINT(("done for good\n"));
900 rx_PrintStats(stdout);
901 rx_PrintPeerStats(stdout, rx_PeerOf(conn));
905 #ifdef AFS_PTHREAD_ENV
906 pthread_attr_destroy(&tattr);
917 fprintf(stderr, "usage: %s client -c send -b <bytes>\n", __progname);
918 fprintf(stderr, "usage: %s client -c recv -b <bytes>\n", __progname);
920 "usage: %s client -c rpc -S <sendbytes> -R <recvbytes>\n",
922 fprintf(stderr, "usage: %s client -c file -f filename\n", __progname);
924 "%s: usage: common option to the client "
925 "-w <write-bytes> -r <read-bytes> -T times -p port -s server -D\n",
927 fprintf(stderr, "usage: %s server -p port\n", __progname);
935 * do argument processing and call networking functions
939 rxperf_server(int argc, char **argv)
941 short port = DEFAULT_PORT;
945 int udpbufsz = 64 * 1024;
950 int minpeertimeout = 0;
954 while ((ch = getopt(argc, argv, "r:d:p:P:w:W:HNjm:u:4:s:S:V")) != -1) {
958 rx_debugFile = fopen(optarg, "w");
959 if (rx_debugFile == NULL)
960 err(1, "fopen %s", optarg);
962 errx(1, "compiled without RXDEBUG");
966 rxread_size = strtol(optarg, &ptr, 0);
967 if (ptr != 0 && ptr[0] != '\0')
968 errx(1, "can't resolve readsize");
969 if (rxread_size > sizeof(somebuf))
970 errx(1, "%d > sizeof(somebuf) (%d)", rxread_size,
974 minprocs = strtol(optarg, &ptr, 0);
975 if (ptr != 0 && ptr[0] != '\0')
976 errx(1, "can't resolve minprocs");
979 maxprocs = strtol(optarg, &ptr, 0);
980 if (ptr != 0 && ptr[0] != '\0')
981 errx(1, "can't resolve maxprocs");
984 minpeertimeout = strtol(optarg, &ptr, 0);
985 if (ptr != 0 && ptr[0] != '\0')
986 errx(1, "can't resolve min peer timeout");
989 port = (short) strtol(optarg, &ptr, 0);
990 if (ptr != 0 && ptr[0] != '\0')
991 errx(1, "can't resolve portname");
994 rxwrite_size = strtol(optarg, &ptr, 0);
995 if (ptr != 0 && ptr[0] != '\0')
996 errx(1, "can't resolve writesize");
997 if (rxwrite_size > sizeof(somebuf))
998 errx(1, "%d > sizeof(somebuf) (%d)", rxwrite_size,
1011 maxmtu = strtol(optarg, &ptr, 0);
1012 if (ptr && *ptr != '\0')
1013 errx(1, "can't resolve rx maxmtu to use");
1016 udpbufsz = strtol(optarg, &ptr, 0) * 1024;
1017 if (ptr && *ptr != '\0')
1018 errx(1, "can't resolve upd buffer size (Kbytes)");
1024 maxwsize = strtol(optarg, &ptr, 0);
1025 if (ptr && *ptr != '\0')
1026 errx(1, "can't resolve max send/recv window size (packets)");
1039 do_server(port, nojumbo, maxmtu, maxwsize, minpeertimeout, udpbufsz,
1040 nostats, hotthreads, minprocs, maxprocs);
1046 * do argument processing and call networking functions
1050 rxperf_client(int argc, char **argv)
1052 char *host = DEFAULT_HOST;
1053 int bytes = DEFAULT_BYTES;
1054 short port = DEFAULT_PORT;
1055 char *filename = NULL;
1066 int udpbufsz = 64 * 1024;
1068 int minpeertimeout = 0;
1072 cmd = RX_PERF_UNKNOWN;
1074 while ((ch = getopt(argc, argv, "T:S:R:b:c:d:p:P:r:s:w:W:f:HDNjm:u:4:t:V")) != -1) {
1077 bytes = strtol(optarg, &ptr, 0);
1078 if (ptr && *ptr != '\0')
1079 errx(1, "can't resolve number of bytes to transfer");
1082 if (strcasecmp(optarg, "send") == 0)
1084 else if (strcasecmp(optarg, "recv") == 0)
1086 else if (strcasecmp(optarg, "rpc") == 0)
1088 else if (strcasecmp(optarg, "file") == 0)
1091 errx(1, "unknown command %s", optarg);
1095 rx_debugFile = fopen(optarg, "w");
1096 if (rx_debugFile == NULL)
1097 err(1, "fopen %s", optarg);
1099 errx(1, "compiled without RXDEBUG");
1103 minpeertimeout = strtol(optarg, &ptr, 0);
1104 if (ptr != 0 && ptr[0] != '\0')
1105 errx(1, "can't resolve min peer timeout");
1108 port = (short) strtol(optarg, &ptr, 0);
1109 if (ptr != 0 && ptr[0] != '\0')
1110 errx(1, "can't resolve portname");
1113 rxread_size = strtol(optarg, &ptr, 0);
1114 if (ptr != 0 && ptr[0] != '\0')
1115 errx(1, "can't resolve readsize");
1116 if (rxread_size > sizeof(somebuf))
1117 errx(1, "%d > sizeof(somebuf) (%d)", rxread_size,
1121 host = strdup(optarg);
1129 rxwrite_size = strtol(optarg, &ptr, 0);
1130 if (ptr != 0 && ptr[0] != '\0')
1131 errx(1, "can't resolve writesize");
1132 if (rxwrite_size > sizeof(somebuf))
1133 errx(1, "%d > sizeof(somebuf) (%d)", rxwrite_size,
1137 maxwsize = strtol(optarg, &ptr, 0);
1138 if (ptr && *ptr != '\0')
1139 errx(1, "can't resolve max send/recv window size (packets)");
1142 times = strtol(optarg, &ptr, 0);
1143 if (ptr && *ptr != '\0')
1144 errx(1, "can't resolve number of times to execute rpc");
1147 sendbytes = strtol(optarg, &ptr, 0);
1148 if (ptr && *ptr != '\0')
1149 errx(1, "can't resolve number of bytes to send");
1152 readbytes = strtol(optarg, &ptr, 0);
1153 if (ptr && *ptr != '\0')
1154 errx(1, "can't resolve number of bytes to receive");
1157 #ifdef AFS_PTHREAD_ENV
1158 threads = strtol(optarg, &ptr, 0);
1159 if (ptr && *ptr != '\0')
1160 errx(1, "can't resolve number of threads to execute");
1161 if (threads > MAX_THREADS)
1162 errx(1, "too many threads");
1164 errx(1, "Not built for pthreads");
1183 maxmtu = strtol(optarg, &ptr, 0);
1184 if (ptr && *ptr != '\0')
1185 errx(1, "can't resolve rx maxmtu to use");
1188 udpbufsz = strtol(optarg, &ptr, 0) * 1024;
1189 if (ptr && *ptr != '\0')
1190 errx(1, "can't resolve upd buffer size (Kbytes)");
1200 if (nostats && dumpstats)
1201 errx(1, "cannot set both -N and -D");
1203 if (threads > 1 && cmd == RX_PERF_FILE)
1204 errx(1, "cannot use multiple threads with file command");
1209 if (cmd == RX_PERF_UNKNOWN)
1210 errx(1, "no command given to the client");
1212 do_client(host, port, filename, cmd, times, bytes, sendbytes,
1213 readbytes, dumpstats, nojumbo, maxmtu, maxwsize, minpeertimeout,
1214 udpbufsz, nostats, hotthreads, threads);
1220 * setup world and call cmd
1224 main(int argc, char **argv)
1226 #ifndef AFS_PTHREAD_ENV
1230 __progname = strrchr(argv[0], '/');
1231 if (__progname == 0)
1232 __progname = argv[0];
1234 #ifndef AFS_NT40_ENV
1235 signal(SIGUSR1, sigusr1);
1236 signal(SIGINT, sigint);
1239 #ifndef AFS_PTHREAD_ENV
1240 LWP_InitializeProcessSupport(LWP_NORMAL_PRIORITY, &pid);
1243 memset(somebuf, 0, sizeof(somebuf));
1245 if (argc >= 2 && strcmp(argv[1], "server") == 0)
1246 rxperf_server(argc - 1, argv + 1);
1247 else if (argc >= 2 && strcmp(argv[1], "client") == 0)
1248 rxperf_client(argc - 1, argv + 1);