OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [Documentation/] [networking/] [pktgen.txt] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1275 phoenix
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 "multiskb 1"      use multiple SKBs for packet generation
15
      pgset "multiskb 0"      use single SKB for all transmits
16
      pgset "pkt_size 9014"   sets packet size to 9014
17
      pgset "frags 5"         packet will consist of 5 fragments
18
      pgset "count 200000"    sets number of packets to send, set to zero
19
                              for continious sends untill explicitly
20
                              stopped.
21
      pgset "ipg 5000"        sets artificial gap inserted between packets
22
                              to 5000 nanoseconds
23
      pgset "dst 10.0.0.1"    sets IP destination address
24
                              (BEWARE! This generator is very aggressive!)
25
      pgset "dst_min 10.0.0.1"            Same as dst
26
      pgset "dst_max 10.0.0.254"          Set the maximum destination IP.
27
      pgset "src_min 10.0.0.1"            Set the minimum (or only) source IP.
28
      pgset "src_max 10.0.0.254"          Set the maximum source IP.
29
      pgset "dstmac 00:00:00:00:00:00"    sets MAC destination address
30
      pgset "srcmac 00:00:00:00:00:00"    sets MAC source address
31
      pgset "src_mac_count 1" Sets the number of MACs we'll range through.  The
32
                              'minimum' MAC is what you set with srcmac.
33
      pgset "dst_mac_count 1" Sets the number of MACs we'll range through.  The
34
                              'minimum' MAC is what you set with dstmac.
35
      pgset "flag [name]"     Set a flag to determine behaviour.  Current flags
36
                              are: IPSRC_RND #IP Source is random (between min/max),
37
                                   IPDST_RND, UDPSRC_RND,
38
                                   UDPDST_RND, MACSRC_RND, MACDST_RND
39
      pgset "udp_src_min 9"   set UDP source port min, If < udp_src_max, then
40
                              cycle through the port range.
41
      pgset "udp_src_max 9"   set UDP source port max.
42
      pgset "udp_dst_min 9"   set UDP destination port min, If < udp_dst_max, then
43
                              cycle through the port range.
44
      pgset "udp_dst_max 9"   set UDP destination port max.
45
      pgset stop              aborts injection
46
 
47
  Also, ^C aborts generator.
48
 
49
---- cut here
50
 
51
#! /bin/sh
52
 
53
modprobe pktgen
54
 
55
PGDEV=/proc/net/pktgen/pg0
56
 
57
function pgset() {
58
    local result
59
 
60
    echo $1 > $PGDEV
61
 
62
    result=`cat $PGDEV | fgrep "Result: OK:"`
63
    if [ "$result" = "" ]; then
64
         cat $PGDEV | fgrep Result:
65
    fi
66
}
67
 
68
function pg() {
69
    echo inject > $PGDEV
70
    cat $PGDEV
71
}
72
 
73
pgset "odev eth0"
74
pgset "dst 0.0.0.0"
75
 
76
---- cut here

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.