2006-10-22 21:33:57 +00:00
|
|
|
.\" Copyright 2002-2006 Sandvine Inc.
|
2002-10-31 23:03:09 +00:00
|
|
|
.\" All rights reserved.
|
|
|
|
.\"
|
|
|
|
.\" Subject to the following obligations and disclaimer of warranty, use and
|
|
|
|
.\" redistribution of this software, in source or object code forms, with or
|
|
|
|
.\" without modifications are expressly permitted by Sandvine Inc.; provided,
|
|
|
|
.\" however, that:
|
|
|
|
.\" 1. Any and all reproductions of the source or object code must include the
|
|
|
|
.\" copyright notice above and the following disclaimer of warranties; and
|
|
|
|
.\" 2. No rights are granted, in any manner or form, to use Sandvine Inc.
|
|
|
|
.\" trademarks, including the mark "SANDVINE" on advertising, endorsements,
|
|
|
|
.\" or otherwise except as such appears in the above copyright notice or in
|
|
|
|
.\" the software.
|
|
|
|
.\"
|
|
|
|
.\" THIS SOFTWARE IS BEING PROVIDED BY SANDVINE "AS IS", AND TO THE MAXIMUM
|
|
|
|
.\" EXTENT PERMITTED BY LAW, SANDVINE MAKES NO REPRESENTATIONS OR WARRANTIES,
|
|
|
|
.\" EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE, INCLUDING WITHOUT LIMITATION,
|
|
|
|
.\" ANY AND ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
|
|
|
.\" PURPOSE, OR NON-INFRINGEMENT. SANDVINE DOES NOT WARRANT, GUARANTEE, OR
|
|
|
|
.\" MAKE ANY REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE
|
|
|
|
.\" USE OF THIS SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY
|
|
|
|
.\" OR OTHERWISE. IN NO EVENT SHALL SANDVINE BE LIABLE FOR ANY DAMAGES
|
|
|
|
.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
|
|
|
|
.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
|
|
|
.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
|
|
.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY
|
|
|
|
.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
.\" THIS SOFTWARE, EVEN IF SANDVINE IS ADVISED OF THE POSSIBILITY OF SUCH
|
|
|
|
.\" DAMAGE.
|
|
|
|
.\"
|
|
|
|
.\" Author: Dave Chapeskie <dchapeskie@sandvine.com>
|
|
|
|
.\" $FreeBSD$
|
|
|
|
.\"
|
2006-10-22 21:33:57 +00:00
|
|
|
.Dd October 22, 2006
|
2002-10-31 23:03:09 +00:00
|
|
|
.Dt NG_SOURCE 4
|
|
|
|
.Os
|
|
|
|
.Sh NAME
|
|
|
|
.Nm ng_source
|
2005-04-05 17:27:36 +00:00
|
|
|
.Nd netgraph node for traffic generation
|
2002-10-31 23:03:09 +00:00
|
|
|
.Sh SYNOPSIS
|
2005-02-05 11:31:31 +00:00
|
|
|
.In sys/types.h
|
2002-10-31 23:03:09 +00:00
|
|
|
.In netgraph/ng_source.h
|
|
|
|
.Sh DESCRIPTION
|
2002-12-12 15:25:56 +00:00
|
|
|
The
|
2002-10-31 23:03:09 +00:00
|
|
|
.Nm source
|
|
|
|
node acts as a source of packets according to the parameters set up
|
|
|
|
using control messages and input packets.
|
2002-12-12 15:25:56 +00:00
|
|
|
The
|
2005-04-05 17:27:36 +00:00
|
|
|
.Nm
|
|
|
|
node type is used primarily for testing and benchmarking.
|
2002-10-31 23:03:09 +00:00
|
|
|
.Sh HOOKS
|
2002-12-12 15:25:56 +00:00
|
|
|
The
|
2002-10-31 23:03:09 +00:00
|
|
|
.Nm source
|
2002-12-12 15:25:56 +00:00
|
|
|
node has two hooks:
|
2005-04-05 17:27:36 +00:00
|
|
|
.Va input
|
2002-12-12 15:25:56 +00:00
|
|
|
and
|
2005-04-05 17:27:36 +00:00
|
|
|
.Va output .
|
2002-12-12 15:25:56 +00:00
|
|
|
The
|
2005-04-05 17:27:36 +00:00
|
|
|
.Va output
|
2002-10-31 23:03:09 +00:00
|
|
|
hook must remain connected, its disconnection will shutdown the node.
|
2005-04-05 17:27:36 +00:00
|
|
|
.Sh OPERATION
|
|
|
|
The operation of the node is as follows.
|
|
|
|
Packets received on the
|
|
|
|
.Va input
|
|
|
|
hook are queued internally.
|
2005-06-15 13:31:23 +00:00
|
|
|
When
|
2005-04-05 17:27:36 +00:00
|
|
|
.Va output
|
|
|
|
hook is connected,
|
|
|
|
.Nm
|
|
|
|
node assumes that its neighbour node is of
|
2005-06-15 13:31:23 +00:00
|
|
|
.Xr ng_ether 4
|
2005-04-05 17:27:36 +00:00
|
|
|
node type.
|
2005-06-15 13:31:23 +00:00
|
|
|
The neighbour is queried for its interface name.
|
|
|
|
The
|
2005-04-05 17:27:36 +00:00
|
|
|
.Nm
|
|
|
|
node then uses queue of the interface for its evil purposes.
|
2005-06-15 13:31:23 +00:00
|
|
|
The
|
2005-04-05 17:27:36 +00:00
|
|
|
.Nm
|
|
|
|
node also disables
|
|
|
|
.Va autosrc
|
|
|
|
option on neighbour
|
2005-06-15 13:31:23 +00:00
|
|
|
.Xr ng_ether 4
|
2005-04-05 17:27:36 +00:00
|
|
|
node.
|
2005-06-15 13:31:23 +00:00
|
|
|
If interface name cannot be obtained automatically, it should
|
|
|
|
be configured explicitly with the
|
|
|
|
.Dv NGM_SOURCE_SETIFACE
|
2005-04-05 17:27:36 +00:00
|
|
|
control message, and
|
|
|
|
.Va autosrc
|
|
|
|
should be turned off on
|
2005-06-15 13:31:23 +00:00
|
|
|
.Xr ng_ether 4
|
2005-04-05 17:27:36 +00:00
|
|
|
node manually.
|
|
|
|
.Pp
|
2005-06-15 13:31:23 +00:00
|
|
|
Once interface is configured, upon receipt of a
|
2005-04-05 17:27:36 +00:00
|
|
|
.Dv NGM_SOURCE_START
|
|
|
|
control message the node starts sending
|
|
|
|
the previously queued packets out the
|
|
|
|
.Va output
|
|
|
|
hook on every clock tick as fast
|
|
|
|
as the connected interface will take them.
|
|
|
|
While active, on every clock tick the node checks the available space
|
|
|
|
in the interface queue and sends that many packets out its
|
|
|
|
.Va output
|
|
|
|
hook.
|
2005-06-15 13:31:23 +00:00
|
|
|
Once the number of packets indicated in the start message has been
|
|
|
|
sent, or upon receipt of a
|
|
|
|
.Dv NGM_SOURCE_STOP
|
|
|
|
message, the node stops sending data.
|
2002-10-31 23:03:09 +00:00
|
|
|
.Sh CONTROL MESSAGES
|
|
|
|
This node type supports the generic control messages as well as the following,
|
|
|
|
which must be sent with the
|
2002-12-12 15:25:56 +00:00
|
|
|
.Dv NGM_SOURCE_COOKIE
|
2002-10-31 23:03:09 +00:00
|
|
|
attached.
|
2002-12-12 15:25:56 +00:00
|
|
|
.Bl -tag -width indent
|
|
|
|
.It Dv NGM_SOURCE_GET_STATS Pq Ic getstats
|
2002-10-31 23:03:09 +00:00
|
|
|
Returns a structure containing the following fields:
|
2002-12-12 15:25:56 +00:00
|
|
|
.Bl -tag -width indent
|
|
|
|
.It Va outOctets
|
|
|
|
The number of octets/bytes sent out the
|
2005-06-15 13:31:23 +00:00
|
|
|
.Va output
|
2002-12-12 15:25:56 +00:00
|
|
|
hook.
|
|
|
|
.It Va outFrames
|
|
|
|
The number of frames/packets sent out the
|
2005-06-15 13:31:23 +00:00
|
|
|
.Va output
|
2002-12-12 15:25:56 +00:00
|
|
|
hook.
|
|
|
|
.It Va queueOctets
|
|
|
|
The number of octets queued from the
|
2005-06-15 13:31:23 +00:00
|
|
|
.Va input
|
2002-12-12 15:25:56 +00:00
|
|
|
hook.
|
|
|
|
.It Va queueFrames
|
|
|
|
The number of frames queued from the
|
2005-06-15 13:31:23 +00:00
|
|
|
.Va input
|
2002-12-12 15:25:56 +00:00
|
|
|
hook.
|
|
|
|
.It Va startTime
|
|
|
|
The time the last start message was received.
|
|
|
|
.It Va endTime
|
|
|
|
The time the last end message was received or
|
2002-10-31 23:03:09 +00:00
|
|
|
the output packet count was reached.
|
2002-12-12 15:25:56 +00:00
|
|
|
.It Va elapsedTime
|
|
|
|
Either
|
|
|
|
.Va endTime Li \- Va startTime
|
|
|
|
or current time
|
|
|
|
\-
|
|
|
|
.Va startTime .
|
2002-10-31 23:03:09 +00:00
|
|
|
.El
|
2002-12-12 15:25:56 +00:00
|
|
|
.It Dv NGM_SOURCE_CLR_STATS Pq Ic clrstats
|
|
|
|
Clears and resets the statistics returned by
|
|
|
|
.Ic getstats
|
|
|
|
(except
|
|
|
|
.Va queueOctets
|
|
|
|
and
|
|
|
|
.Va queueFrames ) .
|
|
|
|
.It Dv NGM_SOURCE_GETCLR_STATS Pq Ic getclrstats
|
|
|
|
As
|
|
|
|
.Ic getstats
|
|
|
|
but clears the statistics at the same time.
|
|
|
|
.It Dv NGM_SOURCE_START Pq Ic start
|
2005-04-05 17:27:36 +00:00
|
|
|
This message requires a single
|
|
|
|
.Vt uint64_t
|
2002-12-12 15:25:56 +00:00
|
|
|
parameter which is the number of packets to
|
2002-10-31 23:03:09 +00:00
|
|
|
send before stopping.
|
2005-06-15 13:31:23 +00:00
|
|
|
Node starts sending the queued packets out the
|
|
|
|
.Va output
|
|
|
|
hook.
|
|
|
|
The
|
|
|
|
.Va output
|
|
|
|
hook must be connected and node must have
|
2005-04-05 17:27:36 +00:00
|
|
|
interface configured.
|
2002-12-12 15:25:56 +00:00
|
|
|
.It Dv NGM_SOURCE_STOP Pq Ic stop
|
2002-10-31 23:03:09 +00:00
|
|
|
Stops the node if it is active.
|
2002-12-12 15:25:56 +00:00
|
|
|
.It Dv NGM_SOURCE_CLR_DATA Pq Ic clrdata
|
|
|
|
Clears the packets queued from the
|
2005-06-15 13:31:23 +00:00
|
|
|
.Va input
|
2002-12-12 15:25:56 +00:00
|
|
|
hook.
|
2005-04-05 17:27:36 +00:00
|
|
|
.It Dv NGM_SOURCE_SETIFACE Pq Ic setiface
|
2005-06-15 13:31:23 +00:00
|
|
|
This message requires the name of the interface
|
|
|
|
to be configured as an argument.
|
2005-12-23 19:14:38 +00:00
|
|
|
.It Dv NGM_SOURCE_SETPPS Pq Ic setpps
|
|
|
|
This message requires a single
|
|
|
|
.Vt uint32_t
|
|
|
|
parameter which puts upper limit on the amount of packets
|
|
|
|
sent per second.
|
2002-10-31 23:03:09 +00:00
|
|
|
.El
|
|
|
|
.Sh SHUTDOWN
|
|
|
|
This node shuts down upon receipt of a
|
|
|
|
.Dv NGM_SHUTDOWN
|
2005-06-15 13:31:23 +00:00
|
|
|
control message, when all hooks have been disconnected, or when the
|
2005-04-05 17:27:36 +00:00
|
|
|
.Va output
|
2002-10-31 23:03:09 +00:00
|
|
|
hook has been disconnected.
|
2002-12-12 15:25:56 +00:00
|
|
|
.Sh EXAMPLES
|
|
|
|
Attach the node to an
|
|
|
|
.Xr ng_ether 4
|
|
|
|
node for an interface.
|
|
|
|
If
|
|
|
|
.Nm ng_ether
|
|
|
|
is
|
|
|
|
not already loaded you will need to do so.
|
|
|
|
For example, these commands
|
|
|
|
load the
|
|
|
|
.Nm ng_ether
|
|
|
|
module and attach the
|
2005-06-15 13:31:23 +00:00
|
|
|
.Va output
|
2002-12-12 15:25:56 +00:00
|
|
|
hook of a new
|
|
|
|
.Nm source
|
|
|
|
node to
|
2005-06-15 13:31:23 +00:00
|
|
|
.Va orphans
|
2002-12-12 15:25:56 +00:00
|
|
|
hook of the
|
|
|
|
.Li bge0:
|
|
|
|
.Nm ng_ether
|
|
|
|
node.
|
|
|
|
.Bd -literal -offset indent
|
|
|
|
kldload ng_ether
|
|
|
|
ngctl mkpeer bge0: source orphans output
|
2002-10-31 23:03:09 +00:00
|
|
|
.Ed
|
|
|
|
.Pp
|
2002-12-12 15:25:56 +00:00
|
|
|
At this point the new node can be referred to as
|
|
|
|
.Dq Li bge0:orphans .
|
|
|
|
The
|
|
|
|
node can be given its own name like this:
|
2002-10-31 23:03:09 +00:00
|
|
|
.Pp
|
2002-12-12 15:25:56 +00:00
|
|
|
.Dl "ngctl name bge0:orphans src0"
|
2002-10-31 23:03:09 +00:00
|
|
|
.Pp
|
2002-12-12 15:25:56 +00:00
|
|
|
After which it can be referred to as
|
|
|
|
.Dq Li src0: .
|
2002-10-31 23:03:09 +00:00
|
|
|
.Pp
|
2006-10-22 21:33:57 +00:00
|
|
|
Once created, packets can be sent to the node as raw binary data.
|
|
|
|
Each packet must be delivered in a separate netgraph message.
|
2002-10-31 23:03:09 +00:00
|
|
|
.Pp
|
2006-10-22 21:33:57 +00:00
|
|
|
The following example uses a short Perl script to convert the hex
|
|
|
|
representation of an ICMP packet to binary and deliver it to the
|
2002-12-12 15:25:56 +00:00
|
|
|
.Nm source
|
|
|
|
node's
|
2005-06-15 13:31:23 +00:00
|
|
|
.Va input
|
2002-12-12 15:25:56 +00:00
|
|
|
hook via
|
|
|
|
.Xr nghook 8 :
|
2006-10-22 21:33:57 +00:00
|
|
|
.Bd -literal -offset indent
|
|
|
|
perl -pe 's/(..)[ \et\en]*/chr(hex($1))/ge' <<EOF | nghook src0: input
|
|
|
|
ff ff ff ff ff ff 00 00 00 00 00 00 08 00 45 00
|
|
|
|
00 54 cb 13 00 00 40 01 b9 87 c0 a8 2b 65 0a 00
|
|
|
|
00 01 08 00 f8 d0 c9 76 00 00 45 37 01 73 00 01
|
|
|
|
04 0a 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15
|
|
|
|
16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24 25
|
|
|
|
26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 34 35
|
|
|
|
36 37
|
|
|
|
EOF
|
|
|
|
.Ed
|
2002-10-31 23:03:09 +00:00
|
|
|
.Pp
|
|
|
|
To check that the node has queued these packets you can get the node
|
|
|
|
statistics:
|
2002-12-12 15:25:56 +00:00
|
|
|
.Bd -literal -offset indent
|
|
|
|
ngctl msg bge0:orphans getstats
|
2002-10-31 23:03:09 +00:00
|
|
|
Args: { queueOctets=64 queueFrames=1 }
|
|
|
|
.Ed
|
|
|
|
.Pp
|
2002-12-12 15:25:56 +00:00
|
|
|
Send as many packets as required out the
|
2005-06-15 13:31:23 +00:00
|
|
|
.Va output
|
2002-12-12 15:25:56 +00:00
|
|
|
hook:
|
2002-10-31 23:03:09 +00:00
|
|
|
.Pp
|
2002-12-12 15:25:56 +00:00
|
|
|
.Dl "ngctl msg bge0:orphans start 16"
|
|
|
|
.Pp
|
|
|
|
Either wait for them to be sent (periodically fetching stats if desired)
|
2002-10-31 23:03:09 +00:00
|
|
|
or send the stop message:
|
|
|
|
.Pp
|
2002-12-12 15:25:56 +00:00
|
|
|
.Dl "ngctl msg bge0:orphans stop"
|
|
|
|
.Pp
|
|
|
|
Check the statistics (here we use
|
|
|
|
.Ic getclrstats
|
|
|
|
to also clear the statistics):
|
|
|
|
.Bd -literal -offset indent
|
|
|
|
ngctl msg bge0:orphans getclrstats
|
2002-10-31 23:03:09 +00:00
|
|
|
Args: { outOctets=1024 outFrames=16 queueOctets=64 queueFrames=1
|
|
|
|
startTime={ tv_sec=1035305880 tv_usec=758036 } endTime={ tv_sec=1035305880
|
|
|
|
tv_usec=759041 } elapsedTime={ tv_usec=1005 } }
|
|
|
|
.Ed
|
|
|
|
.Pp
|
2002-12-12 15:25:56 +00:00
|
|
|
The times are from
|
|
|
|
.Vt "struct timeval" Ns s ,
|
|
|
|
the
|
|
|
|
.Va tv_sec
|
|
|
|
field is seconds since
|
|
|
|
the Epoch and can be converted into a date string via TCL's [clock
|
|
|
|
format] or via the
|
|
|
|
.Xr date 1
|
|
|
|
command:
|
|
|
|
.Bd -literal -offset indent
|
|
|
|
date -r 1035305880
|
2002-10-31 23:03:09 +00:00
|
|
|
Tue Oct 22 12:58:00 EDT 2002
|
|
|
|
.Ed
|
|
|
|
.Sh SEE ALSO
|
|
|
|
.Xr netgraph 4 ,
|
|
|
|
.Xr ng_echo 4 ,
|
|
|
|
.Xr ng_hole 4 ,
|
|
|
|
.Xr ng_tee 4 ,
|
2002-12-12 15:25:56 +00:00
|
|
|
.Xr ngctl 8 ,
|
2002-10-31 23:03:09 +00:00
|
|
|
.Xr nghook 8
|
|
|
|
.Sh HISTORY
|
|
|
|
The
|
|
|
|
.Nm
|
|
|
|
node type was implemented in
|
|
|
|
.Fx 4.8 .
|
|
|
|
.Sh AUTHORS
|
|
|
|
.An Dave Chapeskie Aq dchapeskie@SANDVINE.com
|