summaryrefslogtreecommitdiff
path: root/usr/src/man/man3socket/spray.3socket
blob: ed725e2c3d46357b43e3f49f3ba909caf6515fba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
'\" te
.\"  Copyright 1989 AT&T  Copyright (c) 1997, Sun Microsystems, Inc.  All Rights Reserved
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
.TH SPRAY 3SOCKET "Dec 30, 1996"
.SH NAME
spray \- scatter data in order to test the network
.SH SYNOPSIS
.LP
.nf
\fBcc\fR [ \fIflag\fR ... ] \fIfile\fR ... \fB-lsocket\fR \fB -lnsl \fR [ \fIlibrary\fR ... ]
#include <rpcsvc/spray.h>

\fBbool_t\fR \fBxdr_sprayarr\fR(\fBXDR *\fR\fIxdrs\fR, \fBsprayarr *\fR\fIobjp\fR);
.fi

.LP
.nf
\fBbool_t\fR \fBxdr_spraycumul\fR(\fBXDR *\fR\fIxdrs\fR, \fBspraycumul *\fR\fIobjp\fR);
.fi

.SH DESCRIPTION
.sp
.LP
The spray program sends packets to a given machine to test communications with
that machine.
.sp
.LP
The spray program is not a C function interface, per se, but it can be accessed
using the generic remote procedure calling interface \fBclnt_call()\fR. See
\fBrpc_clnt_calls\fR(3NSL). The program sends a packet to the called host. The
host acknowledges receipt of the packet. The program counts the number of
acknowledgments and can return that count.
.sp
.LP
The spray program currently supports the following procedures, which should be
called in the order given:
.sp
.ne 2
.na
\fB\fBSPRAYPROC_CLEAR\fR\fR
.ad
.RS 19n
This procedure clears the counter.
.RE

.sp
.ne 2
.na
\fB\fBSPRAYPROC_SPRAY\fR\fR
.ad
.RS 19n
This procedure sends the packet.
.RE

.sp
.ne 2
.na
\fB\fBSPRAYPROC_GET\fR\fR
.ad
.RS 19n
This procedure returns the count and the amount of time since the last
\fBSPRAYPROC_CLEAR\fR.
.RE

.SH EXAMPLES
.LP
\fBExample 1 \fRUsing \fBspray()\fR
.sp
.LP
The following code fragment demonstrates how the spray program is used:

.sp
.in +2
.nf
#include <rpc/rpc.h>
#include <rpcsvc/spray.h>
 .  .  .
	spraycumul	spray_result;
	sprayarr	spray_data;
	char		buf[100];		/* arbitrary data */
	int		loop = 1000;
	CLIENT	*clnt;
	struct timeval timeout0 = {0, 0};
	struct timeval timeout25 = {25, 0};
	spray_data.sprayarr_len = (uint_t)100;
	spray_data.sprayarr_val = buf;
	clnt = clnt_create("somehost", SPRAYPROG, SPRAYVERS, "netpath");
	if (clnt == (CLIENT *)NULL) {
		/* handle this error */
	}
	if (clnt_call(clnt, SPRAYPROC_CLEAR,
		xdr_void, NULL, xdr_void, NULL, timeout25)) {
			/* handle this error */
	}
	while (loop\(mi > 0) {
		if (clnt_call(clnt, SPRAYPROC_SPRAY,
			xdr_sprayarr, &spray_data, xdr_void, NULL, timeout0)) {
				/* handle this error */
		}
	}
	if (clnt_call(clnt, SPRAYPROC_GET,
		xdr_void, NULL, xdr_spraycumul, &spray_result, timeout25)) {
			/* handle this error */
	}
	printf("Acknowledged %ld of 1000 packets in %d secs %d usecs\en",
		spray_result.counter,
		spray_result.clock.sec,
		spray_result.clock.usec);
.fi
.in -2

.SH ATTRIBUTES
.sp
.LP
See \fBattributes\fR(5) for descriptions of the following attributes:
.sp

.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE	ATTRIBUTE VALUE
_
MT-Level	Unsafe
.TE

.SH SEE ALSO
.sp
.LP
\fBspray\fR(1M), \fBrpc_clnt_calls\fR(3NSL), \fBattributes\fR(5)
.SH NOTES
.sp
.LP
This interface is unsafe in multithreaded applications.  Unsafe interfaces
should be called only from the main thread.
.sp
.LP
A spray program is not useful as a networking benchmark as it uses  unreliable
connectionless transports, for example, udp. It can report a large number of
packets dropped, when the drops were caused by the program sending packets
faster than they can be buffered locally, that is, before the packets get to
the network medium.