1.\" Copyright 2002 Sandvine Inc. 2.\" All rights reserved. 3.\" 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, 7.\" however, that: 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 13.\" the software. 14.\" 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 30.\" DAMAGE. 31.\" 32.\" Author: Dave Chapeskie <dchapeskie@sandvine.com> 33.\" $FreeBSD$ 34.\" 35.Dd April 5, 2005 36.Dt NG_SOURCE 4 37.Os 38.Sh NAME 39.Nm ng_source 40.Nd netgraph node for traffic generation 41.Sh SYNOPSIS 42.In sys/types.h 43.In netgraph/ng_source.h 44.Sh DESCRIPTION 45The 46.Nm source 47node acts as a source of packets according to the parameters set up 48using control messages and input packets. 49The 50.Nm 51node type is used primarily for testing and benchmarking. 52.Sh HOOKS 53The 54.Nm source 55node has two hooks: 56.Va input 57and 58.Va output . 59The 60.Va output 61hook must remain connected, its disconnection will shutdown the node. 62.Sh OPERATION 63The operation of the node is as follows. 64Packets received on the 65.Va input 66hook are queued internally. 67When 68.Va output 69hook is connected, 70.Nm 71node assumes that its neighbour node is of 72.Xr ng_ether 4 73node type. 74The neighbour is queried for its interface name. 75The 76.Nm 77node then uses queue of the interface for its evil purposes. 78The 79.Nm 80node also disables 81.Va autosrc 82option on neighbour 83.Xr ng_ether 4 84node. 85If interface name cannot be obtained automatically, it should 86be configured explicitly with the 87.Dv NGM_SOURCE_SETIFACE 88control message, and 89.Va autosrc 90should be turned off on 91.Xr ng_ether 4 92node manually. 93.Pp 94Once interface is configured, upon receipt of a 95.Dv NGM_SOURCE_START 96control message the node starts sending 97the previously queued packets out the 98.Va output 99hook on every clock tick as fast 100as the connected interface will take them. 101While active, on every clock tick the node checks the available space 102in the interface queue and sends that many packets out its 103.Va output 104hook. 105Once the number of packets indicated in the start message has been 106sent, or upon receipt of a 107.Dv NGM_SOURCE_STOP 108message, the node stops sending data. 109.Sh CONTROL MESSAGES 110This node type supports the generic control messages as well as the following, 111which must be sent with the 112.Dv NGM_SOURCE_COOKIE 113attached. 114.Bl -tag -width indent 115.It Dv NGM_SOURCE_GET_STATS Pq Ic getstats 116Returns a structure containing the following fields: 117.Bl -tag -width indent 118.It Va outOctets 119The number of octets/bytes sent out the 120.Va output 121hook. 122.It Va outFrames 123The number of frames/packets sent out the 124.Va output 125hook. 126.It Va queueOctets 127The number of octets queued from the 128.Va input 129hook. 130.It Va queueFrames 131The number of frames queued from the 132.Va input 133hook. 134.It Va startTime 135The time the last start message was received. 136.It Va endTime 137The time the last end message was received or 138the output packet count was reached. 139.It Va elapsedTime 140Either 141.Va endTime Li \- Va startTime 142or current time 143\- 144.Va startTime . 145.El 146.It Dv NGM_SOURCE_CLR_STATS Pq Ic clrstats 147Clears and resets the statistics returned by 148.Ic getstats 149(except 150.Va queueOctets 151and 152.Va queueFrames ) . 153.It Dv NGM_SOURCE_GETCLR_STATS Pq Ic getclrstats 154As 155.Ic getstats 156but clears the statistics at the same time. 157.It Dv NGM_SOURCE_START Pq Ic start 158This message requires a single 159.Vt uint64_t 160parameter which is the number of packets to 161send before stopping. 162Node starts sending the queued packets out the 163.Va output 164hook. 165The 166.Va output 167hook must be connected and node must have 168interface configured. 169.It Dv NGM_SOURCE_STOP Pq Ic stop 170Stops the node if it is active. 171.It Dv NGM_SOURCE_CLR_DATA Pq Ic clrdata 172Clears the packets queued from the 173.Va input 174hook. 175.It Dv NGM_SOURCE_SETIFACE Pq Ic setiface 176This message requires the name of the interface 177to be configured as an argument. 178.El 179.Sh SHUTDOWN 180This node shuts down upon receipt of a 181.Dv NGM_SHUTDOWN 182control message, when all hooks have been disconnected, or when the 183.Va output 184hook has been disconnected. 185.Sh EXAMPLES 186Attach the node to an 187.Xr ng_ether 4 188node for an interface. 189If 190.Nm ng_ether 191is 192not already loaded you will need to do so. 193For example, these commands 194load the 195.Nm ng_ether 196module and attach the 197.Va output 198hook of a new 199.Nm source 200node to 201.Va orphans 202hook of the 203.Li bge0: 204.Nm ng_ether 205node. 206.Bd -literal -offset indent 207kldload ng_ether 208ngctl mkpeer bge0: source orphans output 209.Ed 210.Pp 211At this point the new node can be referred to as 212.Dq Li bge0:orphans . 213The 214node can be given its own name like this: 215.Pp 216.Dl "ngctl name bge0:orphans src0" 217.Pp 218After which it can be referred to as 219.Dq Li src0: . 220.Pp 221Once created, packets need to be sent to the node, the TCL net package 222can be used to generate these packets: 223.Pp 224[Sandvine specific TCL code example omitted] 225.Pp 226To feed the output of the above TCL script to the 227.Nm source 228node's 229.Va input 230hook via 231.Xr nghook 8 : 232.Pp 233.Dl "tcl genPacket | nghook bge0:orphans input" 234.Pp 235To check that the node has queued these packets you can get the node 236statistics: 237.Bd -literal -offset indent 238ngctl msg bge0:orphans getstats 239Args: { queueOctets=64 queueFrames=1 } 240.Ed 241.Pp 242Send as many packets as required out the 243.Va output 244hook: 245.Pp 246.Dl "ngctl msg bge0:orphans start 16" 247.Pp 248Either wait for them to be sent (periodically fetching stats if desired) 249or send the stop message: 250.Pp 251.Dl "ngctl msg bge0:orphans stop" 252.Pp 253Check the statistics (here we use 254.Ic getclrstats 255to also clear the statistics): 256.Bd -literal -offset indent 257ngctl msg bge0:orphans getclrstats 258Args: { outOctets=1024 outFrames=16 queueOctets=64 queueFrames=1 259startTime={ tv_sec=1035305880 tv_usec=758036 } endTime={ tv_sec=1035305880 260tv_usec=759041 } elapsedTime={ tv_usec=1005 } } 261.Ed 262.Pp 263The times are from 264.Vt "struct timeval" Ns s , 265the 266.Va tv_sec 267field is seconds since 268the Epoch and can be converted into a date string via TCL's [clock 269format] or via the 270.Xr date 1 271command: 272.Bd -literal -offset indent 273date -r 1035305880 274Tue Oct 22 12:58:00 EDT 2002 275.Ed 276.Sh SEE ALSO 277.Xr netgraph 4 , 278.Xr ng_echo 4 , 279.Xr ng_hole 4 , 280.Xr ng_tee 4 , 281.Xr ngctl 8 , 282.Xr nghook 8 283.Sh HISTORY 284The 285.Nm 286node type was implemented in 287.Fx 4.8 . 288.Sh AUTHORS 289.An Dave Chapeskie Aq dchapeskie@SANDVINE.com 290