1spray(3SOCKET)             Sockets Library Functions            spray(3SOCKET)
2
3
4

NAME

6       spray - scatter data in order to test the network
7

SYNOPSIS

9       cc [ flag ... ] file ... -lsocket  -lnsl  [ library ... ]
10       #include <rpcsvc/spray.h>
11
12       bool_t xdr_sprayarr(XDR *xdrs, sprayarr *objp);
13
14
15       bool_t xdr_spraycumul(XDR *xdrs, spraycumul *objp);
16
17

DESCRIPTION

19       The  spray  program sends packets to a given machine to test communica‐
20       tions with that machine.
21
22
23       The spray program is not a C function interface, per se, but it can  be
24       accessed   using   the   generic  remote  procedure  calling  interface
25       clnt_call(). See rpc_clnt_calls(3NSL). The program sends  a  packet  to
26       the  called host. The host acknowledges receipt of the packet. The pro‐
27       gram counts the number of acknowledgments and can return that count.
28
29
30       The spray program currently supports the  following  procedures,  which
31       should be called in the order given:
32
33       SPRAYPROC_CLEAR    This procedure clears the counter.
34
35
36       SPRAYPROC_SPRAY    This procedure sends the packet.
37
38
39       SPRAYPROC_GET      This  procedure  returns the count and the amount of
40                          time since the last SPRAYPROC_CLEAR.
41
42

EXAMPLES

44       Example 1 Using spray()
45
46
47       The following code fragment demonstrates how the spray program is used:
48
49
50         #include <rpc/rpc.h>
51         #include <rpcsvc/spray.h>
52          .  .  .
53              spraycumul     spray_result;
54              sprayarr  spray_data;
55              char      buf[100];      /* arbitrary data */
56              int       loop = 1000;
57              CLIENT    *clnt;
58              struct timeval timeout0 = {0, 0};
59              struct timeval timeout25 = {25, 0};
60              spray_data.sprayarr_len = (uint_t)100;
61              spray_data.sprayarr_val = buf;
62              clnt = clnt_create("somehost", SPRAYPROG, SPRAYVERS, "netpath");
63              if (clnt == (CLIENT *)NULL) {
64                   /* handle this error */
65              }
66              if (clnt_call(clnt, SPRAYPROC_CLEAR,
67                   xdr_void, NULL, xdr_void, NULL, timeout25)) {
68                        /* handle this error */
69              }
70              while (loop− > 0) {
71                   if (clnt_call(clnt, SPRAYPROC_SPRAY,
72                        xdr_sprayarr, &spray_data, xdr_void, NULL, timeout0)) {
73                             /* handle this error */
74                   }
75              }
76              if (clnt_call(clnt, SPRAYPROC_GET,
77                   xdr_void, NULL, xdr_spraycumul, &spray_result, timeout25)) {
78                        /* handle this error */
79              }
80              printf("Acknowledged %ld of 1000 packets in %d secs %d usecs\n",
81                   spray_result.counter,
82                   spray_result.clock.sec,
83                   spray_result.clock.usec);
84
85

ATTRIBUTES

87       See attributes(5) for descriptions of the following attributes:
88
89
90
91
92       ┌─────────────────────────────┬─────────────────────────────┐
93       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
94       ├─────────────────────────────┼─────────────────────────────┤
95       │MT-Level                     │Unsafe                       │
96       └─────────────────────────────┴─────────────────────────────┘
97

SEE ALSO

99       spray(1M), rpc_clnt_calls(3NSL), attributes(5)
100

NOTES

102       This interface is unsafe in multithreaded applications.  Unsafe  inter‐
103       faces should be called only from the main thread.
104
105
106       A  spray  program  is  not  useful as a networking benchmark as it uses
107       unreliable connectionless transports, for example, udp. It can report a
108       large number of packets dropped, when the drops were caused by the pro‐
109       gram sending packets faster than they can be buffered locally, that is,
110       before the packets get to the network medium.
111
112
113
114SunOS 5.11                        30 Dec 1996                   spray(3SOCKET)
Impressum