http://downloads.netgear.com/files/GPL/GPL_Source_V361j_DM111PSP_series_consumer_rele...
[bcm963xx.git] / kernel / linux / Documentation / networking / pktgen.txt
1 How to use the Linux packet generator module.
2
3 1. Enable CONFIG_NET_PKTGEN to compile and build pktgen.o, install it
4    in the place where insmod may find it.
5 2. Cut script "ipg" (see below).
6 3. Edit script to set preferred device and destination IP address.
7 3a.  Create more scripts for different interfaces.  Up to thirty-two
8      pktgen processes can be configured and run at once by using the
9      32 /proc/net/pktgen/pg* files.
10 4. Run in shell: ". ipg"
11 5. After this two commands are defined:
12    A. "pg" to start generator and to get results.
13    B. "pgset" to change generator parameters. F.e.
14       pgset "clone_skb 100"   sets the number of copies of the same packet 
15                               will be sent before a new packet is allocated
16       pgset "clone_skb 0"     use multiple SKBs for packet generation
17       pgset "pkt_size 9014"   sets packet size to 9014
18       pgset "frags 5"         packet will consist of 5 fragments
19       pgset "count 200000"    sets number of packets to send, set to zero
20                               for continuous sends until explicitly
21                               stopped.
22       pgset "ipg 5000"        sets artificial gap inserted between packets
23                               to 5000 nanoseconds
24       pgset "dst 10.0.0.1"    sets IP destination address
25                               (BEWARE! This generator is very aggressive!)
26       pgset "dst_min 10.0.0.1"            Same as dst
27       pgset "dst_max 10.0.0.254"          Set the maximum destination IP.
28       pgset "src_min 10.0.0.1"            Set the minimum (or only) source IP.
29       pgset "src_max 10.0.0.254"          Set the maximum source IP.
30       pgset "dstmac 00:00:00:00:00:00"    sets MAC destination address
31       pgset "srcmac 00:00:00:00:00:00"    sets MAC source address
32       pgset "src_mac_count 1" Sets the number of MACs we'll range through.  The
33                               'minimum' MAC is what you set with srcmac.
34       pgset "dst_mac_count 1" Sets the number of MACs we'll range through.  The
35                               'minimum' MAC is what you set with dstmac.
36       pgset "flag [name]"     Set a flag to determine behaviour.  Current flags
37                               are: IPSRC_RND #IP Source is random (between min/max),
38                                    IPDST_RND, UDPSRC_RND,
39                                    UDPDST_RND, MACSRC_RND, MACDST_RND 
40       pgset "udp_src_min 9"   set UDP source port min, If < udp_src_max, then
41                               cycle through the port range.
42       pgset "udp_src_max 9"   set UDP source port max.
43       pgset "udp_dst_min 9"   set UDP destination port min, If < udp_dst_max, then
44                               cycle through the port range.
45       pgset "udp_dst_max 9"   set UDP destination port max.
46       pgset stop              aborts injection
47       
48   Also, ^C aborts generator.
49
50 ---- cut here
51
52 #! /bin/sh
53
54 modprobe pktgen
55
56 PGDEV=/proc/net/pktgen/pg0
57
58 function pgset() {
59     local result
60
61     echo $1 > $PGDEV
62
63     result=`cat $PGDEV | fgrep "Result: OK:"`
64     if [ "$result" = "" ]; then
65          cat $PGDEV | fgrep Result:
66     fi
67 }
68
69 function pg() {
70     echo inject > $PGDEV
71     cat $PGDEV
72 }
73
74 pgset "odev eth0"
75 pgset "dst 0.0.0.0"
76
77 ---- cut here