spray(3N) 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 procedure 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 routines are available in librpcsvc:
xdrsprayarr
xdrspraycumul
EXAMPLE
The following code fragment demonstrates how the spray protocol 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;
7/91 Page 1
spray(3N) spray(3N)
spraydata.sprayarrval = buf;
clnt = clntcreate("somehost", SPRAYPROG, SPRAYVERS, "netpath");
if (clnt == (CLIENT *)NULL) {
/* 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).
Page 2 7/91