spray.c (2a8bcb4efb45d99ac41c94a75c396b362c414f7f) | spray.c (201ceb75ab95f9bf1f42ea1dc9ab363b43ba47cf) |
---|---|
1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * --- 122 unchanged lines hidden (view full) --- 131 } 132 if ((co = sprayproc_get_1(NULL, clnt)) == NULL) { 133 clnt_perror(clnt, "SPRAYPROC_GET "); 134 exit(1); 135 } 136 cumul = *co; 137 if (cumul.counter < cnt) 138 printf("\n\t%d packets (%.3f%%) dropped by %s\n", | 1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * --- 122 unchanged lines hidden (view full) --- 131 } 132 if ((co = sprayproc_get_1(NULL, clnt)) == NULL) { 133 clnt_perror(clnt, "SPRAYPROC_GET "); 134 exit(1); 135 } 136 cumul = *co; 137 if (cumul.counter < cnt) 138 printf("\n\t%d packets (%.3f%%) dropped by %s\n", |
139 cnt - cumul.counter, 140 100.0 * (cnt - cumul.counter)/cnt, host); | 139 cnt - cumul.counter, 140 100.0 * (cnt - cumul.counter)/cnt, host); |
141 else 142 printf("\n\tno packets dropped by %s\n", host); | 141 else 142 printf("\n\tno packets dropped by %s\n", host); |
143 psec = (1000000.0 * cumul.counter) 144 / (1000000.0 * cumul.clock.sec + cumul.clock.usec); 145 bsec = (lnth * 1000000.0 * cumul.counter)/ 146 (1000000.0 * cumul.clock.sec + cumul.clock.usec); | 143 psec = (1000000.0 * cumul.counter) / 144 (1000000.0 * cumul.clock.sec + cumul.clock.usec); 145 bsec = (lnth * 1000000.0 * cumul.counter) / 146 (1000000.0 * cumul.clock.sec + cumul.clock.usec); |
147 printf("\t%u packets/sec, %u bytes/sec\n", psec, bsec); 148 exit(0); 149 /* NOTREACHED */ 150} 151 152/* 153 * A special call, where the TIMEOUT is 0. So, every call times-out. 154 */ 155static struct timeval TIMEOUT = { 0, 0 }; 156 157enum clnt_stat | 147 printf("\t%u packets/sec, %u bytes/sec\n", psec, bsec); 148 exit(0); 149 /* NOTREACHED */ 150} 151 152/* 153 * A special call, where the TIMEOUT is 0. So, every call times-out. 154 */ 155static struct timeval TIMEOUT = { 0, 0 }; 156 157enum clnt_stat |
158sprayproc_spray_1nd(argp, clnt) 159 sprayarr *argp; 160 CLIENT *clnt; | 158sprayproc_spray_1nd(sprayarr *argp, CLIENT *clnt) |
161{ 162 return (clnt_call(clnt, SPRAYPROC_SPRAY, xdr_sprayarr, (caddr_t)argp, | 159{ 160 return (clnt_call(clnt, SPRAYPROC_SPRAY, xdr_sprayarr, (caddr_t)argp, |
163 xdr_void, NULL, TIMEOUT)); | 161 xdr_void, NULL, TIMEOUT)); |
164} 165 166/* A cheap milliseconds sleep call */ 167static void | 162} 163 164/* A cheap milliseconds sleep call */ 165static void |
168slp(usecs) | 166slp(int usecs) |
169{ 170 static struct pollfd pfds[1] = { 171 0, POLLIN, 0 172 }; 173 pfds[0].fd = fileno(stdout); 174 poll(pfds, 1, usecs/1000); 175} 176 177static void 178usage() 179{ 180 printf("spray host [-t nettype] [-l lnth] [-c cnt] [-d delay]\n"); 181 exit(1); 182} | 167{ 168 static struct pollfd pfds[1] = { 169 0, POLLIN, 0 170 }; 171 pfds[0].fd = fileno(stdout); 172 poll(pfds, 1, usecs/1000); 173} 174 175static void 176usage() 177{ 178 printf("spray host [-t nettype] [-l lnth] [-c cnt] [-d delay]\n"); 179 exit(1); 180} |