spray(3N) LIBRARY FUNCTIONS spray(3N)
NAME
spray - scatter data in order to check the network
SYNOPSIS
#include <rpcsvc/spray.h>
DESCRIPTION
The spray protocol sends packets to a given machine to test
the speed and reliability of communications with that
machine. The spray protocol is not a C function interface,
per se, but can be accessed using the generic remote pro-
cedure calling interface clntcall() [see
rpcclntcalls(3N)]. The protocol sends a packet to the
called host. The host acknowledges receipt of the packet.
The protocol counts the number of acknowledgments and can
return that count. The spray protocol currently supports
the following procedures, which should be called in the
order given:
SPRAYPROCCLEAR
This procedure clears the counter.
SPRAYPROCSPRAY
This procedure sends the packet.
SPRAYPROCGET
This procedure returns the count and the amount of time
since the last SPRAYPROCCLEAR. The following XDR rou-
tines are available in librpcsvc:
xdrsprayarr
xdrspraycumul
EXAMPLE
The following code fragment demonstrates how the spray pro-
tocol is used:
#include <rpc/rpc.h>
#include <rpcsvc/spray.h>
. . .
spraycumul sprayresult;
sprayarr spraydata;
char buf[100]; /* arbitrary data */
int loop = 1000;
CLIENT *clnt;
struct timeval timeout0 = {0, 0};
struct timeval timeout25 = {25, 0};
spraydata.sprayarrlen = (uint)100;
spraydata.sprayarrval = buf;
clnt = clntcreate("somehost", SPRAYPROG, SPRAYVERS, "netpath");
if (clnt == (CLIENT *)NULL) {
1
spray(3N) LIBRARY FUNCTIONS spray(3N)
/* handle this error */
}
if (clntcall(clnt, SPRAYPROCCLEAR,
xdrvoid, NULL, xdrvoid, NULL, timeout25)) {
/* handle this error */
}
while (loop-- > 0) {
if (clntcall(clnt, SPRAYPROCSPRAY,
xdrsprayarr, &spraydata, xdrvoid, NULL, timeout0)) {
/* handle this error */
}
}
if (clntcall(clnt, SPRAYPROCGET,
xdrvoid, NULL, xdrspraycumul, &sprayresult, timeout25)) {
/* handle this error */
}
printf("Acknowledged %ld of 1000 packets in %d secs %d usecs\n",
sprayresult.counter,
sprayresult.clock.sec,
sprayresult.clock.usec);
SEE ALSO
rpcclntcalls(3N), spray(1M), sprayd(1M).
2