]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - samples/pktgen/parameters.sh
pktgen: Specify num packets per thread
[mirror_ubuntu-artful-kernel.git] / samples / pktgen / parameters.sh
1 #
2 # Common parameter parsing for pktgen scripts
3 #
4
5 function usage() {
6 echo ""
7 echo "Usage: $0 [-vx] -i ethX"
8 echo " -i : (\$DEV) output interface/device (required)"
9 echo " -s : (\$PKT_SIZE) packet size"
10 echo " -d : (\$DEST_IP) destination IP"
11 echo " -m : (\$DST_MAC) destination MAC-addr"
12 echo " -t : (\$THREADS) threads to start"
13 echo " -c : (\$SKB_CLONE) SKB clones send before alloc new SKB"
14 echo " -n : (\$COUNT) num messages to send per thread, 0 means indefinitely"
15 echo " -b : (\$BURST) HW level bursting of SKBs"
16 echo " -v : (\$VERBOSE) verbose"
17 echo " -x : (\$DEBUG) debug"
18 echo " -6 : (\$IP6) IPv6"
19 echo ""
20 }
21
22 ## --- Parse command line arguments / parameters ---
23 ## echo "Commandline options:"
24 while getopts "s:i:d:m:t:c:n:b:vxh6" option; do
25 case $option in
26 i) # interface
27 export DEV=$OPTARG
28 info "Output device set to: DEV=$DEV"
29 ;;
30 s)
31 export PKT_SIZE=$OPTARG
32 info "Packet size set to: PKT_SIZE=$PKT_SIZE bytes"
33 ;;
34 d) # destination IP
35 export DEST_IP=$OPTARG
36 info "Destination IP set to: DEST_IP=$DEST_IP"
37 ;;
38 m) # MAC
39 export DST_MAC=$OPTARG
40 info "Destination MAC set to: DST_MAC=$DST_MAC"
41 ;;
42 t)
43 export THREADS=$OPTARG
44 export CPU_THREADS=$OPTARG
45 let "CPU_THREADS -= 1"
46 info "Number of threads to start: $THREADS (0 to $CPU_THREADS)"
47 ;;
48 c)
49 export CLONE_SKB=$OPTARG
50 info "CLONE_SKB=$CLONE_SKB"
51 ;;
52 n)
53 export COUNT=$OPTARG
54 info "COUNT=$COUNT"
55 ;;
56 b)
57 export BURST=$OPTARG
58 info "SKB bursting: BURST=$BURST"
59 ;;
60 v)
61 export VERBOSE=yes
62 info "Verbose mode: VERBOSE=$VERBOSE"
63 ;;
64 x)
65 export DEBUG=yes
66 info "Debug mode: DEBUG=$DEBUG"
67 ;;
68 6)
69 export IP6=6
70 info "IP6: IP6=$IP6"
71 ;;
72 h|?|*)
73 usage;
74 err 2 "[ERROR] Unknown parameters!!!"
75 esac
76 done
77 shift $(( $OPTIND - 1 ))
78
79 if [ -z "$PKT_SIZE" ]; then
80 # NIC adds 4 bytes CRC
81 export PKT_SIZE=60
82 info "Default packet size set to: set to: $PKT_SIZE bytes"
83 fi
84
85 if [ -z "$THREADS" ]; then
86 # Zero CPU threads means one thread, because CPU numbers are zero indexed
87 export CPU_THREADS=0
88 export THREADS=1
89 fi
90
91 if [ -z "$DEV" ]; then
92 usage
93 err 2 "Please specify output device"
94 fi
95
96 if [ -z "$DST_MAC" ]; then
97 warn "Missing destination MAC address"
98 fi
99
100 if [ -z "$DEST_IP" ]; then
101 warn "Missing destination IP address"
102 fi
103
104 if [ ! -d /proc/net/pktgen ]; then
105 info "Loading kernel module: pktgen"
106 modprobe pktgen
107 fi