|
NAMEng_source —
netgraph node for traffic generation
SYNOPSIS#include <sys/types.h>
#include <netgraph/ng_source.h>
DESCRIPTIONThesource node acts as a source of packets according to
the parameters set up using control messages and input packets. The
ng_source node type is used primarily for testing and
benchmarking.
HOOKSThesource node has two hooks:
input and output. The
output hook must remain connected, its disconnection
will shutdown the node.
OPERATIONThe operation of the node is as follows. Packets received on the input hook are queued internally. When output hook is connected,ng_source node assumes that its neighbour node is of
ng_ether(4)
node type. The neighbour is queried for its interface name. The
ng_source node then uses queue of the interface for
its evil purposes. The ng_source node also disables
autosrc option on neighbour
ng_ether(4)
node. If interface name cannot be obtained automatically, it should be
configured explicitly with the NGM_SOURCE_SETIFACE
control message, and autosrc should be turned off on
ng_ether(4)
node manually.
If the node is connected to a netgraph network, which does not terminate in a real ng_ether(4) interface, limit the packet injection rate explicitly with the NGM_SOURCE_SETPPS control message. Upon receipt of a CONTROL MESSAGESThis node type supports the generic control messages as well as the following, which must be sent with theNGM_SOURCE_COOKIE
attached.
SHUTDOWNThis node shuts down upon receipt of aNGM_SHUTDOWN
control message, when all hooks have been disconnected, or when the
output hook has been disconnected.
EXAMPLESAttach the node to an ng_ether(4) node for an interface. Ifng_ether is not already
loaded you will need to do so. For example, these commands load the
ng_ether module and attach the
output hook of a new source node
to orphans hook of the bge0:
ng_ether node.
kldload ng_ether ngctl mkpeer bge0: source orphans output At this point the new node can be referred to as
“ ngctl name bge0:orphans
src0 After which it can be referred to as
“ Once created, packets can be sent to the node as raw binary data. Each packet must be delivered in a separate netgraph message. The following example uses a short Perl script to convert the hex
representation of an ICMP packet to binary and deliver it to the
perl -pe 's/(..)[ \t\n]*/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 To check that the node has queued these packets you can get the node statistics: ngctl msg bge0:orphans getstats Args: { queueOctets=64 queueFrames=1 } Send as many packets as required out the output hook: ngctl msg bge0:orphans start
16 Either wait for them to be sent (periodically fetching stats if desired) or send the stop message: ngctl msg bge0:orphans
stop Check the statistics (here we use
ngctl msg bge0:orphans getclrstats 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 } } The times are from struct timevals, the tv_sec field is seconds since the Epoch and can be converted into a date string via TCL's [clock format] or via the date(1) command: date -r 1035305880 Tue Oct 22 12:58:00 EDT 2002 SEE ALSOnetgraph(4), ng_echo(4), ng_hole(4), ng_tee(4), ngctl(8), nghook(8)HISTORYTheng_source node type was implemented in
FreeBSD 4.8.
AUTHORSDave Chapeskie
Visit the GSP FreeBSD Man Page Interface. |