1585ff168SJulian Elischer.\" Copyright 2002 Sandvine Inc. 2585ff168SJulian Elischer.\" All rights reserved. 3585ff168SJulian Elischer.\" 4585ff168SJulian Elischer.\" Subject to the following obligations and disclaimer of warranty, use and 5585ff168SJulian Elischer.\" redistribution of this software, in source or object code forms, with or 6585ff168SJulian Elischer.\" without modifications are expressly permitted by Sandvine Inc.; provided, 7585ff168SJulian Elischer.\" however, that: 8585ff168SJulian Elischer.\" 1. Any and all reproductions of the source or object code must include the 9585ff168SJulian Elischer.\" copyright notice above and the following disclaimer of warranties; and 10585ff168SJulian Elischer.\" 2. No rights are granted, in any manner or form, to use Sandvine Inc. 11585ff168SJulian Elischer.\" trademarks, including the mark "SANDVINE" on advertising, endorsements, 12585ff168SJulian Elischer.\" or otherwise except as such appears in the above copyright notice or in 13585ff168SJulian Elischer.\" the software. 14585ff168SJulian Elischer.\" 15585ff168SJulian Elischer.\" THIS SOFTWARE IS BEING PROVIDED BY SANDVINE "AS IS", AND TO THE MAXIMUM 16585ff168SJulian Elischer.\" EXTENT PERMITTED BY LAW, SANDVINE MAKES NO REPRESENTATIONS OR WARRANTIES, 17585ff168SJulian Elischer.\" EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE, INCLUDING WITHOUT LIMITATION, 18585ff168SJulian Elischer.\" ANY AND ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 19585ff168SJulian Elischer.\" PURPOSE, OR NON-INFRINGEMENT. SANDVINE DOES NOT WARRANT, GUARANTEE, OR 20585ff168SJulian Elischer.\" MAKE ANY REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE 21585ff168SJulian Elischer.\" USE OF THIS SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY 22585ff168SJulian Elischer.\" OR OTHERWISE. IN NO EVENT SHALL SANDVINE BE LIABLE FOR ANY DAMAGES 23585ff168SJulian Elischer.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING 24585ff168SJulian Elischer.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 25585ff168SJulian Elischer.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR 26585ff168SJulian Elischer.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY 27585ff168SJulian Elischer.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28585ff168SJulian Elischer.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29585ff168SJulian Elischer.\" THIS SOFTWARE, EVEN IF SANDVINE IS ADVISED OF THE POSSIBILITY OF SUCH 30585ff168SJulian Elischer.\" DAMAGE. 31585ff168SJulian Elischer.\" 32585ff168SJulian Elischer.\" Author: Dave Chapeskie <dchapeskie@sandvine.com> 33585ff168SJulian Elischer.\" $FreeBSD$ 34585ff168SJulian Elischer.\" 3537684cf3SGleb Smirnoff.Dd April 5, 2005 36585ff168SJulian Elischer.Dt NG_SOURCE 4 37585ff168SJulian Elischer.Os 38585ff168SJulian Elischer.Sh NAME 39585ff168SJulian Elischer.Nm ng_source 4037684cf3SGleb Smirnoff.Nd netgraph node for traffic generation 41585ff168SJulian Elischer.Sh SYNOPSIS 42fbad9e2dSRuslan Ermilov.In sys/types.h 43585ff168SJulian Elischer.In netgraph/ng_source.h 44585ff168SJulian Elischer.Sh DESCRIPTION 45585ff168SJulian ElischerThe 46585ff168SJulian Elischer.Nm source 47585ff168SJulian Elischernode acts as a source of packets according to the parameters set up 48585ff168SJulian Elischerusing control messages and input packets. 4976648c1fSRuslan ErmilovThe 5037684cf3SGleb Smirnoff.Nm 5137684cf3SGleb Smirnoffnode type is used primarily for testing and benchmarking. 52585ff168SJulian Elischer.Sh HOOKS 53585ff168SJulian ElischerThe 54585ff168SJulian Elischer.Nm source 5576648c1fSRuslan Ermilovnode has two hooks: 5637684cf3SGleb Smirnoff.Va input 5776648c1fSRuslan Ermilovand 5837684cf3SGleb Smirnoff.Va output . 5976648c1fSRuslan ErmilovThe 6037684cf3SGleb Smirnoff.Va output 61585ff168SJulian Elischerhook must remain connected, its disconnection will shutdown the node. 6237684cf3SGleb Smirnoff.Sh OPERATION 6337684cf3SGleb SmirnoffThe operation of the node is as follows. 6437684cf3SGleb SmirnoffPackets received on the 6537684cf3SGleb Smirnoff.Va input 6637684cf3SGleb Smirnoffhook are queued internally. 6737684cf3SGleb SmirnoffWhen 6837684cf3SGleb Smirnoff.Va output 6937684cf3SGleb Smirnoffhook is connected, 7037684cf3SGleb Smirnoff.Nm 7137684cf3SGleb Smirnoffnode assumes that its neighbour node is of 7237684cf3SGleb Smirnoff.Xr ng_ether 7337684cf3SGleb Smirnoffnode type. 7437684cf3SGleb SmirnoffThe neighbor is queried for its interface name. 7537684cf3SGleb Smirnoff.Nm 7637684cf3SGleb Smirnoffnode then uses queue of the interface for its evil purposes. 7737684cf3SGleb Smirnoff.Nm 7837684cf3SGleb Smirnoffnode also disables 7937684cf3SGleb Smirnoff.Va autosrc 8037684cf3SGleb Smirnoffoption on neighbour 8137684cf3SGleb Smirnoff.Xr ng_ether 8237684cf3SGleb Smirnoffnode. 8337684cf3SGleb SmirnoffIf interface name can't be obtained automatically, it should 8437684cf3SGleb Smirnoffbe configured explicitly with help of 8537684cf3SGleb Smirnoff.Dv NGM_SOURCE_SETIFACE 8637684cf3SGleb Smirnoffcontrol message, and 8737684cf3SGleb Smirnoff.Va autosrc 8837684cf3SGleb Smirnoffshould be turned off on 8937684cf3SGleb Smirnoff.Xr ng_ether 9037684cf3SGleb Smirnoffnode manually. 9137684cf3SGleb Smirnoff.Pp 9237684cf3SGleb SmirnoffOnce interface is configured, upon receival of 9337684cf3SGleb Smirnoff.Dv NGM_SOURCE_START 9437684cf3SGleb Smirnoffcontrol message the node starts sending 9537684cf3SGleb Smirnoffthe previously queued packets out the 9637684cf3SGleb Smirnoff.Va output 9737684cf3SGleb Smirnoffhook on every clock tick as fast 9837684cf3SGleb Smirnoffas the connected interface will take them. 9937684cf3SGleb SmirnoffWhile active, on every clock tick the node checks the available space 10037684cf3SGleb Smirnoffin the interface queue and sends that many packets out its 10137684cf3SGleb Smirnoff.Va output 10237684cf3SGleb Smirnoffhook. 10337684cf3SGleb SmirnoffOnce the number of packets indicated in the start message have been 10437684cf3SGleb Smirnoffsent, or upon reception of a stop message, the node stops sending data. 105585ff168SJulian Elischer.Sh CONTROL MESSAGES 106585ff168SJulian ElischerThis node type supports the generic control messages as well as the following, 107585ff168SJulian Elischerwhich must be sent with the 10876648c1fSRuslan Ermilov.Dv NGM_SOURCE_COOKIE 109585ff168SJulian Elischerattached. 11076648c1fSRuslan Ermilov.Bl -tag -width indent 11176648c1fSRuslan Ermilov.It Dv NGM_SOURCE_GET_STATS Pq Ic getstats 112585ff168SJulian ElischerReturns a structure containing the following fields: 11376648c1fSRuslan Ermilov.Bl -tag -width indent 11476648c1fSRuslan Ermilov.It Va outOctets 11576648c1fSRuslan ErmilovThe number of octets/bytes sent out the 11676648c1fSRuslan Ermilov.Dv output 11776648c1fSRuslan Ermilovhook. 11876648c1fSRuslan Ermilov.It Va outFrames 11976648c1fSRuslan ErmilovThe number of frames/packets sent out the 12076648c1fSRuslan Ermilov.Dv output 12176648c1fSRuslan Ermilovhook. 12276648c1fSRuslan Ermilov.It Va queueOctets 12376648c1fSRuslan ErmilovThe number of octets queued from the 12476648c1fSRuslan Ermilov.Dv input 12576648c1fSRuslan Ermilovhook. 12676648c1fSRuslan Ermilov.It Va queueFrames 12776648c1fSRuslan ErmilovThe number of frames queued from the 12876648c1fSRuslan Ermilov.Dv input 12976648c1fSRuslan Ermilovhook. 13076648c1fSRuslan Ermilov.It Va startTime 13176648c1fSRuslan ErmilovThe time the last start message was received. 13276648c1fSRuslan Ermilov.It Va endTime 13376648c1fSRuslan ErmilovThe time the last end message was received or 134585ff168SJulian Elischerthe output packet count was reached. 13576648c1fSRuslan Ermilov.It Va elapsedTime 13676648c1fSRuslan ErmilovEither 13776648c1fSRuslan Ermilov.Va endTime Li \- Va startTime 13876648c1fSRuslan Ermilovor current time 13976648c1fSRuslan Ermilov\- 14076648c1fSRuslan Ermilov.Va startTime . 141585ff168SJulian Elischer.El 14276648c1fSRuslan Ermilov.It Dv NGM_SOURCE_CLR_STATS Pq Ic clrstats 14376648c1fSRuslan ErmilovClears and resets the statistics returned by 14476648c1fSRuslan Ermilov.Ic getstats 14576648c1fSRuslan Ermilov(except 14676648c1fSRuslan Ermilov.Va queueOctets 14776648c1fSRuslan Ermilovand 14876648c1fSRuslan Ermilov.Va queueFrames ) . 14976648c1fSRuslan Ermilov.It Dv NGM_SOURCE_GETCLR_STATS Pq Ic getclrstats 15076648c1fSRuslan ErmilovAs 15176648c1fSRuslan Ermilov.Ic getstats 15276648c1fSRuslan Ermilovbut clears the statistics at the same time. 15376648c1fSRuslan Ermilov.It Dv NGM_SOURCE_START Pq Ic start 15437684cf3SGleb SmirnoffThis message requires a single 15537684cf3SGleb Smirnoff.Vt uint64_t 15676648c1fSRuslan Ermilovparameter which is the number of packets to 157585ff168SJulian Elischersend before stopping. 15837684cf3SGleb SmirnoffNode starts sending the queued packets out the output hook. 15937684cf3SGleb SmirnoffThe output hook must be connected and node must have 16037684cf3SGleb Smirnoffinterface configured. 16176648c1fSRuslan Ermilov.It Dv NGM_SOURCE_STOP Pq Ic stop 162585ff168SJulian ElischerStops the node if it is active. 16376648c1fSRuslan Ermilov.It Dv NGM_SOURCE_CLR_DATA Pq Ic clrdata 16476648c1fSRuslan ErmilovClears the packets queued from the 16576648c1fSRuslan Ermilov.Dv input 16676648c1fSRuslan Ermilovhook. 16737684cf3SGleb Smirnoff.It Dv NGM_SOURCE_SETIFACE Pq Ic setiface 16837684cf3SGleb SmirnoffThis message requires a string argument - name of the interface 16937684cf3SGleb Smirnoffto be configured. 170585ff168SJulian Elischer.El 171585ff168SJulian Elischer.Sh SHUTDOWN 172585ff168SJulian ElischerThis node shuts down upon receipt of a 173585ff168SJulian Elischer.Dv NGM_SHUTDOWN 17437684cf3SGleb Smirnoffcontrol message, when all hooks has been disconnected, or when the 17537684cf3SGleb Smirnoff.Va output 176585ff168SJulian Elischerhook has been disconnected. 17776648c1fSRuslan Ermilov.Sh EXAMPLES 17876648c1fSRuslan ErmilovAttach the node to an 17976648c1fSRuslan Ermilov.Xr ng_ether 4 18076648c1fSRuslan Ermilovnode for an interface. 18176648c1fSRuslan ErmilovIf 18276648c1fSRuslan Ermilov.Nm ng_ether 18376648c1fSRuslan Ermilovis 18476648c1fSRuslan Ermilovnot already loaded you will need to do so. 18576648c1fSRuslan ErmilovFor example, these commands 18676648c1fSRuslan Ermilovload the 18776648c1fSRuslan Ermilov.Nm ng_ether 18876648c1fSRuslan Ermilovmodule and attach the 18976648c1fSRuslan Ermilov.Dv output 19076648c1fSRuslan Ermilovhook of a new 19176648c1fSRuslan Ermilov.Nm source 19276648c1fSRuslan Ermilovnode to 19376648c1fSRuslan Ermilov.Dv orphans 19476648c1fSRuslan Ermilovhook of the 19576648c1fSRuslan Ermilov.Li bge0: 19676648c1fSRuslan Ermilov.Nm ng_ether 19776648c1fSRuslan Ermilovnode. 19876648c1fSRuslan Ermilov.Bd -literal -offset indent 19976648c1fSRuslan Ermilovkldload ng_ether 20076648c1fSRuslan Ermilovngctl mkpeer bge0: source orphans output 201585ff168SJulian Elischer.Ed 202585ff168SJulian Elischer.Pp 20376648c1fSRuslan ErmilovAt this point the new node can be referred to as 20476648c1fSRuslan Ermilov.Dq Li bge0:orphans . 20576648c1fSRuslan ErmilovThe 20676648c1fSRuslan Ermilovnode can be given its own name like this: 207585ff168SJulian Elischer.Pp 20876648c1fSRuslan Ermilov.Dl "ngctl name bge0:orphans src0" 209585ff168SJulian Elischer.Pp 21076648c1fSRuslan ErmilovAfter which it can be referred to as 21176648c1fSRuslan Ermilov.Dq Li src0: . 212585ff168SJulian Elischer.Pp 21376648c1fSRuslan ErmilovOnce created, packets need to be sent to the node, the TCL net package 214585ff168SJulian Elischercan be used to generate these packets: 215585ff168SJulian Elischer.Pp 216585ff168SJulian Elischer[Sandvine specific TCL code example omitted] 217585ff168SJulian Elischer.Pp 21876648c1fSRuslan ErmilovTo feed the output of the above TCL script to the 21976648c1fSRuslan Ermilov.Nm source 22076648c1fSRuslan Ermilovnode's 22176648c1fSRuslan Ermilov.Dv input 22276648c1fSRuslan Ermilovhook via 22376648c1fSRuslan Ermilov.Xr nghook 8 : 22476648c1fSRuslan Ermilov.Pp 22576648c1fSRuslan Ermilov.Dl "tcl genPacket | nghook bge0:orphans input" 226585ff168SJulian Elischer.Pp 227585ff168SJulian ElischerTo check that the node has queued these packets you can get the node 228585ff168SJulian Elischerstatistics: 22976648c1fSRuslan Ermilov.Bd -literal -offset indent 23076648c1fSRuslan Ermilovngctl msg bge0:orphans getstats 231585ff168SJulian ElischerArgs: { queueOctets=64 queueFrames=1 } 232585ff168SJulian Elischer.Ed 233585ff168SJulian Elischer.Pp 23476648c1fSRuslan ErmilovSend as many packets as required out the 23576648c1fSRuslan Ermilov.Dv output 23676648c1fSRuslan Ermilovhook: 237585ff168SJulian Elischer.Pp 23876648c1fSRuslan Ermilov.Dl "ngctl msg bge0:orphans start 16" 23976648c1fSRuslan Ermilov.Pp 24076648c1fSRuslan ErmilovEither wait for them to be sent (periodically fetching stats if desired) 241585ff168SJulian Elischeror send the stop message: 242585ff168SJulian Elischer.Pp 24376648c1fSRuslan Ermilov.Dl "ngctl msg bge0:orphans stop" 24476648c1fSRuslan Ermilov.Pp 24576648c1fSRuslan ErmilovCheck the statistics (here we use 24676648c1fSRuslan Ermilov.Ic getclrstats 24776648c1fSRuslan Ermilovto also clear the statistics): 24876648c1fSRuslan Ermilov.Bd -literal -offset indent 24976648c1fSRuslan Ermilovngctl msg bge0:orphans getclrstats 250585ff168SJulian ElischerArgs: { outOctets=1024 outFrames=16 queueOctets=64 queueFrames=1 251585ff168SJulian ElischerstartTime={ tv_sec=1035305880 tv_usec=758036 } endTime={ tv_sec=1035305880 252585ff168SJulian Elischertv_usec=759041 } elapsedTime={ tv_usec=1005 } } 253585ff168SJulian Elischer.Ed 254585ff168SJulian Elischer.Pp 25576648c1fSRuslan ErmilovThe times are from 25676648c1fSRuslan Ermilov.Vt "struct timeval" Ns s , 25776648c1fSRuslan Ermilovthe 25876648c1fSRuslan Ermilov.Va tv_sec 25976648c1fSRuslan Ermilovfield is seconds since 26076648c1fSRuslan Ermilovthe Epoch and can be converted into a date string via TCL's [clock 26176648c1fSRuslan Ermilovformat] or via the 26276648c1fSRuslan Ermilov.Xr date 1 26376648c1fSRuslan Ermilovcommand: 26476648c1fSRuslan Ermilov.Bd -literal -offset indent 26576648c1fSRuslan Ermilovdate -r 1035305880 266585ff168SJulian ElischerTue Oct 22 12:58:00 EDT 2002 267585ff168SJulian Elischer.Ed 268585ff168SJulian Elischer.Sh SEE ALSO 269585ff168SJulian Elischer.Xr netgraph 4 , 270585ff168SJulian Elischer.Xr ng_echo 4 , 271585ff168SJulian Elischer.Xr ng_hole 4 , 272585ff168SJulian Elischer.Xr ng_tee 4 , 27376648c1fSRuslan Ermilov.Xr ngctl 8 , 274585ff168SJulian Elischer.Xr nghook 8 275585ff168SJulian Elischer.Sh HISTORY 276585ff168SJulian ElischerThe 277585ff168SJulian Elischer.Nm 278585ff168SJulian Elischernode type was implemented in 279585ff168SJulian Elischer.Fx 4.8 . 280585ff168SJulian Elischer.Sh AUTHORS 281585ff168SJulian Elischer.An Dave Chapeskie Aq dchapeskie@SANDVINE.com 282