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 #define DEFAULT_PORT 7009 /* To match tcpdump */
63 #define DEFAULT_HOST "127.0.0.1"
64 #define DEFAULT_BYTES 1024 * 1024
65 #define RXPERF_BUFSIZE 512 * 1024
67 enum { RX_PERF_VERSION = 3 };
68 enum { RX_SERVER_ID = 147 };
69 enum { RX_PERF_UNKNOWN = -1,
76 enum { RXPERF_MAGIC_COOKIE = 0x4711 };
83 #define DBFPRINT(x) do { printf x ; } while(0)
91 exit(2); /* XXX profiler */
98 exit(2); /* XXX profiler */
105 static struct timeval timer_start;
106 static struct timeval timer_stop;
107 static int timer_check = 0;
113 gettimeofday(&timer_start, NULL);
121 end_and_print_timer(char *str, long long bytes)
123 long long start_l, stop_l;
127 assert(timer_check == 0);
128 gettimeofday(&timer_stop, NULL);
129 start_l = timer_start.tv_sec * 1000000 + timer_start.tv_usec;
130 stop_l = timer_stop.tv_sec * 1000000 + timer_stop.tv_usec;
131 printf("%s:\t%8llu msec", str, (stop_l - start_l) / 1000);
133 kbps = bytes * 8000.0 / (stop_l - start_l);
134 if (kbps > 1000000.0)
135 printf("\t[%.4g Gbit/s]\n", kbps/1000000.0);
136 else if (kbps > 1000.0)
137 printf("\t[%.4g Mbit/s]\n", kbps/1000.0);
139 printf("\t[%.4g kbit/s]\n", kbps);
147 str2addr(const char *s)
149 struct in_addr server;
153 #define INADDR_NONE 0xffffffff
155 if (inet_addr(s) != INADDR_NONE)
157 h = gethostbyname(s);
159 memcpy(&server, h->h_addr_list[0], sizeof(server));
160 return server.s_addr;
171 get_sec(int serverp, struct rx_securityClass **sec, int *secureindex)
174 *sec = rxnull_NewServerSecurityObject();
177 *sec = rxnull_NewClientSecurityObject();
183 * process the "RPC" and return the results
186 char somebuf[RXPERF_BUFSIZE];
188 afs_int32 rxwrite_size = sizeof(somebuf);
189 afs_int32 rxread_size = sizeof(somebuf);
190 afs_int32 use_rx_readv = 0;
193 do_readbytes(struct rx_call *call, afs_int32 bytes)
195 struct iovec tiov[RX_MAXIOVECS];
206 if (size > RX_MAX_PACKET_DATA_SIZE)
207 size = RX_MAX_PACKET_DATA_SIZE;
208 code = rx_Readv(call, tiov, &tnio, RX_MAXIOVECS, size);
210 code = rx_Read(call, somebuf, size);
220 do_sendbytes(struct rx_call *call, afs_int32 bytes)
228 if (rx_Write(call, somebuf, size) != size)
237 rxperf_ExecuteRequest(struct rx_call *call)
246 afs_uint32 *readwrite;
250 DBFPRINT(("got a request\n"));
252 if (rx_Read32(call, &version) != 4) {
253 warn("rx_Read failed to read version");
257 if (htonl(RX_PERF_VERSION) != version) {
258 warnx("client has wrong version");
262 if (rx_Read32(call, &command) != 4) {
263 warnx("rx_Read failed to read command");
266 command = ntohl(command);
268 if (rx_Read32(call, &data) != 4) {
269 warnx("rx_Read failed to read size");
272 rxread_size = ntohl(data);
273 if (rxread_size > sizeof(somebuf)) {
274 warnx("rxread_size too large %d", rxread_size);
278 if (rx_Read32(call, &data) != 4) {
279 warnx("rx_Read failed to write size");
282 rxwrite_size = ntohl(data);
283 if (rxwrite_size > sizeof(somebuf)) {
284 warnx("rxwrite_size too large %d", rxwrite_size);
290 DBFPRINT(("got a send request\n"));
292 if (rx_Read32(call, &bytes) != 4) {
293 warnx("rx_Read failed to read bytes");
296 bytes = ntohl(bytes);
298 DBFPRINT(("reading(%d) ", bytes));
299 do_readbytes(call, bytes);
301 data = htonl(RXPERF_MAGIC_COOKIE);
302 if (rx_Write32(call, &data) != 4) {
303 warnx("rx_Write failed when sending back result");
306 DBFPRINT(("done\n"));
310 DBFPRINT(("got a rpc request, reading commands\n"));
312 if (rx_Read32(call, &recvb) != 4) {
313 warnx("rx_Read failed to read recvbytes");
316 recvb = ntohl(recvb);
317 if (rx_Read32(call, &sendb) != 4) {
318 warnx("rx_Read failed to read sendbytes");
321 sendb = ntohl(sendb);
323 DBFPRINT(("read(%d) ", recvb));
324 if (do_readbytes(call, recvb)) {
325 warnx("do_readbytes failed");
328 DBFPRINT(("send(%d) ", sendb));
329 if (do_sendbytes(call, sendb)) {
330 warnx("sendbytes failed");
334 DBFPRINT(("done\n"));
336 data = htonl(RXPERF_MAGIC_COOKIE);
337 if (rx_Write32(call, &data) != 4) {
338 warnx("rx_Write failed when sending back magic cookie");
344 if (rx_Read32(call, &data) != 4)
345 errx(1, "failed to read num from client");
348 readwrite = malloc(num * sizeof(afs_uint32));
349 if (readwrite == NULL)
352 if (rx_Read(call, (char*)readwrite, num * sizeof(afs_uint32)) !=
353 num * sizeof(afs_uint32))
354 errx(1, "failed to read recvlist from client");
356 for (i = 0; i < num; i++) {
357 if (readwrite[i] == 0) {
358 DBFPRINT(("readp %d", readwrite[i]));
362 bytes = ntohl(readwrite[i]) * sizeof(afs_uint32);
365 DBFPRINT(("read\n"));
366 do_readbytes(call, bytes);
368 do_sendbytes(call, bytes);
369 DBFPRINT(("send\n"));
375 DBFPRINT(("got a recv request\n"));
377 if (rx_Read32(call, &bytes) != 4) {
378 warnx("rx_Read failed to read bytes");
381 bytes = ntohl(bytes);
383 DBFPRINT(("sending(%d) ", bytes));
384 do_sendbytes(call, bytes);
386 data = htonl(RXPERF_MAGIC_COOKIE);
387 if (rx_Write32(call, &data) != 4) {
388 warnx("rx_Write failed when sending back result");
391 DBFPRINT(("done\n"));
395 warnx("client sent a unsupported command");
398 DBFPRINT(("done with command\n"));
408 do_server(short port, int nojumbo, int maxmtu, int maxwsize, int minpeertimeout,
409 int udpbufsz, int nostats, int hotthread,
410 int minprocs, int maxprocs)
412 struct rx_service *service;
413 struct rx_securityClass *secureobj;
418 if (afs_winsockInit() < 0) {
419 printf("Can't initialize winsock.\n");
425 rx_EnableHotThread();
430 rx_SetUdpBufSize(udpbufsz);
432 ret = rx_Init(htons(port));
434 errx(1, "rx_Init failed");
440 rx_SetMaxMTU(maxmtu);
443 rx_SetMaxReceiveWindow(maxwsize);
444 rx_SetMaxSendWindow(maxwsize);
448 rx_SetMinPeerTimeout(minpeertimeout);
451 get_sec(1, &secureobj, &secureindex);
454 rx_NewService(0, RX_SERVER_ID, "rxperf", &secureobj, secureindex,
455 rxperf_ExecuteRequest);
457 errx(1, "Cant create server");
459 rx_SetMinProcs(service, minprocs);
460 rx_SetMaxProcs(service, maxprocs);
462 rx_SetCheckReach(service, 1);
474 readfile(const char *filename, afs_uint32 ** readwrite, afs_uint32 * size)
483 *readwrite = malloc(sizeof(afs_uint32) * len);
484 buf = malloc(RXPERF_BUFSIZE);
486 if (*readwrite == NULL)
489 f = fopen(filename, "r");
493 while (fgets(buf, sizeof(buf), f) != NULL) {
496 *readwrite = realloc(*readwrite, len * sizeof(afs_uint32));
497 if (*readwrite == NULL)
502 data = htonl(strtol(buf, &ptr, 0));
503 if (ptr && ptr == buf)
504 errx(1, "can't resolve number of bytes to transfer");
509 (*readwrite)[num] = data;
522 struct rx_connection *conn;
532 client_thread( void *vparams)
534 struct client_data *params = (struct client_data *)vparams;
535 struct rx_call *call;
538 afs_uint32 *readwrite;
543 for (i = 0; i < params->times; i++) {
545 DBFPRINT(("starting command "));
547 call = rx_NewCall(params->conn);
549 errx(1, "rx_NewCall failed");
551 data = htonl(RX_PERF_VERSION);
552 if (rx_Write32(call, &data) != 4)
553 errx(1, "rx_Write failed to send version (err %d)", rx_Error(call));
555 data = htonl(params->command);
556 if (rx_Write32(call, &data) != 4)
557 errx(1, "rx_Write failed to send command (err %d)", rx_Error(call));
559 data = htonl(rxread_size);
560 if (rx_Write32(call, &data) != 4)
561 errx(1, "rx_Write failed to send read size (err %d)", rx_Error(call));
562 data = htonl(rxwrite_size);
563 if (rx_Write32(call, &data) != 4)
564 errx(1, "rx_Write failed to send write read (err %d)", rx_Error(call));
567 switch (params->command) {
569 DBFPRINT(("command "));
571 data = htonl(params->bytes);
572 if (rx_Write32(call, &data) != 4)
573 errx(1, "rx_Write failed to send size (err %d)", rx_Error(call));
575 DBFPRINT(("sending(%d) ", params->bytes));
576 if (do_readbytes(call, params->bytes))
577 errx(1, "sendbytes (err %d)", rx_Error(call));
579 if (rx_Read32(call, &data) != 4)
580 errx(1, "failed to read result from server (err %d)", rx_Error(call));
582 if (data != htonl(RXPERF_MAGIC_COOKIE))
583 warn("server send wrong magic cookie in responce");
585 DBFPRINT(("done\n"));
589 DBFPRINT(("command "));
591 data = htonl(params->bytes);
592 if (rx_Write32(call, &data) != 4)
593 errx(1, "rx_Write failed to send size (err %d)", rx_Error(call));
595 DBFPRINT(("sending(%d) ", params->bytes));
596 if (do_sendbytes(call, params->bytes))
597 errx(1, "sendbytes (err %d)", rx_Error(call));
599 if (rx_Read32(call, &data) != 4)
600 errx(1, "failed to read result from server (err %d)", rx_Error(call));
602 if (data != htonl(RXPERF_MAGIC_COOKIE))
603 warn("server send wrong magic cookie in responce");
605 DBFPRINT(("done\n"));
609 DBFPRINT(("commands "));
611 data = htonl(params->sendbytes);
612 if (rx_Write32(call, &data) != 4)
613 errx(1, "rx_Write failed to send command (err %d)", rx_Error(call));
615 data = htonl(params->readbytes);
616 if (rx_Write32(call, &data) != 4)
617 errx(1, "rx_Write failed to send command (err %d)", rx_Error(call));
619 DBFPRINT(("send(%d) ", params->sendbytes));
620 if (do_sendbytes(call, params->sendbytes))
621 errx(1, "sendbytes (err %d)", rx_Error(call));
623 DBFPRINT(("recv(%d) ", params->readbytes));
624 if (do_readbytes(call, params->readbytes))
625 errx(1, "sendbytes (err %d)", rx_Error(call));
627 if (rx_Read32(call, &data) != 4)
628 errx(1, "failed to read result from server (err %d)", rx_Error(call));
630 if (data != htonl(RXPERF_MAGIC_COOKIE))
631 warn("server send wrong magic cookie in responce");
633 DBFPRINT(("done\n"));
638 readfile(params->filename, &readwrite, &num);
641 if (rx_Write32(call, &data) != 4)
642 errx(1, "rx_Write failed to send size (err %d)", rx_Error(call));
644 if (rx_Write(call, (char *)readwrite, num * sizeof(afs_uint32))
645 != num * sizeof(afs_uint32))
646 errx(1, "rx_Write failed to send list (err %d)", rx_Error(call));
648 for (j = 0; j < num; j++) {
649 if (readwrite[j] == 0)
652 size = ntohl(readwrite[j]) * sizeof(afs_uint32);
655 if (do_readbytes(call, size))
656 errx(1, "sendbytes (err %d)", rx_Error(call));
657 DBFPRINT(("read\n"));
659 if (do_sendbytes(call, size))
660 errx(1, "sendbytes (err %d)", rx_Error(call));
661 DBFPRINT(("send\n"));
672 #ifdef AFS_PTHREAD_ENV
674 AFS_UNREACHED(return NULL);
685 do_client(const char *server, short port, char *filename, afs_int32 command,
686 afs_int32 times, afs_int32 bytes, afs_int32 sendbytes, afs_int32 readbytes,
687 int dumpstats, int nojumbo, int maxmtu, int maxwsize, int minpeertimeout,
688 int udpbufsz, int nostats, int hotthread, int threads)
690 struct rx_connection *conn;
692 struct rx_securityClass *secureobj;
696 struct client_data *params;
698 #ifdef AFS_PTHREAD_ENV
700 pthread_t thread[MAX_THREADS];
701 pthread_attr_t tattr;
705 params = calloc(1, sizeof(struct client_data));
708 if (afs_winsockInit() < 0) {
709 printf("Can't initialize winsock.\n");
715 rx_EnableHotThread();
720 addr = str2addr(server);
722 rx_SetUdpBufSize(udpbufsz);
726 errx(1, "rx_Init failed");
732 rx_SetMaxMTU(maxmtu);
735 rx_SetMaxReceiveWindow(maxwsize);
736 rx_SetMaxSendWindow(maxwsize);
740 rx_SetMinPeerTimeout(minpeertimeout);
743 get_sec(0, &secureobj, &secureindex);
747 sprintf(stamp, "RPC: threads\t%d, times\t%d, write bytes\t%d, read bytes\t%d",
748 threads, times, sendbytes, readbytes);
751 sprintf(stamp, "RECV: threads\t%d, times\t%d, bytes\t%d",
752 threads, times, bytes);
755 sprintf(stamp, "SEND: threads\t%d, times\t%d, bytes\t%d",
756 threads, times, bytes);
759 sprintf(stamp, "FILE %s: threads\t%d, times\t%d, bytes\t%d",
760 filename, threads, times, bytes);
764 conn = rx_NewConnection(addr, htons(port), RX_SERVER_ID, secureobj, secureindex);
766 errx(1, "failed to contact server");
768 #ifdef AFS_PTHREAD_ENV
769 pthread_attr_init(&tattr);
770 pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_JOINABLE);
774 params->filename = filename;
775 params->command = command;
776 params->times = times;
777 params->bytes = bytes;
778 params->sendbytes = sendbytes;
779 params->readbytes = readbytes;
783 #ifdef AFS_PTHREAD_ENV
784 for ( i=0; i<threads; i++) {
785 pthread_create(&thread[i], &tattr, client_thread, params);
786 if ( (i + 1) % RX_MAXCALLS == 0 ) {
787 conn = rx_NewConnection(addr, htons(port), RX_SERVER_ID, secureobj, secureindex);
789 struct client_data *new_params = malloc(sizeof(struct client_data));
790 memcpy(new_params, params, sizeof(struct client_data));
791 new_params->conn = conn;
797 client_thread(params);
800 #ifdef AFS_PTHREAD_ENV
801 for ( i=0; i<threads; i++)
802 pthread_join(thread[i], &status);
807 end_and_print_timer(stamp, (long long)threads*times*(sendbytes+readbytes));
812 end_and_print_timer(stamp, (long long)threads*times*bytes);
816 DBFPRINT(("done for good\n"));
819 rx_PrintStats(stdout);
820 rx_PrintPeerStats(stdout, rx_PeerOf(conn));
824 #ifdef AFS_PTHREAD_ENV
825 pthread_attr_destroy(&tattr);
836 fprintf(stderr, "usage: %s client -c send -b <bytes>\n", getprogname());
837 fprintf(stderr, "usage: %s client -c recv -b <bytes>\n", getprogname());
839 "usage: %s client -c rpc -S <sendbytes> -R <recvbytes>\n",
841 fprintf(stderr, "usage: %s client -c file -f filename\n", getprogname());
843 "%s: usage: common option to the client "
844 "-w <write-bytes> -r <read-bytes> -T times -p port -s server -D\n",
846 fprintf(stderr, "usage: %s server -p port\n", getprogname());
854 * do argument processing and call networking functions
858 rxperf_server(int argc, char **argv)
860 short port = DEFAULT_PORT;
864 int udpbufsz = 64 * 1024;
869 int minpeertimeout = 0;
873 while ((ch = getopt(argc, argv, "r:d:p:P:w:W:HNjm:u:4:s:S:V")) != -1) {
877 rx_debugFile = fopen(optarg, "w");
878 if (rx_debugFile == NULL)
879 err(1, "fopen %s", optarg);
881 errx(1, "compiled without RXDEBUG");
885 rxread_size = strtol(optarg, &ptr, 0);
886 if (ptr != 0 && ptr[0] != '\0')
887 errx(1, "can't resolve readsize");
888 if (rxread_size > sizeof(somebuf))
889 errx(1, "%d > sizeof(somebuf) (%"AFS_SIZET_FMT")", rxread_size,
893 minprocs = strtol(optarg, &ptr, 0);
894 if (ptr != 0 && ptr[0] != '\0')
895 errx(1, "can't resolve minprocs");
898 maxprocs = strtol(optarg, &ptr, 0);
899 if (ptr != 0 && ptr[0] != '\0')
900 errx(1, "can't resolve maxprocs");
903 minpeertimeout = strtol(optarg, &ptr, 0);
904 if (ptr != 0 && ptr[0] != '\0')
905 errx(1, "can't resolve min peer timeout");
908 port = (short) strtol(optarg, &ptr, 0);
909 if (ptr != 0 && ptr[0] != '\0')
910 errx(1, "can't resolve portname");
913 rxwrite_size = strtol(optarg, &ptr, 0);
914 if (ptr != 0 && ptr[0] != '\0')
915 errx(1, "can't resolve writesize");
916 if (rxwrite_size > sizeof(somebuf))
917 errx(1, "%d > sizeof(somebuf) (%"AFS_SIZET_FMT")", rxwrite_size,
930 maxmtu = strtol(optarg, &ptr, 0);
931 if (ptr && *ptr != '\0')
932 errx(1, "can't resolve rx maxmtu to use");
935 udpbufsz = strtol(optarg, &ptr, 0) * 1024;
936 if (ptr && *ptr != '\0')
937 errx(1, "can't resolve upd buffer size (Kbytes)");
943 maxwsize = strtol(optarg, &ptr, 0);
944 if (ptr && *ptr != '\0')
945 errx(1, "can't resolve max send/recv window size (packets)");
958 do_server(port, nojumbo, maxmtu, maxwsize, minpeertimeout, udpbufsz,
959 nostats, hotthreads, minprocs, maxprocs);
965 * do argument processing and call networking functions
969 rxperf_client(int argc, char **argv)
971 char *host = DEFAULT_HOST;
972 int bytes = DEFAULT_BYTES;
973 short port = DEFAULT_PORT;
974 char *filename = NULL;
985 int udpbufsz = 64 * 1024;
987 int minpeertimeout = 0;
991 cmd = RX_PERF_UNKNOWN;
993 while ((ch = getopt(argc, argv, "T:S:R:b:c:d:p:P:r:s:w:W:f:HDNjm:u:4:t:V")) != -1) {
996 bytes = strtol(optarg, &ptr, 0);
997 if (ptr && *ptr != '\0')
998 errx(1, "can't resolve number of bytes to transfer");
1001 if (strcasecmp(optarg, "send") == 0)
1003 else if (strcasecmp(optarg, "recv") == 0)
1005 else if (strcasecmp(optarg, "rpc") == 0)
1007 else if (strcasecmp(optarg, "file") == 0)
1010 errx(1, "unknown command %s", optarg);
1014 rx_debugFile = fopen(optarg, "w");
1015 if (rx_debugFile == NULL)
1016 err(1, "fopen %s", optarg);
1018 errx(1, "compiled without RXDEBUG");
1022 minpeertimeout = strtol(optarg, &ptr, 0);
1023 if (ptr != 0 && ptr[0] != '\0')
1024 errx(1, "can't resolve min peer timeout");
1027 port = (short) strtol(optarg, &ptr, 0);
1028 if (ptr != 0 && ptr[0] != '\0')
1029 errx(1, "can't resolve portname");
1032 rxread_size = strtol(optarg, &ptr, 0);
1033 if (ptr != 0 && ptr[0] != '\0')
1034 errx(1, "can't resolve readsize");
1035 if (rxread_size > sizeof(somebuf))
1036 errx(1, "%d > sizeof(somebuf) (%"AFS_SIZET_FMT")", rxread_size,
1040 host = strdup(optarg);
1048 rxwrite_size = strtol(optarg, &ptr, 0);
1049 if (ptr != 0 && ptr[0] != '\0')
1050 errx(1, "can't resolve writesize");
1051 if (rxwrite_size > sizeof(somebuf))
1052 errx(1, "%d > sizeof(somebuf) (%"AFS_SIZET_FMT")", rxwrite_size,
1056 maxwsize = strtol(optarg, &ptr, 0);
1057 if (ptr && *ptr != '\0')
1058 errx(1, "can't resolve max send/recv window size (packets)");
1061 times = strtol(optarg, &ptr, 0);
1062 if (ptr && *ptr != '\0')
1063 errx(1, "can't resolve number of times to execute rpc");
1066 sendbytes = strtol(optarg, &ptr, 0);
1067 if (ptr && *ptr != '\0')
1068 errx(1, "can't resolve number of bytes to send");
1071 readbytes = strtol(optarg, &ptr, 0);
1072 if (ptr && *ptr != '\0')
1073 errx(1, "can't resolve number of bytes to receive");
1076 #ifdef AFS_PTHREAD_ENV
1077 threads = strtol(optarg, &ptr, 0);
1078 if (ptr && *ptr != '\0')
1079 errx(1, "can't resolve number of threads to execute");
1080 if (threads > MAX_THREADS)
1081 errx(1, "too many threads");
1083 errx(1, "Not built for pthreads");
1102 maxmtu = strtol(optarg, &ptr, 0);
1103 if (ptr && *ptr != '\0')
1104 errx(1, "can't resolve rx maxmtu to use");
1107 udpbufsz = strtol(optarg, &ptr, 0) * 1024;
1108 if (ptr && *ptr != '\0')
1109 errx(1, "can't resolve upd buffer size (Kbytes)");
1119 if (nostats && dumpstats)
1120 errx(1, "cannot set both -N and -D");
1122 if (threads > 1 && cmd == RX_PERF_FILE)
1123 errx(1, "cannot use multiple threads with file command");
1128 if (cmd == RX_PERF_UNKNOWN)
1129 errx(1, "no command given to the client");
1131 do_client(host, port, filename, cmd, times, bytes, sendbytes,
1132 readbytes, dumpstats, nojumbo, maxmtu, maxwsize, minpeertimeout,
1133 udpbufsz, nostats, hotthreads, threads);
1139 * setup world and call cmd
1143 main(int argc, char **argv)
1145 #ifndef AFS_PTHREAD_ENV
1149 setprogname(argv[0]);
1151 #ifndef AFS_NT40_ENV
1152 signal(SIGUSR1, sigusr1);
1153 signal(SIGINT, sigint);
1156 #ifndef AFS_PTHREAD_ENV
1157 LWP_InitializeProcessSupport(LWP_NORMAL_PRIORITY, &pid);
1160 memset(somebuf, 0, sizeof(somebuf));
1162 if (argc >= 2 && strcmp(argv[1], "server") == 0)
1163 rxperf_server(argc - 1, argv + 1);
1164 else if (argc >= 2 && strcmp(argv[1], "client") == 0)
1165 rxperf_client(argc - 1, argv + 1);