1 .\" Copyright 2002 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 <dchapeskie@sandvine.com>
40 .Nd netgraph discard node type
42 .In netgraph/ng_source.h
46 node acts as a source of packets according to the parameters set up
47 using control messages and input packets.
50 hook must also be connected to a node that responds to the
51 .Dv NGM_ETHER_COOKIE Ns / Ns
52 .Dv NGM_ETHER_GET_IFINDEX
56 This type is used for testing and debugging.
58 The operation of the node is as follows:
61 Packets received on the
63 hook are queued internally.
67 message the node starts sending
68 the queued packets out the
70 hook on every clock tick as fast
71 as the connect interface will take them.
73 While active, on every clock tick the node checks the available space
76 of the interface connected to the output hook and sends
77 that many packets out its
81 Once the number of packets indicated in the start message have been
82 sent, or on reception of a stop message, the node stops sending data.
93 hook must remain connected, its disconnection will shutdown the node.
95 This node type supports the generic control messages as well as the following,
96 which must be sent with the
99 .Bl -tag -width indent
100 .It Dv NGM_SOURCE_GET_STATS Pq Ic getstats
101 Returns a structure containing the following fields:
102 .Bl -tag -width indent
104 The number of octets/bytes sent out the
108 The number of frames/packets sent out the
112 The number of octets queued from the
116 The number of frames queued from the
120 The time the last start message was received.
122 The time the last end message was received or
123 the output packet count was reached.
126 .Va endTime Li \- Va startTime
131 .It Dv NGM_SOURCE_CLR_STATS Pq Ic clrstats
132 Clears and resets the statistics returned by
138 .It Dv NGM_SOURCE_GETCLR_STATS Pq Ic getclrstats
141 but clears the statistics at the same time.
142 .It Dv NGM_SOURCE_START Pq Ic start
147 parameter which is the number of packets to
148 send before stopping.
150 Starts sending the queued packets out the output hook.
152 The output hook must be connected or
156 The node connected to the output hook must respond to
157 .Dv NGM_ETHER_GET_IFINDEX
158 which is used to get the
160 of the attached interface.
162 .Dv NGM_ETHER_SET_AUTOSRC
163 is sent to the node connected to the
166 to turn off automatic ethernet source address overwriting (any errors
167 from this message are ignored).
169 .It Dv NGM_SOURCE_STOP Pq Ic stop
170 Stops the node if it is active.
171 .It Dv NGM_SOURCE_CLR_DATA Pq Ic clrdata
172 Clears the packets queued from the
177 This node shuts down upon receipt of a
179 control message, or when the
181 hook has been disconnected.
183 Attach the node to an
185 node for an interface.
189 not already loaded you will need to do so.
190 For example, these commands
193 module and attach the
203 .Bd -literal -offset indent
205 ngctl mkpeer bge0: source orphans output
208 At this point the new node can be referred to as
209 .Dq Li bge0:orphans .
211 node can be given its own name like this:
213 .Dl "ngctl name bge0:orphans src0"
215 After which it can be referred to as
218 Once created, packets need to be sent to the node, the TCL net package
219 can be used to generate these packets:
221 [Sandvine specific TCL code example omitted]
223 To feed the output of the above TCL script to the
230 .Dl "tcl genPacket | nghook bge0:orphans input"
232 To check that the node has queued these packets you can get the node
234 .Bd -literal -offset indent
235 ngctl msg bge0:orphans getstats
236 Args: { queueOctets=64 queueFrames=1 }
239 Send as many packets as required out the
243 .Dl "ngctl msg bge0:orphans start 16"
245 Either wait for them to be sent (periodically fetching stats if desired)
246 or send the stop message:
248 .Dl "ngctl msg bge0:orphans stop"
250 Check the statistics (here we use
252 to also clear the statistics):
253 .Bd -literal -offset indent
254 ngctl msg bge0:orphans getclrstats
255 Args: { outOctets=1024 outFrames=16 queueOctets=64 queueFrames=1
256 startTime={ tv_sec=1035305880 tv_usec=758036 } endTime={ tv_sec=1035305880
257 tv_usec=759041 } elapsedTime={ tv_usec=1005 } }
261 .Vt "struct timeval" Ns s ,
264 field is seconds since
265 the Epoch and can be converted into a date string via TCL's [clock
269 .Bd -literal -offset indent
271 Tue Oct 22 12:58:00 EDT 2002
273 .Sh IMPLEMENTATION NOTES
283 the time taken by a single invocation of
286 large and the packet rate drops.
287 Probably due to the NIC starting to
288 send the packets right away.
290 Copying all the packets in one loop and sending them in another inside
293 is done to limit how long we are at
296 minor packet rate increases (~5% at 256 byte packets).
298 that if there are errors in the send loop, the remaining copied packets
299 are simply freed and discarded; thus we skip those packets, and ordering
300 of the input queue to the output is not maintained.
307 beginning is done to help avoid CPU starvation if
309 takes a long time to run.
314 It is used for synchronization
315 within the node (e.g., data received on the
319 is active) but we do not want to hold it too long and risk
322 For clarity and simplicity, debugging messages and instrumentation code
324 On i386 one can include
325 .In machine/cpufunc.h
326 to have access to the
328 function to read the instruction counter at the
331 Also useful is the packet count returned by
333 Do not try to report such things from within
335 instead include the values in
347 node type was implemented in
350 .An Dave Chapeskie Aq dchapeskie@SANDVINE.com