1 .\" Copyright 2002-2007 Sandvine Inc.
2 .\" All rights reserved.
4 .\" Subject to the following obligations and disclaimer of warranty, use and
5 .\" redistribution of this software, in source or object code forms, with or
6 .\" without modifications are expressly permitted by Sandvine Inc.; provided,
8 .\" 1. Any and all reproductions of the source or object code must include the
9 .\" copyright notice above and the following disclaimer of warranties; and
10 .\" 2. No rights are granted, in any manner or form, to use Sandvine Inc.
11 .\" trademarks, including the mark "SANDVINE" on advertising, endorsements,
12 .\" or otherwise except as such appears in the above copyright notice or in
15 .\" THIS SOFTWARE IS BEING PROVIDED BY SANDVINE "AS IS", AND TO THE MAXIMUM
16 .\" EXTENT PERMITTED BY LAW, SANDVINE MAKES NO REPRESENTATIONS OR WARRANTIES,
17 .\" EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE, INCLUDING WITHOUT LIMITATION,
18 .\" ANY AND ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
19 .\" PURPOSE, OR NON-INFRINGEMENT. SANDVINE DOES NOT WARRANT, GUARANTEE, OR
20 .\" MAKE ANY REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE
21 .\" USE OF THIS SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY
22 .\" OR OTHERWISE. IN NO EVENT SHALL SANDVINE BE LIABLE FOR ANY DAMAGES
23 .\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
24 .\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
25 .\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
26 .\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY
27 .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 .\" THIS SOFTWARE, EVEN IF SANDVINE IS ADVISED OF THE POSSIBILITY OF SUCH
32 .\" Author: Dave Chapeskie
40 .Nd netgraph node for traffic generation
43 .In netgraph/ng_source.h
47 node acts as a source of packets according to the parameters set up
48 using control messages and input packets.
51 node type is used primarily for testing and benchmarking.
61 hook must remain connected, its disconnection will shutdown the node.
63 The operation of the node is as follows.
64 Packets received on the
66 hook are queued internally.
71 node assumes that its neighbour node is of
74 The neighbour is queried for its interface name.
77 node then uses queue of the interface for its evil purposes.
85 If interface name cannot be obtained automatically, it should
86 be configured explicitly with the
87 .Dv NGM_SOURCE_SETIFACE
90 should be turned off on
94 If the node is connected to a netgraph network, which does not
97 interface, limit the packet injection rate explicitly with the
103 control message the node starts sending
104 the previously queued packets out the
106 hook on every clock tick as fast
107 as the connected interface will take them.
108 While active, on every clock tick the node checks the available space
109 in the interface queue and sends that many packets out its
112 Once the number of packets indicated in the start message has been
113 sent, or upon receipt of a
115 message, the node stops sending data.
117 This node type supports the generic control messages as well as the following,
118 which must be sent with the
119 .Dv NGM_SOURCE_COOKIE
122 .It Dv NGM_SOURCE_GET_STATS Pq Ic getstats
123 Returns a structure containing the following fields:
124 .Bl -tag -width ".Va elapsedTime"
126 The number of octets/bytes sent out the
130 The number of frames/packets sent out the
134 The number of octets queued from the
138 The number of frames queued from the
142 The time the last start message was received.
144 The time the last end message was received or
145 the output packet count was reached.
148 .Va endTime Li \- Va startTime
153 .It Dv NGM_SOURCE_CLR_STATS Pq Ic clrstats
154 Clears and resets the statistics returned by
160 .It Dv NGM_SOURCE_GETCLR_STATS Pq Ic getclrstats
163 but clears the statistics at the same time.
164 .It Dv NGM_SOURCE_START Pq Ic start
165 This message requires a single
167 parameter which is the number of packets to
168 send before stopping.
169 Node starts sending the queued packets out the
174 hook must be connected and node must have
175 interface configured.
176 .It Dv NGM_SOURCE_STOP Pq Ic stop
177 Stops the node if it is active.
178 .It Dv NGM_SOURCE_CLR_DATA Pq Ic clrdata
179 Clears the packets queued from the
182 .It Dv NGM_SOURCE_SETIFACE Pq Ic setiface
183 This message requires the name of the interface
184 to be configured as an argument.
185 .It Dv NGM_SOURCE_SETPPS Pq Ic setpps
186 This message requires a single
188 parameter which puts upper limit on the amount of packets
190 .It Dv NGM_SOURCE_SET_TIMESTAMP Pq Ic settimestamp
191 This message specifies that a timestamp (in the format of a
192 .Vt "struct timeval" )
193 should be inserted in the transmitted packets.
194 This message requires a structure containing the following fields:
195 .Bl -tag -width ".Va offset"
197 The offset from the beginning of the packet at which the timestamp is to be
200 Set to 1 to enable the timestamp.
202 .It Dv NGM_SOURCE_GET_TIMESTAMP Pq Ic gettimestamp
203 Returns the current timestamp settings in the form of the structure described
205 .It Dv NGM_SOURCE_SET_COUNTER Pq Ic setcounter
206 This message specifies that a counter should be embedded in transmitted
208 Up to four counters may be independently configured.
209 This message requires a structure containing the following fields:
210 .Bl -tag -width ".Va increment"
212 The offset from the beginning of the packet at which the counter is to be
215 Set to 1 to enable the counter.
217 The byte width of the counter.
218 It may be 1, 2, or 4.
220 The value for the next insertion of the counter.
222 The minimum value to be used by the counter.
224 The maximum value to be used by the counter.
226 The value to be added to the counter after each insertion.
229 The counter to be configured, from 0 to 3.
231 .It Dv NGM_SOURCE_GET_COUNTER Pq Ic getcounter
232 This message requires a single
234 parameter which specifies the counter to query.
235 Returns the current counter settings in the form of the structure described
239 This node shuts down upon receipt of a
241 control message, when all hooks have been disconnected, or when the
243 hook has been disconnected.
245 Attach the node to an
247 node for an interface.
251 not already loaded you will need to do so.
252 For example, these commands
255 module and attach the
265 .Bd -literal -offset indent
267 ngctl mkpeer bge0: source orphans output
270 At this point the new node can be referred to as
271 .Dq Li bge0:orphans .
273 node can be given its own name like this:
275 .Dl "ngctl name bge0:orphans src0"
277 After which it can be referred to as
280 Once created, packets can be sent to the node as raw binary data.
281 Each packet must be delivered in a separate netgraph message.
283 The following example uses a short Perl script to convert the hex
284 representation of an ICMP packet to binary and deliver it to the
290 .Bd -literal -offset indent
291 perl -pe 's/(..)[ \et\en]*/chr(hex($1))/ge' <<EOF | nghook src0: input
292 ff ff ff ff ff ff 00 00 00 00 00 00 08 00 45 00
293 00 54 cb 13 00 00 40 01 b9 87 c0 a8 2b 65 0a 00
294 00 01 08 00 f8 d0 c9 76 00 00 45 37 01 73 00 01
295 04 0a 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15
296 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24 25
297 26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 34 35
302 To check that the node has queued these packets you can get the node
304 .Bd -literal -offset indent
305 ngctl msg bge0:orphans getstats
306 Args: { queueOctets=64 queueFrames=1 }
309 Send as many packets as required out the
313 .Dl "ngctl msg bge0:orphans start 16"
315 Either wait for them to be sent (periodically fetching stats if desired)
316 or send the stop message:
318 .Dl "ngctl msg bge0:orphans stop"
320 Check the statistics (here we use
322 to also clear the statistics):
323 .Bd -literal -offset indent
324 ngctl msg bge0:orphans getclrstats
325 Args: { outOctets=1024 outFrames=16 queueOctets=64 queueFrames=1
326 startTime={ tv_sec=1035305880 tv_usec=758036 } endTime={ tv_sec=1035305880
327 tv_usec=759041 } elapsedTime={ tv_usec=1005 } }
331 .Vt "struct timeval" Ns s ,
334 field is seconds since
335 the Epoch and can be converted into a date string via TCL's [clock
339 .Bd -literal -offset indent
341 Tue Oct 22 12:58:00 EDT 2002
353 node type was implemented in