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 static const char *__progname;
66 warnx(const char *fmt, ...)
71 fprintf(stderr, "%s: ", __progname);
72 vfprintf(stderr, fmt, args);
73 fprintf(stderr, "\n");
76 #endif /* !HAVE_WARNX */
80 errx(int eval, const char *fmt, ...)
85 fprintf(stderr, "%s: ", __progname);
86 vfprintf(stderr, fmt, args);
87 fprintf(stderr, "\n");
92 #endif /* !HAVE_ERRX */
96 warn(const char *fmt, ...)
102 fprintf(stderr, "%s: ", __progname);
103 vfprintf(stderr, fmt, args);
105 errstr = strerror(errno);
107 fprintf(stderr, ": %s\n", errstr ? errstr : "unknown error");
110 #endif /* !HAVE_WARN */
114 err(int eval, const char *fmt, ...)
120 fprintf(stderr, "%s: ", __progname);
121 vfprintf(stderr, fmt, args);
123 errstr = strerror(errno);
125 fprintf(stderr, ": %s\n", errstr ? errstr : "unknown error");
130 #endif /* !HAVE_ERR */
132 #define DEFAULT_PORT 7009 /* To match tcpdump */
133 #define DEFAULT_HOST "127.0.0.1"
134 #define DEFAULT_BYTES 1024 * 1024
135 #define RXPERF_BUFSIZE 512 * 1024
137 enum { RX_PERF_VERSION = 3 };
138 enum { RX_SERVER_ID = 147 };
139 enum { RX_PERF_UNKNOWN = -1,
146 enum { RXPERF_MAGIC_COOKIE = 0x4711 };
153 #define DBFPRINT(x) do { printf x ; } while(0)
161 exit(2); /* XXX profiler */
168 exit(2); /* XXX profiler */
175 static struct timeval timer_start;
176 static struct timeval timer_stop;
177 static int timer_check = 0;
183 gettimeofday(&timer_start, NULL);
191 end_and_print_timer(char *str)
193 long long start_l, stop_l;
196 assert(timer_check == 0);
197 gettimeofday(&timer_stop, NULL);
198 start_l = timer_start.tv_sec * 1000000 + timer_start.tv_usec;
199 stop_l = timer_stop.tv_sec * 1000000 + timer_stop.tv_usec;
200 printf("%s:\t%8llu msec\n", str, (stop_l - start_l) / 1000);
208 str2addr(const char *s)
210 struct in_addr server;
214 #define INADDR_NONE 0xffffffff
216 if (inet_addr(s) != INADDR_NONE)
218 h = gethostbyname(s);
220 memcpy(&server, h->h_addr_list[0], sizeof(server));
221 return server.s_addr;
232 get_sec(int serverp, struct rx_securityClass **sec, int *secureindex)
235 *sec = rxnull_NewServerSecurityObject();
238 *sec = rxnull_NewClientSecurityObject();
244 * process the "RPC" and return the results
247 char somebuf[RXPERF_BUFSIZE];
249 afs_int32 rxwrite_size = sizeof(somebuf);
250 afs_int32 rxread_size = sizeof(somebuf);
251 afs_int32 use_rx_readv = 0;
254 do_readbytes(struct rx_call *call, afs_int32 bytes)
256 struct iovec tiov[RX_MAXIOVECS];
267 if (size > RX_MAX_PACKET_DATA_SIZE)
268 size = RX_MAX_PACKET_DATA_SIZE;
269 code = rx_Readv(call, tiov, &tnio, RX_MAXIOVECS, size);
271 code = rx_Read(call, somebuf, size);
281 do_sendbytes(struct rx_call *call, afs_int32 bytes)
289 if (rx_Write(call, somebuf, size) != size)
298 rxperf_ExecuteRequest(struct rx_call *call)
307 afs_uint32 *readwrite;
311 DBFPRINT(("got a request\n"));
313 if (rx_Read32(call, &version) != 4) {
314 warn("rx_Read failed to read version");
318 if (htonl(RX_PERF_VERSION) != version) {
319 warnx("client has wrong version");
323 if (rx_Read32(call, &command) != 4) {
324 warnx("rx_Read failed to read command");
327 command = ntohl(command);
329 if (rx_Read32(call, &data) != 4) {
330 warnx("rx_Read failed to read size");
333 rxread_size = ntohl(data);
334 if (rxread_size > sizeof(somebuf)) {
335 warnx("rxread_size too large %d", rxread_size);
339 if (rx_Read32(call, &data) != 4) {
340 warnx("rx_Read failed to write size");
343 rxwrite_size = ntohl(data);
344 if (rxwrite_size > sizeof(somebuf)) {
345 warnx("rxwrite_size too large %d", rxwrite_size);
351 DBFPRINT(("got a send request\n"));
353 if (rx_Read32(call, &bytes) != 4) {
354 warnx("rx_Read failed to read bytes");
357 bytes = ntohl(bytes);
359 DBFPRINT(("reading(%d) ", bytes));
360 do_readbytes(call, bytes);
362 data = htonl(RXPERF_MAGIC_COOKIE);
363 if (rx_Write32(call, &data) != 4) {
364 warnx("rx_Write failed when sending back result");
367 DBFPRINT(("done\n"));
371 DBFPRINT(("got a rpc request, reading commands\n"));
373 if (rx_Read32(call, &recvb) != 4) {
374 warnx("rx_Read failed to read recvbytes");
377 recvb = ntohl(recvb);
378 if (rx_Read32(call, &sendb) != 4) {
379 warnx("rx_Read failed to read sendbytes");
382 sendb = ntohl(sendb);
384 DBFPRINT(("read(%d) ", recvb));
385 if (do_readbytes(call, recvb)) {
386 warnx("do_readbytes failed");
389 DBFPRINT(("send(%d) ", sendb));
390 if (do_sendbytes(call, sendb)) {
391 warnx("sendbytes failed");
395 DBFPRINT(("done\n"));
397 data = htonl(RXPERF_MAGIC_COOKIE);
398 if (rx_Write32(call, &data) != 4) {
399 warnx("rx_Write failed when sending back magic cookie");
405 if (rx_Read32(call, &data) != 4)
406 errx(1, "failed to read num from client");
409 readwrite = malloc(num * sizeof(afs_uint32));
410 if (readwrite == NULL)
413 if (rx_Read(call, (char*)readwrite, num * sizeof(afs_uint32)) !=
414 num * sizeof(afs_uint32))
415 errx(1, "failed to read recvlist from client");
417 for (i = 0; i < num; i++) {
418 if (readwrite[i] == 0) {
419 DBFPRINT(("readp %d", readwrite[i]));
423 bytes = ntohl(readwrite[i]) * sizeof(afs_uint32);
426 DBFPRINT(("read\n"));
427 do_readbytes(call, bytes);
429 do_sendbytes(call, bytes);
430 DBFPRINT(("send\n"));
436 DBFPRINT(("got a recv request\n"));
438 if (rx_Read32(call, &bytes) != 4) {
439 warnx("rx_Read failed to read bytes");
442 bytes = ntohl(bytes);
444 DBFPRINT(("sending(%d) ", bytes));
445 do_sendbytes(call, bytes);
447 data = htonl(RXPERF_MAGIC_COOKIE);
448 if (rx_Write32(call, &data) != 4) {
449 warnx("rx_Write failed when sending back result");
452 DBFPRINT(("done\n"));
456 warnx("client sent a unsupported command");
459 DBFPRINT(("done with command\n"));
469 do_server(short port, int nojumbo, int maxmtu, int maxwsize, int minpeertimeout,
470 int udpbufsz, int nostats, int hotthread,
471 int minprocs, int maxprocs)
473 struct rx_service *service;
474 struct rx_securityClass *secureobj;
479 if (afs_winsockInit() < 0) {
480 printf("Can't initialize winsock.\n");
486 rx_EnableHotThread();
491 rx_SetUdpBufSize(udpbufsz);
493 ret = rx_Init(htons(port));
495 errx(1, "rx_Init failed");
501 rx_SetMaxMTU(maxmtu);
504 rx_SetMaxReceiveWindow(maxwsize);
505 rx_SetMaxSendWindow(maxwsize);
509 rx_SetMinPeerTimeout(minpeertimeout);
512 get_sec(1, &secureobj, &secureindex);
515 rx_NewService(0, RX_SERVER_ID, "rxperf", &secureobj, secureindex,
516 rxperf_ExecuteRequest);
518 errx(1, "Cant create server");
520 rx_SetMinProcs(service, minprocs);
521 rx_SetMaxProcs(service, maxprocs);
523 rx_SetCheckReach(service, 1);
535 readfile(const char *filename, afs_uint32 ** readwrite, afs_uint32 * size)
544 *readwrite = malloc(sizeof(afs_uint32) * len);
545 buf = malloc(RXPERF_BUFSIZE);
547 if (*readwrite == NULL)
550 f = fopen(filename, "r");
554 while (fgets(buf, sizeof(buf), f) != NULL) {
557 *readwrite = realloc(*readwrite, len * sizeof(afs_uint32));
558 if (*readwrite == NULL)
563 data = htonl(strtol(buf, &ptr, 0));
564 if (ptr && ptr == buf)
565 errx(1, "can't resolve number of bytes to transfer");
570 (*readwrite)[num] = data;
583 struct rx_connection *conn;
593 client_thread( void *vparams)
595 struct client_data *params = (struct client_data *)vparams;
596 struct rx_call *call;
599 afs_uint32 *readwrite;
604 for (i = 0; i < params->times; i++) {
606 DBFPRINT(("starting command "));
608 call = rx_NewCall(params->conn);
610 errx(1, "rx_NewCall failed");
612 data = htonl(RX_PERF_VERSION);
613 if (rx_Write32(call, &data) != 4)
614 errx(1, "rx_Write failed to send version (err %d)", rx_Error(call));
616 data = htonl(params->command);
617 if (rx_Write32(call, &data) != 4)
618 errx(1, "rx_Write failed to send command (err %d)", rx_Error(call));
620 data = htonl(rxread_size);
621 if (rx_Write32(call, &data) != 4)
622 errx(1, "rx_Write failed to send read size (err %d)", rx_Error(call));
623 data = htonl(rxwrite_size);
624 if (rx_Write32(call, &data) != 4)
625 errx(1, "rx_Write failed to send write read (err %d)", rx_Error(call));
628 switch (params->command) {
630 DBFPRINT(("command "));
632 data = htonl(params->bytes);
633 if (rx_Write32(call, &data) != 4)
634 errx(1, "rx_Write failed to send size (err %d)", rx_Error(call));
636 DBFPRINT(("sending(%d) ", params->bytes));
637 if (do_readbytes(call, params->bytes))
638 errx(1, "sendbytes (err %d)", rx_Error(call));
640 if (rx_Read32(call, &data) != 4)
641 errx(1, "failed to read result from server (err %d)", rx_Error(call));
643 if (data != htonl(RXPERF_MAGIC_COOKIE))
644 warn("server send wrong magic cookie in responce");
646 DBFPRINT(("done\n"));
650 DBFPRINT(("command "));
652 data = htonl(params->bytes);
653 if (rx_Write32(call, &data) != 4)
654 errx(1, "rx_Write failed to send size (err %d)", rx_Error(call));
656 DBFPRINT(("sending(%d) ", params->bytes));
657 if (do_sendbytes(call, params->bytes))
658 errx(1, "sendbytes (err %d)", rx_Error(call));
660 if (rx_Read32(call, &data) != 4)
661 errx(1, "failed to read result from server (err %d)", rx_Error(call));
663 if (data != htonl(RXPERF_MAGIC_COOKIE))
664 warn("server send wrong magic cookie in responce");
666 DBFPRINT(("done\n"));
670 DBFPRINT(("commands "));
672 data = htonl(params->sendbytes);
673 if (rx_Write32(call, &data) != 4)
674 errx(1, "rx_Write failed to send command (err %d)", rx_Error(call));
676 data = htonl(params->readbytes);
677 if (rx_Write32(call, &data) != 4)
678 errx(1, "rx_Write failed to send command (err %d)", rx_Error(call));
680 DBFPRINT(("send(%d) ", params->sendbytes));
681 if (do_sendbytes(call, params->sendbytes))
682 errx(1, "sendbytes (err %d)", rx_Error(call));
684 DBFPRINT(("recv(%d) ", params->readbytes));
685 if (do_readbytes(call, params->readbytes))
686 errx(1, "sendbytes (err %d)", rx_Error(call));
688 if (rx_Read32(call, &data) != 4)
689 errx(1, "failed to read result from server (err %d)", rx_Error(call));
691 if (data != htonl(RXPERF_MAGIC_COOKIE))
692 warn("server send wrong magic cookie in responce");
694 DBFPRINT(("done\n"));
699 readfile(params->filename, &readwrite, &num);
702 if (rx_Write32(call, &data) != 4)
703 errx(1, "rx_Write failed to send size (err %d)", rx_Error(call));
705 if (rx_Write(call, (char *)readwrite, num * sizeof(afs_uint32))
706 != num * sizeof(afs_uint32))
707 errx(1, "rx_Write failed to send list (err %d)", rx_Error(call));
709 for (j = 0; j < num; j++) {
710 if (readwrite[j] == 0)
713 size = ntohl(readwrite[j]) * sizeof(afs_uint32);
716 if (do_readbytes(call, size))
717 errx(1, "sendbytes (err %d)", rx_Error(call));
718 DBFPRINT(("read\n"));
720 if (do_sendbytes(call, size))
721 errx(1, "sendbytes (err %d)", rx_Error(call));
722 DBFPRINT(("send\n"));
733 #ifdef AFS_PTHREAD_ENV
745 do_client(const char *server, short port, char *filename, afs_int32 command,
746 afs_int32 times, afs_int32 bytes, afs_int32 sendbytes, afs_int32 readbytes,
747 int dumpstats, int nojumbo, int maxmtu, int maxwsize, int minpeertimeout,
748 int udpbufsz, int nostats, int hotthread, int threads)
750 struct rx_connection *conn;
752 struct rx_securityClass *secureobj;
756 struct client_data *params;
758 #ifdef AFS_PTHREAD_ENV
760 pthread_t thread[MAX_THREADS];
761 pthread_attr_t tattr;
765 params = malloc(sizeof(struct client_data));
766 memset(params, 0, sizeof(struct client_data));
769 if (afs_winsockInit() < 0) {
770 printf("Can't initialize winsock.\n");
776 rx_EnableHotThread();
781 addr = str2addr(server);
783 rx_SetUdpBufSize(udpbufsz);
787 errx(1, "rx_Init failed");
793 rx_SetMaxMTU(maxmtu);
796 rx_SetMaxReceiveWindow(maxwsize);
797 rx_SetMaxSendWindow(maxwsize);
801 rx_SetMinPeerTimeout(minpeertimeout);
804 get_sec(0, &secureobj, &secureindex);
808 sprintf(stamp, "RPC: threads\t%d, times\t%d, write bytes\t%d, read bytes\t%d",
809 threads, times, sendbytes, readbytes);
812 sprintf(stamp, "RECV: threads\t%d, times\t%d, bytes\t%d",
813 threads, times, bytes);
816 sprintf(stamp, "SEND: threads\t%d, times\t%d, bytes\t%d",
817 threads, times, bytes);
820 sprintf(stamp, "FILE %s: threads\t%d, times\t%d, bytes\t%d",
821 filename, threads, times, bytes);
825 conn = rx_NewConnection(addr, htons(port), RX_SERVER_ID, secureobj, secureindex);
827 errx(1, "failed to contact server");
829 #ifdef AFS_PTHREAD_ENV
830 pthread_attr_init(&tattr);
831 pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_JOINABLE);
835 params->filename = filename;
836 params->command = command;
837 params->times = times;
838 params->bytes = bytes;
839 params->sendbytes = sendbytes;
840 params->readbytes = readbytes;
844 #ifdef AFS_PTHREAD_ENV
845 for ( i=0; i<threads; i++) {
846 pthread_create(&thread[i], &tattr, client_thread, params);
847 if ( (i + 1) % RX_MAXCALLS == 0 ) {
848 conn = rx_NewConnection(addr, htons(port), RX_SERVER_ID, secureobj, secureindex);
850 struct client_data *new_params = malloc(sizeof(struct client_data));
851 memcpy(new_params, params, sizeof(struct client_data));
852 new_params->conn = conn;
858 client_thread(params);
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, rx_PeerOf(conn));
875 #ifdef AFS_PTHREAD_ENV
876 pthread_attr_destroy(&tattr);
887 fprintf(stderr, "usage: %s client -c send -b <bytes>\n", __progname);
888 fprintf(stderr, "usage: %s client -c recv -b <bytes>\n", __progname);
890 "usage: %s client -c rpc -S <sendbytes> -R <recvbytes>\n",
892 fprintf(stderr, "usage: %s client -c file -f filename\n", __progname);
894 "%s: usage: common option to the client "
895 "-w <write-bytes> -r <read-bytes> -T times -p port -s server -D\n",
897 fprintf(stderr, "usage: %s server -p port\n", __progname);
905 * do argument processing and call networking functions
909 rxperf_server(int argc, char **argv)
911 short port = DEFAULT_PORT;
915 int udpbufsz = 64 * 1024;
920 int minpeertimeout = 0;
924 while ((ch = getopt(argc, argv, "r:d:p:P:w:W:HNjm:u:4:s:S:V")) != -1) {
928 rx_debugFile = fopen(optarg, "w");
929 if (rx_debugFile == NULL)
930 err(1, "fopen %s", optarg);
932 errx(1, "compiled without RXDEBUG");
936 rxread_size = strtol(optarg, &ptr, 0);
937 if (ptr != 0 && ptr[0] != '\0')
938 errx(1, "can't resolve readsize");
939 if (rxread_size > sizeof(somebuf))
940 errx(1, "%d > sizeof(somebuf) (%"AFS_SIZET_FMT")", rxread_size,
944 minprocs = strtol(optarg, &ptr, 0);
945 if (ptr != 0 && ptr[0] != '\0')
946 errx(1, "can't resolve minprocs");
949 maxprocs = strtol(optarg, &ptr, 0);
950 if (ptr != 0 && ptr[0] != '\0')
951 errx(1, "can't resolve maxprocs");
954 minpeertimeout = strtol(optarg, &ptr, 0);
955 if (ptr != 0 && ptr[0] != '\0')
956 errx(1, "can't resolve min peer timeout");
959 port = (short) strtol(optarg, &ptr, 0);
960 if (ptr != 0 && ptr[0] != '\0')
961 errx(1, "can't resolve portname");
964 rxwrite_size = strtol(optarg, &ptr, 0);
965 if (ptr != 0 && ptr[0] != '\0')
966 errx(1, "can't resolve writesize");
967 if (rxwrite_size > sizeof(somebuf))
968 errx(1, "%d > sizeof(somebuf) (%"AFS_SIZET_FMT")", rxwrite_size,
981 maxmtu = strtol(optarg, &ptr, 0);
982 if (ptr && *ptr != '\0')
983 errx(1, "can't resolve rx maxmtu to use");
986 udpbufsz = strtol(optarg, &ptr, 0) * 1024;
987 if (ptr && *ptr != '\0')
988 errx(1, "can't resolve upd buffer size (Kbytes)");
994 maxwsize = strtol(optarg, &ptr, 0);
995 if (ptr && *ptr != '\0')
996 errx(1, "can't resolve max send/recv window size (packets)");
1009 do_server(port, nojumbo, maxmtu, maxwsize, minpeertimeout, udpbufsz,
1010 nostats, hotthreads, minprocs, maxprocs);
1016 * do argument processing and call networking functions
1020 rxperf_client(int argc, char **argv)
1022 char *host = DEFAULT_HOST;
1023 int bytes = DEFAULT_BYTES;
1024 short port = DEFAULT_PORT;
1025 char *filename = NULL;
1036 int udpbufsz = 64 * 1024;
1038 int minpeertimeout = 0;
1042 cmd = RX_PERF_UNKNOWN;
1044 while ((ch = getopt(argc, argv, "T:S:R:b:c:d:p:P:r:s:w:W:f:HDNjm:u:4:t:V")) != -1) {
1047 bytes = strtol(optarg, &ptr, 0);
1048 if (ptr && *ptr != '\0')
1049 errx(1, "can't resolve number of bytes to transfer");
1052 if (strcasecmp(optarg, "send") == 0)
1054 else if (strcasecmp(optarg, "recv") == 0)
1056 else if (strcasecmp(optarg, "rpc") == 0)
1058 else if (strcasecmp(optarg, "file") == 0)
1061 errx(1, "unknown command %s", optarg);
1065 rx_debugFile = fopen(optarg, "w");
1066 if (rx_debugFile == NULL)
1067 err(1, "fopen %s", optarg);
1069 errx(1, "compiled without RXDEBUG");
1073 minpeertimeout = strtol(optarg, &ptr, 0);
1074 if (ptr != 0 && ptr[0] != '\0')
1075 errx(1, "can't resolve min peer timeout");
1078 port = (short) strtol(optarg, &ptr, 0);
1079 if (ptr != 0 && ptr[0] != '\0')
1080 errx(1, "can't resolve portname");
1083 rxread_size = strtol(optarg, &ptr, 0);
1084 if (ptr != 0 && ptr[0] != '\0')
1085 errx(1, "can't resolve readsize");
1086 if (rxread_size > sizeof(somebuf))
1087 errx(1, "%d > sizeof(somebuf) (%"AFS_SIZET_FMT")", rxread_size,
1091 host = strdup(optarg);
1099 rxwrite_size = strtol(optarg, &ptr, 0);
1100 if (ptr != 0 && ptr[0] != '\0')
1101 errx(1, "can't resolve writesize");
1102 if (rxwrite_size > sizeof(somebuf))
1103 errx(1, "%d > sizeof(somebuf) (%"AFS_SIZET_FMT")", rxwrite_size,
1107 maxwsize = strtol(optarg, &ptr, 0);
1108 if (ptr && *ptr != '\0')
1109 errx(1, "can't resolve max send/recv window size (packets)");
1112 times = strtol(optarg, &ptr, 0);
1113 if (ptr && *ptr != '\0')
1114 errx(1, "can't resolve number of times to execute rpc");
1117 sendbytes = strtol(optarg, &ptr, 0);
1118 if (ptr && *ptr != '\0')
1119 errx(1, "can't resolve number of bytes to send");
1122 readbytes = strtol(optarg, &ptr, 0);
1123 if (ptr && *ptr != '\0')
1124 errx(1, "can't resolve number of bytes to receive");
1127 #ifdef AFS_PTHREAD_ENV
1128 threads = strtol(optarg, &ptr, 0);
1129 if (ptr && *ptr != '\0')
1130 errx(1, "can't resolve number of threads to execute");
1131 if (threads > MAX_THREADS)
1132 errx(1, "too many threads");
1134 errx(1, "Not built for pthreads");
1153 maxmtu = strtol(optarg, &ptr, 0);
1154 if (ptr && *ptr != '\0')
1155 errx(1, "can't resolve rx maxmtu to use");
1158 udpbufsz = strtol(optarg, &ptr, 0) * 1024;
1159 if (ptr && *ptr != '\0')
1160 errx(1, "can't resolve upd buffer size (Kbytes)");
1170 if (nostats && dumpstats)
1171 errx(1, "cannot set both -N and -D");
1173 if (threads > 1 && cmd == RX_PERF_FILE)
1174 errx(1, "cannot use multiple threads with file command");
1179 if (cmd == RX_PERF_UNKNOWN)
1180 errx(1, "no command given to the client");
1182 do_client(host, port, filename, cmd, times, bytes, sendbytes,
1183 readbytes, dumpstats, nojumbo, maxmtu, maxwsize, minpeertimeout,
1184 udpbufsz, nostats, hotthreads, threads);
1190 * setup world and call cmd
1194 main(int argc, char **argv)
1196 #ifndef AFS_PTHREAD_ENV
1200 __progname = strrchr(argv[0], '/');
1201 if (__progname == 0)
1202 __progname = argv[0];
1204 #ifndef AFS_NT40_ENV
1205 signal(SIGUSR1, sigusr1);
1206 signal(SIGINT, sigint);
1209 #ifndef AFS_PTHREAD_ENV
1210 LWP_InitializeProcessSupport(LWP_NORMAL_PRIORITY, &pid);
1213 memset(somebuf, 0, sizeof(somebuf));
1215 if (argc >= 2 && strcmp(argv[1], "server") == 0)
1216 rxperf_server(argc - 1, argv + 1);
1217 else if (argc >= 2 && strcmp(argv[1], "client") == 0)
1218 rxperf_client(argc - 1, argv + 1);