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 rx_SetUdpBufSize(udpbufsz);
510 ret = rx_Init(htons(port));
512 errx(1, "rx_Init failed");
518 rx_SetMaxMTU(maxmtu);
521 rx_SetMaxReceiveWindow(maxwsize);
522 rx_SetMaxSendWindow(maxwsize);
526 rx_SetMinPeerTimeout(minpeertimeout);
529 get_sec(1, &secureobj, &secureindex);
532 rx_NewService(0, RX_SERVER_ID, "rxperf", &secureobj, secureindex,
533 rxperf_ExecuteRequest);
535 errx(1, "Cant create server");
537 rx_SetMinProcs(service, minprocs);
538 rx_SetMaxProcs(service, maxprocs);
540 rx_SetCheckReach(service, 1);
552 readfile(const char *filename, afs_uint32 ** readwrite, afs_uint32 * size)
561 *readwrite = malloc(sizeof(afs_uint32) * len);
562 buf = malloc(RXPERF_BUFSIZE);
564 if (*readwrite == NULL)
567 f = fopen(filename, "r");
571 while (fgets(buf, sizeof(buf), f) != NULL) {
574 *readwrite = realloc(*readwrite, len * sizeof(afs_uint32));
575 if (*readwrite == NULL)
580 data = htonl(strtol(buf, &ptr, 0));
581 if (ptr && ptr == buf)
582 errx(1, "can't resolve number of bytes to transfer");
587 (*readwrite)[num] = data;
600 struct rx_connection *conn;
610 client_thread( void *vparams)
612 struct client_data *params = (struct client_data *)vparams;
613 struct rx_call *call;
616 afs_uint32 *readwrite;
621 for (i = 0; i < params->times; i++) {
623 DBFPRINT(("starting command "));
625 call = rx_NewCall(params->conn);
627 errx(1, "rx_NewCall failed");
629 data = htonl(RX_PERF_VERSION);
630 if (rx_Write32(call, &data) != 4)
631 errx(1, "rx_Write failed to send version (err %d)", rx_Error(call));
633 data = htonl(params->command);
634 if (rx_Write32(call, &data) != 4)
635 errx(1, "rx_Write failed to send command (err %d)", rx_Error(call));
637 data = htonl(rxread_size);
638 if (rx_Write32(call, &data) != 4)
639 errx(1, "rx_Write failed to send read size (err %d)", rx_Error(call));
640 data = htonl(rxwrite_size);
641 if (rx_Write32(call, &data) != 4)
642 errx(1, "rx_Write failed to send write read (err %d)", rx_Error(call));
645 switch (params->command) {
647 DBFPRINT(("command "));
649 data = htonl(params->bytes);
650 if (rx_Write32(call, &data) != 4)
651 errx(1, "rx_Write failed to send size (err %d)", rx_Error(call));
653 DBFPRINT(("sending(%d) ", params->bytes));
654 if (readbytes(call, params->bytes))
655 errx(1, "sendbytes (err %d)", rx_Error(call));
657 if (rx_Read32(call, &data) != 4)
658 errx(1, "failed to read result from server (err %d)", rx_Error(call));
660 if (data != htonl(RXPERF_MAGIC_COOKIE))
661 warn("server send wrong magic cookie in responce");
663 DBFPRINT(("done\n"));
667 DBFPRINT(("command "));
669 data = htonl(params->bytes);
670 if (rx_Write32(call, &data) != 4)
671 errx(1, "rx_Write failed to send size (err %d)", rx_Error(call));
673 DBFPRINT(("sending(%d) ", params->bytes));
674 if (sendbytes(call, params->bytes))
675 errx(1, "sendbytes (err %d)", rx_Error(call));
677 if (rx_Read32(call, &data) != 4)
678 errx(1, "failed to read result from server (err %d)", rx_Error(call));
680 if (data != htonl(RXPERF_MAGIC_COOKIE))
681 warn("server send wrong magic cookie in responce");
683 DBFPRINT(("done\n"));
687 DBFPRINT(("commands "));
689 data = htonl(params->sendtimes);
690 if (rx_Write32(call, &data) != 4)
691 errx(1, "rx_Write failed to send command (err %d)", rx_Error(call));
693 data = htonl(params->recvtimes);
694 if (rx_Write32(call, &data) != 4)
695 errx(1, "rx_Write failed to send command (err %d)", rx_Error(call));
697 DBFPRINT(("send(%d) ", params->sendtimes));
698 if (sendbytes(call, params->sendtimes))
699 errx(1, "sendbytes (err %d)", rx_Error(call));
701 DBFPRINT(("recv(%d) ", params->recvtimes));
702 if (readbytes(call, params->recvtimes))
703 errx(1, "sendbytes (err %d)", rx_Error(call));
705 if (rx_Read32(call, &data) != 4)
706 errx(1, "failed to read result from server (err %d)", rx_Error(call));
708 if (data != htonl(RXPERF_MAGIC_COOKIE))
709 warn("server send wrong magic cookie in responce");
711 DBFPRINT(("done\n"));
716 readfile(params->filename, &readwrite, &num);
719 if (rx_Write32(call, &data) != 4)
720 errx(1, "rx_Write failed to send size (err %d)", rx_Error(call));
722 if (rx_Write(call, (char *)readwrite, num * sizeof(afs_uint32))
723 != num * sizeof(afs_uint32))
724 errx(1, "rx_Write failed to send list (err %d)", rx_Error(call));
726 for (j = 0; j < num; j++) {
727 if (readwrite[j] == 0)
730 size = ntohl(readwrite[j]) * sizeof(afs_uint32);
733 if (readbytes(call, size))
734 errx(1, "sendbytes (err %d)", rx_Error(call));
735 DBFPRINT(("read\n"));
737 if (sendbytes(call, size))
738 errx(1, "sendbytes (err %d)", rx_Error(call));
739 DBFPRINT(("send\n"));
750 #ifdef AFS_PTHREAD_ENV
762 do_client(const char *server, short port, char *filename, afs_int32 command,
763 afs_int32 times, afs_int32 bytes, afs_int32 sendtimes, afs_int32 recvtimes,
764 int dumpstats, int nojumbo, int maxmtu, int maxwsize, int minpeertimeout,
765 int udpbufsz, int nostats, int hotthread, int threads)
767 struct rx_connection *conn;
769 struct rx_securityClass *secureobj;
773 struct client_data *params;
775 #ifdef AFS_PTHREAD_ENV
777 pthread_t thread[MAX_THREADS];
778 pthread_attr_t tattr;
782 params = malloc(sizeof(struct client_data));
783 memset(params, 0, sizeof(struct client_data));
786 if (afs_winsockInit() < 0) {
787 printf("Can't initialize winsock.\n");
793 rx_EnableHotThread();
798 addr = str2addr(server);
800 rx_SetUdpBufSize(udpbufsz);
804 errx(1, "rx_Init failed");
810 rx_SetMaxMTU(maxmtu);
813 rx_SetMaxReceiveWindow(maxwsize);
814 rx_SetMaxSendWindow(maxwsize);
818 rx_SetMinPeerTimeout(minpeertimeout);
821 get_sec(0, &secureobj, &secureindex);
823 conn = rx_NewConnection(addr, htons(port), RX_SERVER_ID, secureobj, secureindex);
825 errx(1, "failed to contact server");
827 #ifdef AFS_PTHREAD_ENV
828 pthread_attr_init(&tattr);
829 pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_JOINABLE);
833 params->filename = filename;
834 params->command = command;
835 params->times = times;
836 params->bytes = bytes;
837 params->sendtimes = sendtimes;
838 params->recvtimes = recvtimes;
842 sprintf(stamp, "RPC: threads\t%d, times\t%d, writes\t%d, reads\t%d",
843 threads, times, sendtimes, recvtimes);
846 sprintf(stamp, "RECV: threads\t%d, times\t%d, bytes\t%d",
847 threads, times, bytes);
850 sprintf(stamp, "SEND: threads\t%d, times\t%d, bytes\t%d",
851 threads, times, bytes);
854 sprintf(stamp, "FILE %s: threads\t%d, times\t%d, bytes\t%d",
855 filename, threads, times, bytes);
861 #ifdef AFS_PTHREAD_ENV
862 for ( i=0; i<threads; i++)
863 pthread_create(&thread[i], &tattr, client_thread, params);
865 client_thread(params);
868 #ifdef AFS_PTHREAD_ENV
869 for ( i=0; i<threads; i++)
870 pthread_join(thread[i], &status);
873 end_and_print_timer(stamp);
874 DBFPRINT(("done for good\n"));
877 rx_PrintStats(stdout);
878 rx_PrintPeerStats(stdout, conn->peer);
882 #ifdef AFS_PTHREAD_ENV
883 pthread_attr_destroy(&tattr);
894 fprintf(stderr, "usage: %s client -c send -b <bytes>\n", __progname);
895 fprintf(stderr, "usage: %s client -c recv -b <bytes>\n", __progname);
897 "usage: %s client -c rpc -S <sendbytes> -R <recvbytes>\n",
899 fprintf(stderr, "usage: %s client -c file -f filename\n", __progname);
901 "%s: usage: common option to the client "
902 "-w <write-bytes> -r <read-bytes> -T times -p port -s server -D\n",
904 fprintf(stderr, "usage: %s server -p port\n", __progname);
912 * do argument processing and call networking functions
916 rxperf_server(int argc, char **argv)
918 short port = DEFAULT_PORT;
922 int udpbufsz = 64 * 1024;
927 int minpeertimeout = 0;
931 while ((ch = getopt(argc, argv, "r:d:p:P:w:W:HNjm:u:4:s:S")) != -1) {
935 rx_debugFile = fopen(optarg, "w");
936 if (rx_debugFile == NULL)
937 err(1, "fopen %s", optarg);
939 errx(1, "compiled without RXDEBUG");
943 rxread_size = strtol(optarg, &ptr, 0);
944 if (ptr != 0 && ptr[0] != '\0')
945 errx(1, "can't resolve readsize");
946 if (rxread_size > sizeof(somebuf))
947 errx(1, "%d > sizeof(somebuf) (%d)", rxread_size,
951 minprocs = strtol(optarg, &ptr, 0);
952 if (ptr != 0 && ptr[0] != '\0')
953 errx(1, "can't resolve minprocs");
956 maxprocs = strtol(optarg, &ptr, 0);
957 if (ptr != 0 && ptr[0] != '\0')
958 errx(1, "can't resolve maxprocs");
961 minpeertimeout = strtol(optarg, &ptr, 0);
962 if (ptr != 0 && ptr[0] != '\0')
963 errx(1, "can't resolve min peer timeout");
966 port = (short) strtol(optarg, &ptr, 0);
967 if (ptr != 0 && ptr[0] != '\0')
968 errx(1, "can't resolve portname");
971 rxwrite_size = strtol(optarg, &ptr, 0);
972 if (ptr != 0 && ptr[0] != '\0')
973 errx(1, "can't resolve writesize");
974 if (rxwrite_size > sizeof(somebuf))
975 errx(1, "%d > sizeof(somebuf) (%d)", rxwrite_size,
988 maxmtu = strtol(optarg, &ptr, 0);
989 if (ptr && *ptr != '\0')
990 errx(1, "can't resolve rx maxmtu to use");
993 udpbufsz = strtol(optarg, &ptr, 0) * 1024;
994 if (ptr && *ptr != '\0')
995 errx(1, "can't resolve upd buffer size (Kbytes)");
998 maxwsize = strtol(optarg, &ptr, 0);
999 if (ptr && *ptr != '\0')
1000 errx(1, "can't resolve max send/recv window size (packets)");
1013 do_server(port, nojumbo, maxmtu, maxwsize, minpeertimeout, udpbufsz,
1014 nostats, hotthreads, minprocs, maxprocs);
1020 * do argument processing and call networking functions
1024 rxperf_client(int argc, char **argv)
1026 char *host = DEFAULT_HOST;
1027 int bytes = DEFAULT_BYTES;
1028 short port = DEFAULT_PORT;
1029 char *filename = NULL;
1040 int udpbufsz = 64 * 1024;
1042 int minpeertimeout = 0;
1046 cmd = RX_PERF_UNKNOWN;
1048 while ((ch = getopt(argc, argv, "T:S:R:b:c:d:p:P:r:s:w:W:f:HDNjm:u:4:t:")) != -1) {
1051 bytes = strtol(optarg, &ptr, 0);
1052 if (ptr && *ptr != '\0')
1053 errx(1, "can't resolve number of bytes to transfer");
1056 if (strcasecmp(optarg, "send") == 0)
1058 else if (strcasecmp(optarg, "recv") == 0)
1060 else if (strcasecmp(optarg, "rpc") == 0)
1062 else if (strcasecmp(optarg, "file") == 0)
1065 errx(1, "unknown command %s", optarg);
1069 rx_debugFile = fopen(optarg, "w");
1070 if (rx_debugFile == NULL)
1071 err(1, "fopen %s", optarg);
1073 errx(1, "compiled without RXDEBUG");
1077 minpeertimeout = strtol(optarg, &ptr, 0);
1078 if (ptr != 0 && ptr[0] != '\0')
1079 errx(1, "can't resolve min peer timeout");
1082 port = (short) strtol(optarg, &ptr, 0);
1083 if (ptr != 0 && ptr[0] != '\0')
1084 errx(1, "can't resolve portname");
1087 rxread_size = strtol(optarg, &ptr, 0);
1088 if (ptr != 0 && ptr[0] != '\0')
1089 errx(1, "can't resolve readsize");
1090 if (rxread_size > sizeof(somebuf))
1091 errx(1, "%d > sizeof(somebuf) (%d)", rxread_size,
1095 host = strdup(optarg);
1100 rxwrite_size = strtol(optarg, &ptr, 0);
1101 if (ptr != 0 && ptr[0] != '\0')
1102 errx(1, "can't resolve writesize");
1103 if (rxwrite_size > sizeof(somebuf))
1104 errx(1, "%d > sizeof(somebuf) (%d)", rxwrite_size,
1108 maxwsize = strtol(optarg, &ptr, 0);
1109 if (ptr && *ptr != '\0')
1110 errx(1, "can't resolve max send/recv window size (packets)");
1113 times = strtol(optarg, &ptr, 0);
1114 if (ptr && *ptr != '\0')
1115 errx(1, "can't resolve number of times to execute rpc");
1118 sendtimes = strtol(optarg, &ptr, 0);
1119 if (ptr && *ptr != '\0')
1120 errx(1, "can't resolve number of bytes to send");
1123 recvtimes = strtol(optarg, &ptr, 0);
1124 if (ptr && *ptr != '\0')
1125 errx(1, "can't resolve number of bytes to receive");
1128 #ifdef AFS_PTHREAD_ENV
1129 threads = strtol(optarg, &ptr, 0);
1130 if (ptr && *ptr != '\0')
1131 errx(1, "can't resolve number of threads to execute");
1132 if (threads > MAX_THREADS)
1133 errx(1, "too many threads");
1135 errx(1, "Not built for pthreads");
1154 maxmtu = strtol(optarg, &ptr, 0);
1155 if (ptr && *ptr != '\0')
1156 errx(1, "can't resolve rx maxmtu to use");
1159 udpbufsz = strtol(optarg, &ptr, 0) * 1024;
1160 if (ptr && *ptr != '\0')
1161 errx(1, "can't resolve upd buffer size (Kbytes)");
1171 if (nostats && dumpstats)
1172 errx(1, "cannot set both -N and -D");
1174 if (threads > 1 && cmd == RX_PERF_FILE)
1175 errx(1, "cannot use multiple threads with file command");
1180 if (cmd == RX_PERF_UNKNOWN)
1181 errx(1, "no command given to the client");
1183 do_client(host, port, filename, cmd, times, bytes, sendtimes,
1184 recvtimes, dumpstats, nojumbo, maxmtu, maxwsize, minpeertimeout,
1185 udpbufsz, nostats, hotthreads, threads);
1191 * setup world and call cmd
1195 main(int argc, char **argv)
1197 #ifndef AFS_PTHREAD_ENV
1201 __progname = strrchr(argv[0], '/');
1202 if (__progname == 0)
1203 __progname = argv[0];
1205 #ifndef AFS_NT40_ENV
1206 signal(SIGUSR1, sigusr1);
1207 signal(SIGINT, sigint);
1210 #ifndef AFS_PTHREAD_ENV
1211 LWP_InitializeProcessSupport(LWP_NORMAL_PRIORITY, &pid);
1214 memset(somebuf, 0, sizeof(somebuf));
1216 if (argc >= 2 && strcmp(argv[1], "server") == 0)
1217 rxperf_server(argc - 1, argv + 1);
1218 else if (argc >= 2 && strcmp(argv[1], "client") == 0)
1219 rxperf_client(argc - 1, argv + 1);